1.1 --- a/README Sun Sep 06 23:14:42 2009 -0700
1.2 +++ b/README Tue Sep 15 23:41:40 2009 -0700
1.3 @@ -9,35 +9,25 @@
1.4 http://java.sun.com/javase/downloads/index.jsp
1.5 Set the environment variable ALT_BOOTDIR to the location of this JDK 6.
1.6
1.7 - 2. Download and install the JIBX libraries, version 1.1.5 from
1.8 - http://sourceforge.net/project/showfiles.php?group_id=69358&package_id=68290
1.9 - You'll need the following four JAR files:
1.10 - bcel.jar
1.11 - jibx-bind.jar
1.12 - jibx-run.jar
1.13 - xpp3.jar
1.14 - Set the environment variable ALT_JIBX_LIBS_PATH to the location of
1.15 - these JAR files.
1.16 -
1.17 - 3. Download and install the Binary Plugs for the most recent JDK7 from
1.18 + 2. Download and install the Binary Plugs for the most recent JDK7 from
1.19 http://download.java.net/openjdk/jdk7/
1.20 Set the environment variable ALT_BINARY_PLUGS_PATH to the location of
1.21 these binary plugs.
1.22
1.23 - 4. Either download and install the latest JDK7 from
1.24 + 3. Either download and install the latest JDK7 from
1.25 http://download.java.net/openjdk/jdk7/, or build your own complete
1.26 OpenJDK7 by using the top level Makefile in the OpenJDK Mercurial forest.
1.27 Set the environment variable ALT_JDK_IMPORT_PATH to the location of
1.28 this latest JDK7 or OpenJDK7 build.
1.29
1.30 - 5. Check the sanity of doing a build with the current machine:
1.31 + 4. Check the sanity of doing a build with the current machine:
1.32 cd make && gnumake sanity
1.33 See README-builds.html if you run into problems.
1.34
1.35 - 6. Do a partial build of the jdk:
1.36 + 5. Do a partial build of the jdk:
1.37 cd make && gnumake all
1.38
1.39 - 7. Construct the images:
1.40 + 6. Construct the images:
1.41 cd make && gnumake images
1.42 The resulting JDK image should be found in build/*/j2sdk-image
1.43
2.1 --- a/make/common/Sanity.gmk Sun Sep 06 23:14:42 2009 -0700
2.2 +++ b/make/common/Sanity.gmk Tue Sep 15 23:41:40 2009 -0700
2.3 @@ -93,8 +93,7 @@
2.4 sane-alt_bootdir \
2.5 sane-bootdir \
2.6 sane-local-bootdir \
2.7 - sane-alsa-headers \
2.8 - sane-jibx
2.9 + sane-alsa-headers
2.10
2.11 ifdef OPENJDK
2.12 sanity-all:: sane-freetype
3.1 --- a/make/common/shared/Defs.gmk Sun Sep 06 23:14:42 2009 -0700
3.2 +++ b/make/common/shared/Defs.gmk Tue Sep 15 23:41:40 2009 -0700
3.3 @@ -536,15 +536,6 @@
3.4 # NOTE: ISA_DIR is usually empty, on Solaris it might be /sparcv9 or /amd64
3.5 BINDIR = $(OUTPUTDIR)/bin$(ISA_DIR)
3.6
3.7 -# JIBX_LIBS_PATH: path to JIBX libraries, needed for NimbusLookAndFeel
3.8 -ifdef ALT_JIBX_LIBS_PATH
3.9 - JIBX_LIBS_PATH:=$(call FullPath,$(ALT_JIBX_LIBS_PATH))
3.10 - JIBX_LIBS_PATH:=$(call AltCheckSpaces,JIBX_LIBS_PATH)
3.11 - JIBX_LIBS_PATH:=$(call AltCheckValue,JIBX_LIBS_PATH)
3.12 -else
3.13 - JIBX_LIBS_PATH=$(JDK_DEVTOOLS_DIR)/share/jibx/lib
3.14 -endif
3.15 -
3.16 # MOZILLA_HEADERS_PATH: path to mozilla header files for plugin
3.17 ifdef ALT_MOZILLA_HEADERS_PATH
3.18 MOZILLA_HEADERS_PATH :=$(call FullPath,$(ALT_MOZILLA_HEADERS_PATH))
4.1 --- a/make/common/shared/Sanity-Settings.gmk Sun Sep 06 23:14:42 2009 -0700
4.2 +++ b/make/common/shared/Sanity-Settings.gmk Tue Sep 15 23:41:40 2009 -0700
4.3 @@ -233,7 +233,6 @@
4.4 endif
4.5 endif
4.6 ALL_SETTINGS+=$(call addAltSetting,CACERTS_FILE)
4.7 -ALL_SETTINGS+=$(call addAltSetting,JIBX_LIBS_PATH)
4.8 ifndef OPENJDK
4.9 ALL_SETTINGS+=$(call addAltSetting,MOZILLA_HEADERS_PATH)
4.10 endif
5.1 --- a/make/common/shared/Sanity.gmk Sun Sep 06 23:14:42 2009 -0700
5.2 +++ b/make/common/shared/Sanity.gmk Tue Sep 15 23:41:40 2009 -0700
5.3 @@ -214,7 +214,6 @@
5.4 sane-link \
5.5 sane-cacerts \
5.6 sane-alsa-headers \
5.7 - sane-jibx \
5.8 sane-ant_version \
5.9 sane-zip_version \
5.10 sane-unzip_version \
5.11 @@ -1517,22 +1516,6 @@
5.12
5.13
5.14 ######################################################
5.15 -# JIBX_LIBS_PATH must be valid
5.16 -######################################################
5.17 -sane-jibx:
5.18 -ifdef DISABLE_NIMBUS
5.19 - $(call SanityWarning,Disabling Nimbus will remove public API in javax.swing.plaf.nimbus.)
5.20 -else
5.21 - @if [ ! -r $(subst \,/,$(JIBX_LIBS_PATH))/jibx-run.jar ]; then \
5.22 - $(ECHO) "ERROR: You do not have access to valid JIBX library files. \n" \
5.23 - " Please check your access to \n" \
5.24 - " $(subst \,/,$(JIBX_LIBS_PATH))/jibx-run.jar \n" \
5.25 - " and/or check your value of ALT_JDK_DEVTOOLS_DIR, ALT_JIBX_LIBS_PATH \n" \
5.26 - "" >> $(ERROR_FILE) ; \
5.27 - fi
5.28 -endif
5.29 -
5.30 -######################################################
5.31 # MOZILLA_HEADERS_PATH must be valid
5.32 ######################################################
5.33 sane-mozilla:
6.1 --- a/make/javax/swing/plaf/Makefile Sun Sep 06 23:14:42 2009 -0700
6.2 +++ b/make/javax/swing/plaf/Makefile Tue Sep 15 23:41:40 2009 -0700
6.3 @@ -34,16 +34,14 @@
6.4 #
6.5 include FILES.gmk
6.6 AUTO_FILES_JAVA_DIRS = javax/swing/plaf sun/swing com/sun/java/swing/plaf
6.7 -ifndef DISABLE_NIMBUS
6.8 - SUBDIRS = nimbus
6.9 -endif
6.10 -
6.11 -# Nimbus is handled in its own directory
6.12 -AUTO_JAVA_PRUNE = nimbus
6.13
6.14 ifeq ($(PLATFORM), windows)
6.15 # Don't build GTK L&F on Windows
6.16 - AUTO_JAVA_PRUNE += gtk
6.17 + AUTO_JAVA_PRUNE = gtk
6.18 +endif
6.19 +
6.20 +ifdef DISABLE_NIMBUS
6.21 + AUTO_JAVA_PRUNE += nimbus
6.22 endif
6.23
6.24 MISC_FILES = $(MISC_SWING_FILES)
6.25 @@ -52,6 +50,10 @@
6.26 MISC_FILES += $(MISC_SWING_FILES_UNIX)
6.27 endif
6.28
6.29 +NIMBUS_GENSRC_DIR = $(GENSRCDIR)/javax/swing/plaf/nimbus
6.30 +NIMBUS_SKIN_FILE = $(SWING_SRC)/plaf/nimbus/skin.laf
6.31 +NIMBUS_GENERATOR_JAR = $(BUILDTOOLJARDIR)/generatenimbus.jar
6.32 +
6.33 FILES_java = $(FILES_SWING_java)
6.34
6.35 #
6.36 @@ -75,14 +77,25 @@
6.37 # Process LOGO_ICONS and Motif Icons first.
6.38 #
6.39 build: $(LOGO_ICONS) $(MISC_SWING_FILES_MOTIF_GIF) $(MISC_SWING_FILES_MOTIF_PNG) other_files
6.40 - $(SUBDIRS-loop)
6.41
6.42 -clean clobber::
6.43 - $(SUBDIRS-loop)
6.44 +$(NIMBUS_GENSRC_DIR): $(NIMBUS_SKIN_FILE) $(NIMBUS_GENERATOR_JAR)
6.45 + @$(ECHO) "Generating Nimbus source files:"
6.46 + $(RM) -r $(NIMBUS_GENSRC_DIR)
6.47 + $(BOOT_JAVA_CMD) -jar $(NIMBUS_GENERATOR_JAR) \
6.48 + -skinFile $(NIMBUS_SKIN_FILE) -buildDir $(GENSRCDIR) \
6.49 + -packagePrefix $(PACKAGE).nimbus -lafName Nimbus
6.50 + @$(ECHO) "Finished generating Nimbus source files"
6.51 +
6.52 +clean:: classes.clean
6.53 + $(RM) -r $(NIMBUS_GENSRC_DIR)
6.54
6.55 #
6.56 # Include
6.57 #
6.58 +ifndef DISABLE_NIMBUS
6.59 + CLASSES_INIT = $(NIMBUS_GENSRC_DIR)
6.60 +endif
6.61 +
6.62 include $(BUILDDIR)/common/Classes.gmk
6.63
6.64 ifndef OPENJDK
7.1 --- a/make/javax/swing/plaf/nimbus/Makefile Sun Sep 06 23:14:42 2009 -0700
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,60 +0,0 @@
7.4 -#
7.5 -# Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved.
7.6 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7.7 -#
7.8 -# This code is free software; you can redistribute it and/or modify it
7.9 -# under the terms of the GNU General Public License version 2 only, as
7.10 -# published by the Free Software Foundation. Sun designates this
7.11 -# particular file as subject to the "Classpath" exception as provided
7.12 -# by Sun in the LICENSE file that accompanied this code.
7.13 -#
7.14 -# This code is distributed in the hope that it will be useful, but WITHOUT
7.15 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7.16 -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7.17 -# version 2 for more details (a copy is included in the LICENSE file that
7.18 -# accompanied this code).
7.19 -#
7.20 -# You should have received a copy of the GNU General Public License version
7.21 -# 2 along with this work; if not, write to the Free Software Foundation,
7.22 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7.23 -#
7.24 -# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
7.25 -# CA 95054 USA or visit www.sun.com if you need additional information or
7.26 -# have any questions.
7.27 -#
7.28 -
7.29 -BUILDDIR = ../../../..
7.30 -PACKAGE = javax.swing.plaf.nimbus
7.31 -PRODUCT = com
7.32 -SWING_SRC = $(SHARE_SRC)/classes/javax/swing
7.33 -include $(BUILDDIR)/common/Defs.gmk
7.34 -
7.35 -#
7.36 -# Files
7.37 -#
7.38 -NIMBUS_PKG = javax/swing/plaf/nimbus
7.39 -NIMBUS_COMPAT_PKG = com/sun/java/swing/plaf/nimbus
7.40 -NIMBUS_GENSRC_DIR = $(GENSRCDIR)/$(NIMBUS_PKG)
7.41 -NIMBUS_SKIN_FILE = $(SHARE_SRC)/classes/$(NIMBUS_PKG)/skin.laf
7.42 -NIMBUS_GENERATOR_JAR = $(BUILDTOOLJARDIR)/nimbus_generator.jar
7.43 -
7.44 -AUTO_FILES_JAVA_DIRS = $(NIMBUS_PKG) $(NIMBUS_COMPAT_PKG)
7.45 -
7.46 -
7.47 -#
7.48 -# Rules
7.49 -#
7.50 -CLASSES_INIT = $(NIMBUS_GENSRC_DIR)
7.51 -
7.52 -include $(BUILDDIR)/common/Classes.gmk
7.53 -
7.54 -$(NIMBUS_GENSRC_DIR): $(NIMBUS_SKIN_FILE) $(NIMBUS_GENERATOR_JAR)
7.55 - @$(ECHO) "Generating Nimbus source files:"
7.56 - $(BOOT_JAVA_CMD) -jar $(NIMBUS_GENERATOR_JAR) \
7.57 - -skinFile $(NIMBUS_SKIN_FILE) \
7.58 - -buildDir $(GENSRCDIR) -srcDir $(GENSRCDIR) \
7.59 - -packagePrefix $(PACKAGE) -lafName Nimbus
7.60 - @$(ECHO) "Finished generating Nimbus source files"
7.61 -
7.62 -clean clobber::
7.63 - $(RM) -r $(NIMBUS_GENSRC_DIR)
8.1 --- a/make/sun/javazic/tzdata/VERSION Sun Sep 06 23:14:42 2009 -0700
8.2 +++ b/make/sun/javazic/tzdata/VERSION Tue Sep 15 23:41:40 2009 -0700
8.3 @@ -21,4 +21,4 @@
8.4 # CA 95054 USA or visit www.sun.com if you need additional information or
8.5 # have any questions.
8.6 #
8.7 -tzdata2009g
8.8 +tzdata2009l
9.1 --- a/make/sun/javazic/tzdata/africa Sun Sep 06 23:14:42 2009 -0700
9.2 +++ b/make/sun/javazic/tzdata/africa Tue Sep 15 23:41:40 2009 -0700
9.3 @@ -22,6 +22,8 @@
9.4 # have any questions.
9.5 #
9.6 # <pre>
9.7 +# This file is in the public domain, so clarified as of
9.8 +# 2009-05-17 by Arthur David Olson.
9.9
9.10 # This data is by no means authoritative; if you think you know better,
9.11 # go ahead and edit the file (and please send any changes to
9.12 @@ -263,18 +265,18 @@
9.13 # The following appeared in Red Hat bugzilla[1] (edited):
9.14 #
9.15 # > $ zdump -v /usr/share/zoneinfo/Africa/Cairo | grep 2009
9.16 -# > /usr/share/zoneinfo/Africa/Cairo Thu Apr 23 21:59:59 2009 UTC =3D Thu =
9.17 +# > /usr/share/zoneinfo/Africa/Cairo Thu Apr 23 21:59:59 2009 UTC = Thu =
9.18 # Apr 23
9.19 -# > 23:59:59 2009 EET isdst=3D0 gmtoff=3D7200
9.20 -# > /usr/share/zoneinfo/Africa/Cairo Thu Apr 23 22:00:00 2009 UTC =3D Fri =
9.21 +# > 23:59:59 2009 EET isdst=0 gmtoff=7200
9.22 +# > /usr/share/zoneinfo/Africa/Cairo Thu Apr 23 22:00:00 2009 UTC = Fri =
9.23 # Apr 24
9.24 -# > 01:00:00 2009 EEST isdst=3D1 gmtoff=3D10800
9.25 -# > /usr/share/zoneinfo/Africa/Cairo Thu Aug 27 20:59:59 2009 UTC =3D Thu =
9.26 +# > 01:00:00 2009 EEST isdst=1 gmtoff=10800
9.27 +# > /usr/share/zoneinfo/Africa/Cairo Thu Aug 27 20:59:59 2009 UTC = Thu =
9.28 # Aug 27
9.29 -# > 23:59:59 2009 EEST isdst=3D1 gmtoff=3D10800
9.30 -# > /usr/share/zoneinfo/Africa/Cairo Thu Aug 27 21:00:00 2009 UTC =3D Thu =
9.31 +# > 23:59:59 2009 EEST isdst=1 gmtoff=10800
9.32 +# > /usr/share/zoneinfo/Africa/Cairo Thu Aug 27 21:00:00 2009 UTC = Thu =
9.33 # Aug 27
9.34 -# > 23:00:00 2009 EET isdst=3D0 gmtoff=3D7200
9.35 +# > 23:00:00 2009 EET isdst=0 gmtoff=7200
9.36 #
9.37 # > end date should be Thu Sep 24 2009 (Last Thursday in September at 23:59=
9.38 # :59)
9.39 @@ -282,11 +284,11 @@
9.40 #
9.41 # timeanddate[2] and another site I've found[3] also support that.
9.42 #
9.43 -# [1] <a href="https://bugzilla.redhat.com/show_bug.cgi?id=3D492263">
9.44 -# https://bugzilla.redhat.com/show_bug.cgi?id=3D492263
9.45 +# [1] <a href="https://bugzilla.redhat.com/show_bug.cgi?id=492263">
9.46 +# https://bugzilla.redhat.com/show_bug.cgi?id=492263
9.47 # </a>
9.48 -# [2] <a href="http://www.timeanddate.com/worldclock/clockchange.html?n=3D53">
9.49 -# http://www.timeanddate.com/worldclock/clockchange.html?n=3D53
9.50 +# [2] <a href="http://www.timeanddate.com/worldclock/clockchange.html?n=53">
9.51 +# http://www.timeanddate.com/worldclock/clockchange.html?n=53
9.52 # </a>
9.53 # [3] <a href="http://wwp.greenwichmeantime.com/time-zone/africa/egypt/">
9.54 # http://wwp.greenwichmeantime.com/time-zone/africa/egypt/
9.55 @@ -296,8 +298,27 @@
9.56 # In 2009 (and for the next several years), Ramadan ends before the fourth
9.57 # Thursday in September; Egypt is expected to revert to the last Thursday
9.58 # in September.
9.59 +
9.60 +# From Steffen Thorsen (2009-08-11):
9.61 +# We have been able to confirm the August change with the Egyptian Cabinet
9.62 +# Information and Decision Support Center:
9.63 +# <a href="http://www.timeanddate.com/news/time/egypt-dst-ends-2009.html">
9.64 +# http://www.timeanddate.com/news/time/egypt-dst-ends-2009.html
9.65 +# </a>
9.66 +#
9.67 +# The Middle East News Agency
9.68 +# <a href="http://www.mena.org.eg/index.aspx">
9.69 +# http://www.mena.org.eg/index.aspx
9.70 +# </a>
9.71 +# also reports "Egypt starts winter time on August 21"
9.72 +# today in article numbered "71, 11/08/2009 12:25 GMT."
9.73 +# Only the title above is available without a subscription to their service,
9.74 +# and can be found by searching for "winter" in their search engine
9.75 +# (at least today).
9.76 +
9.77 Rule Egypt 2008 only - Aug lastThu 23:00s 0 -
9.78 -Rule Egypt 2009 max - Sep lastThu 23:00s 0 -
9.79 +Rule Egypt 2009 only - Aug 20 23:00s 0 -
9.80 +Rule Egypt 2010 max - Sep lastThu 23:00s 0 -
9.81
9.82 # Zone NAME GMTOFF RULES FORMAT [UNTIL]
9.83 Zone Africa/Cairo 2:05:00 - LMT 1900 Oct
9.84 @@ -499,8 +520,8 @@
9.85
9.86 # From Riad M. Hossen Ally (2008-08-03):
9.87 # The Government of Mauritius weblink
9.88 -# <a href="http://www.gov.mu/portal/site/pmosite/menuitem.4ca0efdee47462e7440a600248a521ca/?content_id=3D4728ca68b2a5b110VgnVCM1000000a04a8c0RCRD">
9.89 -# http://www.gov.mu/portal/site/pmosite/menuitem.4ca0efdee47462e7440a600248a521ca/?content_id=3D4728ca68b2a5b110VgnVCM1000000a04a8c0RCRD
9.90 +# <a href="http://www.gov.mu/portal/site/pmosite/menuitem.4ca0efdee47462e7440a600248a521ca/?content_id=4728ca68b2a5b110VgnVCM1000000a04a8c0RCRD">
9.91 +# http://www.gov.mu/portal/site/pmosite/menuitem.4ca0efdee47462e7440a600248a521ca/?content_id=4728ca68b2a5b110VgnVCM1000000a04a8c0RCRD
9.92 # </a>
9.93 # Cabinet Decision of July 18th, 2008 states as follows:
9.94 #
9.95 @@ -522,11 +543,33 @@
9.96 # http://www.gov.mu/portal/goc/assemblysite/file/bill2708.pdf
9.97 # </a>
9.98
9.99 +# From Steffen Thorsen (2009-06-05):
9.100 +# According to several sources, Mauritius will not continue to observe
9.101 +# DST the coming summer...
9.102 +#
9.103 +# Some sources, in French:
9.104 +# <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">
9.105 +# 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
9.106 +# </a>
9.107 +# <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-">
9.108 +# 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-
9.109 +# </a>
9.110 +#
9.111 +# Our wrap-up:
9.112 +# <a href="http://www.timeanddate.com/news/time/mauritius-dst-will-not-repeat.html">
9.113 +# http://www.timeanddate.com/news/time/mauritius-dst-will-not-repeat.html
9.114 +# </a>
9.115 +
9.116 +# From Arthur David Olson (2009-07-11):
9.117 +# The "mauritius-dst-will-not-repeat" wrapup includes this:
9.118 +# "The trial ended on March 29, 2009, when the clocks moved back by one hour
9.119 +# at 2am (or 02:00) local time..."
9.120 +
9.121 # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
9.122 Rule Mauritius 1982 only - Oct 10 0:00 1:00 S
9.123 Rule Mauritius 1983 only - Mar 21 0:00 0 -
9.124 -Rule Mauritius 2008 max - Oct lastSun 2:00s 1:00 S
9.125 -Rule Mauritius 2009 max - Mar lastSun 2:00s 0 -
9.126 +Rule Mauritius 2008 only - Oct lastSun 2:00 1:00 S
9.127 +Rule Mauritius 2009 only - Mar lastSun 2:00 0 -
9.128 # Zone NAME GMTOFF RULES FORMAT [UNTIL]
9.129 Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis
9.130 4:00 Mauritius MU%sT # Mauritius Time
10.1 --- a/make/sun/javazic/tzdata/antarctica Sun Sep 06 23:14:42 2009 -0700
10.2 +++ b/make/sun/javazic/tzdata/antarctica Tue Sep 15 23:41:40 2009 -0700
10.3 @@ -22,6 +22,8 @@
10.4 # have any questions.
10.5 #
10.6 # <pre>
10.7 +# This file is in the public domain, so clarified as of
10.8 +# 2009-05-17 by Arthur David Olson.
10.9
10.10 # From Paul Eggert (1999-11-15):
10.11 # To keep things manageable, we list only locations occupied year-round; see
11.1 --- a/make/sun/javazic/tzdata/asia Sun Sep 06 23:14:42 2009 -0700
11.2 +++ b/make/sun/javazic/tzdata/asia Tue Sep 15 23:41:40 2009 -0700
11.3 @@ -22,6 +22,8 @@
11.4 # have any questions.
11.5 #
11.6 # <pre>
11.7 +# This file is in the public domain, so clarified as of
11.8 +# 2009-05-17 by Arthur David Olson.
11.9
11.10 # This data is by no means authoritative; if you think you know better,
11.11 # go ahead and edit the file (and please send any changes to
11.12 @@ -147,6 +149,57 @@
11.13 3:00 - AST
11.14
11.15 # Bangladesh
11.16 +# From Alexander Krivenyshev (2009-05-13):
11.17 +# According to newspaper Asian Tribune (May 6, 2009) Bangladesh may introduce
11.18 +# Daylight Saving Time from June 16 to Sept 30
11.19 +#
11.20 +# Bangladesh to introduce daylight saving time likely from June 16
11.21 +# <a href="http://www.asiantribune.com/?q=node/17288">
11.22 +# http://www.asiantribune.com/?q=node/17288
11.23 +# </a>
11.24 +# or
11.25 +# <a href="http://www.worldtimezone.com/dst_news/dst_news_bangladesh02.html">
11.26 +# http://www.worldtimezone.com/dst_news/dst_news_bangladesh02.html
11.27 +# </a>
11.28 +#
11.29 +# "... Bangladesh government has decided to switch daylight saving time from
11.30 +# June
11.31 +# 16 till September 30 in a bid to ensure maximum use of daylight to cope with
11.32 +# crippling power crisis. "
11.33 +#
11.34 +# The switch will remain in effect from June 16 to Sept 30 (2009) but if
11.35 +# implemented the next year, it will come in force from April 1, 2010
11.36 +
11.37 +# From Steffen Thorsen (2009-06-02):
11.38 +# They have finally decided now, but changed the start date to midnight between
11.39 +# the 19th and 20th, and they have not set the end date yet.
11.40 +#
11.41 +# Some sources:
11.42 +# <a href="http://in.reuters.com/article/southAsiaNews/idINIndia-40017620090601">
11.43 +# http://in.reuters.com/article/southAsiaNews/idINIndia-40017620090601
11.44 +# </a>
11.45 +# <a href="http://bdnews24.com/details.php?id=85889&cid=2">
11.46 +# http://bdnews24.com/details.php?id=85889&cid=2
11.47 +# </a>
11.48 +#
11.49 +# Our wrap-up:
11.50 +# <a href="http://www.timeanddate.com/news/time/bangladesh-daylight-saving-2009.html">
11.51 +# http://www.timeanddate.com/news/time/bangladesh-daylight-saving-2009.html
11.52 +# </a>
11.53 +
11.54 +# From A. N. M. Kamrus Saadat (2009-06-15):
11.55 +# Finally we've got the official mail regarding DST start time where DST start
11.56 +# time is mentioned as Jun 19 2009, 23:00 from BTRC (Bangladesh
11.57 +# Telecommunication Regulatory Commission).
11.58 +#
11.59 +# No DST end date has been announced yet.
11.60 +
11.61 +# From Arthur David Olson (2009-07-11):
11.62 +# Arbitrarily end DST at the end of 2009 so that a POSIX-sytle time zone string
11.63 +# can appear in the Dhaka binary file and for the benefit of old glibc
11.64 +# reimplementations of the time zone software that mishandle permanent DST.
11.65 +# A change will be required once the end date is known.
11.66 +
11.67 # Zone NAME GMTOFF RULES FORMAT [UNTIL]
11.68 Zone Asia/Dhaka 6:01:40 - LMT 1890
11.69 5:53:20 - HMT 1941 Oct # Howrah Mean Time?
11.70 @@ -154,7 +207,9 @@
11.71 5:30 - IST 1942 Sep
11.72 6:30 - BURT 1951 Sep 30
11.73 6:00 - DACT 1971 Mar 26 # Dacca Time
11.74 - 6:00 - BDT # Bangladesh Time
11.75 + 6:00 - BDT 2009 Jun 19 23:00 # Bangladesh Time
11.76 + 6:00 1:00 BDST 2010
11.77 + 6:00 - BDT
11.78
11.79 # Bhutan
11.80 # Zone NAME GMTOFF RULES FORMAT [UNTIL]
11.81 @@ -1129,7 +1184,7 @@
11.82 Rule Jordan 1999 only - Jul 1 0:00s 1:00 S
11.83 Rule Jordan 1999 2002 - Sep lastFri 0:00s 0 -
11.84 Rule Jordan 2000 2001 - Mar lastThu 0:00s 1:00 S
11.85 -Rule Jordan 2002 max - Mar lastFri 0:00s 1:00 S
11.86 +Rule Jordan 2002 max - Mar lastThu 24:00 1:00 S
11.87 Rule Jordan 2003 only - Oct 24 0:00s 0 -
11.88 Rule Jordan 2004 only - Oct 15 0:00s 0 -
11.89 Rule Jordan 2005 only - Sep lastFri 0:00s 0 -
12.1 --- a/make/sun/javazic/tzdata/australasia Sun Sep 06 23:14:42 2009 -0700
12.2 +++ b/make/sun/javazic/tzdata/australasia Tue Sep 15 23:41:40 2009 -0700
12.3 @@ -22,6 +22,8 @@
12.4 # have any questions.
12.5 #
12.6 # <pre>
12.7 +# This file is in the public domain, so clarified as of
12.8 +# 2009-05-17 by Arthur David Olson.
12.9
12.10 # This file also includes Pacific islands.
12.11
12.12 @@ -447,6 +449,22 @@
12.13 -11:00 - SST # S=Samoa
12.14
12.15 # Samoa
12.16 +
12.17 +# From Alexander Krivenyshev (2008-12-06):
12.18 +# The Samoa government (Western Samoa) may implement DST on the first Sunday of
12.19 +# October 2009 (October 4, 2009) until the last Sunday of March 2010 (March 28,
12.20 +# 2010).
12.21 +#
12.22 +# "Selected Committee reports to Cabinet on Daylight Saving Time",
12.23 +# Government of Samoa:
12.24 +# <a href="http://www.govt.ws/pr_article.cfm?pr_id=560">
12.25 +# http://www.govt.ws/pr_article.cfm?pr_id=560
12.26 +# </a>
12.27 +# or
12.28 +# <a href="http://www.worldtimezone.com/dst_news/dst_news_samoa01.html">
12.29 +# http://www.worldtimezone.com/dst_news/dst_news_samoa01.html
12.30 +# </a>
12.31 +
12.32 Zone Pacific/Apia 12:33:04 - LMT 1879 Jul 5
12.33 -11:26:56 - LMT 1911
12.34 -11:30 - SAMT 1950 # Samoa Time
12.35 @@ -1141,6 +1159,27 @@
12.36 # From Paul Eggert (2007-07-23):
12.37 # See "southeast Australia" above for 2008 and later.
12.38
12.39 +# From Steffen Thorsen (2009-04-28):
12.40 +# According to the official press release, South Australia's extended daylight
12.41 +# saving period will continue with the same rules as used during the 2008-2009
12.42 +# summer (southern hemisphere).
12.43 +#
12.44 +# From
12.45 +# <a href="http://www.safework.sa.gov.au/uploaded_files/DaylightDatesSet.pdf">
12.46 +# http://www.safework.sa.gov.au/uploaded_files/DaylightDatesSet.pdf
12.47 +# </a>
12.48 +# The extended daylight saving period that South Australia has been trialling
12.49 +# for over the last year is now set to be ongoing.
12.50 +# Daylight saving will continue to start on the first Sunday in October each
12.51 +# year and finish on the first Sunday in April the following year.
12.52 +# Industrial Relations Minister, Paul Caica, says this provides South Australia
12.53 +# with a consistent half hour time difference with NSW, Victoria, Tasmania and
12.54 +# the ACT for all 52 weeks of the year...
12.55 +#
12.56 +# We have a wrap-up here:
12.57 +# <a href="http://www.timeanddate.com/news/time/south-australia-extends-dst.html">
12.58 +# http://www.timeanddate.com/news/time/south-australia-extends-dst.html
12.59 +# </a>
12.60 ###############################################################################
12.61
12.62 # New Zealand
13.1 --- a/make/sun/javazic/tzdata/backward Sun Sep 06 23:14:42 2009 -0700
13.2 +++ b/make/sun/javazic/tzdata/backward Tue Sep 15 23:41:40 2009 -0700
13.3 @@ -21,6 +21,9 @@
13.4 # CA 95054 USA or visit www.sun.com if you need additional information or
13.5 # have any questions.
13.6 #
13.7 +# <pre>
13.8 +# This file is in the public domain, so clarified as of
13.9 +# 2009-05-17 by Arthur David Olson.
13.10
13.11 # This file provides links between current names for time zones
13.12 # and their old names. Many names changed in late 1993.
14.1 --- a/make/sun/javazic/tzdata/etcetera Sun Sep 06 23:14:42 2009 -0700
14.2 +++ b/make/sun/javazic/tzdata/etcetera Tue Sep 15 23:41:40 2009 -0700
14.3 @@ -21,6 +21,9 @@
14.4 # CA 95054 USA or visit www.sun.com if you need additional information or
14.5 # have any questions.
14.6 #
14.7 +# <pre>
14.8 +# This file is in the public domain, so clarified as of
14.9 +# 2009-05-17 by Arthur David Olson.
14.10
14.11 # These entries are mostly present for historical reasons, so that
14.12 # people in areas not otherwise covered by the tz files could "zic -l"
15.1 --- a/make/sun/javazic/tzdata/europe Sun Sep 06 23:14:42 2009 -0700
15.2 +++ b/make/sun/javazic/tzdata/europe Tue Sep 15 23:41:40 2009 -0700
15.3 @@ -22,6 +22,8 @@
15.4 # have any questions.
15.5 #
15.6 # <pre>
15.7 +# This file is in the public domain, so clarified as of
15.8 +# 2009-05-17 by Arthur David Olson.
15.9
15.10 # This data is by no means authoritative; if you think you know better,
15.11 # go ahead and edit the file (and please send any changes to
15.12 @@ -479,7 +481,7 @@
15.13 Rule EU 1981 max - Mar lastSun 1:00u 1:00 S
15.14 Rule EU 1996 max - Oct lastSun 1:00u 0 -
15.15 # The most recent directive covers the years starting in 2002. See:
15.16 -# <a href="http://europa.eu.int/eur-lex/en/lif/dat/2000/en_300L0084.html">
15.17 +# <a="http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32000L0084:EN:NOT">
15.18 # Directive 2000/84/EC of the European Parliament and of the Council
15.19 # of 19 January 2001 on summer-time arrangements.
15.20 # </a>
16.1 --- a/make/sun/javazic/tzdata/factory Sun Sep 06 23:14:42 2009 -0700
16.2 +++ b/make/sun/javazic/tzdata/factory Tue Sep 15 23:41:40 2009 -0700
16.3 @@ -21,6 +21,9 @@
16.4 # CA 95054 USA or visit www.sun.com if you need additional information or
16.5 # have any questions.
16.6 #
16.7 +# <pre>
16.8 +# This file is in the public domain, so clarified as of
16.9 +# 2009-05-17 by Arthur David Olson.
16.10
16.11 # For companies who don't want to put time zone specification in
16.12 # their installation procedures. When users run date, they'll get the message.
17.1 --- a/make/sun/javazic/tzdata/iso3166.tab Sun Sep 06 23:14:42 2009 -0700
17.2 +++ b/make/sun/javazic/tzdata/iso3166.tab Tue Sep 15 23:41:40 2009 -0700
17.3 @@ -21,9 +21,11 @@
17.4 # CA 95054 USA or visit www.sun.com if you need additional information or
17.5 # have any questions.
17.6 #
17.7 +# <pre>
17.8 +# This file is in the public domain, so clarified as of
17.9 +# 2009-05-17 by Arthur David Olson.
17.10 # ISO 3166 alpha-2 country codes
17.11 #
17.12 -#
17.13 # From Paul Eggert (2006-09-27):
17.14 #
17.15 # This file contains a table with the following columns:
18.1 --- a/make/sun/javazic/tzdata/leapseconds Sun Sep 06 23:14:42 2009 -0700
18.2 +++ b/make/sun/javazic/tzdata/leapseconds Tue Sep 15 23:41:40 2009 -0700
18.3 @@ -21,6 +21,9 @@
18.4 # CA 95054 USA or visit www.sun.com if you need additional information or
18.5 # have any questions.
18.6 #
18.7 +# <pre>
18.8 +# This file is in the public domain, so clarified as of
18.9 +# 2009-05-17 by Arthur David Olson.
18.10
18.11 # Allowance for leapseconds added to each timezone file.
18.12
18.13 @@ -75,13 +78,13 @@
18.14 # SERVICE DE LA ROTATION TERRESTRE
18.15 # OBSERVATOIRE DE PARIS
18.16 # 61, Av. de l'Observatoire 75014 PARIS (France)
18.17 -# Tel. : 33 (0) 1 40 51 22 29
18.18 +# Tel. : 33 (0) 1 40 51 22 26
18.19 # FAX : 33 (0) 1 40 51 22 91
18.20 # Internet : services.iers@obspm.fr
18.21 #
18.22 -# Paris, 15 January 2009
18.23 +# Paris, 4 July 2009
18.24 #
18.25 -# Bulletin C 37
18.26 +# Bulletin C 38
18.27 #
18.28 # To authorities responsible
18.29 # for the measurement and
18.30 @@ -89,7 +92,7 @@
18.31 #
18.32 # INFORMATION ON UTC - TAI
18.33 #
18.34 -# NO positive leap second will be introduced at the end of June 2009.
18.35 +# NO positive leap second will be introduced at the end of December 2009.
18.36 # The difference between Coordinated Universal Time UTC and the
18.37 # International Atomic Time TAI is :
18.38 #
18.39 @@ -101,6 +104,6 @@
18.40 # will be no time step at the next possible date.
18.41 #
18.42 # Daniel GAMBIS
18.43 -# Head
18.44 -# Earth Orientation Center of the IERS
18.45 +# Director
18.46 +# Earth Orientation Center of IERS
18.47 # Observatoire de Paris, France
19.1 --- a/make/sun/javazic/tzdata/northamerica Sun Sep 06 23:14:42 2009 -0700
19.2 +++ b/make/sun/javazic/tzdata/northamerica Tue Sep 15 23:41:40 2009 -0700
19.3 @@ -22,6 +22,8 @@
19.4 # have any questions.
19.5 #
19.6 # <pre>
19.7 +# This file is in the public domain, so clarified as of
19.8 +# 2009-05-17 by Arthur David Olson.
19.9
19.10 # also includes Central America and the Caribbean
19.11
20.1 --- a/make/sun/javazic/tzdata/pacificnew Sun Sep 06 23:14:42 2009 -0700
20.2 +++ b/make/sun/javazic/tzdata/pacificnew Tue Sep 15 23:41:40 2009 -0700
20.3 @@ -21,6 +21,9 @@
20.4 # CA 95054 USA or visit www.sun.com if you need additional information or
20.5 # have any questions.
20.6 #
20.7 +# <pre>
20.8 +# This file is in the public domain, so clarified as of
20.9 +# 2009-05-17 by Arthur David Olson.
20.10
20.11 # From Arthur David Olson (1989-04-05):
20.12 # On 1989-04-05, the U. S. House of Representatives passed (238-154) a bill
21.1 --- a/make/sun/javazic/tzdata/solar87 Sun Sep 06 23:14:42 2009 -0700
21.2 +++ b/make/sun/javazic/tzdata/solar87 Tue Sep 15 23:41:40 2009 -0700
21.3 @@ -21,6 +21,9 @@
21.4 # CA 95054 USA or visit www.sun.com if you need additional information or
21.5 # have any questions.
21.6 #
21.7 +# <pre>
21.8 +# This file is in the public domain, so clarified as of
21.9 +# 2009-05-17 by Arthur David Olson.
21.10
21.11 # So much for footnotes about Saudi Arabia.
21.12 # Apparent noon times below are for Riyadh; your mileage will vary.
22.1 --- a/make/sun/javazic/tzdata/solar88 Sun Sep 06 23:14:42 2009 -0700
22.2 +++ b/make/sun/javazic/tzdata/solar88 Tue Sep 15 23:41:40 2009 -0700
22.3 @@ -21,6 +21,9 @@
22.4 # CA 95054 USA or visit www.sun.com if you need additional information or
22.5 # have any questions.
22.6 #
22.7 +# <pre>
22.8 +# This file is in the public domain, so clarified as of
22.9 +# 2009-05-17 by Arthur David Olson.
22.10
22.11 # Apparent noon times below are for Riyadh; they're a bit off for other places.
22.12 # Times were computed using formulas in the U.S. Naval Observatory's
23.1 --- a/make/sun/javazic/tzdata/solar89 Sun Sep 06 23:14:42 2009 -0700
23.2 +++ b/make/sun/javazic/tzdata/solar89 Tue Sep 15 23:41:40 2009 -0700
23.3 @@ -21,6 +21,9 @@
23.4 # CA 95054 USA or visit www.sun.com if you need additional information or
23.5 # have any questions.
23.6 #
23.7 +# <pre>
23.8 +# This file is in the public domain, so clarified as of
23.9 +# 2009-05-17 by Arthur David Olson.
23.10
23.11 # Apparent noon times below are for Riyadh; they're a bit off for other places.
23.12 # Times were computed using a formula provided by the U. S. Naval Observatory:
24.1 --- a/make/sun/javazic/tzdata/southamerica Sun Sep 06 23:14:42 2009 -0700
24.2 +++ b/make/sun/javazic/tzdata/southamerica Tue Sep 15 23:41:40 2009 -0700
24.3 @@ -22,6 +22,8 @@
24.4 # have any questions.
24.5 #
24.6 # <pre>
24.7 +# This file is in the public domain, so clarified as of
24.8 +# 2009-05-17 by Arthur David Olson.
24.9
24.10 # This data is by no means authoritative; if you think you know better,
24.11 # go ahead and edit the file (and please send any changes to
24.12 @@ -696,8 +698,8 @@
24.13
24.14 # From Rodrigo Severo (2008-06-24):
24.15 # Just correcting the URL:
24.16 -# <a href="https://www.in.gov.br/imprensa/visualiza/index.jsp?jornal=3Ddo&secao=3D1&pagina=3D1&data=3D25/04/2008">
24.17 -# https://www.in.gov.br/imprensa/visualiza/index.jsp?jornal=3Ddo&secao=3D1&pagina=3D1&data=3D25/04/2008
24.18 +# <a href="https://www.in.gov.br/imprensa/visualiza/index.jsp?jornal=do&secao=1&pagina=1&data=25/04/2008">
24.19 +# https://www.in.gov.br/imprensa/visualiza/index.jsp?jornal=do&secao=1&pagina=1&data=25/04/2008
24.20 # </a>
24.21 #
24.22 # As a result of the above Decree I believe the America/Rio_Branco
25.1 --- a/make/sun/javazic/tzdata/systemv Sun Sep 06 23:14:42 2009 -0700
25.2 +++ b/make/sun/javazic/tzdata/systemv Tue Sep 15 23:41:40 2009 -0700
25.3 @@ -21,6 +21,9 @@
25.4 # CA 95054 USA or visit www.sun.com if you need additional information or
25.5 # have any questions.
25.6 #
25.7 +# <pre>
25.8 +# This file is in the public domain, so clarified as of
25.9 +# 2009-05-17 by Arthur David Olson.
25.10
25.11 # Old rules, should the need arise.
25.12 # No attempt is made to handle Newfoundland, since it cannot be expressed
26.1 --- a/make/sun/javazic/tzdata/zone.tab Sun Sep 06 23:14:42 2009 -0700
26.2 +++ b/make/sun/javazic/tzdata/zone.tab Tue Sep 15 23:41:40 2009 -0700
26.3 @@ -21,6 +21,9 @@
26.4 # CA 95054 USA or visit www.sun.com if you need additional information or
26.5 # have any questions.
26.6 #
26.7 +# <pre>
26.8 +# This file is in the public domain, so clarified as of
26.9 +# 2009-05-17 by Arthur David Olson.
26.10 #
26.11 # TZ zone descriptions
26.12 #
26.13 @@ -123,7 +126,7 @@
26.14 BR -0958-06748 America/Rio_Branco Acre
26.15 BS +2505-07721 America/Nassau
26.16 BT +2728+08939 Asia/Thimphu
26.17 -BW -2545+02555 Africa/Gaborone
26.18 +BW -2439+02555 Africa/Gaborone
26.19 BY +5354+02734 Europe/Minsk
26.20 BZ +1730-08812 America/Belize
26.21 CA +4734-05243 America/St_Johns Newfoundland Time, including SE Labrador
26.22 @@ -307,7 +310,7 @@
26.23 MY +0133+11020 Asia/Kuching Sabah & Sarawak
26.24 MZ -2558+03235 Africa/Maputo
26.25 NA -2234+01706 Africa/Windhoek
26.26 -NC -2216+16530 Pacific/Noumea
26.27 +NC -2216+16627 Pacific/Noumea
26.28 NE +1331+00207 Africa/Niamey
26.29 NF -2903+16758 Pacific/Norfolk
26.30 NG +0627+00324 Africa/Lagos
26.31 @@ -387,7 +390,7 @@
26.32 TL -0833+12535 Asia/Dili
26.33 TM +3757+05823 Asia/Ashgabat
26.34 TN +3648+01011 Africa/Tunis
26.35 -TO -2110+17510 Pacific/Tongatapu
26.36 +TO -2110-17510 Pacific/Tongatapu
26.37 TR +4101+02858 Europe/Istanbul
26.38 TT +1039-06131 America/Port_of_Spain
26.39 TV -0831+17913 Pacific/Funafuti
26.40 @@ -431,7 +434,7 @@
26.41 UY -3453-05611 America/Montevideo
26.42 UZ +3940+06648 Asia/Samarkand west Uzbekistan
26.43 UZ +4120+06918 Asia/Tashkent east Uzbekistan
26.44 -VA +4154+01227 Europe/Vatican
26.45 +VA +415408+0122711 Europe/Vatican
26.46 VC +1309-06114 America/St_Vincent
26.47 VE +1030-06656 America/Caracas
26.48 VG +1827-06437 America/Tortola
27.1 --- a/make/tools/Makefile Sun Sep 06 23:14:42 2009 -0700
27.2 +++ b/make/tools/Makefile Tue Sep 15 23:41:40 2009 -0700
27.3 @@ -54,7 +54,7 @@
27.4 CharsetMapping
27.5
27.6 ifndef DISABLE_NIMBUS
27.7 - SUBDIRS += swing-nimbus
27.8 + SUBDIRS += generate_nimbus
27.9 endif
27.10
27.11 all build clean clobber::
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
28.2 +++ b/make/tools/generate_nimbus/Makefile Tue Sep 15 23:41:40 2009 -0700
28.3 @@ -0,0 +1,72 @@
28.4 +#
28.5 +# Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved.
28.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28.7 +#
28.8 +# This code is free software; you can redistribute it and/or modify it
28.9 +# under the terms of the GNU General Public License version 2 only, as
28.10 +# published by the Free Software Foundation. Sun designates this
28.11 +# particular file as subject to the "Classpath" exception as provided
28.12 +# by Sun in the LICENSE file that accompanied this code.
28.13 +#
28.14 +# This code is distributed in the hope that it will be useful, but WITHOUT
28.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
28.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28.17 +# version 2 for more details (a copy is included in the LICENSE file that
28.18 +# accompanied this code).
28.19 +#
28.20 +# You should have received a copy of the GNU General Public License version
28.21 +# 2 along with this work; if not, write to the Free Software Foundation,
28.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28.23 +#
28.24 +# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
28.25 +# CA 95054 USA or visit www.sun.com if you need additional information or
28.26 +# have any questions.
28.27 +#
28.28 +
28.29 +#
28.30 +# Makefile for building the Nimbus generator
28.31 +#
28.32 +
28.33 +BUILDDIR = ../..
28.34 +PACKAGE = build.tools.generatenimbus
28.35 +PRODUCT = tools
28.36 +PROGRAM = generatenimbus
28.37 +include $(BUILDDIR)/common/Defs.gmk
28.38 +
28.39 +BUILDTOOL_SOURCE_ROOT = $(BUILDDIR)/tools/src
28.40 +BUILDTOOL_MAIN = $(PKGDIR)/Generator.java
28.41 +
28.42 +
28.43 +#
28.44 +# Files
28.45 +#
28.46 +
28.47 +SOURCE_FILES = Generator.java \
28.48 + ObjectFactory.java \
28.49 + Paint.java \
28.50 + SynthModel.java \
28.51 + UIDefault.java \
28.52 + UIStyle.java
28.53 +TEMPLATE_FILES = Defaults.template \
28.54 + PainterImpl.template \
28.55 + StateImpl.template
28.56 +TEMPLATE_DEST = $(BUILDTOOLCLASSDIR)/$(PKGDIR)/resources
28.57 +
28.58 +
28.59 +#
28.60 +# Rules
28.61 +#
28.62 +
28.63 +all: $(TEMPLATE_DEST) $(BUILDTOOL_JAR_FILE)
28.64 +
28.65 +include $(BUILDDIR)/common/BuildToolJar.gmk
28.66 +
28.67 +$(TEMPLATE_DEST): $(TEMPLATE_FILES:%=$(SHARE_SRC)/classes/javax/swing/plaf/nimbus/%)
28.68 + $(MKDIR) -p $@
28.69 + $(RM) $(TEMPLATE_FILES:%=$@/%)
28.70 + $(CP) $^ $@
28.71 +
28.72 +BUILDTOOL_MAIN_SOURCE_FILE = $(SOURCE_FILES:%=$(BUILDTOOL_SOURCE_ROOT)/$(PKGDIR)/%)
28.73 +
28.74 +clean clobber::
28.75 + $(RM) -r $(TEMPLATE_DEST)
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
29.2 +++ b/make/tools/src/build/tools/generatenimbus/Generator.java Tue Sep 15 23:41:40 2009 -0700
29.3 @@ -0,0 +1,267 @@
29.4 +/*
29.5 + * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
29.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
29.7 + *
29.8 + * This code is free software; you can redistribute it and/or modify it
29.9 + * under the terms of the GNU General Public License version 2 only, as
29.10 + * published by the Free Software Foundation. Sun designates this
29.11 + * particular file as subject to the "Classpath" exception as provided
29.12 + * by Sun in the LICENSE file that accompanied this code.
29.13 + *
29.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
29.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
29.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
29.17 + * version 2 for more details (a copy is included in the LICENSE file that
29.18 + * accompanied this code).
29.19 + *
29.20 + * You should have received a copy of the GNU General Public License version
29.21 + * 2 along with this work; if not, write to the Free Software Foundation,
29.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
29.23 + *
29.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
29.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
29.26 + * have any questions.
29.27 + */
29.28 +package build.tools.generatenimbus;
29.29 +
29.30 +import java.io.*;
29.31 +import java.util.HashMap;
29.32 +import java.util.Map;
29.33 +import javax.xml.bind.JAXBContext;
29.34 +import javax.xml.bind.Unmarshaller;
29.35 +
29.36 +/**
29.37 + * Generates the various Java artifacts based on a SynthModel.
29.38 + * <p/>
29.39 + * Generated source files are split up among two different locations. There are those source files that are meant to be
29.40 + * edited (generally, only the LookAndFeel class itself) and those that are autogenerated (everything else).
29.41 + * <p/>
29.42 + * All autogenerated files are placed in "buildPackageRoot" and are package private. A LAF author (one who has access to
29.43 + * the generated sources) will be able to access any of the generated classes. Those referencing the library, however,
29.44 + * will only be able to access the main LookAndFeel class itself (since everything else is package private).
29.45 + *
29.46 + * @author Richard Bair
29.47 + * @author Jasper Potts
29.48 + */
29.49 +public class Generator {
29.50 + private static Generator instance;
29.51 +
29.52 + /** A map of variables that are used for variable substitution in the template files. */
29.53 + private Map<String, String> variables;
29.54 + private boolean full = false;
29.55 + private File buildPackageRoot;
29.56 + private String packageNamePrefix;
29.57 + private String lafName;
29.58 + private SynthModel model;
29.59 +
29.60 + /**
29.61 + * MAIN APPLICATION
29.62 + * <p/>
29.63 + * This is for using the generator as part of the java build process
29.64 + *
29.65 + * @param args The commandline arguments
29.66 + */
29.67 + public static void main(String[] args) throws Exception {
29.68 + if (args.length == 0 || (args.length % 2) != 0) {
29.69 + System.out.println("Usage: generator [-options]\n" +
29.70 + " -full <true|false> True if we should build the whole LAF or false for building just states and painters.\n" +
29.71 + " -skinFile <value> Path to the skin.laf file for the LAF to be generated from.\n" +
29.72 + " -buildDir <value> The directory beneath which the build-controlled artifacts (such as the Painters) should\n" +
29.73 + " be placed. This is the root directory beneath which the necessary packages and source\n" +
29.74 + " files will be created.\n" +
29.75 + " -resourcesDir <value> The resources directory containing templates and images.\n" +
29.76 + " -packagePrefix <value> The package name associated with this synth look and feel. For example,\n" +
29.77 + " \"org.mypackage.mylaf\"\n" +
29.78 + " -lafName <value> The name of the laf, such as \"MyLAF\".\n");
29.79 + } else {
29.80 + boolean full = false;
29.81 + File skinFile = new File(System.getProperty("user.dir"));
29.82 + File buildDir = new File(System.getProperty("user.dir"));
29.83 + File resourcesDir = new File(System.getProperty("user.dir"));
29.84 + String packagePrefix = "org.mypackage.mylaf";
29.85 + String lafName = "MyLAF";
29.86 + for (int i = 0; i < args.length; i += 2) {
29.87 + String key = args[i].trim().toLowerCase();
29.88 + String value = args[i + 1].trim();
29.89 + if ("-full".equals(key)) {
29.90 + full = Boolean.parseBoolean(value);
29.91 + } else if ("-skinfile".equals(key)) {
29.92 + skinFile = new File(value);
29.93 + } else if ("-builddir".equals(key)) {
29.94 + buildDir = new File(value);
29.95 + } else if ("-resourcesdir".equals(key)) {
29.96 + resourcesDir = new File(value);
29.97 + } else if ("-packageprefix".equals(key)) {
29.98 + packagePrefix = value;
29.99 + } else if ("-lafname".equals(key)) {
29.100 + lafName = value;
29.101 + }
29.102 + }
29.103 + System.out.println("### GENERATING LAF CODE ################################");
29.104 + System.out.println(" full :" + full);
29.105 + System.out.println(" skinFile :" + skinFile.getAbsolutePath());
29.106 + System.out.println(" buildDir :" + buildDir.getAbsolutePath());
29.107 + System.out.println(" resourcesDir :" + resourcesDir.getAbsolutePath());
29.108 + System.out.println(" packagePrefix :" +packagePrefix);
29.109 + System.out.println(" lafName :" +lafName);
29.110 +
29.111 + JAXBContext ctx = JAXBContext.newInstance("build.tools.generatenimbus");
29.112 + Unmarshaller u = ctx.createUnmarshaller();
29.113 + SynthModel model = (SynthModel) u.unmarshal(skinFile);
29.114 + Generator.init(full, buildDir, packagePrefix, lafName, model);
29.115 + Generator.getInstance().generate();
29.116 + }
29.117 + }
29.118 +
29.119 + /**
29.120 + * Creates a new Generator, capable of outputting the source code artifacts related to a given SynthModel. It is
29.121 + * capable of generating the one-time artifacts in addition to the regeneration of build-controlled artifacts.
29.122 + *
29.123 + * @param full True if we should build the whole LAF or false for building just states and painters.
29.124 + * @param buildDir The directory beneath which the build-controlled artifacts (such as the Painters) should
29.125 + * be placed. This is the root directory beneath which the necessary packages and source
29.126 + * files will be created.
29.127 + * @param srcDir The directory beneath which the normal user-controlled artifacts (such as the core
29.128 + * LookAndFeel file) should be placed. These are one-time generated files. This is the root
29.129 + * directory beneath which the necessary packages and source files will be created.
29.130 + * @param packageNamePrefix The package name associated with this synth look and feel. For example,
29.131 + * org.mypackage.mylaf
29.132 + * @param lafName The name of the laf, such as MyLAF.
29.133 + * @param model The actual SynthModel to base these generated files on.
29.134 + */
29.135 + private Generator(boolean full, File buildDir,
29.136 + String packageNamePrefix, String lafName, SynthModel model) {
29.137 + this.full = full;
29.138 + //validate the input variables
29.139 + if (packageNamePrefix == null) {
29.140 + throw new IllegalArgumentException("You must specify a package name prefix");
29.141 + }
29.142 + if (buildDir == null) {
29.143 + throw new IllegalArgumentException("You must specify the build directory");
29.144 + }
29.145 + if (model == null) {
29.146 + throw new IllegalArgumentException("You must specify the SynthModel");
29.147 + }
29.148 + if (lafName == null) {
29.149 + throw new IllegalArgumentException("You must specify the name of the look and feel");
29.150 + }
29.151 +
29.152 + //construct the map which is used to do variable substitution of the template
29.153 + //files
29.154 + variables = new HashMap<String, String>();
29.155 + variables.put("PACKAGE", packageNamePrefix);
29.156 + variables.put("LAF_NAME", lafName);
29.157 +
29.158 + //generate and save references to the package-root directories.
29.159 + //(That is, given the buildDir and srcDir, generate references to the
29.160 + //org.mypackage.mylaf subdirectories)
29.161 + buildPackageRoot = new File(buildDir, packageNamePrefix.replaceAll("\\.", "\\/"));
29.162 + buildPackageRoot.mkdirs();
29.163 +
29.164 + //save the variables
29.165 + this.packageNamePrefix = packageNamePrefix;
29.166 + this.lafName = lafName;
29.167 + this.model = model;
29.168 + }
29.169 +
29.170 + public static void init(boolean full, File buildDir,
29.171 + String packageNamePrefix, String lafName, SynthModel model) {
29.172 + instance = new Generator(full, buildDir, packageNamePrefix, lafName, model);
29.173 + model.initStyles();
29.174 + }
29.175 +
29.176 + public static Generator getInstance() {
29.177 + return instance;
29.178 + }
29.179 +
29.180 + public static Map<String, String> getVariables() {
29.181 + return new HashMap<String, String>(instance.variables);
29.182 + }
29.183 +
29.184 + public void generate() {
29.185 + if (full) {
29.186 + //create the LookAndFeel file
29.187 + writeSrcFileImpl("LookAndFeel", variables, lafName + "LookAndFeel");
29.188 +
29.189 + writeSrcFileImpl("AbstractRegionPainter", variables);
29.190 + writeSrcFileImpl("BlendingMode", variables);
29.191 + writeSrcFileImpl("SynthPainterImpl", variables);
29.192 + writeSrcFileImpl("IconImpl", variables, lafName + "Icon.java");
29.193 + writeSrcFileImpl("StyleImpl", variables, lafName + "Style.java");
29.194 + writeSrcFileImpl("Effect", variables);
29.195 + writeSrcFileImpl("EffectUtils", variables);
29.196 + writeSrcFileImpl("ShadowEffect", variables);
29.197 + writeSrcFileImpl("DropShadowEffect", variables);
29.198 + writeSrcFileImpl("InnerShadowEffect", variables);
29.199 + writeSrcFileImpl("InnerGlowEffect", variables);
29.200 + writeSrcFileImpl("OuterGlowEffect", variables);
29.201 + writeSrcFileImpl("State", variables);
29.202 + writeSrcFileImpl("ImageCache", variables);
29.203 + writeSrcFileImpl("ImageScalingHelper", variables);
29.204 + }
29.205 + //next, populate the first set of ui defaults based on what is in the
29.206 + //various palettes of the synth model
29.207 + StringBuilder defBuffer = new StringBuilder();
29.208 + StringBuilder styleBuffer = new StringBuilder();
29.209 + model.write(defBuffer, styleBuffer, packageNamePrefix);
29.210 +
29.211 + Map<String, String> vars = getVariables();
29.212 + vars.put("UI_DEFAULT_INIT", defBuffer.toString());
29.213 + vars.put("STYLE_INIT", styleBuffer.toString());
29.214 + writeSrcFile("Defaults", vars, lafName + "Defaults");
29.215 + }
29.216 +
29.217 + private void writeSrcFileImpl(String name, Map<String, String> variables) {
29.218 + writeSrcFileImpl(name, variables, name);
29.219 + }
29.220 +
29.221 + private void writeSrcFileImpl(String templateName,
29.222 + Map<String, String> variables, String outputName) {
29.223 + PrintWriter out = null;
29.224 + try {
29.225 + InputStream stream = getClass().getResourceAsStream(
29.226 + "resources/" + templateName + ".template");
29.227 + TemplateReader in = new TemplateReader(variables, stream);
29.228 +
29.229 + out = new PrintWriter(new File(buildPackageRoot, outputName + ".java"));
29.230 + String line = in.readLine();
29.231 + while (line != null) {
29.232 + out.println(line);
29.233 + line = in.readLine();
29.234 + }
29.235 + } catch (IOException e) {
29.236 + throw new RuntimeException("IOException in writer", e);
29.237 + } finally {
29.238 + if (out != null) out.close();
29.239 + }
29.240 + }
29.241 +
29.242 + public static void writeSrcFile(String templateName,
29.243 + Map<String, String> variables, String outputName) {
29.244 + instance.writeSrcFileImpl(templateName, variables, outputName);
29.245 + }
29.246 +
29.247 + /** A BufferedReader implementation that automatically performs
29.248 + * string replacements as needed.
29.249 + */
29.250 + private static final class TemplateReader extends BufferedReader {
29.251 + private Map<String, String> variables;
29.252 +
29.253 + TemplateReader(Map<String, String> variables, InputStream template) {
29.254 + super(new InputStreamReader(template));
29.255 + this.variables = variables;
29.256 + }
29.257 +
29.258 + @Override public String readLine() throws IOException {
29.259 + return substituteVariables(super.readLine());
29.260 + }
29.261 +
29.262 + private String substituteVariables(String input) {
29.263 + if (input == null) return null;
29.264 + for (Map.Entry<String, String> variable : variables.entrySet()) {
29.265 + input = input.replace("${" + variable.getKey() + "}", variable.getValue());
29.266 + }
29.267 + return input;
29.268 + }
29.269 + }
29.270 +}
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
30.2 +++ b/make/tools/src/build/tools/generatenimbus/ObjectFactory.java Tue Sep 15 23:41:40 2009 -0700
30.3 @@ -0,0 +1,62 @@
30.4 +/*
30.5 + * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
30.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
30.7 + *
30.8 + * This code is free software; you can redistribute it and/or modify it
30.9 + * under the terms of the GNU General Public License version 2 only, as
30.10 + * published by the Free Software Foundation. Sun designates this
30.11 + * particular file as subject to the "Classpath" exception as provided
30.12 + * by Sun in the LICENSE file that accompanied this code.
30.13 + *
30.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
30.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
30.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
30.17 + * version 2 for more details (a copy is included in the LICENSE file that
30.18 + * accompanied this code).
30.19 + *
30.20 + * You should have received a copy of the GNU General Public License version
30.21 + * 2 along with this work; if not, write to the Free Software Foundation,
30.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
30.23 + *
30.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
30.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
30.26 + * have any questions.
30.27 + */
30.28 +
30.29 +package build.tools.generatenimbus;
30.30 +
30.31 +import javax.xml.bind.annotation.XmlRegistry;
30.32 +
30.33 +
30.34 +/**
30.35 + * This object contains factory methods for each
30.36 + * Java content interface and Java element interface
30.37 + * generated in the test package.
30.38 + * <p>An ObjectFactory allows you to programatically
30.39 + * construct new instances of the Java representation
30.40 + * for XML content. The Java representation of XML
30.41 + * content can consist of schema derived interfaces
30.42 + * and classes representing the binding of schema
30.43 + * type definitions, element declarations and model
30.44 + * groups. Factory methods for each of these are
30.45 + * provided in this class.
30.46 + *
30.47 + */
30.48 +@XmlRegistry
30.49 +public class ObjectFactory {
30.50 +
30.51 + /**
30.52 + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: test
30.53 + *
30.54 + */
30.55 + public ObjectFactory() {
30.56 + }
30.57 +
30.58 + /**
30.59 + * Create an instance of {@link SynthModel }
30.60 + *
30.61 + */
30.62 + public SynthModel createSynthModel() {
30.63 + return new SynthModel();
30.64 + }
30.65 +}
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
31.2 +++ b/make/tools/src/build/tools/generatenimbus/Paint.java Tue Sep 15 23:41:40 2009 -0700
31.3 @@ -0,0 +1,181 @@
31.4 +/*
31.5 + * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
31.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
31.7 + *
31.8 + * This code is free software; you can redistribute it and/or modify it
31.9 + * under the terms of the GNU General Public License version 2 only, as
31.10 + * published by the Free Software Foundation. Sun designates this
31.11 + * particular file as subject to the "Classpath" exception as provided
31.12 + * by Sun in the LICENSE file that accompanied this code.
31.13 + *
31.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
31.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
31.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
31.17 + * version 2 for more details (a copy is included in the LICENSE file that
31.18 + * accompanied this code).
31.19 + *
31.20 + * You should have received a copy of the GNU General Public License version
31.21 + * 2 along with this work; if not, write to the Free Software Foundation,
31.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
31.23 + *
31.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
31.26 + * have any questions.
31.27 + */
31.28 +
31.29 +package build.tools.generatenimbus;
31.30 +
31.31 +import java.util.ArrayList;
31.32 +import java.util.List;
31.33 +import javax.xml.bind.annotation.XmlAttribute;
31.34 +import javax.xml.bind.annotation.XmlElement;
31.35 +
31.36 +public abstract class Paint {
31.37 +}
31.38 +
31.39 +class Matte extends Paint {
31.40 + @XmlAttribute private int red;
31.41 + @XmlAttribute private int green;
31.42 + @XmlAttribute private int blue;
31.43 + @XmlAttribute private int alpha;
31.44 +
31.45 + @XmlAttribute private String uiDefaultParentName = null;
31.46 + @XmlAttribute private float hueOffset = 0;
31.47 + @XmlAttribute private float saturationOffset = 0;
31.48 + @XmlAttribute private float brightnessOffset = 0;
31.49 + @XmlAttribute private int alphaOffset = 0;
31.50 +
31.51 + @XmlAttribute private String componentPropertyName = null;
31.52 + public String getComponentPropertyName() { return componentPropertyName; }
31.53 +
31.54 + @XmlAttribute private boolean uiResource = true;
31.55 +
31.56 + public boolean isAbsolute() {
31.57 + return uiDefaultParentName == null;
31.58 + }
31.59 +
31.60 + public String getDeclaration() {
31.61 + if (isAbsolute()) {
31.62 + return String.format("new Color(%d, %d, %d, %d)",
31.63 + red, green, blue, alpha);
31.64 + } else {
31.65 + return String.format("decodeColor(\"%s\", %sf, %sf, %sf, %d)",
31.66 + uiDefaultParentName, String.valueOf(hueOffset),
31.67 + String.valueOf(saturationOffset),
31.68 + String.valueOf(brightnessOffset), alphaOffset);
31.69 + }
31.70 + }
31.71 +
31.72 + public String write() {
31.73 + if (isAbsolute()) {
31.74 + return String.format("%s, %s, %s, %s", red, green, blue, alpha);
31.75 + } else {
31.76 + String s = String.format("\"%s\", %sf, %sf, %sf, %d",
31.77 + uiDefaultParentName, String.valueOf(hueOffset),
31.78 + String.valueOf(saturationOffset),
31.79 + String.valueOf(brightnessOffset), alphaOffset);
31.80 + if (! uiResource) {
31.81 + s += ", false";
31.82 + }
31.83 + return s;
31.84 + }
31.85 + }
31.86 +
31.87 + public ComponentColor createComponentColor(String variableName) {
31.88 + return new ComponentColor(componentPropertyName, variableName,
31.89 + saturationOffset, brightnessOffset, alphaOffset);
31.90 + }
31.91 +}
31.92 +
31.93 +class ComponentColor {
31.94 + private String propertyName;
31.95 + private String defaultColorVariableName;
31.96 + private float saturationOffset = 0, brightnessOffset = 0;
31.97 + private int alphaOffset = 0;
31.98 +
31.99 + ComponentColor(String propertyName,
31.100 + String defaultColorVariableName,
31.101 + float saturationOffset,
31.102 + float brightnessOffset,
31.103 + int alphaOffset) {
31.104 + this.propertyName = propertyName;
31.105 + this.defaultColorVariableName = defaultColorVariableName;
31.106 + this.saturationOffset = saturationOffset;
31.107 + this.brightnessOffset = brightnessOffset;
31.108 + this.alphaOffset = alphaOffset;
31.109 + }
31.110 +
31.111 + @Override
31.112 + public boolean equals(Object o) {
31.113 + if (this == o) {
31.114 + return true;
31.115 + }
31.116 + if (o == null || getClass() != o.getClass()) {
31.117 + return false;
31.118 + }
31.119 +
31.120 + ComponentColor c = (ComponentColor) o;
31.121 + if (alphaOffset != c.alphaOffset) {
31.122 + return false;
31.123 + }
31.124 + if (Float.compare(saturationOffset, c.saturationOffset) != 0) {
31.125 + return false;
31.126 + }
31.127 + if (Float.compare(brightnessOffset, c.brightnessOffset) != 0) {
31.128 + return false;
31.129 + }
31.130 + if (defaultColorVariableName != null ? !defaultColorVariableName.equals(c.defaultColorVariableName) : c.defaultColorVariableName != null) {
31.131 + return false;
31.132 + }
31.133 + if (propertyName != null ? !propertyName.equals(c.propertyName) : c.propertyName != null) {
31.134 + return false;
31.135 + }
31.136 + return true;
31.137 + }
31.138 +
31.139 + @Override
31.140 + public int hashCode() {
31.141 + int hash = 5;
31.142 + hash = 61 * hash + (this.propertyName != null ? this.propertyName.hashCode() : 0);
31.143 + hash = 61 * hash + (this.defaultColorVariableName != null ? this.defaultColorVariableName.hashCode() : 0);
31.144 + hash = 61 * hash + Float.floatToIntBits(this.saturationOffset);
31.145 + hash = 61 * hash + Float.floatToIntBits(this.brightnessOffset);
31.146 + hash = 61 * hash + this.alphaOffset;
31.147 + return hash;
31.148 + }
31.149 +
31.150 + public void write(StringBuilder sb) {
31.151 + sb.append(" getComponentColor(c, \"").
31.152 + append(propertyName).append("\", ").
31.153 + append(defaultColorVariableName).append(", ").
31.154 + append(saturationOffset).append("f, ").
31.155 + append(brightnessOffset).append("f, ").
31.156 + append(alphaOffset);
31.157 + }
31.158 +}
31.159 +
31.160 +class GradientStop {
31.161 + @XmlAttribute private float position;
31.162 + public float getPosition() { return position; }
31.163 +
31.164 + @XmlAttribute private float midpoint;
31.165 + public float getMidpoint() { return midpoint; }
31.166 +
31.167 + @XmlElement private Matte matte;
31.168 + public Matte getColor() { return matte; }
31.169 +}
31.170 +
31.171 +class AbstractGradient extends Paint {
31.172 + public static enum CycleMethod {
31.173 + NO_CYCLE, REFLECT, REPEAT
31.174 + }
31.175 +
31.176 + @XmlElement(name="stop") private ArrayList<GradientStop> stops;
31.177 + public List<GradientStop> getStops() { return stops; }
31.178 +}
31.179 +
31.180 +class Gradient extends AbstractGradient {
31.181 +}
31.182 +
31.183 +class RadialGradient extends AbstractGradient {
31.184 +}
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
32.2 +++ b/make/tools/src/build/tools/generatenimbus/PainterGenerator.java Tue Sep 15 23:41:40 2009 -0700
32.3 @@ -0,0 +1,627 @@
32.4 +/*
32.5 + * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
32.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
32.7 + *
32.8 + * This code is free software; you can redistribute it and/or modify it
32.9 + * under the terms of the GNU General Public License version 2 only, as
32.10 + * published by the Free Software Foundation. Sun designates this
32.11 + * particular file as subject to the "Classpath" exception as provided
32.12 + * by Sun in the LICENSE file that accompanied this code.
32.13 + *
32.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
32.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
32.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
32.17 + * version 2 for more details (a copy is included in the LICENSE file that
32.18 + * accompanied this code).
32.19 + *
32.20 + * You should have received a copy of the GNU General Public License version
32.21 + * 2 along with this work; if not, write to the Free Software Foundation,
32.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
32.23 + *
32.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
32.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
32.26 + * have any questions.
32.27 + */
32.28 +package build.tools.generatenimbus;
32.29 +
32.30 +import java.awt.geom.Point2D;
32.31 +import java.util.ArrayList;
32.32 +import java.util.HashMap;
32.33 +import java.util.LinkedHashMap;
32.34 +import java.util.List;
32.35 +import java.util.Map;
32.36 +
32.37 +
32.38 +/**
32.39 + * PainterGenerator - Class for generating Painter class java source from a Canvas
32.40 + *
32.41 + * Following in the general theory that is used to generate a Painter file.
32.42 + *
32.43 + * Each Painter file represents a Region. So there is one painter file per region. In
32.44 + * skin.laf we support Icon subregions, which are really just hacked versions of the
32.45 + * parent region.
32.46 + *
32.47 + * In order to generate the most compact and efficient bytecode possible for the
32.48 + * Painters, we actually perform the generation sequence in two steps. The first
32.49 + * step is the analysis phase, where we walk through the SynthModel for the region
32.50 + * and discover commonality among the different states in the region. For example,
32.51 + * do they have common paths? Do they have common colors? Gradients? Is the painting
32.52 + * code for the different states identical other than for colors?
32.53 + *
32.54 + * We gather this information up. On the second pass, we use this data to determine the
32.55 + * methods that need to be generated, and the class variables that need to be generated.
32.56 + * We try to keep the actual bytecode count as small as possible so that we may reduce
32.57 + * the overall size of the look and feel significantly.
32.58 + *
32.59 + * @author Richard Bair
32.60 + * @author Jasper Potts
32.61 + */
32.62 +public class PainterGenerator {
32.63 + //a handful of counters, incremented whenever the associated object type is encounted.
32.64 + //These counters form the basis of the field and method suffixes.
32.65 + //These are all 1 based, because I felt like it :-)
32.66 + private int colorCounter = 1;
32.67 + private int gradientCounter = 1;
32.68 + private int radialCounter = 1;
32.69 + private int pathCounter = 1;
32.70 + private int rectCounter = 1;
32.71 + private int roundRectCounter = 1;
32.72 + private int ellipseCounter = 1;
32.73 +
32.74 + private int stateTypeCounter = 1;
32.75 +
32.76 + //during the first pass, we will construct these maps
32.77 + private Map<String, String> colors = new HashMap<String, String>();
32.78 + /**
32.79 + * Code=>method name.
32.80 + */
32.81 + private Map<String, String> methods = new HashMap<String, String>();
32.82 +
32.83 + //these variables hold the generated code
32.84 + /**
32.85 + * The source code in this variable will be used to define the various state types
32.86 + */
32.87 + private StringBuilder stateTypeCode = new StringBuilder();
32.88 + /**
32.89 + * The source code in this variable will be used to define the switch statement for painting
32.90 + */
32.91 + private StringBuilder switchCode = new StringBuilder();
32.92 + /**
32.93 + * The source code in this variable will be used to define the methods for painting each state
32.94 + */
32.95 + private StringBuilder paintingCode = new StringBuilder();
32.96 + /**
32.97 + * The source code in this variable will be used to add getExtendedCacheKeys
32.98 + * implementation if needed.
32.99 + */
32.100 + private StringBuilder getExtendedCacheKeysCode = new StringBuilder();
32.101 + /**
32.102 + * The source code in this variable will be used to define the methods for decoding gradients
32.103 + * and shapes.
32.104 + */
32.105 + private StringBuilder gradientsCode = new StringBuilder();
32.106 + private StringBuilder colorCode = new StringBuilder();
32.107 + private StringBuilder shapesCode = new StringBuilder();
32.108 + /**
32.109 + * Map of component colors keyed by state constant name
32.110 + */
32.111 + private Map<String, List<ComponentColor>> componentColorsMap =
32.112 + new LinkedHashMap<String, List<ComponentColor>>();
32.113 + /**
32.114 + * For the current state the list of all component colors used by this
32.115 + * painter, the index in this list is also the index in the runtime array
32.116 + * of defaults and keys.
32.117 + */
32.118 + private List<ComponentColor> componentColors = null;
32.119 +
32.120 + PainterGenerator(UIRegion r) {
32.121 + generate(r);
32.122 + }
32.123 +
32.124 + private void generate(UIRegion r) {
32.125 + for (UIState state : r.getBackgroundStates()) {
32.126 + Canvas canvas = state.getCanvas();
32.127 + String type = (r instanceof UIIconRegion ? r.getKey() : "Background");
32.128 + generate(state, canvas, type);
32.129 + }
32.130 + for (UIState state : r.getForegroundStates()) {
32.131 + Canvas canvas = state.getCanvas();
32.132 + generate(state, canvas, "Foreground");
32.133 + }
32.134 + for (UIState state : r.getBorderStates()) {
32.135 + Canvas canvas = state.getCanvas();
32.136 + generate(state, canvas, "Border");
32.137 + }
32.138 + //now check for any uiIconRegions, since these are collapsed together.
32.139 + for (UIRegion sub : r.getSubRegions()) {
32.140 + if (sub instanceof UIIconRegion) {
32.141 + generate(sub);
32.142 + }
32.143 + }
32.144 + //generate all the code for component colors
32.145 + if (!componentColorsMap.isEmpty()) {
32.146 + getExtendedCacheKeysCode
32.147 + .append(" protected Object[] getExtendedCacheKeys(JComponent c) {\n")
32.148 + .append(" Object[] extendedCacheKeys = null;\n")
32.149 + .append(" switch(state) {\n");
32.150 + for (Map.Entry<String, List<ComponentColor>> entry : componentColorsMap.entrySet()) {
32.151 + getExtendedCacheKeysCode
32.152 + .append(" case ")
32.153 + .append(entry.getKey()).append(":\n")
32.154 + .append(" extendedCacheKeys = new Object[] {\n");
32.155 + for (int i=0; i<entry.getValue().size(); i++) {
32.156 + ComponentColor cc = entry.getValue().get(i);
32.157 + cc.write(getExtendedCacheKeysCode);
32.158 + if (i + 1 < entry.getValue().size()) {
32.159 + getExtendedCacheKeysCode.append("),\n");
32.160 + } else {
32.161 + getExtendedCacheKeysCode.append(")");
32.162 + }
32.163 + }
32.164 + getExtendedCacheKeysCode.append("};\n")
32.165 + .append(" break;\n");
32.166 + }
32.167 + getExtendedCacheKeysCode
32.168 + .append(" }\n")
32.169 + .append(" return extendedCacheKeys;\n")
32.170 + .append(" }");
32.171 + }
32.172 + }
32.173 +
32.174 + //type is background, foreground, border, upArrowIcon, etc.
32.175 + private void generate(UIState state, Canvas canvas, String type) {
32.176 + String states = state.getStateKeys();
32.177 + String stateType = Utils.statesToConstantName(type + "_" + states);
32.178 + String paintMethodName = "paint" + type + Utils.statesToClassName(states);
32.179 + //create new array for component colors for this state
32.180 + componentColors = new ArrayList<ComponentColor>();
32.181 +
32.182 + stateTypeCode.append(" static final int ").append(stateType).append(" = ").append(stateTypeCounter++).append(";\n");
32.183 +
32.184 + if (canvas.isBlank()) {
32.185 + return;
32.186 + }
32.187 +
32.188 + switchCode.append(" case ").append(stateType).append(": ").append(paintMethodName).append("(g); break;\n");
32.189 + paintingCode.append(" private void ").append(paintMethodName).append("(Graphics2D g) {\n");
32.190 +
32.191 + //start by setting up common info needed to encode the control points
32.192 + Insets in = canvas.getStretchingInsets();
32.193 + float a = in.left;
32.194 + float b = canvas.getSize().width - in.right;
32.195 + float c = in.top;
32.196 + float d = canvas.getSize().height - in.bottom;
32.197 + float width = canvas.getSize().width;
32.198 + float height = canvas.getSize().height;
32.199 + float cw = b - a;
32.200 + float ch = d - c;
32.201 +
32.202 + Layer[] layers = canvas.getLayers().toArray(new Layer[0]);
32.203 + for (int index=layers.length-1; index >= 0; index--) {
32.204 + Layer layer = layers[index];
32.205 +
32.206 + //shapes must be painted in reverse order
32.207 + List<Shape> shapes = layer.getShapes();
32.208 + for (int i=shapes.size()-1; i>=0; i--) {
32.209 + Shape shape = shapes.get(i);
32.210 + Paint paint = shape.getPaint();
32.211 +
32.212 + /*
32.213 + We attempt to write the minimal number of bytecodes as possible when
32.214 + generating code. Due to the inherit complexities in determining what
32.215 + is extraneous, we use the following system:
32.216 +
32.217 + We first generate the code for the shape. Then, we check to see if
32.218 + this shape has already been generated. If so, then we defer to an
32.219 + existing method. If not, then we will create a new methods, stick
32.220 + the code in it, and refer to that method.
32.221 + */
32.222 +
32.223 + String shapeMethodName = null; // will contain the name of the method which creates the shape
32.224 + String shapeVariable = null; // will be one of rect, roundRect, ellipse, or path.
32.225 + String shapeMethodBody = null;
32.226 +
32.227 + if (shape instanceof Rectangle) {
32.228 + Rectangle rshape = (Rectangle) shape;
32.229 + float x1 = encode((float)rshape.getX1(), a, b, width);
32.230 + float y1 = encode((float)rshape.getY1(), c, d, height);
32.231 + float x2 = encode((float)rshape.getX2(), a, b, width);
32.232 + float y2 = encode((float)rshape.getY2(), c, d, height);
32.233 + if (rshape.isRounded()) {
32.234 + //it is a rounded rectangle
32.235 + float rounding = (float)rshape.getRounding();
32.236 +
32.237 + shapeMethodBody =
32.238 + " roundRect.setRoundRect(" +
32.239 + writeDecodeX(x1) + ", //x\n" +
32.240 + " " + writeDecodeY(y1) + ", //y\n" +
32.241 + " " + writeDecodeX(x2) + " - " + writeDecodeX(x1) + ", //width\n" +
32.242 + " " + writeDecodeY(y2) + " - " + writeDecodeY(y1) + ", //height\n" +
32.243 + " " + rounding + "f, " + rounding + "f); //rounding";
32.244 + shapeVariable = "roundRect";
32.245 + } else {
32.246 + shapeMethodBody =
32.247 + " rect.setRect(" +
32.248 + writeDecodeX(x1) + ", //x\n" +
32.249 + " " + writeDecodeY(y1) + ", //y\n" +
32.250 + " " + writeDecodeX(x2) + " - " + writeDecodeX(x1) + ", //width\n" +
32.251 + " " + writeDecodeY(y2) + " - " + writeDecodeY(y1) + "); //height";
32.252 + shapeVariable = "rect";
32.253 + }
32.254 + } else if (shape instanceof Ellipse) {
32.255 + Ellipse eshape = (Ellipse) shape;
32.256 + float x1 = encode((float)eshape.getX1(), a, b, width);
32.257 + float y1 = encode((float)eshape.getY1(), c, d, height);
32.258 + float x2 = encode((float)eshape.getX2(), a, b, width);
32.259 + float y2 = encode((float)eshape.getY2(), c, d, height);
32.260 + shapeMethodBody =
32.261 + " ellipse.setFrame(" +
32.262 + writeDecodeX(x1) + ", //x\n" +
32.263 + " " + writeDecodeY(y1) + ", //y\n" +
32.264 + " " + writeDecodeX(x2) + " - " + writeDecodeX(x1) + ", //width\n" +
32.265 + " " + writeDecodeY(y2) + " - " + writeDecodeY(y1) + "); //height";
32.266 + shapeVariable = "ellipse";
32.267 + } else if (shape instanceof Path) {
32.268 + Path pshape = (Path) shape;
32.269 + List<Point> controlPoints = pshape.getControlPoints();
32.270 + Point first, last;
32.271 + first = last = controlPoints.get(0);
32.272 + StringBuilder buffer = new StringBuilder();
32.273 + buffer.append(" path.reset();\n");
32.274 + buffer.append(" path.moveTo(" + writeDecodeX(encode((float)first.getX(), a, b, width)) + ", " + writeDecodeY(encode((float)first.getY(), c, d, height)) + ");\n");
32.275 + for (int j=1; j<controlPoints.size(); j++) {
32.276 + Point cp = controlPoints.get(j);
32.277 + if (last.isP2Sharp() && cp.isP1Sharp()) {
32.278 + float x = encode((float)cp.getX(), a, b, width);
32.279 + float y = encode((float)cp.getY(), c, d, height);
32.280 + buffer.append(" path.lineTo(" + writeDecodeX(x) + ", " + writeDecodeY(y) + ");\n");
32.281 + } else {
32.282 + float x1 = encode((float)last.getX(), a, b, width);
32.283 + float y1 = encode((float)last.getY(), c, d, height);
32.284 + float x2 = encode((float)cp.getX(), a, b, width);
32.285 + float y2 = encode((float)cp.getY(), c, d, height);
32.286 + buffer.append(
32.287 + " path.curveTo(" + writeDecodeBezierX(x1, last.getX(), last.getCp2X()) + ", "
32.288 + + writeDecodeBezierY(y1, last.getY(), last.getCp2Y()) + ", "
32.289 + + writeDecodeBezierX(x2, cp.getX(), cp.getCp1X()) + ", "
32.290 + + writeDecodeBezierY(y2, cp.getY(), cp.getCp1Y()) + ", "
32.291 + + writeDecodeX(x2) + ", " + writeDecodeY(y2) + ");\n");
32.292 + }
32.293 + last = cp;
32.294 + }
32.295 + if (last.isP2Sharp() && first.isP1Sharp()) {
32.296 + float x = encode((float)first.getX(), a, b, width);
32.297 + float y = encode((float)first.getY(), c, d, height);
32.298 + buffer.append(" path.lineTo(" + writeDecodeX(x) + ", " + writeDecodeY(y) + ");\n");
32.299 + } else {
32.300 + float x1 = encode((float)last.getX(), a, b, width);
32.301 + float y1 = encode((float)last.getY(), c, d, height);
32.302 + float x2 = encode((float)first.getX(), a, b, width);
32.303 + float y2 = encode((float)first.getY(), c, d, height);
32.304 + buffer.append(
32.305 + " path.curveTo(" + writeDecodeBezierX(x1, last.getX(), last.getCp2X()) + ", "
32.306 + + writeDecodeBezierY(y1, last.getY(), last.getCp2Y()) + ", "
32.307 + + writeDecodeBezierX(x2, first.getX(), first.getCp1X()) + ", "
32.308 + + writeDecodeBezierY(y2, first.getY(), first.getCp1Y()) + ", "
32.309 + + writeDecodeX(x2) + ", " + writeDecodeY(y2) + ");\n");
32.310 + }
32.311 + buffer.append(" path.closePath();");
32.312 + shapeMethodBody = buffer.toString();
32.313 + shapeVariable = "path";
32.314 + } else {
32.315 + throw new RuntimeException("Cannot happen unless a new Shape has been defined");
32.316 + }
32.317 +
32.318 + //now that we have the shape defined in shapeMethodBody, and a shapeVariable name,
32.319 + //look to see if such a body has been previously defined.
32.320 + shapeMethodName = methods.get(shapeMethodBody);
32.321 + String returnType = null;
32.322 + if (shapeMethodName == null) {
32.323 + if ("rect".equals(shapeVariable)) {
32.324 + shapeMethodName = "decodeRect" + rectCounter++;
32.325 + returnType = "Rectangle2D";
32.326 + } else if ("roundRect".equals(shapeVariable)) {
32.327 + shapeMethodName = "decodeRoundRect" + roundRectCounter++;
32.328 + returnType = "RoundRectangle2D";
32.329 + } else if ("ellipse".equals(shapeVariable)) {
32.330 + shapeMethodName = "decodeEllipse" + ellipseCounter++;
32.331 + returnType = "Ellipse2D";
32.332 + } else {
32.333 + shapeMethodName = "decodePath" + pathCounter++;
32.334 + returnType = "Path2D";
32.335 + }
32.336 + methods.put(shapeMethodBody, shapeMethodName);
32.337 +
32.338 + //since the method wasn't previously defined, time to define it
32.339 + shapesCode.append(" private ").append(returnType).append(" ").append(shapeMethodName).append("() {\n");
32.340 + shapesCode.append(shapeMethodBody);
32.341 + shapesCode.append("\n");
32.342 + shapesCode.append(" return " + shapeVariable + ";\n");
32.343 + shapesCode.append(" }\n\n");
32.344 + }
32.345 +
32.346 + //now that the method has been defined, I can go on and decode the
32.347 + //paint. After the paint is decoded, I can write the g.fill() method call,
32.348 + //using the result of the shapeMethodName. Yay!
32.349 +
32.350 +// if (shapeVariable != null) {
32.351 + //first, calculate the bounds of the shape being painted and store in variables
32.352 + paintingCode.append(" ").append(shapeVariable).append(" = ").append(shapeMethodName).append("();\n");
32.353 +
32.354 + if (paint instanceof Matte) {
32.355 + String colorVariable = encodeMatte((Matte)paint);
32.356 + paintingCode.append(" g.setPaint(").append(colorVariable).append(");\n");
32.357 + } else if (paint instanceof Gradient) {
32.358 + String gradientMethodName = encodeGradient(shape, (Gradient)paint);
32.359 + paintingCode.append(" g.setPaint(").append(gradientMethodName).append("(").append(shapeVariable).append("));\n");
32.360 + } else if (paint instanceof RadialGradient) {
32.361 + String radialMethodName = encodeRadial(shape, (RadialGradient)paint);
32.362 + paintingCode.append(" g.setPaint(").append(radialMethodName).append("(").append(shapeVariable).append("));\n");
32.363 + }
32.364 + paintingCode.append(" g.fill(").append(shapeVariable).append(");\n");
32.365 + }
32.366 + }
32.367 +
32.368 + paintingCode.append("\n }\n\n");
32.369 +
32.370 + //collect component colors
32.371 + if (!componentColors.isEmpty()) {
32.372 + componentColorsMap.put(stateType, componentColors);
32.373 + componentColors = null;
32.374 + }
32.375 + }
32.376 +
32.377 + private float encode(float x, float a, float b, float w) {
32.378 + float r = 0;
32.379 + if (x < a) {
32.380 + r = (x / a);
32.381 + } else if (x > b) {
32.382 + r = 2 + ((x - b) / (w - b));
32.383 + } else if (x == a && x == b) {
32.384 + return 1.5f;
32.385 + } else {
32.386 + r = 1 + ((x - a) / (b - a));
32.387 + }
32.388 +
32.389 + if (Float.isNaN(r)) {
32.390 + System.err.println("[Error] Encountered NaN: encode(" + x + ", " + a + ", " + b + ", " + w + ")");
32.391 + return 0;
32.392 + } else if (Float.isInfinite(r)) {
32.393 + System.err.println("[Error] Encountered Infinity: encode(" + x + ", " + a + ", " + b + ", " + w + ")");
32.394 + return 0;
32.395 + } else if (r < 0) {
32.396 + System.err.println("[Error] encoded value was less than 0: encode(" + x + ", " + a + ", " + b + ", " + w + ")");
32.397 + return 0;
32.398 + } else if (r > 3) {
32.399 + System.err.println("[Error] encoded value was greater than 3: encode(" + x + ", " + a + ", " + b + ", " + w + ")");
32.400 + return 3;
32.401 + } else {
32.402 + return r;
32.403 + }
32.404 + }
32.405 +
32.406 + private String writeDecodeX(float encodedX) {
32.407 + return "decodeX(" + encodedX + "f)";
32.408 + }
32.409 +
32.410 + private String writeDecodeY(float encodedY) {
32.411 + return "decodeY(" + encodedY + "f)";
32.412 + }
32.413 +
32.414 + /**
32.415 + *
32.416 + * @param ex encoded x value
32.417 + * @param x unencoded x value
32.418 + * @param cpx unencoded cpx value
32.419 + * @return
32.420 + */
32.421 + private static String writeDecodeBezierX(double ex, double x, double cpx) {
32.422 + return "decodeAnchorX(" + ex + "f, " + (cpx - x) + "f)";
32.423 + }
32.424 +
32.425 + /**
32.426 + *
32.427 + * @param ey encoded y value
32.428 + * @param y unencoded y value
32.429 + * @param cpy unencoded cpy value
32.430 + * @return
32.431 + */
32.432 + private static String writeDecodeBezierY(double ey, double y, double cpy) {
32.433 + return "decodeAnchorY(" + ey + "f, " + (cpy - y) + "f)";
32.434 + }
32.435 +
32.436 + private String encodeMatte(Matte m) {
32.437 + String declaration = m.getDeclaration();
32.438 + String variableName = colors.get(declaration);
32.439 + if (variableName == null) {
32.440 + variableName = "color" + colorCounter++;
32.441 + colors.put(declaration, variableName);
32.442 + colorCode.append(String.format(" private Color %s = %s;\n",
32.443 + variableName, declaration));
32.444 + }
32.445 + // handle component colors
32.446 + if (m.getComponentPropertyName() != null) {
32.447 + ComponentColor cc = m.createComponentColor(variableName);
32.448 + int index = componentColors.indexOf(cc);
32.449 + if (index == -1) {
32.450 + index = componentColors.size();
32.451 + componentColors.add(cc);
32.452 + }
32.453 + return "(Color)componentColors[" + index + "]";
32.454 + } else {
32.455 + return variableName;
32.456 + }
32.457 + }
32.458 +
32.459 + private String encodeGradient(Shape ps, Gradient g) {
32.460 + StringBuilder b = new StringBuilder();
32.461 + float x1 = (float)ps.getPaintX1();
32.462 + float y1 = (float)ps.getPaintY1();
32.463 + float x2 = (float)ps.getPaintX2();
32.464 + float y2 = (float)ps.getPaintY2();
32.465 + b.append(" return decodeGradient((");
32.466 + b.append(x1);
32.467 + b.append("f * w) + x, (");
32.468 + b.append(y1);
32.469 + b.append("f * h) + y, (");
32.470 + b.append(x2);
32.471 + b.append("f * w) + x, (");
32.472 + b.append(y2);
32.473 + b.append("f * h) + y,\n");
32.474 + encodeGradientColorsAndFractions(g,b);
32.475 + b.append(");");
32.476 +
32.477 + String methodBody = b.toString();
32.478 + String methodName = methods.get(methodBody);
32.479 + if (methodName == null) {
32.480 + methodName = "decodeGradient" + gradientCounter++;
32.481 + gradientsCode.append(" private Paint ").append(methodName).append("(Shape s) {\n");
32.482 + gradientsCode.append(" Rectangle2D bounds = s.getBounds2D();\n");
32.483 + gradientsCode.append(" float x = (float)bounds.getX();\n");
32.484 + gradientsCode.append(" float y = (float)bounds.getY();\n");
32.485 + gradientsCode.append(" float w = (float)bounds.getWidth();\n");
32.486 + gradientsCode.append(" float h = (float)bounds.getHeight();\n");
32.487 + gradientsCode.append(methodBody);
32.488 + gradientsCode.append("\n }\n\n");
32.489 + methods.put(methodBody, methodName);
32.490 + }
32.491 + return methodName;
32.492 + }
32.493 +
32.494 + /**
32.495 + * Takes a abstract gradient and creates the code for the fractions float
32.496 + * array and the colors array that can be used in the constructors of linear
32.497 + * and radial gradients.
32.498 + *
32.499 + * @param g The abstract gradient to get stops from
32.500 + * @param b Append code string of the form "new float[]{...},
32.501 + * new Color[]{...}" to this StringBuilder
32.502 + */
32.503 + private void encodeGradientColorsAndFractions(AbstractGradient g,
32.504 + StringBuilder b) {
32.505 + List<GradientStop> stops = g.getStops();
32.506 + // there are stops.size() number of main stops. Between each is a
32.507 + // fractional stop. Thus, there are: stops.size() + stops.size() - 1
32.508 + // number of fractions and colors.
32.509 + float[] fractions = new float[stops.size() + stops.size() - 1];
32.510 + String[] colors = new String[fractions.length];
32.511 + //for each stop, create the stop and it's associated fraction
32.512 + int index = 0; // the index into fractions and colors
32.513 + for (int i = 0; i < stops.size(); i++) {
32.514 + GradientStop s = stops.get(i);
32.515 + //copy over the stop's data
32.516 + colors[index] = encodeMatte(s.getColor());
32.517 + fractions[index] = s.getPosition();
32.518 +
32.519 + //If this isn't the last stop, then add in the fraction
32.520 + if (index < fractions.length - 1) {
32.521 + float f1 = s.getPosition();
32.522 + float f2 = stops.get(i + 1).getPosition();
32.523 + index++;
32.524 + fractions[index] = f1 + (f2 - f1) * s.getMidpoint();
32.525 + colors[index] = "decodeColor("+
32.526 + colors[index - 1]+","+
32.527 + encodeMatte(stops.get(i + 1).getColor())+",0.5f)";
32.528 + }
32.529 + index++;
32.530 + }
32.531 + // Check boundry conditions
32.532 + for (int i = 1; i < fractions.length; i++) {
32.533 + //to avoid an error with LinearGradientPaint where two fractions
32.534 + //are identical, bump up the fraction value by a miniscule amount
32.535 + //if it is identical to the previous one
32.536 + //NOTE: The <= is critical because the previous value may already
32.537 + //have been bumped up
32.538 + if (fractions[i] <= fractions[i - 1]) {
32.539 + fractions[i] = fractions[i - 1] + .000001f;
32.540 + }
32.541 + }
32.542 + //another boundary condition where multiple stops are all at the end. The
32.543 + //previous loop bumped all but one of these past 1.0, which is bad.
32.544 + //so remove any fractions (and their colors!) that are beyond 1.0
32.545 + int outOfBoundsIndex = -1;
32.546 + for (int i = 0; i < fractions.length; i++) {
32.547 + if (fractions[i] > 1) {
32.548 + outOfBoundsIndex = i;
32.549 + break;
32.550 + }
32.551 + }
32.552 + if (outOfBoundsIndex >= 0) {
32.553 + float[] f = fractions;
32.554 + String[] c = colors;
32.555 + fractions = new float[outOfBoundsIndex];
32.556 + colors = new String[outOfBoundsIndex];
32.557 + System.arraycopy(f, 0, fractions, 0, outOfBoundsIndex);
32.558 + System.arraycopy(c, 0, colors, 0, outOfBoundsIndex);
32.559 + }
32.560 + // build string
32.561 + b.append(" new float[] { ");
32.562 + for (int i = 0; i < fractions.length; i++) {
32.563 + if (i>0)b.append(',');
32.564 + b.append(fractions[i]);
32.565 + b.append('f');
32.566 + }
32.567 + b.append(" },\n new Color[] { ");
32.568 + for (int i = 0; i < colors.length; i++) {
32.569 + if (i>0) b.append(",\n ");
32.570 + b.append(colors[i]);
32.571 + }
32.572 + b.append("}");
32.573 + }
32.574 +
32.575 + private String encodeRadial(Shape ps, RadialGradient g) {
32.576 + float centerX1 = (float)ps.getPaintX1();
32.577 + float centerY1 = (float)ps.getPaintY1();
32.578 + float x2 = (float)ps.getPaintX2();
32.579 + float y2 = (float)ps.getPaintY2();
32.580 + float radius = (float)Point2D.distance(centerX1, centerY1, x2, y2);
32.581 + StringBuilder b = new StringBuilder();
32.582 +
32.583 + b.append(" return decodeRadialGradient((");
32.584 + b.append(centerX1);
32.585 + b.append("f * w) + x, (");
32.586 + b.append(centerY1);
32.587 + b.append("f * h) + y, ");
32.588 + b.append(radius);
32.589 + b.append("f,\n");
32.590 + encodeGradientColorsAndFractions(g,b);
32.591 + b.append(");");
32.592 +
32.593 + String methodBody = b.toString();
32.594 + String methodName = methods.get(methodBody);
32.595 + if (methodName == null) {
32.596 + methodName = "decodeRadial" + radialCounter++;
32.597 + gradientsCode.append(" private Paint ").append(methodName).append("(Shape s) {\n");
32.598 + gradientsCode.append(" Rectangle2D bounds = s.getBounds2D();\n");
32.599 + gradientsCode.append(" float x = (float)bounds.getX();\n");
32.600 + gradientsCode.append(" float y = (float)bounds.getY();\n");
32.601 + gradientsCode.append(" float w = (float)bounds.getWidth();\n");
32.602 + gradientsCode.append(" float h = (float)bounds.getHeight();\n");
32.603 + gradientsCode.append(methodBody);
32.604 + gradientsCode.append("\n }\n\n");
32.605 + methods.put(methodBody, methodName);
32.606 + }
32.607 + return methodName;
32.608 + }
32.609 +
32.610 + //note that this method is not thread-safe. In fact, none of this class is.
32.611 + public static void writePainter(UIRegion r, String painterName) {
32.612 + //Need only write out the stuff for this region, don't need to worry about subregions
32.613 + //since this method will be called for each of those (and they go in their own file, anyway).
32.614 + //The only subregion that we compound into this is the one for icons.
32.615 + PainterGenerator gen = new PainterGenerator(r);
32.616 + System.out.println("Generating source file: " + painterName + ".java");
32.617 +
32.618 + Map<String, String> variables = Generator.getVariables();
32.619 + variables.put("PAINTER_NAME", painterName);
32.620 + variables.put("STATIC_DECL", gen.stateTypeCode.toString());
32.621 + variables.put("COLORS_DECL", gen.colorCode.toString());
32.622 + variables.put("DO_PAINT_SWITCH_BODY", gen.switchCode.toString());
32.623 + variables.put("PAINTING_DECL", gen.paintingCode.toString());
32.624 + variables.put("GET_EXTENDED_CACHE_KEYS", gen.getExtendedCacheKeysCode.toString());
32.625 + variables.put("SHAPES_DECL", gen.shapesCode.toString());
32.626 + variables.put("GRADIENTS_DECL", gen.gradientsCode.toString());
32.627 +
32.628 + Generator.writeSrcFile("PainterImpl", variables, painterName);
32.629 + }
32.630 +}
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
33.2 +++ b/make/tools/src/build/tools/generatenimbus/Shape.java Tue Sep 15 23:41:40 2009 -0700
33.3 @@ -0,0 +1,140 @@
33.4 +/*
33.5 + * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
33.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33.7 + *
33.8 + * This code is free software; you can redistribute it and/or modify it
33.9 + * under the terms of the GNU General Public License version 2 only, as
33.10 + * published by the Free Software Foundation. Sun designates this
33.11 + * particular file as subject to the "Classpath" exception as provided
33.12 + * by Sun in the LICENSE file that accompanied this code.
33.13 + *
33.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
33.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
33.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
33.17 + * version 2 for more details (a copy is included in the LICENSE file that
33.18 + * accompanied this code).
33.19 + *
33.20 + * You should have received a copy of the GNU General Public License version
33.21 + * 2 along with this work; if not, write to the Free Software Foundation,
33.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
33.23 + *
33.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
33.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
33.26 + * have any questions.
33.27 + */
33.28 +
33.29 +package build.tools.generatenimbus;
33.30 +
33.31 +import java.util.ArrayList;
33.32 +import java.util.List;
33.33 +import javax.xml.bind.annotation.XmlAttribute;
33.34 +import javax.xml.bind.annotation.XmlElement;
33.35 +import javax.xml.bind.annotation.XmlElementWrapper;
33.36 +import javax.xml.bind.annotation.XmlElements;
33.37 +
33.38 +
33.39 +public abstract class Shape {
33.40 + @XmlElement
33.41 + private PaintPoints paintPoints;
33.42 + public double getPaintX1() { return paintPoints.x1; }
33.43 + public double getPaintX2() { return paintPoints.x2; }
33.44 + public double getPaintY1() { return paintPoints.y1; }
33.45 + public double getPaintY2() { return paintPoints.y2; }
33.46 +
33.47 + @XmlElements({
33.48 + @XmlElement(name = "matte", type = Matte.class),
33.49 + @XmlElement(name = "gradient", type = Gradient.class),
33.50 + @XmlElement(name = "radialGradient", type = RadialGradient.class)
33.51 + })
33.52 + private Paint paint;
33.53 + public Paint getPaint() { return paint; }
33.54 +
33.55 + static class PaintPoints {
33.56 + @XmlAttribute double x1;
33.57 + @XmlAttribute double y1;
33.58 + @XmlAttribute double x2;
33.59 + @XmlAttribute double y2;
33.60 + }
33.61 +}
33.62 +
33.63 +class Point {
33.64 + @XmlAttribute private double x;
33.65 + public double getX() { return x; }
33.66 +
33.67 + @XmlAttribute private double y;
33.68 + public double getY() { return y; }
33.69 +
33.70 + @XmlAttribute(name="cp1x") private double cp1x;
33.71 + public double getCp1X() { return cp1x; }
33.72 +
33.73 + @XmlAttribute(name="cp1y") private double cp1y;
33.74 + public double getCp1Y() { return cp1y; }
33.75 +
33.76 + @XmlAttribute(name="cp2x") private double cp2x;
33.77 + public double getCp2X() { return cp2x; }
33.78 +
33.79 + @XmlAttribute(name="cp2y") private double cp2y;
33.80 + public double getCp2Y() { return cp2y; }
33.81 +
33.82 + public boolean isP1Sharp() {
33.83 + return cp1x == x && cp1y == y;
33.84 + }
33.85 +
33.86 + public boolean isP2Sharp() {
33.87 + return cp2x == x && cp2y == y;
33.88 + }
33.89 +}
33.90 +
33.91 +class Path extends Shape {
33.92 + @XmlElement(name="point")
33.93 + @XmlElementWrapper(name="points")
33.94 + private List<Point> controlPoints = new ArrayList<Point>();
33.95 + public List<Point> getControlPoints() { return controlPoints; }
33.96 +}
33.97 +
33.98 +class Rectangle extends Shape {
33.99 + @XmlAttribute private double x1;
33.100 + public double getX1() { return x1; }
33.101 +
33.102 + @XmlAttribute private double x2;
33.103 + public double getX2() { return x2; }
33.104 +
33.105 + @XmlAttribute private double y1;
33.106 + public double getY1() { return y1; }
33.107 +
33.108 + @XmlAttribute private double y2;
33.109 + public double getY2() { return y2; }
33.110 +
33.111 + @XmlAttribute
33.112 + public double getRounding() {
33.113 + double rounding = Math.abs(roundingX - x1) * 2;
33.114 + return rounding > 2 ? rounding : 0;
33.115 + }
33.116 +
33.117 + public void setRounding(double rounding) {
33.118 + if (rounding > 0 && rounding < 2) {
33.119 + rounding = 0;
33.120 + }
33.121 + roundingX = rounding / 2d + x1;
33.122 + }
33.123 + private double roundingX;
33.124 +
33.125 + public boolean isRounded() {
33.126 + return getRounding() > 0;
33.127 + }
33.128 +
33.129 +}
33.130 +
33.131 +class Ellipse extends Shape {
33.132 + @XmlAttribute private double x1;
33.133 + public double getX1() { return x1; }
33.134 +
33.135 + @XmlAttribute private double x2;
33.136 + public double getX2() { return x2; }
33.137 +
33.138 + @XmlAttribute private double y1;
33.139 + public double getY1() { return y1; }
33.140 +
33.141 + @XmlAttribute private double y2;
33.142 + public double getY2() { return y2; }
33.143 +}
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
34.2 +++ b/make/tools/src/build/tools/generatenimbus/SynthModel.java Tue Sep 15 23:41:40 2009 -0700
34.3 @@ -0,0 +1,216 @@
34.4 +/*
34.5 + * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
34.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
34.7 + *
34.8 + * This code is free software; you can redistribute it and/or modify it
34.9 + * under the terms of the GNU General Public License version 2 only, as
34.10 + * published by the Free Software Foundation. Sun designates this
34.11 + * particular file as subject to the "Classpath" exception as provided
34.12 + * by Sun in the LICENSE file that accompanied this code.
34.13 + *
34.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
34.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
34.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
34.17 + * version 2 for more details (a copy is included in the LICENSE file that
34.18 + * accompanied this code).
34.19 + *
34.20 + * You should have received a copy of the GNU General Public License version
34.21 + * 2 along with this work; if not, write to the Free Software Foundation,
34.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
34.23 + *
34.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
34.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
34.26 + * have any questions.
34.27 + */
34.28 +
34.29 +package build.tools.generatenimbus;
34.30 +
34.31 +import java.awt.Font;
34.32 +import java.util.ArrayList;
34.33 +import java.util.List;
34.34 +import javax.xml.bind.annotation.*;
34.35 +
34.36 +
34.37 +@XmlRootElement(name="synthModel")
34.38 +public class SynthModel {
34.39 + @XmlElement private UIStyle style;
34.40 +
34.41 + @XmlElement(name="uiColor")
34.42 + @XmlElementWrapper(name="colors")
34.43 + private ArrayList<UIColor> colors;
34.44 +
34.45 + @XmlElement(name="uiFont")
34.46 + @XmlElementWrapper(name="fonts")
34.47 + private ArrayList<UIFont> fonts;
34.48 +
34.49 + @XmlElement(name="uiComponent")
34.50 + @XmlElementWrapper(name="components")
34.51 + private ArrayList<UIComponent> components;
34.52 +
34.53 + public void initStyles() {
34.54 + for (UIComponent c: components) {
34.55 + c.initStyles(this.style);
34.56 + }
34.57 + }
34.58 +
34.59 + public void write(StringBuilder defBuffer, StringBuilder styleBuffer, String packageName) {
34.60 + defBuffer.append(" //Color palette\n");
34.61 + for (UIColor c: colors) defBuffer.append(c.write());
34.62 + defBuffer.append('\n');
34.63 +
34.64 + defBuffer.append(" //Font palette\n");
34.65 + defBuffer.append(" d.put(\"defaultFont\", new FontUIResource(defaultFont));\n");
34.66 + for (UIFont f: fonts) defBuffer.append(f.write());
34.67 + defBuffer.append('\n');
34.68 +
34.69 + defBuffer.append(" //Border palette\n");
34.70 + defBuffer.append('\n');
34.71 +
34.72 + defBuffer.append(" //The global style definition\n");
34.73 + defBuffer.append(style.write(""));
34.74 + defBuffer.append('\n');
34.75 +
34.76 + for (UIComponent c: components) {
34.77 + String prefix = Utils.escape(c.getKey());
34.78 + defBuffer.append(" //Initialize ").append(prefix).append("\n");
34.79 + c.write(defBuffer, styleBuffer, c, prefix, packageName);
34.80 + defBuffer.append('\n');
34.81 + }
34.82 + }
34.83 +}
34.84 +
34.85 +class Typeface {
34.86 + public enum DeriveStyle {
34.87 + Default, Off, On;
34.88 +
34.89 + @Override public String toString() {
34.90 + switch (this) {
34.91 + default: return "null";
34.92 + case On: return "true";
34.93 + case Off: return "false";
34.94 + }
34.95 + }
34.96 + }
34.97 +
34.98 + @XmlAttribute private String uiDefaultParentName;
34.99 + @XmlAttribute(name="family") private String name;
34.100 + @XmlAttribute private int size;
34.101 + @XmlAttribute private DeriveStyle bold = DeriveStyle.Default;
34.102 + @XmlAttribute private DeriveStyle italic = DeriveStyle.Default;
34.103 + @XmlAttribute private float sizeOffset = 1f;
34.104 +
34.105 + public boolean isAbsolute() {
34.106 + return uiDefaultParentName == null;
34.107 + }
34.108 +
34.109 + public String write() {
34.110 + if (isAbsolute()) {
34.111 + int style = Font.PLAIN;
34.112 + if (bold == DeriveStyle.On) {
34.113 + style = style | Font.BOLD;
34.114 + }
34.115 + if (italic == DeriveStyle.On) {
34.116 + style = style | Font.ITALIC;
34.117 + }
34.118 +
34.119 + return String.format(
34.120 + "new javax.swing.plaf.FontUIResource(\"%s\", %d, %d)",
34.121 + name, style, size);
34.122 + } else {
34.123 + return String.format(
34.124 + "new DerivedFont(\"%s\", %sf, %s, %s)",
34.125 + uiDefaultParentName, String.valueOf(sizeOffset), bold, italic);
34.126 + }
34.127 + }
34.128 +}
34.129 +
34.130 +class Border {
34.131 + enum BorderType {
34.132 + @XmlEnumValue("empty") EMPTY,
34.133 + @XmlEnumValue("painter") PAINTER
34.134 + }
34.135 + @XmlAttribute private BorderType type;
34.136 + @XmlAttribute private String painter;
34.137 + @XmlAttribute private int top;
34.138 + @XmlAttribute private int left;
34.139 + @XmlAttribute private int bottom;
34.140 + @XmlAttribute private int right;
34.141 +
34.142 + public String write() {
34.143 + switch (type) {
34.144 + case PAINTER:
34.145 + return String.format("new PainterBorder(\"%s\", new Insets(%d, %d, %d, %d))",
34.146 + painter, top, left, bottom, right);
34.147 + case EMPTY:
34.148 + return String.format("BorderFactory.createEmptyBorder(%d, %d, %d, %d)",
34.149 + top, left, bottom, right);
34.150 + default:
34.151 + return "### Look, here's an unknown border! $$$";
34.152 + }
34.153 + }
34.154 +}
34.155 +
34.156 +class Insets {
34.157 + @XmlAttribute int top;
34.158 + @XmlAttribute int left;
34.159 + @XmlAttribute int bottom;
34.160 + @XmlAttribute int right;
34.161 +
34.162 + public Insets() {
34.163 + this(0, 0, 0, 0);
34.164 + }
34.165 +
34.166 + public Insets(int top, int left, int bottom, int right) {
34.167 + this.top = top;
34.168 + this.left = left;
34.169 + this.bottom = bottom;
34.170 + this.right = right;
34.171 + }
34.172 +
34.173 + public String write(boolean uiResource) {
34.174 + String uiSuffix = (uiResource ? "UIResource" : "");
34.175 + return String.format("new Insets%s(%d, %d, %d, %d)",
34.176 + uiSuffix, top, left, bottom, right);
34.177 + }
34.178 +}
34.179 +
34.180 +class Dimension {
34.181 + @XmlAttribute int width;
34.182 + @XmlAttribute int height;
34.183 +
34.184 + public String write(boolean uiResource) {
34.185 + String uiSuffix = (uiResource ? "UIResource" : "");
34.186 + return String.format("new Dimension%s(%d, %d)", uiSuffix, width, height);
34.187 + }
34.188 +}
34.189 +
34.190 +class Canvas {
34.191 + @XmlElement private Dimension size;
34.192 + public Dimension getSize() { return size; }
34.193 +
34.194 + @XmlElement(name="layer") private List<Layer> layers;
34.195 + public List<Layer> getLayers() { return layers; }
34.196 +
34.197 + @XmlElement private Insets stretchingInsets = null;
34.198 + public Insets getStretchingInsets() { return stretchingInsets; }
34.199 +
34.200 + public boolean isBlank() {
34.201 + return layers.size() == 0 || (layers.size() == 1 && layers.get(0).isEmpty());
34.202 + }
34.203 +}
34.204 +
34.205 +class Layer {
34.206 + /** List of shapes in this layer, first shape is painted on top */
34.207 + @XmlElements({
34.208 + @XmlElement(name = "ellipse", type = Ellipse.class),
34.209 + @XmlElement(name = "path", type = Path.class),
34.210 + @XmlElement(name = "rectangle", type = Rectangle.class)
34.211 + })
34.212 + @XmlElementWrapper(name="shapes")
34.213 + private List<Shape> shapes = new ArrayList<Shape>();
34.214 + public List<Shape> getShapes() { return shapes; }
34.215 +
34.216 + public boolean isEmpty() {
34.217 + return shapes.isEmpty();
34.218 + }
34.219 +}
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
35.2 +++ b/make/tools/src/build/tools/generatenimbus/UIDefault.java Tue Sep 15 23:41:40 2009 -0700
35.3 @@ -0,0 +1,126 @@
35.4 +/*
35.5 + * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
35.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
35.7 + *
35.8 + * This code is free software; you can redistribute it and/or modify it
35.9 + * under the terms of the GNU General Public License version 2 only, as
35.10 + * published by the Free Software Foundation. Sun designates this
35.11 + * particular file as subject to the "Classpath" exception as provided
35.12 + * by Sun in the LICENSE file that accompanied this code.
35.13 + *
35.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
35.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
35.17 + * version 2 for more details (a copy is included in the LICENSE file that
35.18 + * accompanied this code).
35.19 + *
35.20 + * You should have received a copy of the GNU General Public License version
35.21 + * 2 along with this work; if not, write to the Free Software Foundation,
35.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
35.23 + *
35.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
35.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
35.26 + * have any questions.
35.27 + */
35.28 +
35.29 +package build.tools.generatenimbus;
35.30 +
35.31 +import javax.xml.bind.annotation.XmlAttribute;
35.32 +import javax.xml.bind.annotation.XmlElement;
35.33 +
35.34 +public class UIDefault<T> {
35.35 + @XmlAttribute private String name;
35.36 + private T value;
35.37 +
35.38 + public String getName() {
35.39 + return name;
35.40 + }
35.41 +
35.42 + public T getValue() {
35.43 + return value;
35.44 + }
35.45 +
35.46 + public void setValue(T value) {
35.47 + this.value = value;
35.48 + }
35.49 +}
35.50 +
35.51 +class UIColor extends UIDefault<Matte> {
35.52 +
35.53 + @XmlElement
35.54 + public void setMatte(Matte m) {
35.55 + setValue(m);
35.56 + }
35.57 +
35.58 + public String write() {
35.59 + return String.format(" addColor(d, \"%s\", %s);\n",
35.60 + getName(), getValue().write());
35.61 + }
35.62 +}
35.63 +
35.64 +class UIFont extends UIDefault<Typeface> {
35.65 + @XmlElement
35.66 + public void setTypeface(Typeface t) {
35.67 + setValue(t);
35.68 + }
35.69 +
35.70 + public String write() {
35.71 + return String.format(" d.put(\"%s\", %s);\n",
35.72 + getName(), getValue().write());
35.73 + }
35.74 +}
35.75 +
35.76 +class UIProperty extends UIDefault<String> {
35.77 + public static enum PropertyType {
35.78 + BOOLEAN, INT, FLOAT, DOUBLE, STRING, FONT, COLOR, INSETS, DIMENSION, BORDER
35.79 + }
35.80 + @XmlAttribute private PropertyType type;
35.81 +
35.82 + @XmlElement private Border border;
35.83 + @XmlElement private Dimension dimension;
35.84 + @XmlElement private Insets insets;
35.85 + @XmlElement private Matte matte;
35.86 + @XmlElement private Typeface typeface;
35.87 +
35.88 + @XmlAttribute
35.89 + @Override public void setValue(String value) {
35.90 + super.setValue(value);
35.91 + }
35.92 +
35.93 + public String write(String prefix) {
35.94 + switch (type) {
35.95 + case BOOLEAN:
35.96 + return String.format(" d.put(\"%s%s\", Boolean.%s);\n",
35.97 + prefix, getName(), getValue().toUpperCase()); ///autobox
35.98 + case STRING:
35.99 + return String.format(" d.put(\"%s%s\", \"%s\");\n",
35.100 + prefix, getName(), getValue());
35.101 + case INT:
35.102 + return String.format(" d.put(\"%s%s\", new Integer(%s));\n",
35.103 + prefix, getName(), getValue());
35.104 + case FLOAT:
35.105 + return String.format(" d.put(\"%s%s\", new Float(%sf));\n",
35.106 + prefix, getName(), getValue());
35.107 + case DOUBLE:
35.108 + return String.format(" d.put(\"%s%s\", new Double(%s));\n",
35.109 + prefix, getName(), getValue());
35.110 + case COLOR:
35.111 + return String.format(" addColor(d, \"%s%s\", %s);\n",
35.112 + prefix, getName(), matte.write());
35.113 + case FONT:
35.114 + return String.format(" d.put(\"%s%s\", %s);\n",
35.115 + prefix, getName(), typeface.write());
35.116 + case INSETS:
35.117 + return String.format(" d.put(\"%s%s\", %s);\n",
35.118 + prefix, getName(), insets.write(true));
35.119 + case DIMENSION:
35.120 + return String.format(" d.put(\"%s%s\", new DimensionUIResource(%d, %d));\n",
35.121 + prefix, getName(), dimension.width, dimension.height);
35.122 + case BORDER:
35.123 + return String.format(" d.put(\"%s%s\", new BorderUIResource(%s));\n",
35.124 + prefix, getName(), border.write());
35.125 + default:
35.126 + return "### Look, something's wrong with UIProperty.write() $$$";
35.127 + }
35.128 + }
35.129 +}
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
36.2 +++ b/make/tools/src/build/tools/generatenimbus/UIStyle.java Tue Sep 15 23:41:40 2009 -0700
36.3 @@ -0,0 +1,399 @@
36.4 +/*
36.5 + * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
36.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
36.7 + *
36.8 + * This code is free software; you can redistribute it and/or modify it
36.9 + * under the terms of the GNU General Public License version 2 only, as
36.10 + * published by the Free Software Foundation. Sun designates this
36.11 + * particular file as subject to the "Classpath" exception as provided
36.12 + * by Sun in the LICENSE file that accompanied this code.
36.13 + *
36.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
36.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
36.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
36.17 + * version 2 for more details (a copy is included in the LICENSE file that
36.18 + * accompanied this code).
36.19 + *
36.20 + * You should have received a copy of the GNU General Public License version
36.21 + * 2 along with this work; if not, write to the Free Software Foundation,
36.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
36.23 + *
36.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
36.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
36.26 + * have any questions.
36.27 + */
36.28 +
36.29 +package build.tools.generatenimbus;
36.30 +
36.31 +import java.util.ArrayList;
36.32 +import java.util.Arrays;
36.33 +import java.util.Collections;
36.34 +import java.util.Iterator;
36.35 +import java.util.List;
36.36 +import java.util.Map;
36.37 +import javax.xml.bind.annotation.XmlAttribute;
36.38 +import javax.xml.bind.annotation.XmlElement;
36.39 +import javax.xml.bind.annotation.XmlElementWrapper;
36.40 +import javax.xml.bind.annotation.XmlElements;
36.41 +
36.42 +
36.43 +class UIStyle {
36.44 + public static enum CacheMode {
36.45 + NO_CACHING, FIXED_SIZES, NINE_SQUARE_SCALE
36.46 + }
36.47 +
36.48 + @XmlElement private UIColor textForeground = null;
36.49 + @XmlElement(name="inherit-textForeground")
36.50 + private boolean textForegroundInherited = true;
36.51 +
36.52 + @XmlElement private UIColor textBackground = null;
36.53 + @XmlElement(name="inherit-textBackground")
36.54 + private boolean textBackgroundInherited = true;
36.55 +
36.56 + @XmlElement private UIColor background = null;
36.57 + @XmlElement(name="inherit-background")
36.58 + private boolean backgroundInherited = true;
36.59 +
36.60 + @XmlElement private boolean cacheSettingsInherited = true;
36.61 + @XmlElement CacheMode cacheMode = CacheMode.FIXED_SIZES;
36.62 + @XmlElement String maxHozCachedImgScaling = "1.0";
36.63 + @XmlElement String maxVertCachedImgScaling = "1.0";
36.64 +
36.65 + @XmlElement(name="uiProperty")
36.66 + @XmlElementWrapper(name="uiproperties")
36.67 + private List<UIProperty> uiProperties = new ArrayList<UIProperty>();
36.68 +
36.69 + private UIStyle parentStyle = null;
36.70 + public void setParentStyle(UIStyle parentStyle) {
36.71 + this.parentStyle = parentStyle;
36.72 + }
36.73 +
36.74 + public CacheMode getCacheMode() {
36.75 + if (cacheSettingsInherited) {
36.76 + return (parentStyle == null ?
36.77 + CacheMode.FIXED_SIZES : parentStyle.getCacheMode());
36.78 + } else {
36.79 + return cacheMode;
36.80 + }
36.81 + }
36.82 +
36.83 + public String getMaxHozCachedImgScaling() {
36.84 + if (cacheSettingsInherited) {
36.85 + return (parentStyle == null ?
36.86 + "1.0" : parentStyle.getMaxHozCachedImgScaling());
36.87 + } else {
36.88 + return maxHozCachedImgScaling;
36.89 + }
36.90 + }
36.91 +
36.92 + public String getMaxVertCachedImgScaling() {
36.93 + if (cacheSettingsInherited) {
36.94 + return (parentStyle == null ?
36.95 + "1.0" : parentStyle.getMaxVertCachedImgScaling());
36.96 + } else {
36.97 + return maxVertCachedImgScaling;
36.98 + }
36.99 + }
36.100 +
36.101 + public String write(String prefix) {
36.102 + StringBuilder sb = new StringBuilder();
36.103 + if (! textForegroundInherited) {
36.104 + sb.append(String.format(" addColor(d, \"%s%s\", %s);\n",
36.105 + prefix, "textForeground", textForeground.getValue().write()));
36.106 + }
36.107 + if (! textBackgroundInherited) {
36.108 + sb.append(String.format(" addColor(d, \"%s%s\", %s);\n",
36.109 + prefix, "textBackground", textBackground.getValue().write()));
36.110 + }
36.111 + if (! backgroundInherited) {
36.112 + sb.append(String.format(" addColor(d, \"%s%s\", %s);\n",
36.113 + prefix, "background", background.getValue().write()));
36.114 + }
36.115 + for (UIProperty property : uiProperties) {
36.116 + sb.append(property.write(prefix));
36.117 + }
36.118 + return sb.toString();
36.119 + }
36.120 +}
36.121 +
36.122 +class UIRegion {
36.123 + @XmlAttribute protected String name;
36.124 + @XmlAttribute protected String key;
36.125 + @XmlAttribute private boolean opaque = false;
36.126 +
36.127 + @XmlElement private Insets contentMargins = new Insets(0, 0, 0, 0);
36.128 +
36.129 + @XmlElement(name="state")
36.130 + @XmlElementWrapper(name="backgroundStates")
36.131 + protected List<UIState> backgroundStates = new ArrayList<UIState>();
36.132 + public List<UIState> getBackgroundStates() { return backgroundStates; }
36.133 +
36.134 + @XmlElement(name="state")
36.135 + @XmlElementWrapper(name="foregroundStates")
36.136 + protected List<UIState> foregroundStates = new ArrayList<UIState>();
36.137 + public List<UIState> getForegroundStates() { return foregroundStates; }
36.138 +
36.139 + @XmlElement(name="state")
36.140 + @XmlElementWrapper(name="borderStates")
36.141 + protected List<UIState> borderStates = new ArrayList<UIState>();
36.142 + public List<UIState> getBorderStates() { return borderStates; }
36.143 +
36.144 + @XmlElement private UIStyle style = new UIStyle();
36.145 +
36.146 + @XmlElements({
36.147 + @XmlElement(name = "region", type = UIRegion.class),
36.148 + @XmlElement(name = "uiComponent", type = UIComponent.class),
36.149 + @XmlElement(name = "uiIconRegion", type = UIIconRegion.class)
36.150 + })
36.151 + @XmlElementWrapper(name="regions")
36.152 + private List<UIRegion> subRegions = new ArrayList<UIRegion>();
36.153 + public List<UIRegion> getSubRegions() { return subRegions; }
36.154 +
36.155 + protected void initStyles(UIStyle parentStyle) {
36.156 + style.setParentStyle(parentStyle);
36.157 + for (UIState state: backgroundStates) {
36.158 + state.getStyle().setParentStyle(this.style);
36.159 + }
36.160 + for (UIState state: foregroundStates) {
36.161 + state.getStyle().setParentStyle(this.style);
36.162 + }
36.163 + for (UIState state: borderStates) {
36.164 + state.getStyle().setParentStyle(this.style);
36.165 + }
36.166 + for (UIRegion region: subRegions) {
36.167 + region.initStyles(this.style);
36.168 + }
36.169 + }
36.170 +
36.171 + public String getKey() {
36.172 + return key == null || "".equals(key) ? name : key;
36.173 + }
36.174 +
36.175 + private boolean hasCanvas() {
36.176 + for (UIState s : backgroundStates) {
36.177 + if (s.hasCanvas()) return true;
36.178 + }
36.179 + for (UIState s : borderStates) {
36.180 + if (s.hasCanvas()) return true;
36.181 + }
36.182 + for (UIState s : foregroundStates) {
36.183 + if (s.hasCanvas()) return true;
36.184 + }
36.185 + for (UIRegion r: subRegions) {
36.186 + if (r.hasCanvas()) return true;
36.187 + }
36.188 + return false;
36.189 + }
36.190 +
36.191 + public void write(StringBuilder sb, StringBuilder styleBuffer,
36.192 + UIComponent comp, String prefix, String pkg) {
36.193 + // write content margins
36.194 + sb.append(String.format(" d.put(\"%s.contentMargins\", %s);\n",
36.195 + prefix, contentMargins.write(true)));
36.196 + // write opaque if true
36.197 + if (opaque) {
36.198 + sb.append(String.format(" d.put(\"%s.opaque\", Boolean.TRUE);\n", prefix));
36.199 + }
36.200 +
36.201 + // register component with LAF
36.202 + String regionCode = "Region." + Utils.regionNameToCaps(name);
36.203 + styleBuffer.append(String.format(" register(%s, \"%s\");\n",
36.204 + regionCode, prefix));
36.205 +
36.206 + //write the State, if necessary
36.207 + StringBuffer regString = new StringBuffer();
36.208 + List<UIStateType> types = comp.getStateTypes();
36.209 + if (types != null && types.size() > 0) {
36.210 + for (UIStateType type : types) {
36.211 + regString.append(type.getKey());
36.212 + regString.append(",");
36.213 + }
36.214 + //remove the last ","
36.215 + regString.deleteCharAt(regString.length() - 1);
36.216 + }
36.217 +
36.218 + if (! regString.equals("Enabled,MouseOver,Pressed,Disabled,Focused,Selected,Default") && types.size() > 0) {
36.219 + //there were either custom states, or the normal states were in a custom order
36.220 + //so go ahead and write out prefix.State
36.221 + sb.append(String.format(" d.put(\"%s.States\", \"%s\");\n",
36.222 + prefix, regString));
36.223 + }
36.224 +
36.225 + // write out any custom states, if necessary
36.226 + for (UIStateType type : types) {
36.227 + String synthState = type.getKey();
36.228 + if (! "Enabled".equals(synthState) &&
36.229 + ! "MouseOver".equals(synthState) &&
36.230 + ! "Pressed".equals(synthState) &&
36.231 + ! "Disabled".equals(synthState) &&
36.232 + ! "Focused".equals(synthState) &&
36.233 + ! "Selected".equals(synthState) &&
36.234 + ! "Default".equals(synthState)) {
36.235 +
36.236 + //what we have here, gentlemen, is a bona-fide custom state.
36.237 + //if the type is not one of the standard types, then construct a name for
36.238 + //the new type, and write out a new subclass of State.
36.239 + String className = Utils.normalize(prefix) + synthState + "State";
36.240 + sb.append(String.format(" d.put(\"%s.%s\", new %s());\n",
36.241 + prefix, synthState, className));
36.242 +
36.243 + String body = type.getCodeSnippet();
36.244 + Map<String, String> variables = Generator.getVariables();
36.245 + variables.put("STATE_NAME", className);
36.246 + variables.put("STATE_KEY", synthState);
36.247 + variables.put("BODY", body);
36.248 +
36.249 + Generator.writeSrcFile("StateImpl", variables, className);
36.250 + }
36.251 + }
36.252 +
36.253 + // write style
36.254 + sb.append(style.write(prefix + '.'));
36.255 +
36.256 + String fileName = Utils.normalize(prefix) + "Painter";
36.257 + boolean hasCanvas = hasCanvas();
36.258 + if (hasCanvas) {
36.259 + PainterGenerator.writePainter(this, fileName);
36.260 + }
36.261 + // write states ui defaults
36.262 + for (UIState state : backgroundStates) {
36.263 + state.write(sb, prefix, pkg, fileName, "background");
36.264 + }
36.265 + for (UIState state : foregroundStates) {
36.266 + state.write(sb, prefix, pkg, fileName, "foreground");
36.267 + }
36.268 + for (UIState state : borderStates) {
36.269 + state.write(sb, prefix, pkg, fileName, "border");
36.270 + }
36.271 +
36.272 + // handle sub regions
36.273 + for (UIRegion subreg : subRegions) {
36.274 + String p = prefix;
36.275 + if (! (subreg instanceof UIIconRegion)) {
36.276 + p = prefix + ":" + Utils.escape(subreg.getKey());
36.277 + }
36.278 + UIComponent c = comp;
36.279 + if (subreg instanceof UIComponent) {
36.280 + c = (UIComponent) subreg;
36.281 + }
36.282 + subreg.write(sb, styleBuffer, c, p, pkg);
36.283 + }
36.284 + }
36.285 +}
36.286 +
36.287 +class UIIconRegion extends UIRegion {
36.288 + @XmlAttribute private String basicKey;
36.289 +
36.290 + @Override public void write(StringBuilder sb, StringBuilder styleBuffer, UIComponent comp, String prefix, String pkg) {
36.291 + Dimension size = null;
36.292 + String fileNamePrefix = Utils.normalize(prefix) + "Painter";
36.293 + // write states ui defaults
36.294 + for (UIState state : backgroundStates) {
36.295 + Canvas canvas = state.getCanvas();
36.296 + if (!canvas.isBlank()) {
36.297 + state.write(sb, prefix, pkg, fileNamePrefix, getKey());
36.298 + size = canvas.getSize();
36.299 + }
36.300 + }
36.301 +
36.302 + if (size != null) {
36.303 + // Put SynthIconImpl wrapper in UiDefaults
36.304 + String k = (basicKey == null ? prefix + "." + getKey() : basicKey);
36.305 + sb.append(String.format(
36.306 + " d.put(\"%s\", new NimbusIcon(\"%s\", \"%sPainter\", %d, %d));\n",
36.307 + k, prefix, getKey(), size.width, size.height));
36.308 + }
36.309 + }
36.310 +}
36.311 +
36.312 +class UIComponent extends UIRegion {
36.313 + @XmlAttribute private String componentName;
36.314 +
36.315 + @XmlElement(name="stateType")
36.316 + @XmlElementWrapper(name="stateTypes")
36.317 + private List<UIStateType> stateTypes = new ArrayList<UIStateType>();
36.318 + public List<UIStateType> getStateTypes() { return stateTypes; }
36.319 +
36.320 + @Override public String getKey() {
36.321 + if (key == null || "".equals(key)) {
36.322 + if (componentName == null || "".equals(componentName)) {
36.323 + return name;
36.324 + } else {
36.325 + return "\"" + componentName + "\"";
36.326 + }
36.327 + } else {
36.328 + return key;
36.329 + }
36.330 + }
36.331 +}
36.332 +
36.333 +class UIState {
36.334 + @XmlAttribute private String stateKeys;
36.335 + public String getStateKeys() { return stateKeys; }
36.336 +
36.337 + /** Indicates whether to invert the meaning of the 9-square stretching insets */
36.338 + @XmlAttribute private boolean inverted;
36.339 +
36.340 + /** A cached string representing the list of stateKeys deliminated with "+" */
36.341 + private String cachedName = null;
36.342 +
36.343 + @XmlElement private Canvas canvas;
36.344 + public Canvas getCanvas() { return canvas; }
36.345 +
36.346 + @XmlElement private UIStyle style;
36.347 + public UIStyle getStyle() { return style; }
36.348 +
36.349 + public boolean hasCanvas() {
36.350 + return ! canvas.isBlank();
36.351 + }
36.352 +
36.353 + public static List<String> stringToKeys(String keysString) {
36.354 + return Arrays.asList(keysString.split("\\+"));
36.355 + }
36.356 +
36.357 + public String getName() {
36.358 + if (cachedName == null) {
36.359 + StringBuilder buf = new StringBuilder();
36.360 + List<String> keys = stringToKeys(stateKeys);
36.361 + Collections.sort(keys);
36.362 + for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
36.363 + buf.append(iter.next());
36.364 + if (iter.hasNext()) {
36.365 + buf.append('+');
36.366 + }
36.367 + }
36.368 + cachedName = buf.toString();
36.369 + }
36.370 + return cachedName;
36.371 + }
36.372 +
36.373 + public void write(StringBuilder sb, String prefix, String pkg, String fileNamePrefix, String painterPrefix) {
36.374 + String statePrefix = prefix + "[" + getName() + "]";
36.375 + // write state style
36.376 + sb.append(style.write(statePrefix + '.'));
36.377 + // write painter
36.378 + if (hasCanvas()) {
36.379 + writeLazyPainter(sb, statePrefix, pkg, fileNamePrefix, painterPrefix);
36.380 + }
36.381 + }
36.382 +
36.383 + private void writeLazyPainter(StringBuilder sb, String statePrefix, String packageNamePrefix, String fileNamePrefix, String painterPrefix) {
36.384 + String cacheModeString = "AbstractRegionPainter.PaintContext.CacheMode." + style.getCacheMode();
36.385 + String stateConstant = Utils.statesToConstantName(painterPrefix + "_" + stateKeys);
36.386 + sb.append(String.format(
36.387 + " d.put(\"%s.%sPainter\", new LazyPainter(\"%s.%s\", %s.%s, %s, %s, %b, %s, %s, %s));\n",
36.388 + statePrefix, painterPrefix, packageNamePrefix, fileNamePrefix,
36.389 + fileNamePrefix, stateConstant, canvas.getStretchingInsets().write(false),
36.390 + canvas.getSize().write(false), inverted, cacheModeString,
36.391 + Utils.formatDouble(style.getMaxHozCachedImgScaling()),
36.392 + Utils.formatDouble(style.getMaxVertCachedImgScaling())));
36.393 + }
36.394 +}
36.395 +
36.396 +class UIStateType {
36.397 + @XmlAttribute private String key;
36.398 + public String getKey() { return key; }
36.399 +
36.400 + @XmlElement private String codeSnippet;
36.401 + public String getCodeSnippet() { return codeSnippet; }
36.402 +}
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
37.2 +++ b/make/tools/src/build/tools/generatenimbus/Utils.java Tue Sep 15 23:41:40 2009 -0700
37.3 @@ -0,0 +1,215 @@
37.4 +/*
37.5 + * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
37.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
37.7 + *
37.8 + * This code is free software; you can redistribute it and/or modify it
37.9 + * under the terms of the GNU General Public License version 2 only, as
37.10 + * published by the Free Software Foundation. Sun designates this
37.11 + * particular file as subject to the "Classpath" exception as provided
37.12 + * by Sun in the LICENSE file that accompanied this code.
37.13 + *
37.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
37.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
37.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
37.17 + * version 2 for more details (a copy is included in the LICENSE file that
37.18 + * accompanied this code).
37.19 + *
37.20 + * You should have received a copy of the GNU General Public License version
37.21 + * 2 along with this work; if not, write to the Free Software Foundation,
37.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
37.23 + *
37.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
37.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
37.26 + * have any questions.
37.27 + */
37.28 +
37.29 +package build.tools.generatenimbus;
37.30 +
37.31 +import java.util.ArrayList;
37.32 +import java.util.List;
37.33 +import javax.swing.plaf.synth.Region;
37.34 +
37.35 +public class Utils {
37.36 +
37.37 + public static String escape(String s) {
37.38 + return s.replace("\"", "\\\"");
37.39 + }
37.40 +
37.41 + public static String normalize(String s) {
37.42 + char[] src = s.toCharArray();
37.43 + StringBuilder buf = new StringBuilder();
37.44 + List<String> parts = new ArrayList<String>();
37.45 + boolean capitalize = false;
37.46 +
37.47 + for (int i = 0; i < src.length; i++) {
37.48 + switch (src[i]) {
37.49 + case '\\':
37.50 + case '"':
37.51 + break;
37.52 + case '.':
37.53 + capitalize = true;
37.54 + break;
37.55 + case ':':
37.56 + parts.add(buf.toString());
37.57 + buf.delete(0, buf.length());
37.58 + capitalize = true;
37.59 + break;
37.60 + default:
37.61 + buf.append(capitalize ? Character.toUpperCase(src[i]) : src[i]);
37.62 + capitalize = false;
37.63 + break;
37.64 + }
37.65 + }
37.66 + parts.add(buf.toString());
37.67 +
37.68 + // Try to optimize long class names by omitting repeating prefixes, e.g.
37.69 + // SliderTrackPainter.java instead of SliderSliderTrackPainter.java
37.70 + String result = parts.get(0);
37.71 + for (int i = 1; i < parts.size(); i++) {
37.72 + String part = parts.get(i);
37.73 + if (part.startsWith(result)) {
37.74 + result = part;
37.75 + } else {
37.76 + result += part;
37.77 + }
37.78 + }
37.79 + return result;
37.80 + }
37.81 +
37.82 + public static String regionNameToCaps(String regionName) {
37.83 + if (Region.ARROW_BUTTON.getName().equals(regionName)) {
37.84 + return "ARROW_BUTTON";
37.85 + } else if (Region.BUTTON.getName().equals(regionName)) {
37.86 + return "BUTTON";
37.87 + } else if (Region.CHECK_BOX.getName().equals(regionName)) {
37.88 + return "CHECK_BOX";
37.89 + } else if (Region.CHECK_BOX_MENU_ITEM.getName().equals(regionName)) {
37.90 + return "CHECK_BOX_MENU_ITEM";
37.91 + } else if (Region.COLOR_CHOOSER.getName().equals(regionName)) {
37.92 + return "COLOR_CHOOSER";
37.93 + } else if (Region.COMBO_BOX.getName().equals(regionName)) {
37.94 + return "COMBO_BOX";
37.95 + } else if (Region.DESKTOP_ICON.getName().equals(regionName)) {
37.96 + return "DESKTOP_ICON";
37.97 + } else if (Region.DESKTOP_PANE.getName().equals(regionName)) {
37.98 + return "DESKTOP_PANE";
37.99 + } else if (Region.EDITOR_PANE.getName().equals(regionName)) {
37.100 + return "EDITOR_PANE";
37.101 + } else if (Region.FILE_CHOOSER.getName().equals(regionName)) {
37.102 + return "FILE_CHOOSER";
37.103 + } else if (Region.FORMATTED_TEXT_FIELD.getName().equals(regionName)) {
37.104 + return "FORMATTED_TEXT_FIELD";
37.105 + } else if (Region.INTERNAL_FRAME.getName().equals(regionName)) {
37.106 + return "INTERNAL_FRAME";
37.107 + } else if (Region.INTERNAL_FRAME_TITLE_PANE.getName().equals(regionName)) {
37.108 + return "INTERNAL_FRAME_TITLE_PANE";
37.109 + } else if (Region.LABEL.getName().equals(regionName)) {
37.110 + return "LABEL";
37.111 + } else if (Region.LIST.getName().equals(regionName)) {
37.112 + return "LIST";
37.113 + } else if (Region.MENU.getName().equals(regionName)) {
37.114 + return "MENU";
37.115 + } else if (Region.MENU_BAR.getName().equals(regionName)) {
37.116 + return "MENU_BAR";
37.117 + } else if (Region.MENU_ITEM.getName().equals(regionName)) {
37.118 + return "MENU_ITEM";
37.119 + } else if (Region.MENU_ITEM_ACCELERATOR.getName().equals(regionName)) {
37.120 + return "MENU_ITEM_ACCELERATOR";
37.121 + } else if (Region.OPTION_PANE.getName().equals(regionName)) {
37.122 + return "OPTION_PANE";
37.123 + } else if (Region.PANEL.getName().equals(regionName)) {
37.124 + return "PANEL";
37.125 + } else if (Region.PASSWORD_FIELD.getName().equals(regionName)) {
37.126 + return "PASSWORD_FIELD";
37.127 + } else if (Region.POPUP_MENU.getName().equals(regionName)) {
37.128 + return "POPUP_MENU";
37.129 + } else if (Region.POPUP_MENU_SEPARATOR.getName().equals(regionName)) {
37.130 + return "POPUP_MENU_SEPARATOR";
37.131 + } else if (Region.PROGRESS_BAR.getName().equals(regionName)) {
37.132 + return "PROGRESS_BAR";
37.133 + } else if (Region.RADIO_BUTTON.getName().equals(regionName)) {
37.134 + return "RADIO_BUTTON";
37.135 + } else if (Region.RADIO_BUTTON_MENU_ITEM.getName().equals(regionName)) {
37.136 + return "RADIO_BUTTON_MENU_ITEM";
37.137 + } else if (Region.ROOT_PANE.getName().equals(regionName)) {
37.138 + return "ROOT_PANE";
37.139 + } else if (Region.SCROLL_BAR.getName().equals(regionName)) {
37.140 + return "SCROLL_BAR";
37.141 + } else if (Region.SCROLL_BAR_THUMB.getName().equals(regionName)) {
37.142 + return "SCROLL_BAR_THUMB";
37.143 + } else if (Region.SCROLL_BAR_TRACK.getName().equals(regionName)) {
37.144 + return "SCROLL_BAR_TRACK";
37.145 + } else if (Region.SCROLL_PANE.getName().equals(regionName)) {
37.146 + return "SCROLL_PANE";
37.147 + } else if (Region.SEPARATOR.getName().equals(regionName)) {
37.148 + return "SEPARATOR";
37.149 + } else if (Region.SLIDER.getName().equals(regionName)) {
37.150 + return "SLIDER";
37.151 + } else if (Region.SLIDER_THUMB.getName().equals(regionName)) {
37.152 + return "SLIDER_THUMB";
37.153 + } else if (Region.SLIDER_TRACK.getName().equals(regionName)) {
37.154 + return "SLIDER_TRACK";
37.155 + } else if (Region.SPINNER.getName().equals(regionName)) {
37.156 + return "SPINNER";
37.157 + } else if (Region.SPLIT_PANE.getName().equals(regionName)) {
37.158 + return "SPLIT_PANE";
37.159 + } else if (Region.SPLIT_PANE_DIVIDER.getName().equals(regionName)) {
37.160 + return "SPLIT_PANE_DIVIDER";
37.161 + } else if (Region.TABBED_PANE.getName().equals(regionName)) {
37.162 + return "TABBED_PANE";
37.163 + } else if (Region.TABBED_PANE_CONTENT.getName().equals(regionName)) {
37.164 + return "TABBED_PANE_CONTENT";
37.165 + } else if (Region.TABBED_PANE_TAB.getName().equals(regionName)) {
37.166 + return "TABBED_PANE_TAB";
37.167 + } else if (Region.TABBED_PANE_TAB_AREA.getName().equals(regionName)) {
37.168 + return "TABBED_PANE_TAB_AREA";
37.169 + } else if (Region.TABLE.getName().equals(regionName)) {
37.170 + return "TABLE";
37.171 + } else if (Region.TABLE_HEADER.getName().equals(regionName)) {
37.172 + return "TABLE_HEADER";
37.173 + } else if (Region.TEXT_AREA.getName().equals(regionName)) {
37.174 + return "TEXT_AREA";
37.175 + } else if (Region.TEXT_FIELD.getName().equals(regionName)) {
37.176 + return "TEXT_FIELD";
37.177 + } else if (Region.TEXT_PANE.getName().equals(regionName)) {
37.178 + return "TEXT_PANE";
37.179 + } else if (Region.TOGGLE_BUTTON.getName().equals(regionName)) {
37.180 + return "TOGGLE_BUTTON";
37.181 + } else if (Region.TOOL_BAR.getName().equals(regionName)) {
37.182 + return "TOOL_BAR";
37.183 + } else if (Region.TOOL_BAR_CONTENT.getName().equals(regionName)) {
37.184 + return "TOOL_BAR_CONTENT";
37.185 + } else if (Region.TOOL_BAR_DRAG_WINDOW.getName().equals(regionName)) {
37.186 + return "TOOL_BAR_DRAG_WINDOW";
37.187 + } else if (Region.TOOL_BAR_SEPARATOR.getName().equals(regionName)) {
37.188 + return "TOOL_BAR_SEPARATOR";
37.189 + } else if (Region.TOOL_TIP.getName().equals(regionName)) {
37.190 + return "TOOL_TIP";
37.191 + } else if (Region.TREE.getName().equals(regionName)) {
37.192 + return "TREE";
37.193 + } else if (Region.TREE_CELL.getName().equals(regionName)) {
37.194 + return "TREE_CELL";
37.195 + } else if (Region.VIEWPORT.getName().equals(regionName)) {
37.196 + return "VIEWPORT";
37.197 + }
37.198 + throw new RuntimeException("Bad Region name " + regionName);
37.199 + }
37.200 +
37.201 + public static String statesToConstantName(String states) {
37.202 + String s = states.replace(" ", "");
37.203 + s = states.replace("+", "_");
37.204 + return s.toUpperCase();
37.205 + }
37.206 +
37.207 + //takes a states string of the form Enabled+Foo+Bar.
37.208 + //removes any whitespace. Replaces the + signs with And.
37.209 + public static String statesToClassName(String states) {
37.210 + String s = states.replace(" ", "");
37.211 + s = states.replace("+", "And");
37.212 + return s;
37.213 + }
37.214 +
37.215 + public static String formatDouble(String doubleValue) {
37.216 + return doubleValue.replace("INF", "Double.POSITIVE_INFINITY");
37.217 + }
37.218 +}
38.1 --- a/make/tools/swing-nimbus/Makefile Sun Sep 06 23:14:42 2009 -0700
38.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
38.3 @@ -1,91 +0,0 @@
38.4 -#
38.5 -# Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved.
38.6 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
38.7 -#
38.8 -# This code is free software; you can redistribute it and/or modify it
38.9 -# under the terms of the GNU General Public License version 2 only, as
38.10 -# published by the Free Software Foundation. Sun designates this
38.11 -# particular file as subject to the "Classpath" exception as provided
38.12 -# by Sun in the LICENSE file that accompanied this code.
38.13 -#
38.14 -# This code is distributed in the hope that it will be useful, but WITHOUT
38.15 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
38.16 -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
38.17 -# version 2 for more details (a copy is included in the LICENSE file that
38.18 -# accompanied this code).
38.19 -#
38.20 -# You should have received a copy of the GNU General Public License version
38.21 -# 2 along with this work; if not, write to the Free Software Foundation,
38.22 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
38.23 -#
38.24 -# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
38.25 -# CA 95054 USA or visit www.sun.com if you need additional information or
38.26 -# have any questions.
38.27 -#
38.28 -
38.29 -#
38.30 -# Makefile for building the Nimbus generator
38.31 -#
38.32 -
38.33 -BUILDDIR = ../..
38.34 -PACKAGE = org.jdesktop.synthdesigner.generator
38.35 -PRODUCT = tools
38.36 -PROGRAM = nimbus_generator
38.37 -include $(BUILDDIR)/common/Defs.gmk
38.38 -
38.39 -BUILDTOOL_SOURCE_ROOT = classes
38.40 -BUILDTOOL_MAIN = $(PKGDIR)/Generator.java
38.41 -
38.42 -#
38.43 -# Files
38.44 -#
38.45 -
38.46 -MAIN_CLASS_FILE = $(BUILDTOOLCLASSDIR)/$(BUILDTOOL_MAIN:%.java=%.class)
38.47 -SOURCE_FILES = $(shell $(FIND) $(BUILDTOOL_SOURCE_ROOT) -name '*.java' -print)
38.48 -
38.49 -TEMPLATE_FILES = $(SHARE_SRC)/classes/javax/swing/plaf/nimbus/Defaults.template \
38.50 - $(SHARE_SRC)/classes/javax/swing/plaf/nimbus/PainterImpl.template \
38.51 - $(SHARE_SRC)/classes/javax/swing/plaf/nimbus/StateImpl.template
38.52 -TEMPLATE_DEST = $(BUILDTOOLCLASSDIR)/org/jdesktop/synthdesigner/generator/resources
38.53 -
38.54 -JIBX_FILES = $(BUILDTOOL_SOURCE_ROOT)/org/jdesktop/swingx/designer/Designer.jibx.xml \
38.55 - $(BUILDTOOL_SOURCE_ROOT)/org/jdesktop/synthdesigner/synthmodel/SynthModel.jibx.xml
38.56 -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
38.57 -JIBX_LIBS_LIST = $(subst $(CLASSPATH_SEPARATOR), ,$(JIBX_LIBS_CP))
38.58 -
38.59 -
38.60 -#
38.61 -# Rules
38.62 -#
38.63 -
38.64 -include $(BUILDDIR)/common/BuildToolJar.gmk
38.65 -
38.66 -$(MAIN_CLASS_FILE): $(SOURCE_FILES) $(JIBX_LIBS_LIST)
38.67 - @$(MKDIR) -p $(BUILDTOOLCLASSDIR)
38.68 - $(BOOT_JAVAC_CMD) -classpath "$(JIBX_LIBS_CP)" \
38.69 - -d $(BUILDTOOLCLASSDIR) -sourcepath $(BUILDTOOL_SOURCE_ROOT) \
38.70 - $(SOURCE_FILES)
38.71 -
38.72 -$(TEMPLATE_DEST): $(TEMPLATE_FILES)
38.73 - $(MKDIR) -p $(TEMPLATE_DEST)
38.74 - $(RM) $(TEMPLATE_DEST)/*.template
38.75 - $(CP) $(TEMPLATE_FILES) $(TEMPLATE_DEST)
38.76 -
38.77 -$(BUILDTOOL_MANIFEST_FILE): $(MAIN_CLASS_FILE)
38.78 - $(ECHO) "Main-Class: $(BUILTTOOL_MAINCLASS)" > $@
38.79 - $(ECHO) "Class-Path: $(JIBX_LIBS_LIST:$(JIBX_LIBS_PATH)/%=%)" >> $@
38.80 - $(CP) $(JIBX_LIBS_LIST) $(BUILDTOOLJARDIR)
38.81 -
38.82 -$(BUILDTOOL_JAR_FILE): $(MAIN_CLASS_FILE) $(TEMPLATE_DEST) \
38.83 - $(JIBX_FILES) $(BUILDTOOL_MANIFEST_FILE)
38.84 - @$(prep-target)
38.85 - $(BOOT_JAVA_CMD) \
38.86 - -classpath "$(JIBX_LIBS_CP)$(CLASSPATH_SEPARATOR)$(BUILDTOOLCLASSDIR)" \
38.87 - org.jibx.binding.Compile $(JIBX_FILES)
38.88 - $(BOOT_JAR_CMD) cfm $@ $(BUILDTOOL_MANIFEST_FILE) \
38.89 - -C $(BUILDTOOLCLASSDIR) org \
38.90 - $(BOOT_JAR_JFLAGS) || $(RM) $@
38.91 - @$(java-vm-cleanup)
38.92 -
38.93 -clean clobber::
38.94 - $(RM) -r $(TEMPLATE_DEST)
39.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/beans/AbstractBean.java Sun Sep 06 23:14:42 2009 -0700
39.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
39.3 @@ -1,475 +0,0 @@
39.4 -/*
39.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
39.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
39.7 - *
39.8 - * This code is free software; you can redistribute it and/or modify it
39.9 - * under the terms of the GNU General Public License version 2 only, as
39.10 - * published by the Free Software Foundation. Sun designates this
39.11 - * particular file as subject to the "Classpath" exception as provided
39.12 - * by Sun in the LICENSE file that accompanied this code.
39.13 - *
39.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
39.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
39.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
39.17 - * version 2 for more details (a copy is included in the LICENSE file that
39.18 - * accompanied this code).
39.19 - *
39.20 - * You should have received a copy of the GNU General Public License version
39.21 - * 2 along with this work; if not, write to the Free Software Foundation,
39.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
39.23 - *
39.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
39.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
39.26 - * have any questions.
39.27 - */
39.28 -package org.jdesktop.beans;
39.29 -
39.30 -import java.beans.PropertyChangeEvent;
39.31 -import java.beans.PropertyChangeListener;
39.32 -import java.beans.PropertyChangeSupport;
39.33 -import java.beans.PropertyVetoException;
39.34 -import java.beans.VetoableChangeListener;
39.35 -import java.beans.VetoableChangeSupport;
39.36 -
39.37 -/**
39.38 - * <p>A convenience class from which to extend all non-visual AbstractBeans. It
39.39 - * manages the PropertyChange notification system, making it relatively trivial
39.40 - * to add support for property change events in getters/setters.</p>
39.41 - *
39.42 - * <p>A non-visual java bean is a Java class that conforms to the AbstractBean
39.43 - * patterns to allow visual manipulation of the bean's properties and event
39.44 - * handlers at design-time.</p>
39.45 - *
39.46 - * <p>Here is a simple example bean that contains one property, foo, and the
39.47 - * proper pattern for implementing property change notification:
39.48 - * <pre><code>
39.49 - * public class ABean extends AbstractBean {
39.50 - * private String foo;
39.51 - *
39.52 - * public void setFoo(String newFoo) {
39.53 - * String old = getFoo();
39.54 - * this.foo = newFoo;
39.55 - * firePropertyChange("foo", old, getFoo());
39.56 - * }
39.57 - *
39.58 - * public String getFoo() {
39.59 - * return foo;
39.60 - * }
39.61 - * }
39.62 - * </code></pre></p>
39.63 - *
39.64 - * <p>You will notice that "getFoo()" is used in the setFoo method rather than
39.65 - * accessing "foo" directly for the gets. This is done intentionally so that if
39.66 - * a subclass overrides getFoo() to return, for instance, a constant value the
39.67 - * property change notification system will continue to work properly.</p>
39.68 - *
39.69 - * <p>The firePropertyChange method takes into account the old value and the new
39.70 - * value. Only if the two differ will it fire a property change event. So you can
39.71 - * be assured from the above code fragment that a property change event will only
39.72 - * occur if old is indeed different from getFoo()</p>
39.73 - *
39.74 - * <p><code>AbstractBean</code> also supports {@link VetoablePropertyChange} events.
39.75 - * These events are similar to <code>PropertyChange</code> events, except a special
39.76 - * exception can be used to veto changing the property. For example, perhaps the
39.77 - * property is changing from "fred" to "red", but a listener deems that "red" is
39.78 - * unexceptable. In this case, the listener can fire a veto exception and the property must
39.79 - * remain "fred". For example:
39.80 - * <pre><code>
39.81 - * public class ABean extends AbstractBean {
39.82 - * private String foo;
39.83 - *
39.84 - * public void setFoo(String newFoo) throws PropertyVetoException {
39.85 - * String old = getFoo();
39.86 - * this.foo = newFoo;
39.87 - * fireVetoableChange("foo", old, getFoo());
39.88 - * }
39.89 - *
39.90 - * public String getFoo() {
39.91 - * return foo;
39.92 - * }
39.93 - * }
39.94 - *
39.95 - * public class Tester {
39.96 - * public static void main(String... args) {
39.97 - * try {
39.98 - * ABean a = new ABean();
39.99 - * a.setFoo("fred");
39.100 - * a.addVetoableChangeListener(new VetoableChangeListener() {
39.101 - * public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
39.102 - * if ("red".equals(evt.getNewValue()) {
39.103 - * throw new PropertyVetoException("Cannot be red!", evt);
39.104 - * }
39.105 - * }
39.106 - * }
39.107 - * a.setFoo("red");
39.108 - * } catch (Exception e) {
39.109 - * e.printStackTrace(); // this will be executed
39.110 - * }
39.111 - * }
39.112 - * }
39.113 - * </code></pre></p>
39.114 - *
39.115 - * @status REVIEWED
39.116 - * @author rbair
39.117 - */
39.118 -public abstract class AbstractBean {
39.119 - /**
39.120 - * Helper class that manages all the property change notification machinery.
39.121 - * PropertyChangeSupport cannot be extended directly because it requires
39.122 - * a bean in the constructor, and the "this" argument is not valid until
39.123 - * after super construction. Hence, delegation instead of extension
39.124 - */
39.125 - private transient PropertyChangeSupport pcs;
39.126 -
39.127 - /**
39.128 - * Helper class that manages all the veto property change notification machinery.
39.129 - */
39.130 - private transient VetoableChangeSupport vcs;
39.131 -
39.132 - /** Creates a new instance of AbstractBean */
39.133 - protected AbstractBean() {
39.134 - pcs = new PropertyChangeSupport(this);
39.135 - vcs = new VetoableChangeSupport(this);
39.136 - }
39.137 -
39.138 - /**
39.139 - * Creates a new instance of AbstractBean, using the supplied PropertyChangeSupport and
39.140 - * VetoableChangeSupport delegates. Neither of these may be null.
39.141 - */
39.142 - protected AbstractBean(PropertyChangeSupport pcs, VetoableChangeSupport vcs) {
39.143 - if (pcs == null) {
39.144 - throw new NullPointerException("PropertyChangeSupport must not be null");
39.145 - }
39.146 - if (vcs == null) {
39.147 - throw new NullPointerException("VetoableChangeSupport must not be null");
39.148 - }
39.149 -
39.150 - this.pcs = pcs;
39.151 - this.vcs = vcs;
39.152 - }
39.153 -
39.154 - /**
39.155 - * Add a PropertyChangeListener to the listener list.
39.156 - * The listener is registered for all properties.
39.157 - * The same listener object may be added more than once, and will be called
39.158 - * as many times as it is added.
39.159 - * If <code>listener</code> is null, no exception is thrown and no action
39.160 - * is taken.
39.161 - *
39.162 - * @param listener The PropertyChangeListener to be added
39.163 - */
39.164 - public final void addPropertyChangeListener(PropertyChangeListener listener) {
39.165 - pcs.addPropertyChangeListener(listener);
39.166 - }
39.167 -
39.168 - /**
39.169 - * Remove a PropertyChangeListener from the listener list.
39.170 - * This removes a PropertyChangeListener that was registered
39.171 - * for all properties.
39.172 - * If <code>listener</code> was added more than once to the same event
39.173 - * source, it will be notified one less time after being removed.
39.174 - * If <code>listener</code> is null, or was never added, no exception is
39.175 - * thrown and no action is taken.
39.176 - *
39.177 - * @param listener The PropertyChangeListener to be removed
39.178 - */
39.179 - public final void removePropertyChangeListener(PropertyChangeListener listener) {
39.180 - pcs.removePropertyChangeListener(listener);
39.181 - }
39.182 -
39.183 - /**
39.184 - * Returns an array of all the listeners that were added to the
39.185 - * PropertyChangeSupport object with addPropertyChangeListener().
39.186 - * <p>
39.187 - * If some listeners have been added with a named property, then
39.188 - * the returned array will be a mixture of PropertyChangeListeners
39.189 - * and <code>PropertyChangeListenerProxy</code>s. If the calling
39.190 - * method is interested in distinguishing the listeners then it must
39.191 - * test each element to see if it's a
39.192 - * <code>PropertyChangeListenerProxy</code>, perform the cast, and examine
39.193 - * the parameter.
39.194 - *
39.195 - * <pre>
39.196 - * PropertyChangeListener[] listeners = bean.getPropertyChangeListeners();
39.197 - * for (int i = 0; i < listeners.length; i++) {
39.198 - * if (listeners[i] instanceof PropertyChangeListenerProxy) {
39.199 - * PropertyChangeListenerProxy proxy =
39.200 - * (PropertyChangeListenerProxy)listeners[i];
39.201 - * if (proxy.getPropertyName().equals("foo")) {
39.202 - * // proxy is a PropertyChangeListener which was associated
39.203 - * // with the property named "foo"
39.204 - * }
39.205 - * }
39.206 - * }
39.207 - *</pre>
39.208 - *
39.209 - * @see java.beans.PropertyChangeListenerProxy
39.210 - * @return all of the <code>PropertyChangeListeners</code> added or an
39.211 - * empty array if no listeners have been added
39.212 - */
39.213 - public final PropertyChangeListener[] getPropertyChangeListeners() {
39.214 - return pcs.getPropertyChangeListeners();
39.215 - }
39.216 -
39.217 - /**
39.218 - * Add a PropertyChangeListener for a specific property. The listener
39.219 - * will be invoked only when a call on firePropertyChange names that
39.220 - * specific property.
39.221 - * The same listener object may be added more than once. For each
39.222 - * property, the listener will be invoked the number of times it was added
39.223 - * for that property.
39.224 - * If <code>propertyName</code> or <code>listener</code> is null, no
39.225 - * exception is thrown and no action is taken.
39.226 - *
39.227 - * @param propertyName The name of the property to listen on.
39.228 - * @param listener The PropertyChangeListener to be added
39.229 - */
39.230 - public final void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
39.231 - pcs.addPropertyChangeListener(propertyName, listener);
39.232 - }
39.233 -
39.234 - /**
39.235 - * Remove a PropertyChangeListener for a specific property.
39.236 - * If <code>listener</code> was added more than once to the same event
39.237 - * source for the specified property, it will be notified one less time
39.238 - * after being removed.
39.239 - * If <code>propertyName</code> is null, no exception is thrown and no
39.240 - * action is taken.
39.241 - * If <code>listener</code> is null, or was never added for the specified
39.242 - * property, no exception is thrown and no action is taken.
39.243 - *
39.244 - * @param propertyName The name of the property that was listened on.
39.245 - * @param listener The PropertyChangeListener to be removed
39.246 - */
39.247 - public final void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
39.248 - pcs.removePropertyChangeListener(propertyName, listener);
39.249 - }
39.250 -
39.251 - /**
39.252 - * Returns an array of all the listeners which have been associated
39.253 - * with the named property.
39.254 - *
39.255 - * @param propertyName The name of the property being listened to
39.256 - * @return all of the <code>PropertyChangeListeners</code> associated with
39.257 - * the named property. If no such listeners have been added,
39.258 - * or if <code>propertyName</code> is null, an empty array is
39.259 - * returned.
39.260 - */
39.261 - public final PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
39.262 - return pcs.getPropertyChangeListeners(propertyName);
39.263 - }
39.264 -
39.265 - /**
39.266 - * Report a bound property update to any registered listeners.
39.267 - * No event is fired if old and new are equal and non-null.
39.268 - *
39.269 - * <p>
39.270 - * This is merely a convenience wrapper around the more general
39.271 - * firePropertyChange method that takes {@code
39.272 - * PropertyChangeEvent} value.
39.273 - *
39.274 - * @param propertyName The programmatic name of the property
39.275 - * that was changed.
39.276 - * @param oldValue The old value of the property.
39.277 - * @param newValue The new value of the property.
39.278 - */
39.279 - protected final void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
39.280 - pcs.firePropertyChange(propertyName, oldValue, newValue);
39.281 - }
39.282 -
39.283 - /**
39.284 - * Fire an existing PropertyChangeEvent to any registered listeners.
39.285 - * No event is fired if the given event's old and new values are
39.286 - * equal and non-null.
39.287 - * @param evt The PropertyChangeEvent object.
39.288 - */
39.289 - protected final void firePropertyChange(PropertyChangeEvent evt) {
39.290 - pcs.firePropertyChange(evt);
39.291 - }
39.292 -
39.293 -
39.294 - /**
39.295 - * Report a bound indexed property update to any registered
39.296 - * listeners.
39.297 - * <p>
39.298 - * No event is fired if old and new values are equal
39.299 - * and non-null.
39.300 - *
39.301 - * <p>
39.302 - * This is merely a convenience wrapper around the more general
39.303 - * firePropertyChange method that takes {@code PropertyChangeEvent} value.
39.304 - *
39.305 - * @param propertyName The programmatic name of the property that
39.306 - * was changed.
39.307 - * @param index index of the property element that was changed.
39.308 - * @param oldValue The old value of the property.
39.309 - * @param newValue The new value of the property.
39.310 - */
39.311 - protected final void fireIndexedPropertyChange(String propertyName,
39.312 - int index, Object oldValue, Object newValue) {
39.313 - pcs.fireIndexedPropertyChange(propertyName, index, oldValue, newValue);
39.314 - }
39.315 -
39.316 - /**
39.317 - * Check if there are any listeners for a specific property, including
39.318 - * those registered on all properties. If <code>propertyName</code>
39.319 - * is null, only check for listeners registered on all properties.
39.320 - *
39.321 - * @param propertyName the property name.
39.322 - * @return true if there are one or more listeners for the given property
39.323 - */
39.324 - protected final boolean hasPropertyChangeListeners(String propertyName) {
39.325 - return pcs.hasListeners(propertyName);
39.326 - }
39.327 -
39.328 - /**
39.329 - * Check if there are any listeners for a specific property, including
39.330 - * those registered on all properties. If <code>propertyName</code>
39.331 - * is null, only check for listeners registered on all properties.
39.332 - *
39.333 - * @param propertyName the property name.
39.334 - * @return true if there are one or more listeners for the given property
39.335 - */
39.336 - protected final boolean hasVetoableChangeListeners(String propertyName) {
39.337 - return vcs.hasListeners(propertyName);
39.338 - }
39.339 -
39.340 - /**
39.341 - * Add a VetoableListener to the listener list.
39.342 - * The listener is registered for all properties.
39.343 - * The same listener object may be added more than once, and will be called
39.344 - * as many times as it is added.
39.345 - * If <code>listener</code> is null, no exception is thrown and no action
39.346 - * is taken.
39.347 - *
39.348 - * @param listener The VetoableChangeListener to be added
39.349 - */
39.350 -
39.351 - public final void addVetoableChangeListener(VetoableChangeListener listener) {
39.352 - vcs.addVetoableChangeListener(listener);
39.353 - }
39.354 -
39.355 - /**
39.356 - * Remove a VetoableChangeListener from the listener list.
39.357 - * This removes a VetoableChangeListener that was registered
39.358 - * for all properties.
39.359 - * If <code>listener</code> was added more than once to the same event
39.360 - * source, it will be notified one less time after being removed.
39.361 - * If <code>listener</code> is null, or was never added, no exception is
39.362 - * thrown and no action is taken.
39.363 - *
39.364 - * @param listener The VetoableChangeListener to be removed
39.365 - */
39.366 - public final void removeVetoableChangeListener(VetoableChangeListener listener) {
39.367 - vcs.removeVetoableChangeListener(listener);
39.368 - }
39.369 -
39.370 - /**
39.371 - * Returns the list of VetoableChangeListeners. If named vetoable change listeners
39.372 - * were added, then VetoableChangeListenerProxy wrappers will returned
39.373 - * <p>
39.374 - * @return List of VetoableChangeListeners and VetoableChangeListenerProxys
39.375 - * if named property change listeners were added.
39.376 - */
39.377 - public final VetoableChangeListener[] getVetoableChangeListeners(){
39.378 - return vcs.getVetoableChangeListeners();
39.379 - }
39.380 -
39.381 - /**
39.382 - * Add a VetoableChangeListener for a specific property. The listener
39.383 - * will be invoked only when a call on fireVetoableChange names that
39.384 - * specific property.
39.385 - * The same listener object may be added more than once. For each
39.386 - * property, the listener will be invoked the number of times it was added
39.387 - * for that property.
39.388 - * If <code>propertyName</code> or <code>listener</code> is null, no
39.389 - * exception is thrown and no action is taken.
39.390 - *
39.391 - * @param propertyName The name of the property to listen on.
39.392 - * @param listener The VetoableChangeListener to be added
39.393 - */
39.394 -
39.395 - public final void addVetoableChangeListener(String propertyName,
39.396 - VetoableChangeListener listener) {
39.397 - vcs.addVetoableChangeListener(propertyName, listener);
39.398 - }
39.399 -
39.400 - /**
39.401 - * Remove a VetoableChangeListener for a specific property.
39.402 - * If <code>listener</code> was added more than once to the same event
39.403 - * source for the specified property, it will be notified one less time
39.404 - * after being removed.
39.405 - * If <code>propertyName</code> is null, no exception is thrown and no
39.406 - * action is taken.
39.407 - * If <code>listener</code> is null, or was never added for the specified
39.408 - * property, no exception is thrown and no action is taken.
39.409 - *
39.410 - * @param propertyName The name of the property that was listened on.
39.411 - * @param listener The VetoableChangeListener to be removed
39.412 - */
39.413 -
39.414 - public final void removeVetoableChangeListener(String propertyName,
39.415 - VetoableChangeListener listener) {
39.416 - vcs.removeVetoableChangeListener(propertyName, listener);
39.417 - }
39.418 -
39.419 - /**
39.420 - * Returns an array of all the listeners which have been associated
39.421 - * with the named property.
39.422 - *
39.423 - * @param propertyName The name of the property being listened to
39.424 - * @return all the <code>VetoableChangeListeners</code> associated with
39.425 - * the named property. If no such listeners have been added,
39.426 - * or if <code>propertyName</code> is null, an empty array is
39.427 - * returned.
39.428 - */
39.429 - public final VetoableChangeListener[] getVetoableChangeListeners(String propertyName) {
39.430 - return vcs.getVetoableChangeListeners(propertyName);
39.431 - }
39.432 -
39.433 - /**
39.434 - * Report a vetoable property update to any registered listeners. If
39.435 - * anyone vetos the change, then fire a new event reverting everyone to
39.436 - * the old value and then rethrow the PropertyVetoException.
39.437 - * <p>
39.438 - * No event is fired if old and new are equal and non-null.
39.439 - *
39.440 - * @param propertyName The programmatic name of the property
39.441 - * that is about to change..
39.442 - * @param oldValue The old value of the property.
39.443 - * @param newValue The new value of the property.
39.444 - * @exception PropertyVetoException if the recipient wishes the property
39.445 - * change to be rolled back.
39.446 - */
39.447 - protected final void fireVetoableChange(String propertyName,
39.448 - Object oldValue, Object newValue)
39.449 - throws PropertyVetoException {
39.450 - vcs.fireVetoableChange(propertyName, oldValue, newValue);
39.451 - }
39.452 -
39.453 - /**
39.454 - * Fire a vetoable property update to any registered listeners. If
39.455 - * anyone vetos the change, then fire a new event reverting everyone to
39.456 - * the old value and then rethrow the PropertyVetoException.
39.457 - * <p>
39.458 - * No event is fired if old and new are equal and non-null.
39.459 - *
39.460 - * @param evt The PropertyChangeEvent to be fired.
39.461 - * @exception PropertyVetoException if the recipient wishes the property
39.462 - * change to be rolled back.
39.463 - */
39.464 - protected final void fireVetoableChange(PropertyChangeEvent evt)
39.465 - throws PropertyVetoException {
39.466 - vcs.fireVetoableChange(evt);
39.467 - }
39.468 -
39.469 - /**
39.470 - * @inheritDoc
39.471 - */
39.472 - public Object clone() throws CloneNotSupportedException {
39.473 - AbstractBean result = (AbstractBean) super.clone();
39.474 - result.pcs = new PropertyChangeSupport(result);
39.475 - result.vcs = new VetoableChangeSupport(result);
39.476 - return result;
39.477 - }
39.478 -}
40.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/BezierControlPoint.java Sun Sep 06 23:14:42 2009 -0700
40.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
40.3 @@ -1,265 +0,0 @@
40.4 -/*
40.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
40.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
40.7 - *
40.8 - * This code is free software; you can redistribute it and/or modify it
40.9 - * under the terms of the GNU General Public License version 2 only, as
40.10 - * published by the Free Software Foundation. Sun designates this
40.11 - * particular file as subject to the "Classpath" exception as provided
40.12 - * by Sun in the LICENSE file that accompanied this code.
40.13 - *
40.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
40.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
40.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
40.17 - * version 2 for more details (a copy is included in the LICENSE file that
40.18 - * accompanied this code).
40.19 - *
40.20 - * You should have received a copy of the GNU General Public License version
40.21 - * 2 along with this work; if not, write to the Free Software Foundation,
40.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
40.23 - *
40.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
40.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
40.26 - * have any questions.
40.27 - */
40.28 -package org.jdesktop.swingx.designer;
40.29 -
40.30 -import java.awt.BasicStroke;
40.31 -import java.awt.Graphics2D;
40.32 -import java.awt.Shape;
40.33 -import java.awt.geom.Ellipse2D;
40.34 -import java.awt.geom.GeneralPath;
40.35 -import java.awt.geom.Line2D;
40.36 -import java.awt.geom.Point2D;
40.37 -import java.awt.geom.Rectangle2D;
40.38 -import java.beans.PropertyChangeEvent;
40.39 -import java.beans.PropertyChangeListener;
40.40 -import java.util.ArrayList;
40.41 -import java.util.Collections;
40.42 -import java.util.List;
40.43 -
40.44 -/**
40.45 - * BezierControlPoint
40.46 - *
40.47 - * @author Created by Jasper Potts (May 29, 2007)
40.48 - */
40.49 -public class BezierControlPoint extends ControlPoint {
40.50 - private HandleControlPoint cp1 = new HandleControlPoint();
40.51 - private HandleControlPoint cp2 = new HandleControlPoint();
40.52 - private transient boolean makingChange = false;
40.53 - private transient PropertyChangeListener cpListener = new PropertyChangeListener() {
40.54 - public void propertyChange(PropertyChangeEvent evt) {
40.55 -// if (!makingChange) {
40.56 -// makingChange = true;
40.57 -// if (evt.getSource() == cp1) {
40.58 -// double angle = Math.tan((cp1.getY() - getY())/(cp1.getX() - getX()));
40.59 -// double cp2len = Math.sqrt(
40.60 -// Math.pow(cp2.getX() - getX(),2) +
40.61 -// Math.pow(cp2.getY() - getY(),2)
40.62 -// );
40.63 -// double offsetX = cp2len * Math.sin(angle);
40.64 -// double offsetY = cp2len * Math.cos(angle);
40.65 -// cp2.setPosition(getX() - offsetX, getY() - offsetY);
40.66 -// } else {
40.67 -// double angle = Math.tan((cp2.getY() - getY())/(cp2.getX() - getX()));
40.68 -// double cp1len = Math.sqrt(
40.69 -// Math.pow(cp1.getX() - getX(),2) +
40.70 -// Math.pow(cp1.getY() - getY(),2)
40.71 -// );
40.72 -// double offsetX = cp1len * Math.sin(angle);
40.73 -// double offsetY = cp1len * Math.cos(angle);
40.74 -// cp1.setPosition(getX() - offsetX, getY() - offsetY);
40.75 -// }
40.76 -//// if (evt.getSource() == cp1) {
40.77 -//// double offsetX = cp1.getX() - getX();
40.78 -//// double offsetY = cp1.getY() - getY();
40.79 -//// cp2.setPosition(getX() - offsetX, getY() - offsetY);
40.80 -//// } else {
40.81 -//// double offsetX = cp2.getX() - getX();
40.82 -//// double offsetY = cp2.getY() - getY();
40.83 -//// cp1.setPosition(getX() - offsetX, getY() - offsetY);
40.84 -//// }
40.85 -// makingChange = false;
40.86 -// firePropertyChange("cp1", null, cp1);
40.87 -// firePropertyChange("cp2", null, cp1);
40.88 -// }
40.89 - firePropertyChange("shape",null,getShape());
40.90 - }
40.91 - };
40.92 -
40.93 - public BezierControlPoint() {
40.94 - cp1.addPropertyChangeListener(cpListener);
40.95 - cp2.addPropertyChangeListener(cpListener);
40.96 - }
40.97 -
40.98 - public BezierControlPoint(double x, double y) {
40.99 - super(x, y);
40.100 - cp1.addPropertyChangeListener(cpListener);
40.101 - cp2.addPropertyChangeListener(cpListener);
40.102 - cp1.setPosition(x, y);
40.103 - cp2.setPosition(x, y);
40.104 - }
40.105 -
40.106 - public boolean isSharpCorner() {
40.107 - return
40.108 - (cp1.getX() == x.getValue()) &&
40.109 - (cp1.getY() == y.getValue()) &&
40.110 - (cp2.getX() == x.getValue()) &&
40.111 - (cp2.getY() == y.getValue());
40.112 - }
40.113 -
40.114 - public void flip(int width, int height){
40.115 - makingChange = true;
40.116 - if (width > 0){
40.117 - x.setValue(width - x.getValue());
40.118 - cp1.x.setValue(width - cp1.x.getValue());
40.119 - cp2.x.setValue(width - cp2.x.getValue());
40.120 - }
40.121 - if (height > 0){
40.122 - y.setValue(height - y.getValue());
40.123 - cp1.y.setValue(height - cp1.y.getValue());
40.124 - cp2.y.setValue(height - cp2.y.getValue());
40.125 - }
40.126 - makingChange = false;
40.127 - }
40.128 -
40.129 - public void convertToSharpCorner() {
40.130 - cp1.setPosition(x.getValue(), y.getValue());
40.131 - cp2.setPosition(x.getValue(), y.getValue());
40.132 - }
40.133 -
40.134 - public List<ControlPoint> getControlPoints() {
40.135 - if (isSharpCorner()) {
40.136 - return Collections.emptyList();
40.137 - } else {
40.138 - List<ControlPoint> points = new ArrayList<ControlPoint>();
40.139 - points.add(cp1);
40.140 - points.add(cp2);
40.141 - return points;
40.142 - }
40.143 - }
40.144 -
40.145 - public HandleControlPoint getCp1() {
40.146 - return cp1;
40.147 - }
40.148 -
40.149 - public HandleControlPoint getCp2() {
40.150 - return cp2;
40.151 - }
40.152 -
40.153 - public void paintControls(Graphics2D g2, double pixelSize, boolean paintControlLines) {
40.154 - g2.setStroke(new BasicStroke((float) pixelSize));
40.155 - // paint control line
40.156 - g2.setColor(GraphicsHelper.BEZIER_CONTROL_LINE);
40.157 - g2.draw(new Line2D.Double(cp1.getX(), cp1.getY(), getX(), getY()));
40.158 - g2.draw(new Line2D.Double(getX(), getY(), cp2.getX(), cp2.getY()));
40.159 - // paint this control point
40.160 - Shape s;
40.161 - if (isSharpCorner()) {
40.162 - double size = pixelSize * 4d;
40.163 - GeneralPath path = new GeneralPath();
40.164 - path.moveTo(getX() - size, getY());
40.165 - path.lineTo(getX(), getY() + size);
40.166 - path.lineTo(getX() + size, getY());
40.167 - path.lineTo(getX(), getY() - size);
40.168 - path.closePath();
40.169 - s = path;
40.170 - } else {
40.171 - double size = pixelSize * 3d;
40.172 - s = new Ellipse2D.Double(getX() - size, getY() - size,
40.173 - size * 2, size * 2);
40.174 - }
40.175 - g2.setColor(GraphicsHelper.BEZIER_CONTROL_POINT_FILL);
40.176 - g2.fill(s);
40.177 - g2.setColor(GraphicsHelper.BEZIER_CONTROL_POINT_LINE);
40.178 - g2.draw(s);
40.179 - // paint child control points
40.180 - if (!isSharpCorner()) {
40.181 - cp1.paintControls(g2, pixelSize, true);
40.182 - cp2.paintControls(g2, pixelSize, true);
40.183 - }
40.184 - }
40.185 -
40.186 -
40.187 - public void move(double moveX, double moveY, boolean snapPixels) {
40.188 - makingChange = true;
40.189 - super.move(moveX, moveY, snapPixels);
40.190 - cp1.move(moveX, moveY, snapPixels);
40.191 - cp2.move(moveX, moveY, snapPixels);
40.192 - makingChange = false;
40.193 - }
40.194 -
40.195 - public double getCp1X() {
40.196 - return cp1.getX();
40.197 - }
40.198 -
40.199 - public void setCp1X(double v) {
40.200 - cp1.setX(v);
40.201 - }
40.202 -
40.203 - public double getCp1Y() {
40.204 - return cp1.getY();
40.205 - }
40.206 -
40.207 - public void setCp1Y(double v) {
40.208 - cp1.setY(v);
40.209 - }
40.210 -
40.211 - public double getCp2X() {
40.212 - return cp2.getX();
40.213 - }
40.214 -
40.215 - public void setCp2X(double v) {
40.216 - cp2.setX(v);
40.217 - }
40.218 -
40.219 - public double getCp2Y() {
40.220 - return cp2.getY();
40.221 - }
40.222 -
40.223 - public void setCp2Y(double v) {
40.224 - cp2.setY(v);
40.225 - }
40.226 -
40.227 - // =================================================================================================================
40.228 - // Bezier handle control point
40.229 -
40.230 - public class HandleControlPoint extends ControlPoint {
40.231 -
40.232 - public void paintControls(Graphics2D g2, double pixelSize, boolean paintControlLines) {
40.233 - if (!isSharp()){
40.234 - double size = pixelSize * 3d;
40.235 - Shape s = new Ellipse2D.Double(getX() - size, getY() - size,
40.236 - size * 2, size * 2);
40.237 - g2.setColor(GraphicsHelper.BEZIER_CONTROL_POINT_FILL);
40.238 - g2.fill(s);
40.239 - g2.setColor(GraphicsHelper.BEZIER_CONTROL_POINT_LINE);
40.240 - g2.draw(s);
40.241 - g2.draw(new Rectangle2D.Double(getX() - (pixelSize / 2), getY() - (pixelSize / 2), pixelSize, pixelSize));
40.242 - }
40.243 - }
40.244 -
40.245 - public boolean isHit(Point2D p, double pixelSize) {
40.246 - return !isSharp() && super.isHit(p, pixelSize);
40.247 - }
40.248 -
40.249 - /**
40.250 - * Is the line controled by this handle in or out of the parent BezierControlPoint sharp.
40.251 - *
40.252 - * @return <code>true</code> If this is the exact same point as the parent BezierControlPoint.
40.253 - */
40.254 - public boolean isSharp(){
40.255 - return x.getValue() == BezierControlPoint.this.x.getValue() &&
40.256 - y.getValue() == BezierControlPoint.this.y.getValue();
40.257 - }
40.258 -
40.259 - public void convertToSharp(){
40.260 - setPosition(BezierControlPoint.this.x.getValue(),BezierControlPoint.this.y.getValue());
40.261 - }
40.262 -
40.263 - public BezierControlPoint getParentControlPoint(){
40.264 - return BezierControlPoint.this;
40.265 - }
40.266 - }
40.267 -
40.268 -}
41.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/BlendingMode.java Sun Sep 06 23:14:42 2009 -0700
41.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
41.3 @@ -1,100 +0,0 @@
41.4 -/*
41.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
41.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
41.7 - *
41.8 - * This code is free software; you can redistribute it and/or modify it
41.9 - * under the terms of the GNU General Public License version 2 only, as
41.10 - * published by the Free Software Foundation. Sun designates this
41.11 - * particular file as subject to the "Classpath" exception as provided
41.12 - * by Sun in the LICENSE file that accompanied this code.
41.13 - *
41.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
41.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
41.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
41.17 - * version 2 for more details (a copy is included in the LICENSE file that
41.18 - * accompanied this code).
41.19 - *
41.20 - * You should have received a copy of the GNU General Public License version
41.21 - * 2 along with this work; if not, write to the Free Software Foundation,
41.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
41.23 - *
41.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
41.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
41.26 - * have any questions.
41.27 - */
41.28 -package org.jdesktop.swingx.designer;
41.29 -
41.30 -
41.31 -/**
41.32 - * BlendingMode - Enum of composite blending modes, setup to match photoshop as closely as possible
41.33 - *
41.34 - * @author Created by Jasper Potts (May 31, 2007)
41.35 - */
41.36 -public enum BlendingMode {
41.37 - NORMAL,
41.38 - // DISSOLVE, missing
41.39 - // -----------------------------
41.40 - DARKEN,
41.41 - MULTIPLY,
41.42 - COLOR_BURN,
41.43 - LINEAR_BURN, // (SUBTRACT)
41.44 - // -----------------------------
41.45 - LIGHTEN,
41.46 - SCREEN,
41.47 - COLOR_DODGE,
41.48 - LINEAR_DODGE, // (ADD)
41.49 - // -----------------------------
41.50 - OVERLAY,
41.51 - SOFT_LIGHT,
41.52 - HARD_LIGHT,
41.53 - VIVID_LIGHT, // (HEAT) is close
41.54 - LINEAR_LIGHT, // (GLOW) is close
41.55 - //PIN_LIGHT, missing
41.56 - //HARD_MIX, missing
41.57 - // -----------------------------
41.58 - DIFFERENCE,
41.59 - EXCLUSION,
41.60 - // -----------------------------
41.61 - HUE, // nowhere close
41.62 - SATURATION,
41.63 - COLOR,
41.64 - LUMINOSITY, // close but not exact
41.65 - //LIGHTER_COLOR, missing
41.66 - //DARKER_COLOR, missing
41.67 - ;
41.68 -
41.69 -
41.70 - // =================================================================================================================
41.71 - // Helper methods for creating Blending Mode Combo Box
41.72 -
41.73 - public static final Object[] BLENDING_MODES = new Object[]{
41.74 - BlendingMode.NORMAL,
41.75 - // DISSOLVE, missing
41.76 - "-",
41.77 - BlendingMode.DARKEN,
41.78 - BlendingMode.MULTIPLY,
41.79 - BlendingMode.COLOR_BURN,
41.80 - BlendingMode.LINEAR_BURN, // (SUBTRACT)
41.81 - "-",
41.82 - BlendingMode.LIGHTEN,
41.83 - BlendingMode.SCREEN,
41.84 - BlendingMode.COLOR_DODGE,
41.85 - BlendingMode.LINEAR_DODGE, // (ADD)
41.86 - "-",
41.87 - BlendingMode.OVERLAY,
41.88 - BlendingMode.SOFT_LIGHT,
41.89 - BlendingMode.HARD_LIGHT,
41.90 - BlendingMode.VIVID_LIGHT, // (HEAT) is close
41.91 - BlendingMode.LINEAR_LIGHT, // (GLOW) is close
41.92 - //PIN_LIGHT, missing
41.93 - //HARD_MIX, missing
41.94 - "-",
41.95 - BlendingMode.DIFFERENCE,
41.96 - BlendingMode.EXCLUSION,
41.97 - "-",
41.98 - BlendingMode.HUE, // nowhere close
41.99 - BlendingMode.SATURATION,
41.100 - BlendingMode.COLOR,
41.101 - BlendingMode.LUMINOSITY, // close but not exact
41.102 - };
41.103 -}
42.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/Canvas.java Sun Sep 06 23:14:42 2009 -0700
42.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
42.3 @@ -1,308 +0,0 @@
42.4 -/*
42.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
42.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
42.7 - *
42.8 - * This code is free software; you can redistribute it and/or modify it
42.9 - * under the terms of the GNU General Public License version 2 only, as
42.10 - * published by the Free Software Foundation. Sun designates this
42.11 - * particular file as subject to the "Classpath" exception as provided
42.12 - * by Sun in the LICENSE file that accompanied this code.
42.13 - *
42.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
42.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
42.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
42.17 - * version 2 for more details (a copy is included in the LICENSE file that
42.18 - * accompanied this code).
42.19 - *
42.20 - * You should have received a copy of the GNU General Public License version
42.21 - * 2 along with this work; if not, write to the Free Software Foundation,
42.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
42.23 - *
42.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
42.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
42.26 - * have any questions.
42.27 - */
42.28 -package org.jdesktop.swingx.designer;
42.29 -
42.30 -import org.jdesktop.beans.AbstractBean;
42.31 -import org.jdesktop.swingx.designer.utils.HasResources;
42.32 -import org.jdesktop.swingx.designer.utils.HasUIDefaults;
42.33 -import org.jibx.runtime.IUnmarshallingContext;
42.34 -
42.35 -import javax.swing.UIDefaults;
42.36 -import java.awt.AlphaComposite;
42.37 -import java.awt.Dimension;
42.38 -import java.awt.Graphics2D;
42.39 -import java.awt.Insets;
42.40 -import java.awt.RenderingHints;
42.41 -import java.awt.image.BufferedImage;
42.42 -import java.beans.PropertyChangeEvent;
42.43 -import java.beans.PropertyChangeListener;
42.44 -import java.io.File;
42.45 -import java.util.ArrayList;
42.46 -import java.util.Collection;
42.47 -import java.util.Collections;
42.48 -import java.util.Iterator;
42.49 -import java.util.List;
42.50 -
42.51 -/**
42.52 - * ComponentRegion
42.53 - *
42.54 - * @author Created by Jasper Potts (May 22, 2007)
42.55 - */
42.56 -public class Canvas extends AbstractBean implements LayerContainer, HasUIDefaults, HasResources {
42.57 - private Dimension size;
42.58 - /** list of all layers in the canvas, the first layer is painted on top */
42.59 - private List<Layer> layers;
42.60 - private int nextLayerNameIndex = 1;
42.61 - private BufferedImage buffer;
42.62 - private boolean isValid = false;
42.63 - private Insets stretchingInsets = null;
42.64 - private Layer workingLayer = null;
42.65 - private PropertyChangeListener layersPropertyChangeListener;
42.66 - private UIDefaults canvasUIDefaults = null;
42.67 - private transient File resourcesDir;
42.68 - private transient File imagesDir;
42.69 - private transient File templatesDir;
42.70 -
42.71 - // =================================================================================================================
42.72 - // Constructor
42.73 -
42.74 - /** Private constructor for JIBX */
42.75 - protected Canvas() {
42.76 - layersPropertyChangeListener = new PropertyChangeListener() {
42.77 - public void propertyChange(PropertyChangeEvent evt) {
42.78 - isValid = false;
42.79 - // pass on layer change
42.80 - int index = layers.indexOf((Layer) evt.getSource());
42.81 - if (index != -1) {
42.82 - firePropertyChange("layers[" + index + "]." + evt.getPropertyName(), evt.getOldValue(),
42.83 - evt.getNewValue());
42.84 - }
42.85 - }
42.86 - };
42.87 - }
42.88 -
42.89 - public Canvas(int width, int height) {
42.90 - this();
42.91 - stretchingInsets = new Insets(1, 1, 1, 1);
42.92 - layers = new ArrayList<Layer>();
42.93 - setSize(new Dimension(width, height));
42.94 - addLayer(new Layer());
42.95 - }
42.96 -
42.97 - // =================================================================================================================
42.98 - // JIBX Methods
42.99 -
42.100 - /**
42.101 - * Called by JIBX before all fields have been set
42.102 - *
42.103 - * @param context The JIBX Unmarshalling Context
42.104 - */
42.105 - private void preSet(IUnmarshallingContext context) {
42.106 - canvasUIDefaults = (UIDefaults) context.getUserContext();
42.107 - }
42.108 -
42.109 - // =================================================================================================================
42.110 - // Bean Methods
42.111 -
42.112 - /**
42.113 - * Get the UIDefaults for this canvas. The UIDefaults is used to store default pallet of colors, fonts etc.
42.114 - *
42.115 - * @return Canvas UIDefaults
42.116 - */
42.117 - public UIDefaults getUiDefaults() {
42.118 - return canvasUIDefaults;
42.119 - }
42.120 -
42.121 - /**
42.122 - * Set the UIDefaults for this canvas. The UIDefaults is used to store default pallet of colors, fonts etc.
42.123 - *
42.124 - * @param canvasUIDefaults Canvas UIDefaults
42.125 - */
42.126 - public void setUiDefaults(UIDefaults canvasUIDefaults) {
42.127 - this.canvasUIDefaults = canvasUIDefaults;
42.128 - }
42.129 -
42.130 - /**
42.131 - * Get the current working layer, is is the layer that new shapes will be drawn into
42.132 - *
42.133 - * @return The current working layer, may be null if there is no working layer
42.134 - */
42.135 - public Layer getWorkingLayer() {
42.136 - return workingLayer;
42.137 - }
42.138 -
42.139 - /**
42.140 - * Set the current working layer, is is the layer that new shapes will be drawn into
42.141 - *
42.142 - * @param workingLayer the new working layer, must be a child of this canvas
42.143 - */
42.144 - public void setWorkingLayer(Layer workingLayer) {
42.145 - Layer old = getWorkingLayer();
42.146 - this.workingLayer = workingLayer;
42.147 - firePropertyChange("workingLayer", old, getWorkingLayer());
42.148 - }
42.149 -
42.150 - public int getNextLayerNameIndex() {
42.151 - return nextLayerNameIndex++;
42.152 - }
42.153 -
42.154 - public Dimension getSize() {
42.155 - return size;
42.156 - }
42.157 -
42.158 - public void setSize(Dimension size) {
42.159 - Dimension old = getSize();
42.160 - this.size = size;
42.161 - buffer = new BufferedImage(this.size.width, this.size.height, BufferedImage.TYPE_INT_ARGB);
42.162 - isValid = false;
42.163 - firePropertyChange("size", old, getSize());
42.164 - }
42.165 -
42.166 -
42.167 - public Insets getStretchingInsets() {
42.168 - return stretchingInsets;
42.169 - }
42.170 -
42.171 - public void setStretchingInsets(Insets stretchingInsets) {
42.172 - Insets old = getStretchingInsets();
42.173 - this.stretchingInsets = stretchingInsets;
42.174 - firePropertyChange("stretchingInsets", old, getStretchingInsets());
42.175 - }
42.176 -
42.177 - public BufferedImage getRenderedImage() {
42.178 - if (!isValid) {
42.179 - Graphics2D g2 = buffer.createGraphics();
42.180 - // clear
42.181 - g2.setComposite(AlphaComposite.Clear);
42.182 - g2.fillRect(0, 0, buffer.getWidth(), buffer.getHeight());
42.183 - // paint
42.184 - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
42.185 - g2.setComposite(AlphaComposite.SrcOver);
42.186 - for (int i = layers.size() - 1; i >= 0; i--) {
42.187 - layers.get(i).paint(g2, 1);
42.188 - }
42.189 - g2.dispose();
42.190 - }
42.191 - return buffer;
42.192 - }
42.193 -
42.194 - /**
42.195 - * @return true if this Canvas has not been edited.
42.196 - * <p/>
42.197 - * TODO Currently this is not a bound property, but should be. That is, when the Canvas becomes edited
42.198 - * (usually due to the Layer having a shape added to it), then a property change event should be fired.
42.199 - */
42.200 - public boolean isBlank() {
42.201 - return layers.size() == 0 || (layers.size() == 1 && layers.get(0).isEmpty());
42.202 - }
42.203 -
42.204 - public File getResourcesDir() {
42.205 - return resourcesDir;
42.206 - }
42.207 -
42.208 - public void setResourcesDir(File resourcesDir) {
42.209 - File old = getResourcesDir();
42.210 - this.resourcesDir = resourcesDir;
42.211 - firePropertyChange("resourcesDir", old, getResourcesDir());
42.212 - }
42.213 -
42.214 - public File getImagesDir() {
42.215 - return imagesDir;
42.216 - }
42.217 -
42.218 - public void setImagesDir(File imagesDir) {
42.219 - File old = getImagesDir();
42.220 - this.imagesDir = imagesDir;
42.221 - firePropertyChange("imagesDir", old, getImagesDir());
42.222 - }
42.223 -
42.224 - public File getTemplatesDir() {
42.225 - return templatesDir;
42.226 - }
42.227 -
42.228 - public void setTemplatesDir(File templatesDir) {
42.229 - File old = getTemplatesDir();
42.230 - this.templatesDir = templatesDir;
42.231 - firePropertyChange("templatesDir", old, getTemplatesDir());
42.232 - }
42.233 -
42.234 - // =================================================================================================================
42.235 - // LayerContainer Methods
42.236 -
42.237 - public LayerContainer getParent() {
42.238 - // we are root so null
42.239 - return null;
42.240 - }
42.241 -
42.242 - public void addLayerToBottom(Layer layer) {
42.243 - layers.add(layer);
42.244 - layer.setParent(this);
42.245 - layer.addPropertyChangeListener(layersPropertyChangeListener);
42.246 - // no single layer changes so fire all changed event
42.247 - firePropertyChange("layers", null, layers);
42.248 - }
42.249 -
42.250 - public void addLayer(int i, Layer layer) {
42.251 - layers.add(i, layer);
42.252 - layer.setParent(this);
42.253 - layer.addPropertyChangeListener(layersPropertyChangeListener);
42.254 - // no single layer changes so fire all changed event
42.255 - firePropertyChange("layers", null, layers);
42.256 - }
42.257 -
42.258 - public void addLayer(Layer layer) {
42.259 - layers.add(0, layer);
42.260 - layer.setParent(this);
42.261 - layer.addPropertyChangeListener(layersPropertyChangeListener);
42.262 - // no single layer changes so fire all changed event
42.263 - firePropertyChange("layers", null, layers);
42.264 - }
42.265 -
42.266 - public Layer getLayer(int index) {
42.267 - return layers.get(index);
42.268 - }
42.269 -
42.270 - public int getLayerCount() {
42.271 - return layers.size();
42.272 - }
42.273 -
42.274 - public Iterator<Layer> getLayerIterator() {
42.275 - return Collections.unmodifiableList(layers).iterator();
42.276 - }
42.277 -
42.278 - public Collection<Layer> getLayers() {
42.279 - return Collections.unmodifiableList(layers);
42.280 - }
42.281 -
42.282 - public int indexOfLayer(Layer layer) {
42.283 - return layers.indexOf(layer);
42.284 - }
42.285 -
42.286 - public void removeLayer(Layer layer) {
42.287 - int index = layers.indexOf(layer);
42.288 - if (index != -1) {
42.289 - layers.remove(layer);
42.290 - layer.removePropertyChangeListener(layersPropertyChangeListener);
42.291 - fireIndexedPropertyChange("layers", index, layer, null);
42.292 - }
42.293 - }
42.294 -
42.295 - public Dimension getRootSize() {
42.296 - return getSize();
42.297 - }
42.298 -
42.299 - // =================================================================================================================
42.300 - // JIBX Helper Methods
42.301 -
42.302 - /** Called by JIBX after "layers" has been filled so we can set parents and listeners */
42.303 - private void setupLayers() {
42.304 - for (Layer layer : layers) {
42.305 - layer.setParent(this);
42.306 - layer.addPropertyChangeListener(layersPropertyChangeListener);
42.307 - }
42.308 - // no single layer changes so fire all changed event
42.309 - firePropertyChange("layers", null, layers);
42.310 - }
42.311 -}
43.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/ControlPoint.java Sun Sep 06 23:14:42 2009 -0700
43.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
43.3 @@ -1,157 +0,0 @@
43.4 -/*
43.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
43.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
43.7 - *
43.8 - * This code is free software; you can redistribute it and/or modify it
43.9 - * under the terms of the GNU General Public License version 2 only, as
43.10 - * published by the Free Software Foundation. Sun designates this
43.11 - * particular file as subject to the "Classpath" exception as provided
43.12 - * by Sun in the LICENSE file that accompanied this code.
43.13 - *
43.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
43.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
43.17 - * version 2 for more details (a copy is included in the LICENSE file that
43.18 - * accompanied this code).
43.19 - *
43.20 - * You should have received a copy of the GNU General Public License version
43.21 - * 2 along with this work; if not, write to the Free Software Foundation,
43.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
43.23 - *
43.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
43.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
43.26 - * have any questions.
43.27 - */
43.28 -package org.jdesktop.swingx.designer;
43.29 -
43.30 -import java.awt.BasicStroke;
43.31 -import java.awt.Color;
43.32 -import java.awt.Graphics2D;
43.33 -import java.awt.Shape;
43.34 -import java.awt.geom.Point2D;
43.35 -import java.awt.geom.Rectangle2D;
43.36 -import java.beans.PropertyChangeEvent;
43.37 -import java.beans.PropertyChangeListener;
43.38 -import java.util.Collections;
43.39 -import java.util.List;
43.40 -
43.41 -/**
43.42 - * ControlPoint
43.43 - *
43.44 - * @author Created by Jasper Potts (May 24, 2007)
43.45 - */
43.46 -public class ControlPoint extends SimpleShape {
43.47 - protected Color fillColor;
43.48 - protected Color lineColor;
43.49 - protected DoubleBean x, y;
43.50 -
43.51 - public ControlPoint() {
43.52 - this(new DoubleBean(), new DoubleBean());
43.53 - }
43.54 -
43.55 - public ControlPoint(Color fillColor, Color lineColor) {
43.56 - this(new DoubleBean(), new DoubleBean(), fillColor, lineColor);
43.57 - }
43.58 -
43.59 - public ControlPoint(double x, double y) {
43.60 - this(new DoubleBean(x), new DoubleBean(y));
43.61 - }
43.62 -
43.63 - public ControlPoint(DoubleBean x, DoubleBean y) {
43.64 - this(x, y, GraphicsHelper.CONTROL_POINT_FILL, GraphicsHelper.CONTROL_POINT_LINE);
43.65 - }
43.66 -
43.67 - public ControlPoint(DoubleBean x, DoubleBean y, Color fillColor, Color lineColor) {
43.68 - this.x = x;
43.69 - this.y = y;
43.70 - this.fillColor = fillColor;
43.71 - this.lineColor = lineColor;
43.72 - x.addPropertyChangeListener(new PropertyChangeListener() {
43.73 - public void propertyChange(PropertyChangeEvent evt) {
43.74 - firePropertyChange("position",
43.75 - new Point2D.Double((Double) evt.getOldValue(), getY()),
43.76 - getPosition());
43.77 - }
43.78 - });
43.79 - y.addPropertyChangeListener(new PropertyChangeListener() {
43.80 - public void propertyChange(PropertyChangeEvent evt) {
43.81 - firePropertyChange("position",
43.82 - new Point2D.Double(getX(), (Double) evt.getOldValue()),
43.83 - getPosition());
43.84 - }
43.85 - });
43.86 - }
43.87 -
43.88 - public double getX() {
43.89 - return x.getValue();
43.90 - }
43.91 -
43.92 - public double getY() {
43.93 - return y.getValue();
43.94 - }
43.95 -
43.96 - public void setX(double x) {
43.97 - this.x.setValue(x);
43.98 - }
43.99 -
43.100 - public void setY(double y) {
43.101 - this.y.setValue(y);
43.102 - }
43.103 -
43.104 - public void setPosition(Point2D position) {
43.105 - x.setValue(position.getX());
43.106 - y.setValue(position.getY());
43.107 - }
43.108 -
43.109 - public void setPosition(double x, double y) {
43.110 - setPosition(new Point2D.Double(x, y));
43.111 - }
43.112 -
43.113 - public Point2D getPosition() {
43.114 - return new Point2D.Double(getX(), getY());
43.115 - }
43.116 -
43.117 - public Rectangle2D getBounds(double pixelSize) {
43.118 - double size = pixelSize * 4d;
43.119 - return new Rectangle2D.Double(getX() - size, getY() - size,
43.120 - size * 2, size * 2);
43.121 - }
43.122 -
43.123 - public boolean isHit(Point2D p, double pixelSize) {
43.124 - return getBounds(pixelSize).contains(p);
43.125 - }
43.126 -
43.127 -
43.128 - public Shape getShape() {
43.129 - return getBounds(0);
43.130 - }
43.131 -
43.132 - public void paint(Graphics2D g2, double pixelSize) {
43.133 - }
43.134 -
43.135 - public void paintControls(Graphics2D g2, double pixelSize, boolean paintControlLines) {
43.136 - g2.setStroke(new BasicStroke((float) pixelSize));
43.137 - Shape s = getBounds(pixelSize);
43.138 - g2.setColor(fillColor);
43.139 - g2.fill(s);
43.140 - g2.setColor(lineColor);
43.141 - g2.draw(s);
43.142 - }
43.143 -
43.144 - public List<ControlPoint> getControlPoints() {
43.145 - return Collections.emptyList();
43.146 - }
43.147 -
43.148 -
43.149 - public void move(double moveX, double moveY, boolean snapPixels) {
43.150 - if (snapPixels) {
43.151 - setPosition(
43.152 - Math.round(x.getValue() + moveX),
43.153 - Math.round(y.getValue() + moveY));
43.154 - } else {
43.155 - setPosition(x.getValue() + moveX, y.getValue() + moveY);
43.156 - }
43.157 - }
43.158 -
43.159 -
43.160 -}
44.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/Designer.jibx.xml Sun Sep 06 23:14:42 2009 -0700
44.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
44.3 @@ -1,173 +0,0 @@
44.4 -<?xml version="1.0" encoding="UTF-8"?>
44.5 -
44.6 -<!--
44.7 - Copyright 1998-2004 Sun Microsystems, Inc. All Rights Reserved.
44.8 - DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44.9 -
44.10 - This code is free software; you can redistribute it and/or modify it
44.11 - under the terms of the GNU General Public License version 2 only, as
44.12 - published by the Free Software Foundation. Sun designates this
44.13 - particular file as subject to the "Classpath" exception as provided
44.14 - by Sun in the LICENSE file that accompanied this code.
44.15 -
44.16 - This code is distributed in the hope that it will be useful, but WITHOUT
44.17 - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
44.18 - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
44.19 - version 2 for more details (a copy is included in the LICENSE file that
44.20 - accompanied this code).
44.21 -
44.22 - You should have received a copy of the GNU General Public License version
44.23 - 2 along with this work; if not, write to the Free Software Foundation,
44.24 - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
44.25 -
44.26 - Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
44.27 - CA 95054 USA or visit www.sun.com if you need additional information or
44.28 - have any questions.
44.29 --->
44.30 -
44.31 -<!DOCTYPE binding SYSTEM "http://jibx.sourceforge.net">
44.32 -<binding>
44.33 - <!-- == PAINTS =========================================================================================== -->
44.34 - <mapping class="java.awt.Color"
44.35 - marshaller="org.jdesktop.swingx.designer.jibxhelpers.ColorMapper"
44.36 - unmarshaller="org.jdesktop.swingx.designer.jibxhelpers.ColorMapper"/>
44.37 - <mapping name="matte" class="org.jdesktop.swingx.designer.paint.Matte" post-set="postSet">
44.38 - <value name="red" field="red" style="attribute"/>
44.39 - <value name="green" field="green" style="attribute"/>
44.40 - <value name="blue" field="blue" style="attribute"/>
44.41 - <value name="alpha" field="alpha" style="attribute"/>
44.42 - <value name="uiDefaultParentName" field="uiDefaultParentName" style="attribute" usage="optional"/>
44.43 - <value name="componentPropertyName" field="componentPropertyName" style="attribute" usage="optional"/>
44.44 - <value name="hueOffset" field="hueOffset" style="attribute"/>
44.45 - <value name="saturationOffset" field="saturationOffset" style="attribute"/>
44.46 - <value name="brightnessOffset" field="brightnessOffset" style="attribute"/>
44.47 - <value name="alphaOffset" field="alphaOffset" style="attribute"/>
44.48 - <value name="uiResource" field="uiResource" style="attribute" usage="optional" default="true"/>
44.49 - </mapping>
44.50 - <mapping class="org.jdesktop.swingx.designer.paint.AbstractGradient" abstract="true">
44.51 - <value name="cycleMethod" field="cycleMethod" style="attribute"/>
44.52 - <collection field="stops" set-method="setStops" pre-set="clear" create-type="java.util.ArrayList">
44.53 - <structure name="stop" type="org.jdesktop.swingx.designer.paint.GradientStop">
44.54 - <value name="position" field="position" style="attribute"/>
44.55 - <value name="midpoint" field="midpoint" style="attribute"/>
44.56 - <structure field="color" set-method="setColor"/>
44.57 - </structure>
44.58 - </collection>
44.59 - </mapping>
44.60 - <mapping name="gradient" class="org.jdesktop.swingx.designer.paint.Gradient"
44.61 - extends="org.jdesktop.swingx.designer.paint.AbstractGradient">
44.62 - <structure map-as="org.jdesktop.swingx.designer.paint.AbstractGradient"/>
44.63 - </mapping>
44.64 - <mapping name="radialGradient" class="org.jdesktop.swingx.designer.paint.RadialGradient"
44.65 - extends="org.jdesktop.swingx.designer.paint.AbstractGradient">
44.66 - <structure map-as="org.jdesktop.swingx.designer.paint.AbstractGradient"/>
44.67 - </mapping>
44.68 - <!-- == SHAPES =========================================================================================== -->
44.69 - <mapping class="org.jdesktop.swingx.designer.SimpleShape" abstract="true">
44.70 - <!--protected AffineTransform transform = new AffineTransform();-->
44.71 - </mapping>
44.72 - <mapping class="org.jdesktop.swingx.designer.PaintedShape" abstract="true"
44.73 - extends="org.jdesktop.swingx.designer.SimpleShape">
44.74 - <structure map-as="org.jdesktop.swingx.designer.SimpleShape"/>
44.75 - <structure field="paint"/>
44.76 - <structure name="paintPoints">
44.77 - <value name="x1" get-method="getPaintX1" set-method="setPaintX1" style="attribute"/>
44.78 - <value name="y1" get-method="getPaintY1" set-method="setPaintY1" style="attribute"/>
44.79 - <value name="x2" get-method="getPaintX2" set-method="setPaintX2" style="attribute"/>
44.80 - <value name="y2" get-method="getPaintY2" set-method="setPaintY2" style="attribute"/>
44.81 - </structure>
44.82 - </mapping>
44.83 - <mapping name="rectangle" class="org.jdesktop.swingx.designer.RectangleShape"
44.84 - extends="org.jdesktop.swingx.designer.PaintedShape">
44.85 - <structure map-as="org.jdesktop.swingx.designer.PaintedShape"/>
44.86 - <value name="x1" get-method="getX1" set-method="setX1" style="attribute"/>
44.87 - <value name="x2" get-method="getX2" set-method="setX2" style="attribute"/>
44.88 - <value name="y1" get-method="getY1" set-method="setY1" style="attribute"/>
44.89 - <value name="y2" get-method="getY2" set-method="setY2" style="attribute"/>
44.90 - <value name="rounding" get-method="getRounding" set-method="setRounding" style="attribute"/>
44.91 - </mapping>
44.92 - <mapping name="ellipse" class="org.jdesktop.swingx.designer.EllipseShape"
44.93 - extends="org.jdesktop.swingx.designer.PaintedShape">
44.94 - <structure map-as="org.jdesktop.swingx.designer.PaintedShape"/>
44.95 - <value name="x1" get-method="getX1" set-method="setX1" style="attribute"/>
44.96 - <value name="x2" get-method="getX2" set-method="setX2" style="attribute"/>
44.97 - <value name="y1" get-method="getY1" set-method="setY1" style="attribute"/>
44.98 - <value name="y2" get-method="getY2" set-method="setY2" style="attribute"/>
44.99 - </mapping>
44.100 - <mapping name="path" class="org.jdesktop.swingx.designer.PathShape"
44.101 - extends="org.jdesktop.swingx.designer.PaintedShape">
44.102 - <structure map-as="org.jdesktop.swingx.designer.PaintedShape"/>
44.103 - <collection name="points" get-method="getBezierControlPoints"
44.104 - set-method="setControlPoints" create-type="java.util.ArrayList">
44.105 - <structure name="point" type="org.jdesktop.swingx.designer.BezierControlPoint">
44.106 - <value name="x" get-method="getX" set-method="setX" style="attribute"/>
44.107 - <value name="y" get-method="getY" set-method="setY" style="attribute"/>
44.108 - <value name="cp1x" get-method="getCp1X" set-method="setCp1X" style="attribute"/>
44.109 - <value name="cp1y" get-method="getCp1Y" set-method="setCp1Y" style="attribute"/>
44.110 - <value name="cp2x" get-method="getCp2X" set-method="setCp2X" style="attribute"/>
44.111 - <value name="cp2y" get-method="getCp2Y" set-method="setCp2Y" style="attribute"/>
44.112 - </structure>
44.113 - </collection>
44.114 - </mapping>
44.115 - <!-- == EFFECTS =========================================================================================== -->
44.116 - <mapping class="org.jdesktop.swingx.designer.effects.ShadowEffect" abstract="true">
44.117 - <structure field="color"/>
44.118 - <value name="blendingMode" field="blendingMode" style="attribute"/>
44.119 - <value name="opacity" field="opacity" style="attribute"/>
44.120 - <value name="angle" field="angle" style="attribute"/>
44.121 - <value name="distance" field="distance" style="attribute"/>
44.122 - <value name="spread" field="spread" style="attribute"/>
44.123 - <value name="size" field="size" style="attribute"/>
44.124 - </mapping>
44.125 - <mapping name="dropShadow" class="org.jdesktop.swingx.designer.effects.DropShadowEffect"
44.126 - extends="org.jdesktop.swingx.designer.effects.ShadowEffect">
44.127 - <structure map-as="org.jdesktop.swingx.designer.effects.ShadowEffect"/>
44.128 - </mapping>
44.129 - <mapping name="innerShadow" class="org.jdesktop.swingx.designer.effects.InnerShadowEffect"
44.130 - extends="org.jdesktop.swingx.designer.effects.ShadowEffect">
44.131 - <structure map-as="org.jdesktop.swingx.designer.effects.ShadowEffect"/>
44.132 - </mapping>
44.133 - <mapping name="innerGlow" class="org.jdesktop.swingx.designer.effects.InnerGlowEffect"
44.134 - extends="org.jdesktop.swingx.designer.effects.ShadowEffect">
44.135 - <structure map-as="org.jdesktop.swingx.designer.effects.ShadowEffect"/>
44.136 - </mapping>
44.137 - <mapping name="outerGlow" class="org.jdesktop.swingx.designer.effects.OuterGlowEffect"
44.138 - extends="org.jdesktop.swingx.designer.effects.ShadowEffect">
44.139 - <structure map-as="org.jdesktop.swingx.designer.effects.ShadowEffect"/>
44.140 - </mapping>
44.141 - <!-- == TEMPLATE LAYER ================================================================================== -->
44.142 - <mapping name="templateLayer" class="org.jdesktop.swingx.designer.TemplateLayer"
44.143 - extends="org.jdesktop.swingx.designer.Layer" post-set="postInit">
44.144 - <structure map-as="org.jdesktop.swingx.designer.Layer"/>
44.145 - <value name="fileName" field="fileName" style="attribute"/>
44.146 - </mapping>
44.147 - <!-- == LAYER =========================================================================================== -->
44.148 - <mapping name="layer" class="org.jdesktop.swingx.designer.Layer"
44.149 - extends="org.jdesktop.swingx.designer.SimpleShape" post-set="postInit">
44.150 - <structure map-as="org.jdesktop.swingx.designer.SimpleShape"/>
44.151 - <value name="name" field="name" style="attribute"/>
44.152 - <value name="type" field="type" style="attribute" default="standard"/>
44.153 - <value name="opacity" field="opacity"/>
44.154 - <value name="fillOpacity" field="fillOpacity"/>
44.155 - <value name="blendingMode" field="blendingMode"/>
44.156 - <value name="locked" field="locked"/>
44.157 - <value name="visible" field="visible"/>
44.158 - <structure name="shapes">
44.159 - <collection field="shapes" create-type="java.util.ArrayList"/>
44.160 - </structure>
44.161 - <structure name="effects">
44.162 - <collection field="effects" create-type="java.util.ArrayList"/>
44.163 - </structure>
44.164 - </mapping>
44.165 - <!-- == CANVAS =========================================================================================== -->
44.166 - <mapping name="canvas" class="org.jdesktop.swingx.designer.Canvas" pre-set="preSet" post-set="setupLayers">
44.167 - <structure name="size" get-method="getSize" set-method="setSize"
44.168 - marshaller="org.jdesktop.swingx.designer.jibxhelpers.DimensionMapper"
44.169 - unmarshaller="org.jdesktop.swingx.designer.jibxhelpers.DimensionMapper"/>
44.170 - <value name="nextLayerNameIndex" field="nextLayerNameIndex"/>
44.171 - <structure name="stretchingInsets" field="stretchingInsets"
44.172 - marshaller="org.jdesktop.swingx.designer.jibxhelpers.InsetsMapper"
44.173 - unmarshaller="org.jdesktop.swingx.designer.jibxhelpers.InsetsMapper"/>
44.174 - <collection field="layers" create-type="java.util.ArrayList"/>
44.175 - </mapping>
44.176 -</binding>
45.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/DoubleBean.java Sun Sep 06 23:14:42 2009 -0700
45.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
45.3 @@ -1,69 +0,0 @@
45.4 -/*
45.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
45.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
45.7 - *
45.8 - * This code is free software; you can redistribute it and/or modify it
45.9 - * under the terms of the GNU General Public License version 2 only, as
45.10 - * published by the Free Software Foundation. Sun designates this
45.11 - * particular file as subject to the "Classpath" exception as provided
45.12 - * by Sun in the LICENSE file that accompanied this code.
45.13 - *
45.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
45.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
45.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
45.17 - * version 2 for more details (a copy is included in the LICENSE file that
45.18 - * accompanied this code).
45.19 - *
45.20 - * You should have received a copy of the GNU General Public License version
45.21 - * 2 along with this work; if not, write to the Free Software Foundation,
45.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
45.23 - *
45.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
45.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
45.26 - * have any questions.
45.27 - */
45.28 -package org.jdesktop.swingx.designer;
45.29 -
45.30 -import org.jdesktop.beans.AbstractBean;
45.31 -
45.32 -/**
45.33 - * DoubleBean - Simple bean for a observable double value
45.34 - *
45.35 - * @author Created by Jasper Potts (May 25, 2007)
45.36 - */
45.37 -public class DoubleBean extends AbstractBean {
45.38 - private double value = 0;
45.39 -
45.40 - public DoubleBean() {}
45.41 -
45.42 - public DoubleBean(double value) {
45.43 - this.value = value;
45.44 - }
45.45 -
45.46 - public double getValue() {
45.47 - return value;
45.48 - }
45.49 -
45.50 - public void setValue(double value) {
45.51 - double old = this.value;
45.52 - this.value = value;
45.53 - firePropertyChange("value", old, this.value);
45.54 - }
45.55 -
45.56 -
45.57 - public boolean equals(Object o) {
45.58 - if (this == o) return true;
45.59 - if (o == null || getClass() != o.getClass()) return false;
45.60 -
45.61 - DoubleBean that = (DoubleBean) o;
45.62 -
45.63 - if (Double.compare(that.value, value) != 0) return false;
45.64 -
45.65 - return true;
45.66 - }
45.67 -
45.68 - public int hashCode() {
45.69 - long temp = value != +0.0d ? Double.doubleToLongBits(value) : 0L;
45.70 - return (int) (temp ^ (temp >>> 32));
45.71 - }
45.72 -}
46.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/EllipseShape.java Sun Sep 06 23:14:42 2009 -0700
46.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
46.3 @@ -1,189 +0,0 @@
46.4 -/*
46.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
46.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
46.7 - *
46.8 - * This code is free software; you can redistribute it and/or modify it
46.9 - * under the terms of the GNU General Public License version 2 only, as
46.10 - * published by the Free Software Foundation. Sun designates this
46.11 - * particular file as subject to the "Classpath" exception as provided
46.12 - * by Sun in the LICENSE file that accompanied this code.
46.13 - *
46.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
46.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
46.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
46.17 - * version 2 for more details (a copy is included in the LICENSE file that
46.18 - * accompanied this code).
46.19 - *
46.20 - * You should have received a copy of the GNU General Public License version
46.21 - * 2 along with this work; if not, write to the Free Software Foundation,
46.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
46.23 - *
46.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
46.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
46.26 - * have any questions.
46.27 - */
46.28 -package org.jdesktop.swingx.designer;
46.29 -
46.30 -import javax.swing.*;
46.31 -import java.awt.*;
46.32 -import java.awt.geom.Ellipse2D;
46.33 -import java.awt.geom.Point2D;
46.34 -import java.awt.geom.Rectangle2D;
46.35 -import java.beans.PropertyChangeEvent;
46.36 -import java.beans.PropertyChangeListener;
46.37 -import java.util.ArrayList;
46.38 -import java.util.List;
46.39 -
46.40 -/**
46.41 - * EllipseShape
46.42 - *
46.43 - * @author Created by Jasper Potts (May 22, 2007)
46.44 - */
46.45 -public class EllipseShape extends PaintedShape {
46.46 -
46.47 - private DoubleBean x1 = new DoubleBean();
46.48 - private DoubleBean x2 = new DoubleBean();
46.49 - private DoubleBean y1 = new DoubleBean();
46.50 - private DoubleBean y2 = new DoubleBean();
46.51 - private ControlPoint tl = new ControlPoint(x1, y1);
46.52 - private ControlPoint tr = new ControlPoint(x2, y1);
46.53 - private ControlPoint bl = new ControlPoint(x1, y2);
46.54 - private ControlPoint br = new ControlPoint(x2, y2);
46.55 -
46.56 - // =================================================================================================================
46.57 - // Constructors
46.58 -
46.59 - /** private noargs constructor for JIBX */
46.60 - private EllipseShape() {
46.61 - this(null);
46.62 - }
46.63 -
46.64 - public EllipseShape(UIDefaults canvasUiDefaults) {
46.65 - super(canvasUiDefaults);
46.66 - PropertyChangeListener listener = new PropertyChangeListener() {
46.67 - public void propertyChange(PropertyChangeEvent evt) {
46.68 - firePropertyChange("bounds", null, getBounds(0));
46.69 - }
46.70 - };
46.71 - x1.addPropertyChangeListener(listener);
46.72 - y1.addPropertyChangeListener(listener);
46.73 - x2.addPropertyChangeListener(listener);
46.74 - y2.addPropertyChangeListener(listener);
46.75 - }
46.76 -
46.77 - public EllipseShape(double x, double y, double w, double h) {
46.78 - this();
46.79 - x1.setValue(x);
46.80 - y1.setValue(y);
46.81 - x2.setValue(x + w);
46.82 - y2.setValue(y + h);
46.83 - }
46.84 -
46.85 - public Rectangle2D getBounds(double pixelSize) {
46.86 - double left = Math.min(x1.getValue(), x2.getValue());
46.87 - double right = Math.max(x1.getValue(), x2.getValue());
46.88 - double top = Math.min(y1.getValue(), y2.getValue());
46.89 - double bottom = Math.max(y1.getValue(), y2.getValue());
46.90 - return new Rectangle2D.Double(left, top, right - left, bottom - top);
46.91 - }
46.92 -
46.93 - public Ellipse2D getShape() {
46.94 - double left = Math.min(x1.getValue(), x2.getValue());
46.95 - double right = Math.max(x1.getValue(), x2.getValue());
46.96 - double top = Math.min(y1.getValue(), y2.getValue());
46.97 - double bottom = Math.max(y1.getValue(), y2.getValue());
46.98 - return new Ellipse2D.Double(left, top, right - left, bottom - top);
46.99 - }
46.100 -
46.101 - public boolean isHit(Point2D p, double pixelSize) {
46.102 - return getBounds(pixelSize).contains(p);
46.103 - }
46.104 -
46.105 - public void paint(Graphics2D g2, double pixelSize) {
46.106 - g2.setPaint(getPaint());
46.107 - g2.fill(getShape());
46.108 - }
46.109 -
46.110 - public void setFrame(double x1, double y1, double x2, double y2) {
46.111 - this.x1.setValue(x1);
46.112 - this.y1.setValue(y1);
46.113 - this.x2.setValue(x2);
46.114 - this.y2.setValue(y2);
46.115 - }
46.116 -
46.117 - @Override
46.118 - public String toString() {
46.119 - Rectangle2D bounds = getBounds(0);
46.120 - return "ELLIPSE { x=" + bounds.getX() + ", y=" + bounds.getY() + ", w=" + bounds.getWidth() + ", h=" + bounds.getHeight() + " }";
46.121 - }
46.122 -
46.123 - public List<ControlPoint> getControlPoints() {
46.124 - List<ControlPoint> points = new ArrayList<ControlPoint>();
46.125 - points.addAll(super.getControlPoints());
46.126 - points.add(tl);
46.127 - points.add(tr);
46.128 - points.add(bl);
46.129 - points.add(br);
46.130 - return points;
46.131 - }
46.132 -
46.133 - public void paintControls(Graphics2D g2, double pixelSize, boolean paintControlLines) {
46.134 - if (paintControlLines) {
46.135 - g2.setStroke(new BasicStroke((float) pixelSize));
46.136 - g2.setColor(GraphicsHelper.CONTROL_LINE);
46.137 - g2.draw(getShape());
46.138 - }
46.139 - tl.paintControls(g2, pixelSize, true);
46.140 - tr.paintControls(g2, pixelSize, true);
46.141 - bl.paintControls(g2, pixelSize, true);
46.142 - br.paintControls(g2, pixelSize, true);
46.143 -// super.paintControls(g2, pixelSize, paintControlLines);
46.144 - }
46.145 -
46.146 - public void move(double moveX, double moveY, boolean snapPixels) {
46.147 - if (snapPixels) {
46.148 - x1.setValue(Math.round(x1.getValue() + moveX));
46.149 - x2.setValue(Math.round(x2.getValue() + moveX));
46.150 - y1.setValue(Math.round(y1.getValue() + moveY));
46.151 - y2.setValue(Math.round(y2.getValue() + moveY));
46.152 - } else {
46.153 - x1.setValue(x1.getValue() + moveX);
46.154 - x2.setValue(x2.getValue() + moveX);
46.155 - y1.setValue(y1.getValue() + moveY);
46.156 - y2.setValue(y2.getValue() + moveY);
46.157 - }
46.158 - }
46.159 -
46.160 - public double getX1() {
46.161 - return x1.getValue();
46.162 - }
46.163 -
46.164 - public void setX1(double x1) {
46.165 - this.x1.setValue(x1);
46.166 - }
46.167 -
46.168 - public double getX2() {
46.169 - return x2.getValue();
46.170 - }
46.171 -
46.172 - public void setX2(double x2) {
46.173 - this.x2.setValue(x2);
46.174 - }
46.175 -
46.176 - public double getY1() {
46.177 - return y1.getValue();
46.178 - }
46.179 -
46.180 - public void setY1(double y1) {
46.181 - this.y1.setValue(y1);
46.182 - }
46.183 -
46.184 - public double getY2() {
46.185 - return y2.getValue();
46.186 - }
46.187 -
46.188 - public void setY2(double y2) {
46.189 - this.y2.setValue(y2);
46.190 - }
46.191 -
46.192 -}
47.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/GraphicsHelper.java Sun Sep 06 23:14:42 2009 -0700
47.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
47.3 @@ -1,45 +0,0 @@
47.4 -/*
47.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
47.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
47.7 - *
47.8 - * This code is free software; you can redistribute it and/or modify it
47.9 - * under the terms of the GNU General Public License version 2 only, as
47.10 - * published by the Free Software Foundation. Sun designates this
47.11 - * particular file as subject to the "Classpath" exception as provided
47.12 - * by Sun in the LICENSE file that accompanied this code.
47.13 - *
47.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
47.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
47.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
47.17 - * version 2 for more details (a copy is included in the LICENSE file that
47.18 - * accompanied this code).
47.19 - *
47.20 - * You should have received a copy of the GNU General Public License version
47.21 - * 2 along with this work; if not, write to the Free Software Foundation,
47.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
47.23 - *
47.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
47.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
47.26 - * have any questions.
47.27 - */
47.28 -package org.jdesktop.swingx.designer;
47.29 -
47.30 -import java.awt.Color;
47.31 -
47.32 -/**
47.33 - * GraphicsHelper
47.34 - *
47.35 - * @author Created by Jasper Potts (May 29, 2007)
47.36 - */
47.37 -public class GraphicsHelper {
47.38 - public static final Color FILL_LINE = Color.BLUE;
47.39 - public static final Color FILL_CP_LINE = Color.BLUE;
47.40 - public static final Color FILL_CP_FILL = Color.WHITE;
47.41 - public static final Color CONTROL_LINE = Color.RED;
47.42 - public static final Color CONTROL_POINT_LINE = Color.RED;
47.43 - public static final Color CONTROL_POINT_FILL = Color.WHITE;
47.44 - public static final Color BEZIER_CONTROL_POINT_LINE = CONTROL_POINT_LINE;
47.45 - public static final Color BEZIER_CONTROL_POINT_FILL = CONTROL_POINT_FILL;
47.46 - public static final Color BEZIER_CONTROL_LINE = Color.DARK_GRAY;
47.47 -
47.48 -}
48.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/Layer.java Sun Sep 06 23:14:42 2009 -0700
48.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
48.3 @@ -1,443 +0,0 @@
48.4 -/*
48.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
48.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
48.7 - *
48.8 - * This code is free software; you can redistribute it and/or modify it
48.9 - * under the terms of the GNU General Public License version 2 only, as
48.10 - * published by the Free Software Foundation. Sun designates this
48.11 - * particular file as subject to the "Classpath" exception as provided
48.12 - * by Sun in the LICENSE file that accompanied this code.
48.13 - *
48.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
48.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
48.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
48.17 - * version 2 for more details (a copy is included in the LICENSE file that
48.18 - * accompanied this code).
48.19 - *
48.20 - * You should have received a copy of the GNU General Public License version
48.21 - * 2 along with this work; if not, write to the Free Software Foundation,
48.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
48.23 - *
48.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
48.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
48.26 - * have any questions.
48.27 - */
48.28 -package org.jdesktop.swingx.designer;
48.29 -
48.30 -import org.jdesktop.swingx.designer.effects.Effect;
48.31 -
48.32 -import java.awt.Dimension;
48.33 -import java.awt.Graphics2D;
48.34 -import java.awt.Shape;
48.35 -import java.awt.geom.Point2D;
48.36 -import java.awt.geom.Rectangle2D;
48.37 -import java.awt.image.BufferedImage;
48.38 -import java.beans.PropertyChangeEvent;
48.39 -import java.beans.PropertyChangeListener;
48.40 -import java.util.ArrayList;
48.41 -import java.util.Collection;
48.42 -import java.util.Collections;
48.43 -import java.util.Iterator;
48.44 -import java.util.List;
48.45 -
48.46 -/**
48.47 - * Layer
48.48 - *
48.49 - * @author Created by Jasper Potts (May 22, 2007)
48.50 - */
48.51 -public class Layer extends SimpleShape implements Iterable<SimpleShape>, LayerContainer {
48.52 - public static enum LayerType {
48.53 - standard, template
48.54 - }
48.55 -
48.56 - private String name;
48.57 - protected LayerType type = LayerType.standard;
48.58 - /** List of shapes in this layer, first shape is painted on top */
48.59 - private List<SimpleShape> shapes = new ArrayList<SimpleShape>();
48.60 - private List<Effect> effects = new ArrayList<Effect>();
48.61 - private double opacity = 1;
48.62 - private double fillOpacity = 1;
48.63 - private BlendingMode blendingMode = BlendingMode.NORMAL;
48.64 - private boolean locked = false;
48.65 - private boolean visible = true;
48.66 - private PropertyChangeListener shapeChangeListener = new PropertyChangeListener() {
48.67 - public void propertyChange(PropertyChangeEvent evt) {
48.68 - int index = shapes.indexOf((SimpleShape) evt.getSource());
48.69 - firePropertyChange("shapes[" + index + "]." + evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
48.70 - }
48.71 - };
48.72 - private PropertyChangeListener effectChangeListener = new PropertyChangeListener() {
48.73 - public void propertyChange(PropertyChangeEvent evt) {
48.74 - int index = effects.indexOf((Effect) evt.getSource());
48.75 - System.out.println(
48.76 - "Layer.propertyChange EFFECT PROPERTY CHANGED " + evt.getSource() + " -- " + evt.getPropertyName());
48.77 - firePropertyChange("effects[" + index + "]." + evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
48.78 - }
48.79 - };
48.80 - private BufferedImage buffer = null;
48.81 - // =================================================================================================================
48.82 - // Constructors
48.83 -
48.84 - public Layer() {
48.85 - }
48.86 -
48.87 - public Layer(String name) {
48.88 - this();
48.89 - this.name = name;
48.90 - }
48.91 -
48.92 - /** Called by JIBX after populating this layer so we can add listeners to children */
48.93 - protected void postInit() {
48.94 - for (SimpleShape shape : shapes) {
48.95 - shape.addPropertyChangeListener(shapeChangeListener);
48.96 - shape.setParent(this);
48.97 - }
48.98 - for (Effect effect : effects) {
48.99 - effect.addPropertyChangeListener(effectChangeListener);
48.100 - }
48.101 - }
48.102 -
48.103 - // =================================================================================================================
48.104 - // Bean Methods
48.105 -
48.106 - public LayerType getType() {
48.107 - return type;
48.108 - }
48.109 -
48.110 - public boolean isLocked() {
48.111 - return locked;
48.112 - }
48.113 -
48.114 - public void setLocked(boolean locked) {
48.115 - boolean old = isLocked();
48.116 - this.locked = locked;
48.117 - firePropertyChange("locked", old, isLocked());
48.118 - }
48.119 -
48.120 - public boolean isVisible() {
48.121 - return visible;
48.122 - }
48.123 -
48.124 - public void setVisible(boolean visible) {
48.125 - boolean old = isVisible();
48.126 - this.visible = visible;
48.127 - firePropertyChange("visible", old, isVisible());
48.128 - }
48.129 -
48.130 - public String getName() {
48.131 - return name;
48.132 - }
48.133 -
48.134 - public void setName(String name) {
48.135 - String old = getName();
48.136 - this.name = name;
48.137 - firePropertyChange("name", old, getName());
48.138 - }
48.139 -
48.140 - public void setParent(LayerContainer parent) {
48.141 - super.setParent(parent);
48.142 - // generate a name if null
48.143 - if (name == null) {
48.144 - Canvas c = null;
48.145 - LayerContainer p = parent;
48.146 - while (true) {
48.147 - if (p instanceof Canvas) {
48.148 - c = (Canvas) p;
48.149 - break;
48.150 - } else if (p == null) {
48.151 - break;
48.152 - }
48.153 - p = p.getParent();
48.154 - }
48.155 - if (c != null) {
48.156 - setName("Layer " + c.getNextLayerNameIndex());
48.157 - }
48.158 - }
48.159 - }
48.160 -
48.161 - /**
48.162 - * Add shape to top of layer so it paints above all other shapes
48.163 - *
48.164 - * @param shape The shape to add
48.165 - */
48.166 - public void add(SimpleShape shape) {
48.167 - shapes.add(0, shape);
48.168 - shape.setParent(this);
48.169 - shape.addPropertyChangeListener(shapeChangeListener);
48.170 - fireIndexedPropertyChange("shapes", 0, null, shape);
48.171 - }
48.172 -
48.173 - public void remove(SimpleShape shape) {
48.174 - int index = shapes.indexOf(shape);
48.175 - if (index != -1) {
48.176 - shapes.remove(shape);
48.177 - shape.setParent(null);
48.178 - fireIndexedPropertyChange("shapes", index, shape, null);
48.179 - }
48.180 - }
48.181 -
48.182 - /**
48.183 - * Returns an unmodifianle iterator over a set of elements of type SimpleShape.
48.184 - *
48.185 - * @return an Iterator.
48.186 - */
48.187 - public Iterator<SimpleShape> iterator() {
48.188 - return Collections.unmodifiableList(shapes).iterator();
48.189 - }
48.190 -
48.191 -
48.192 - public List<Effect> getEffects() {
48.193 - return Collections.unmodifiableList(effects);
48.194 - }
48.195 -
48.196 - public void addEffect(Effect effect) {
48.197 - int index = effects.size();
48.198 - effects.add(effect);
48.199 - effect.addPropertyChangeListener(effectChangeListener);
48.200 - fireIndexedPropertyChange("effects", index, null, effects);
48.201 - }
48.202 -
48.203 - public void removeEffect(Effect effect) {
48.204 - int index = effects.indexOf(effect);
48.205 - if (index != -1) {
48.206 - effects.remove(effect);
48.207 - effect.removePropertyChangeListener(effectChangeListener);
48.208 - fireIndexedPropertyChange("effects", index, effect, null);
48.209 - }
48.210 - }
48.211 -
48.212 - public double getOpacity() {
48.213 - return opacity;
48.214 - }
48.215 -
48.216 - public void setOpacity(double opacity) {
48.217 - if (opacity < 0 || opacity > 1) return;
48.218 - double old = getOpacity();
48.219 - this.opacity = opacity;
48.220 - firePropertyChange("opacity", old, getOpacity());
48.221 - }
48.222 -
48.223 - public double getFillOpacity() {
48.224 - return fillOpacity;
48.225 - }
48.226 -
48.227 - public void setFillOpacity(double fillOpacity) {
48.228 - if (fillOpacity < 0 || fillOpacity > 1) return;
48.229 - double old = getFillOpacity();
48.230 - this.fillOpacity = fillOpacity;
48.231 - firePropertyChange("fillOpacity", old, getFillOpacity());
48.232 - }
48.233 -
48.234 - public BlendingMode getBlendingMode() {
48.235 - return blendingMode;
48.236 - }
48.237 -
48.238 - public void setBlendingMode(BlendingMode blendingMode) {
48.239 - BlendingMode old = getBlendingMode();
48.240 - this.blendingMode = blendingMode;
48.241 - firePropertyChange("blendingMode", old, getBlendingMode());
48.242 - }
48.243 -
48.244 - // =================================================================================================================
48.245 - // Layer Methods
48.246 -
48.247 - /**
48.248 - * Get the parent canvas that contains this layer
48.249 - *
48.250 - * @return Parant canvas, or null if the layer is not in a canvas
48.251 - */
48.252 - public Canvas getCanvas() {
48.253 - LayerContainer lc = this;
48.254 - while (lc != null) {
48.255 - if (lc instanceof Canvas) return (Canvas) lc;
48.256 - lc = lc.getParent();
48.257 - }
48.258 - return null;
48.259 - }
48.260 -
48.261 - public List<SimpleShape> getShapes() {
48.262 - return new ArrayList<SimpleShape>(shapes);
48.263 - }
48.264 -
48.265 - public List<SimpleShape> getIntersectingShapes(Point2D p, double pixelSize) {
48.266 - if (isLocked() || !isVisible()) return Collections.emptyList();
48.267 - List<SimpleShape> intersectingShapes = new ArrayList<SimpleShape>();
48.268 - for (SimpleShape shape : shapes) {
48.269 - if (shape instanceof Layer) {
48.270 - intersectingShapes.addAll(((Layer) shape).getIntersectingShapes(p, pixelSize));
48.271 - } else {
48.272 - if (shape.isHit(p, pixelSize)) intersectingShapes.add(shape);
48.273 - }
48.274 - }
48.275 - return intersectingShapes;
48.276 - }
48.277 -
48.278 - public List<SimpleShape> getIntersectingShapes(Rectangle2D rect, double pixelSize) {
48.279 - if (isLocked() || !isVisible()) return Collections.emptyList();
48.280 - List<SimpleShape> intersectingShapes = new ArrayList<SimpleShape>();
48.281 - for (SimpleShape shape : shapes) {
48.282 - if (shape instanceof Layer) {
48.283 - intersectingShapes.addAll(((Layer) shape).getIntersectingShapes(rect, pixelSize));
48.284 - } else {
48.285 - if (shape.intersects(rect, pixelSize)) intersectingShapes.add(shape);
48.286 - }
48.287 - }
48.288 - return intersectingShapes;
48.289 -
48.290 - }
48.291 -
48.292 - public boolean isEmpty() {
48.293 - return shapes.isEmpty();
48.294 - }
48.295 -
48.296 - // =================================================================================================================
48.297 - // SimpleShape Methods
48.298 -
48.299 - public Rectangle2D getBounds(double pixelSize) {
48.300 - Rectangle2D.Double rect = new Rectangle2D.Double();
48.301 - for (SimpleShape shape : shapes) {
48.302 - rect.add(shape.getBounds(pixelSize));
48.303 - }
48.304 - return rect;
48.305 - }
48.306 -
48.307 -
48.308 - public Shape getShape() {
48.309 - return getBounds(0);
48.310 - }
48.311 -
48.312 - public boolean isHit(Point2D p, double pixelSize) {
48.313 - if (isLocked() || !isVisible()) return false;
48.314 - for (SimpleShape shape : shapes) {
48.315 - if (shape.isHit(p, pixelSize)) return true;
48.316 - }
48.317 - return false;
48.318 - }
48.319 -
48.320 - public boolean intersects(Rectangle2D rect, double pixelSize) {
48.321 - if (isLocked() || !isVisible()) return false;
48.322 - for (SimpleShape shape : shapes) {
48.323 - if (shape.intersects(rect, pixelSize)) return true;
48.324 - }
48.325 - return false;
48.326 - }
48.327 -
48.328 - public List<ControlPoint> getControlPoints() {
48.329 - return Collections.emptyList();
48.330 - }
48.331 -
48.332 - public void paint(Graphics2D g2, double pixelSize) {
48.333 - }
48.334 -
48.335 - public void paintControls(Graphics2D g2, double pixelSize, boolean paintControlLines) {
48.336 -
48.337 - }
48.338 -
48.339 - public String toString() {
48.340 - return getName();
48.341 - }
48.342 -
48.343 - // =================================================================================================================
48.344 - // LayerContainer Methods
48.345 -
48.346 - public void addLayer(int i, Layer layer) {
48.347 - // get existing layer at index i
48.348 - Layer existingLayer = getLayer(i);
48.349 - if (existingLayer == null) {
48.350 - addLayer(layer);
48.351 - } else {
48.352 - int index = indexOfLayer(existingLayer);
48.353 - shapes.add(index, layer);
48.354 - layer.setParent(this);
48.355 - layer.addPropertyChangeListener(shapeChangeListener);
48.356 - fireIndexedPropertyChange("layers", index, null, layer);
48.357 - }
48.358 - }
48.359 -
48.360 - public void addLayer(Layer layer) {
48.361 - shapes.add(layer);
48.362 - layer.setParent(this);
48.363 - layer.addPropertyChangeListener(shapeChangeListener);
48.364 - int index = indexOfLayer(layer);
48.365 - fireIndexedPropertyChange("layers", index, null, layer);
48.366 - }
48.367 -
48.368 - public Layer getLayer(int index) {
48.369 - int i = -1;
48.370 - for (SimpleShape shape : shapes) {
48.371 - if (shape instanceof Layer) i++;
48.372 - if (i == index) return (Layer) shape;
48.373 - }
48.374 - return null;
48.375 - }
48.376 -
48.377 - public int getLayerCount() {
48.378 - int count = 0;
48.379 - for (SimpleShape shape : shapes) {
48.380 - if (shape instanceof Layer) count++;
48.381 - }
48.382 - return count;
48.383 - }
48.384 -
48.385 -
48.386 - public Collection<Layer> getLayers() {
48.387 - List<Layer> layers = new ArrayList<Layer>();
48.388 - for (SimpleShape shape : shapes) {
48.389 - if (shape instanceof Layer) layers.add((Layer) shape);
48.390 - }
48.391 - return Collections.unmodifiableList(layers);
48.392 - }
48.393 -
48.394 - public Iterator<Layer> getLayerIterator() {
48.395 - return new Iterator<Layer>() {
48.396 - private int index = 0;
48.397 -
48.398 - public boolean hasNext() {
48.399 - for (int i = index; i < shapes.size(); i++) {
48.400 - if (shapes.get(i) instanceof Layer) {
48.401 - return true;
48.402 - }
48.403 - }
48.404 - return false;
48.405 - }
48.406 -
48.407 - public Layer next() {
48.408 - for (; index < shapes.size(); index++) {
48.409 - if (shapes.get(index) instanceof Layer) {
48.410 - Layer nextLayer = (Layer) shapes.get(index);
48.411 - index++; // increment index so we don't find the same one again
48.412 - return nextLayer;
48.413 - }
48.414 - }
48.415 - return null;
48.416 - }
48.417 -
48.418 - public void remove() {
48.419 - throw new UnsupportedOperationException();
48.420 - }
48.421 - };
48.422 - }
48.423 -
48.424 - public int indexOfLayer(Layer layer) {
48.425 - int i = -1;
48.426 - for (SimpleShape s : shapes) {
48.427 - if (s instanceof Layer) i++;
48.428 - if (s == layer) return i;
48.429 - }
48.430 - return -1;
48.431 - }
48.432 -
48.433 - public void removeLayer(Layer layer) {
48.434 - int index = indexOfLayer(layer);
48.435 - if (index != -1) {
48.436 - shapes.remove(layer);
48.437 - layer.removePropertyChangeListener(shapeChangeListener);
48.438 - fireIndexedPropertyChange("layers", index, layer, null);
48.439 - }
48.440 - }
48.441 -
48.442 -
48.443 - public Dimension getRootSize() {
48.444 - return getParent().getRootSize();
48.445 - }
48.446 -}
49.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/LayerContainer.java Sun Sep 06 23:14:42 2009 -0700
49.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
49.3 @@ -1,67 +0,0 @@
49.4 -/*
49.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
49.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
49.7 - *
49.8 - * This code is free software; you can redistribute it and/or modify it
49.9 - * under the terms of the GNU General Public License version 2 only, as
49.10 - * published by the Free Software Foundation. Sun designates this
49.11 - * particular file as subject to the "Classpath" exception as provided
49.12 - * by Sun in the LICENSE file that accompanied this code.
49.13 - *
49.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
49.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
49.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
49.17 - * version 2 for more details (a copy is included in the LICENSE file that
49.18 - * accompanied this code).
49.19 - *
49.20 - * You should have received a copy of the GNU General Public License version
49.21 - * 2 along with this work; if not, write to the Free Software Foundation,
49.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
49.23 - *
49.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
49.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
49.26 - * have any questions.
49.27 - */
49.28 -package org.jdesktop.swingx.designer;
49.29 -
49.30 -import java.awt.Dimension;
49.31 -import java.beans.PropertyChangeListener;
49.32 -import java.util.Collection;
49.33 -import java.util.Iterator;
49.34 -
49.35 -/**
49.36 - * LayerContainer
49.37 - *
49.38 - * @author Created by Jasper Potts (May 31, 2007)
49.39 - */
49.40 -public interface LayerContainer {
49.41 - public void addPropertyChangeListener(PropertyChangeListener listener);
49.42 -
49.43 - public void removePropertyChangeListener(PropertyChangeListener listener);
49.44 -
49.45 - public LayerContainer getParent();
49.46 -
49.47 - public void addLayer(Layer layer);
49.48 -
49.49 - public void addLayer(int i, Layer layer);
49.50 -
49.51 - public void removeLayer(Layer layer);
49.52 -
49.53 - public int getLayerCount();
49.54 -
49.55 - public Layer getLayer(int index);
49.56 -
49.57 - public int indexOfLayer(Layer layer);
49.58 -
49.59 - public Iterator<Layer> getLayerIterator();
49.60 -
49.61 - public Collection<Layer> getLayers();
49.62 -
49.63 - /**
49.64 - * Get the size in pixels of the root of the layer tree, this is usualy a canvas
49.65 - *
49.66 - * @return The size of the whole layer tree
49.67 - */
49.68 - public Dimension getRootSize();
49.69 -
49.70 -}
50.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/PaintedShape.java Sun Sep 06 23:14:42 2009 -0700
50.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
50.3 @@ -1,289 +0,0 @@
50.4 -/*
50.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
50.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
50.7 - *
50.8 - * This code is free software; you can redistribute it and/or modify it
50.9 - * under the terms of the GNU General Public License version 2 only, as
50.10 - * published by the Free Software Foundation. Sun designates this
50.11 - * particular file as subject to the "Classpath" exception as provided
50.12 - * by Sun in the LICENSE file that accompanied this code.
50.13 - *
50.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
50.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
50.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
50.17 - * version 2 for more details (a copy is included in the LICENSE file that
50.18 - * accompanied this code).
50.19 - *
50.20 - * You should have received a copy of the GNU General Public License version
50.21 - * 2 along with this work; if not, write to the Free Software Foundation,
50.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
50.23 - *
50.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
50.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
50.26 - * have any questions.
50.27 - */
50.28 -package org.jdesktop.swingx.designer;
50.29 -
50.30 -import org.jdesktop.swingx.designer.paint.Matte;
50.31 -import org.jdesktop.swingx.designer.paint.PaintModel;
50.32 -
50.33 -import javax.swing.UIDefaults;
50.34 -import java.awt.BasicStroke;
50.35 -import java.awt.Color;
50.36 -import java.awt.GradientPaint;
50.37 -import java.awt.Graphics2D;
50.38 -import java.awt.LinearGradientPaint;
50.39 -import java.awt.Paint;
50.40 -import java.awt.RadialGradientPaint;
50.41 -import java.awt.Shape;
50.42 -import java.awt.geom.Ellipse2D;
50.43 -import java.awt.geom.Line2D;
50.44 -import java.awt.geom.Point2D;
50.45 -import java.awt.geom.Rectangle2D;
50.46 -import java.beans.PropertyChangeEvent;
50.47 -import java.beans.PropertyChangeListener;
50.48 -import java.util.Arrays;
50.49 -import java.util.Collections;
50.50 -import java.util.List;
50.51 -
50.52 -/**
50.53 - * PaintedShape
50.54 - *
50.55 - * @author Created by Jasper Potts (May 22, 2007)
50.56 - */
50.57 -public abstract class PaintedShape extends SimpleShape {
50.58 -
50.59 - private PaintModel paint;
50.60 - // control points for paint control types
50.61 - private DoubleBean px1 = new DoubleBean(0.25);
50.62 - private DoubleBean px2 = new DoubleBean(0.75);
50.63 - private DoubleBean py1 = new DoubleBean(0);
50.64 - private DoubleBean py2 = new DoubleBean(1);
50.65 - private ControlPoint ptl = new PaintControlPoint(px1, py1);
50.66 - private ControlPoint ptr = new PaintControlPoint(px2, py1);
50.67 - private ControlPoint pbl = new PaintControlPoint(px1, py2);
50.68 - private ControlPoint pbr = new PaintControlPoint(px2, py2);
50.69 - private PropertyChangeListener paintListener = new PropertyChangeListener() {
50.70 - public void propertyChange(PropertyChangeEvent evt) {
50.71 - firePropertyChange("paint." + evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
50.72 - }
50.73 - };
50.74 -
50.75 - protected PaintedShape() {
50.76 - px1.addPropertyChangeListener(new PropertyChangeListener() {
50.77 - public void propertyChange(PropertyChangeEvent evt) {
50.78 - firePropertyChange("x1", evt.getOldValue(), evt.getNewValue());
50.79 - }
50.80 - });
50.81 - py1.addPropertyChangeListener(new PropertyChangeListener() {
50.82 - public void propertyChange(PropertyChangeEvent evt) {
50.83 - firePropertyChange("y1", evt.getOldValue(), evt.getNewValue());
50.84 - }
50.85 - });
50.86 - px2.addPropertyChangeListener(new PropertyChangeListener() {
50.87 - public void propertyChange(PropertyChangeEvent evt) {
50.88 - firePropertyChange("x2", evt.getOldValue(), evt.getNewValue());
50.89 - }
50.90 - });
50.91 - py2.addPropertyChangeListener(new PropertyChangeListener() {
50.92 - public void propertyChange(PropertyChangeEvent evt) {
50.93 - firePropertyChange("y2", evt.getOldValue(), evt.getNewValue());
50.94 - }
50.95 - });
50.96 - }
50.97 -
50.98 - protected PaintedShape(UIDefaults canvasUiDefaults) {
50.99 - this();
50.100 - setPaintModel(new Matte(Color.ORANGE, canvasUiDefaults));
50.101 - }
50.102 -
50.103 - public PaintModel getPaintModel() {
50.104 - return paint;
50.105 - }
50.106 -
50.107 - public void setPaintModel(PaintModel paint) {
50.108 - PaintModel old = getPaintModel();
50.109 - if (old != null) old.removePropertyChangeListener(paintListener);
50.110 - this.paint = paint;
50.111 - this.paint.addPropertyChangeListener(paintListener);
50.112 - firePropertyChange("paintModel", old, getPaintModel());
50.113 - }
50.114 -
50.115 - public Paint getPaint() {
50.116 - Paint p = getPaintModel().getPaint();
50.117 - if (p instanceof Color) {
50.118 - return p;
50.119 - }
50.120 - //resize p as necessary to fit the bounds of this PaintedShape
50.121 - Rectangle2D bounds = getBounds(0);
50.122 - if (p instanceof LinearGradientPaint) {
50.123 - LinearGradientPaint lgp = (LinearGradientPaint) p;
50.124 - return new LinearGradientPaint(
50.125 - convertLocalPoint(ptl.getPosition(), bounds),
50.126 - convertLocalPoint(pbr.getPosition(), bounds),
50.127 - lgp.getFractions(),
50.128 - lgp.getColors());
50.129 - } else if (p instanceof RadialGradientPaint) {
50.130 - RadialGradientPaint rgp = (RadialGradientPaint) p;
50.131 - Point2D outer = convertLocalPoint(ptl.getPosition(), bounds);
50.132 - Point2D center = convertLocalPoint(pbr.getPosition(), bounds);
50.133 - double deltaX = Math.abs(center.getX() - outer.getX());
50.134 - double deltaY = Math.abs(center.getY() - outer.getY());
50.135 - float radius = (float) Math.sqrt((deltaX * deltaX) + (deltaY * deltaY));
50.136 - return new RadialGradientPaint(
50.137 - center,
50.138 - radius,
50.139 - rgp.getFractions(),
50.140 - rgp.getColors());
50.141 - } else {
50.142 - return p;
50.143 - }
50.144 - }
50.145 -
50.146 - public List<? extends ControlPoint> getControlPoints() {
50.147 - switch (paint.getPaintControlType()) {
50.148 - case control_line:
50.149 - return Arrays.asList(ptl, pbr);
50.150 - case control_rect:
50.151 - return Arrays.asList(ptl, ptr, pbl, pbr);
50.152 - default:
50.153 - return Collections.emptyList();
50.154 - }
50.155 - }
50.156 -
50.157 - public void paintFillControls(Graphics2D g2, double pixelSize, boolean paintControlLines) {
50.158 - switch (paint.getPaintControlType()) {
50.159 - case control_line:
50.160 - Point2D p1 = convertLocalPoint(ptl.getPosition(), PaintedShape.this.getBounds(0));
50.161 - Point2D p2 = convertLocalPoint(pbr.getPosition(), PaintedShape.this.getBounds(0));
50.162 - g2.setStroke(new BasicStroke((float) pixelSize));
50.163 - g2.setColor(GraphicsHelper.FILL_LINE);
50.164 - g2.draw(new Line2D.Double(p1.getX(), p1.getY(), p2.getX(), p2.getY()));
50.165 - ptl.paintControls(g2, pixelSize, true);
50.166 - pbr.paintControls(g2, pixelSize, true);
50.167 - break;
50.168 - case control_rect:
50.169 - g2.setStroke(new BasicStroke((float) pixelSize));
50.170 - g2.setColor(GraphicsHelper.FILL_LINE);
50.171 - g2.draw(new Rectangle2D.Double(
50.172 - px1.getValue(),
50.173 - py1.getValue(),
50.174 - px2.getValue() - px1.getValue(),
50.175 - py2.getValue() - py1.getValue()));
50.176 - ptl.paintControls(g2, pixelSize, true);
50.177 - ptr.paintControls(g2, pixelSize, true);
50.178 - pbl.paintControls(g2, pixelSize, true);
50.179 - pbr.paintControls(g2, pixelSize, true);
50.180 - break;
50.181 - }
50.182 - }
50.183 -
50.184 - public void move(double moveX, double moveY, boolean snapPixels) {
50.185 - for (ControlPoint controlPoint : getControlPoints()) {
50.186 - if (!(controlPoint instanceof PaintControlPoint)) controlPoint.move(moveX, moveY, snapPixels);
50.187 - }
50.188 - }
50.189 -
50.190 - public double getPaintX1() {
50.191 - return px1.getValue();
50.192 - }
50.193 -
50.194 - public void setPaintX1(double x1) {
50.195 - this.px1.setValue(x1);
50.196 - }
50.197 -
50.198 - public double getPaintX2() {
50.199 - return px2.getValue();
50.200 - }
50.201 -
50.202 - public void setPaintX2(double x2) {
50.203 - this.px2.setValue(x2);
50.204 - }
50.205 -
50.206 - public double getPaintY1() {
50.207 - return py1.getValue();
50.208 - }
50.209 -
50.210 - public void setPaintY1(double y1) {
50.211 - this.py1.setValue(y1);
50.212 - }
50.213 -
50.214 - public double getPaintY2() {
50.215 - return py2.getValue();
50.216 - }
50.217 -
50.218 - public void setPaintY2(double y2) {
50.219 - this.py2.setValue(y2);
50.220 - }
50.221 -
50.222 - // =================================================================================================================
50.223 - // Private helper methods
50.224 -
50.225 - private Point2D convertLocalPoint(Point2D point, Rectangle2D bounds) {
50.226 - point.setLocation(
50.227 - bounds.getX() + (point.getX() * bounds.getWidth()),
50.228 - bounds.getY() + (point.getY() * bounds.getHeight())
50.229 - );
50.230 - return point;
50.231 - }
50.232 -
50.233 - private Point2D convertScreenPoint(Point2D point, Rectangle2D bounds) {
50.234 - return new Point2D.Double(
50.235 - (point.getX() - bounds.getX()) / bounds.getWidth(),
50.236 - (point.getY() - bounds.getY()) / bounds.getHeight()
50.237 - );
50.238 - }
50.239 -
50.240 - // =================================================================================================================
50.241 - // Gradient ControlPoint
50.242 -
50.243 - /**
50.244 - * A Special ControlPoint thats internal values are in coordinates relative to the shapes bounds. With 0,0 being the
50.245 - * top left of the shape and 1.0X == shape width and 1.0Y == shapes height.
50.246 - */
50.247 - public class PaintControlPoint extends ControlPoint {
50.248 - public PaintControlPoint() {
50.249 - super(GraphicsHelper.FILL_CP_FILL, GraphicsHelper.FILL_CP_LINE);
50.250 - }
50.251 -
50.252 - public PaintControlPoint(DoubleBean x, DoubleBean y) {
50.253 - super(x, y, GraphicsHelper.FILL_CP_FILL, GraphicsHelper.FILL_CP_LINE);
50.254 - }
50.255 -
50.256 - public void paintControls(Graphics2D g2, double pixelSize, boolean paintControlLines) {
50.257 - Point2D p = convertLocalPoint(getPosition(), PaintedShape.this.getBounds(0));
50.258 - g2.setStroke(new BasicStroke((float) pixelSize));
50.259 - double size = pixelSize * 4d;
50.260 - Shape s = new Ellipse2D.Double(p.getX() - size, p.getY() - size,
50.261 - size * 2, size * 2);
50.262 - g2.setPaint(new GradientPaint(
50.263 - (float) p.getX(), (float) (p.getY() - size), Color.CYAN,
50.264 - (float) p.getX(), (float) (p.getY() + size), Color.WHITE
50.265 - ));
50.266 - g2.fill(s);
50.267 - g2.setColor(GraphicsHelper.FILL_CP_LINE);
50.268 - g2.draw(s);
50.269 - }
50.270 -
50.271 - public void move(double moveX, double moveY, boolean snapPixels) {
50.272 - Rectangle2D bounds = PaintedShape.this.getBounds(0);
50.273 - moveX = moveX / bounds.getWidth();
50.274 - moveY = moveY / bounds.getHeight();
50.275 - if (snapPixels) {
50.276 - // snap to neareast 0.5
50.277 - double newX = Math.round((x.getValue() + moveX) * 2d) / 2d;
50.278 - double newY = Math.round((y.getValue() + moveY) * 2d) / 2d;
50.279 - setPosition(newX, newY);
50.280 - } else {
50.281 - setPosition(x.getValue() + moveX, y.getValue() + moveY);
50.282 - }
50.283 - }
50.284 -
50.285 - public Rectangle2D getBounds(double pixelSize) {
50.286 - Point2D p = convertLocalPoint(getPosition(), PaintedShape.this.getBounds(0));
50.287 - double size = pixelSize * 4d;
50.288 - return new Rectangle2D.Double(p.getX() - size, p.getY() - size,
50.289 - size * 2, size * 2);
50.290 - }
50.291 - }
50.292 -}
51.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/PathShape.java Sun Sep 06 23:14:42 2009 -0700
51.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
51.3 @@ -1,194 +0,0 @@
51.4 -/*
51.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
51.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
51.7 - *
51.8 - * This code is free software; you can redistribute it and/or modify it
51.9 - * under the terms of the GNU General Public License version 2 only, as
51.10 - * published by the Free Software Foundation. Sun designates this
51.11 - * particular file as subject to the "Classpath" exception as provided
51.12 - * by Sun in the LICENSE file that accompanied this code.
51.13 - *
51.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
51.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
51.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
51.17 - * version 2 for more details (a copy is included in the LICENSE file that
51.18 - * accompanied this code).
51.19 - *
51.20 - * You should have received a copy of the GNU General Public License version
51.21 - * 2 along with this work; if not, write to the Free Software Foundation,
51.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
51.23 - *
51.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
51.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
51.26 - * have any questions.
51.27 - */
51.28 -package org.jdesktop.swingx.designer;
51.29 -
51.30 -import javax.swing.*;
51.31 -import java.awt.*;
51.32 -import java.awt.geom.GeneralPath;
51.33 -import java.awt.geom.Point2D;
51.34 -import java.awt.geom.Rectangle2D;
51.35 -import java.beans.PropertyChangeEvent;
51.36 -import java.beans.PropertyChangeListener;
51.37 -import java.util.ArrayList;
51.38 -import java.util.List;
51.39 -
51.40 -/**
51.41 - * PathShape
51.42 - *
51.43 - * @author Created by Jasper Potts (May 29, 2007)
51.44 - */
51.45 -public class PathShape extends PaintedShape {
51.46 -
51.47 - private Shape cachedShape = null;
51.48 - private List<BezierControlPoint> controlPoints = new ArrayList<BezierControlPoint>();
51.49 - private PropertyChangeListener cpListener = new PropertyChangeListener() {
51.50 - public void propertyChange(PropertyChangeEvent evt) {
51.51 - rebuildShape();
51.52 - }
51.53 - };
51.54 -
51.55 - // =================================================================================================================
51.56 - // Constructors
51.57 -
51.58 - /** private noargs constructor for JIBX */
51.59 - private PathShape() {
51.60 - this(null);
51.61 - }
51.62 -
51.63 - public PathShape(UIDefaults canvasUiDefaults) {
51.64 - super(canvasUiDefaults);
51.65 - }
51.66 -
51.67 - public BezierControlPoint addPoint(double x, double y) {
51.68 - BezierControlPoint cp = new BezierControlPoint(x, y);
51.69 - controlPoints.add(cp);
51.70 - cp.addPropertyChangeListener(cpListener);
51.71 - // update shape
51.72 - rebuildShape();
51.73 - // return new control point
51.74 - return cp;
51.75 - }
51.76 -
51.77 - public Shape getShape() {
51.78 - if (cachedShape == null) {
51.79 - rebuildShape();
51.80 - }
51.81 - return cachedShape;
51.82 - }
51.83 -
51.84 - private void rebuildShape() {
51.85 - GeneralPath path = new GeneralPath();
51.86 - BezierControlPoint first, last;
51.87 - first = last = controlPoints.get(0);
51.88 - path.moveTo((float) first.getX(), (float) first.getY());
51.89 - for (int i = 0; i < controlPoints.size(); i++) {
51.90 - BezierControlPoint controlPoint = controlPoints.get(i);
51.91 - if (last.getCp2().isSharp() && controlPoint.getCp1().isSharp()) {
51.92 - path.lineTo(controlPoint.getX(), controlPoint.getY());
51.93 - } else {
51.94 - path.curveTo(
51.95 - (float) last.getCp2().getX(), (float) last.getCp2().getY(),
51.96 - (float) controlPoint.getCp1().getX(), (float) controlPoint.getCp1().getY(),
51.97 - (float) controlPoint.getX(), (float) controlPoint.getY()
51.98 - );
51.99 - }
51.100 - last = controlPoint;
51.101 - }
51.102 - // close path
51.103 - if (last.getCp2().isSharp() && first.getCp1().isSharp()) {
51.104 - path.lineTo(first.getX(), first.getY());
51.105 - } else {
51.106 - path.curveTo(
51.107 - (float) last.getCp2().getX(), (float) last.getCp2().getY(),
51.108 - (float) first.getCp1().getX(), (float) first.getCp1().getY(),
51.109 - (float) first.getX(), (float) first.getY()
51.110 - );
51.111 - }
51.112 - path.closePath();
51.113 - // fire change
51.114 - cachedShape = path;
51.115 - firePropertyChange("shape", null, cachedShape);
51.116 - }
51.117 -
51.118 - @Override
51.119 - public String toString() {
51.120 - String p = "PATH {\n";
51.121 - BezierControlPoint first, last;
51.122 - first = last = controlPoints.get(0);
51.123 - p += " path.moveTo(" + first.getX() + "," + first.getY() + ");";
51.124 - for (int i = 0; i < controlPoints.size(); i++) {
51.125 - BezierControlPoint controlPoint = controlPoints.get(i);
51.126 - p += " path.curveTo(" +
51.127 - (float) last.getCp2().getX() + "," + (float) last.getCp2().getY() + "," +
51.128 - (float) controlPoint.getCp1().getX() + "," + (float) controlPoint.getCp1().getY() + "," +
51.129 - (float) controlPoint.getX() + "," + (float) controlPoint.getY() +
51.130 - ");\n";
51.131 - last = controlPoint;
51.132 - }
51.133 - // close path
51.134 - p += " path.curveTo(" +
51.135 - (float) last.getCp2().getX() + "," + (float) last.getCp2().getY() + "," +
51.136 - (float) first.getCp1().getX() + "," + (float) first.getCp1().getY() + "," +
51.137 - (float) first.getX() + "," + (float) first.getY() +
51.138 - ");\n";
51.139 - p += "}\n";
51.140 - return p;
51.141 - }
51.142 -
51.143 - // =================================================================================================================
51.144 - // Shape Methods
51.145 -
51.146 - public Rectangle2D getBounds(double pixelSize) {
51.147 - return getShape().getBounds2D();
51.148 - }
51.149 -
51.150 - public List<? extends ControlPoint> getControlPoints() {
51.151 - List<ControlPoint> pts = new ArrayList<ControlPoint>();
51.152 - for (BezierControlPoint controlPoint : controlPoints) {
51.153 - pts.add(controlPoint);
51.154 - }
51.155 - for (ControlPoint controlPoint : super.getControlPoints()) {
51.156 - pts.add(controlPoint);
51.157 - }
51.158 - return pts;
51.159 - }
51.160 -
51.161 - public void setControlPoints(List<BezierControlPoint> controlPoints) {
51.162 - List<BezierControlPoint> old = this.controlPoints;
51.163 - for (BezierControlPoint cp : old) {
51.164 - cp.removePropertyChangeListener(cpListener);
51.165 - }
51.166 - this.controlPoints = controlPoints;
51.167 - for (BezierControlPoint cp : this.controlPoints) {
51.168 - cp.addPropertyChangeListener(cpListener);
51.169 - }
51.170 - // update shape
51.171 - rebuildShape();
51.172 - }
51.173 -
51.174 - public boolean isHit(Point2D p, double pixelSize) {
51.175 - return getShape().contains(p);
51.176 - }
51.177 -
51.178 - public void paint(Graphics2D g2, double pixelSize) {
51.179 - g2.setPaint(getPaint());
51.180 - g2.fill(getShape());
51.181 - }
51.182 -
51.183 - public void paintControls(Graphics2D g2, double pixelSize, boolean paintControlLines) {
51.184 - if (paintControlLines) {
51.185 - g2.setStroke(new BasicStroke((float) pixelSize));
51.186 - g2.setColor(GraphicsHelper.CONTROL_LINE);
51.187 - g2.draw(getShape());
51.188 - }
51.189 - for (BezierControlPoint controlPoint : controlPoints) {
51.190 - if (!controlPoint.isSharpCorner()) controlPoint.paintControls(g2, pixelSize, true);
51.191 - }
51.192 - }
51.193 -
51.194 - public List<BezierControlPoint> getBezierControlPoints() {
51.195 - return controlPoints;
51.196 - }
51.197 -}
52.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/RectangleShape.java Sun Sep 06 23:14:42 2009 -0700
52.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
52.3 @@ -1,266 +0,0 @@
52.4 -/*
52.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
52.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
52.7 - *
52.8 - * This code is free software; you can redistribute it and/or modify it
52.9 - * under the terms of the GNU General Public License version 2 only, as
52.10 - * published by the Free Software Foundation. Sun designates this
52.11 - * particular file as subject to the "Classpath" exception as provided
52.12 - * by Sun in the LICENSE file that accompanied this code.
52.13 - *
52.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
52.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
52.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
52.17 - * version 2 for more details (a copy is included in the LICENSE file that
52.18 - * accompanied this code).
52.19 - *
52.20 - * You should have received a copy of the GNU General Public License version
52.21 - * 2 along with this work; if not, write to the Free Software Foundation,
52.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
52.23 - *
52.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
52.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
52.26 - * have any questions.
52.27 - */
52.28 -package org.jdesktop.swingx.designer;
52.29 -
52.30 -import javax.swing.*;
52.31 -import java.awt.*;
52.32 -import java.awt.geom.Ellipse2D;
52.33 -import java.awt.geom.Point2D;
52.34 -import java.awt.geom.Rectangle2D;
52.35 -import java.awt.geom.RoundRectangle2D;
52.36 -import java.beans.PropertyChangeEvent;
52.37 -import java.beans.PropertyChangeListener;
52.38 -import java.util.ArrayList;
52.39 -import java.util.List;
52.40 -
52.41 -/**
52.42 - * RectangleShape
52.43 - *
52.44 - * @author Created by Jasper Potts (May 22, 2007)
52.45 - */
52.46 -public class RectangleShape extends PaintedShape {
52.47 -
52.48 - private DoubleBean x1 = new DoubleBean();
52.49 - private DoubleBean x2 = new DoubleBean();
52.50 - private DoubleBean y1 = new DoubleBean();
52.51 - private DoubleBean y2 = new DoubleBean();
52.52 - private ControlPoint tl = new ControlPoint(x1, y1);
52.53 - private ControlPoint tr = new ControlPoint(x2, y1);
52.54 - private ControlPoint bl = new ControlPoint(x1, y2);
52.55 - private ControlPoint br = new ControlPoint(x2, y2);
52.56 - private DoubleBean roundingX = new DoubleBean() {
52.57 - public void setValue(double value) {
52.58 - // contrain y = y1 and x is between x1+1 and (x2-x1)/2
52.59 - boolean x1isLess = x1.getValue() < x2.getValue();
52.60 - double min = x1isLess ? x1.getValue() + 1 : x1.getValue() - 1;
52.61 - double max = x1isLess ? x1.getValue() + ((x2.getValue() - x1.getValue()) / 2) :
52.62 - x2.getValue() + ((x1.getValue() - x2.getValue()) / 2);
52.63 - double newX = value;
52.64 - if (newX < min) newX = min;
52.65 - if (newX > max) newX = max;
52.66 - super.setValue(newX);
52.67 - }
52.68 - };
52.69 - private ControlPoint rounding = new ControlPoint(roundingX, y1) {
52.70 - public void paintControls(Graphics2D g2, double pixelSize, boolean paintControlLines) {
52.71 - double size = pixelSize * 3d;
52.72 - Shape s = new Ellipse2D.Double(getX() - size, getY() - size,
52.73 - size * 2, size * 2);
52.74 - g2.setColor(GraphicsHelper.BEZIER_CONTROL_POINT_FILL);
52.75 - g2.fill(s);
52.76 - g2.setColor(GraphicsHelper.BEZIER_CONTROL_POINT_LINE);
52.77 - g2.draw(s);
52.78 - }
52.79 -
52.80 - public void setPosition(Point2D position) {
52.81 - // only alow X to change
52.82 - x.setValue(position.getX());
52.83 - }
52.84 -
52.85 - };
52.86 -
52.87 - // =================================================================================================================
52.88 - // Constructors
52.89 -
52.90 - /** private noargs constructor for JIBX */
52.91 - private RectangleShape() {
52.92 - this(null);
52.93 - }
52.94 -
52.95 - public RectangleShape(UIDefaults canvasUiDefaults) {
52.96 - super(canvasUiDefaults);
52.97 - x1.addPropertyChangeListener(new PropertyChangeListener() {
52.98 - public void propertyChange(PropertyChangeEvent evt) {
52.99 - // keep rounding point in sync
52.100 - roundingX.setValue(roundingX.getValue() +
52.101 - ((Double) evt.getNewValue() - (Double) evt.getOldValue()));
52.102 - firePropertyChange("bounds", null, getBounds(0));
52.103 - }
52.104 - });
52.105 - x2.addPropertyChangeListener(new PropertyChangeListener() {
52.106 - public void propertyChange(PropertyChangeEvent evt) {
52.107 - // keep rounding point in sync
52.108 - double distanceFromX1 = Math.abs(roundingX.getValue() - x1.getValue());
52.109 - roundingX.setValue(
52.110 - (x1.getValue() < x2.getValue()) ? x1.getValue() + distanceFromX1 :
52.111 - x1.getValue() - distanceFromX1
52.112 - );
52.113 - firePropertyChange("bounds", null, getBounds(0));
52.114 - }
52.115 - });
52.116 - PropertyChangeListener listener = new PropertyChangeListener() {
52.117 - public void propertyChange(PropertyChangeEvent evt) {
52.118 - firePropertyChange("bounds", null, getBounds(0));
52.119 - }
52.120 - };
52.121 - y1.addPropertyChangeListener(listener);
52.122 - y2.addPropertyChangeListener(listener);
52.123 - rounding.addPropertyChangeListener(listener);
52.124 - }
52.125 -
52.126 - public RectangleShape(double x, double y, double w, double h) {
52.127 - this();
52.128 - x1.setValue(x);
52.129 - y1.setValue(y);
52.130 - x2.setValue(x + w);
52.131 - y2.setValue(y + h);
52.132 - }
52.133 -
52.134 - public Shape getShape() {
52.135 - double rounding = getRounding();
52.136 - double left = Math.min(x1.getValue(), x2.getValue());
52.137 - double right = Math.max(x1.getValue(), x2.getValue());
52.138 - double top = Math.min(y1.getValue(), y2.getValue());
52.139 - double bottom = Math.max(y1.getValue(), y2.getValue());
52.140 - if (rounding > 0) {
52.141 - return new RoundRectangle2D.Double(
52.142 - left, top, right - left, bottom - top, rounding, rounding
52.143 - );
52.144 - } else {
52.145 - return new Rectangle2D.Double(left, top, right - left, bottom - top);
52.146 - }
52.147 - }
52.148 -
52.149 - public double getRounding() {
52.150 - double rounding = Math.abs(roundingX.getValue() - x1.getValue()) * 2;
52.151 - return rounding > 2 ? rounding : 0;
52.152 - }
52.153 -
52.154 - public void setRounding(double rounding) {
52.155 - if (rounding > 0 && rounding < 2) rounding = 0;
52.156 - roundingX.setValue((rounding / 2d) + x1.getValue());
52.157 - }
52.158 -
52.159 - public boolean isRounded() {
52.160 - return getRounding() > 0;
52.161 - }
52.162 -
52.163 - public double getX1() {
52.164 - return x1.getValue();
52.165 - }
52.166 -
52.167 - public void setX1(double x1) {
52.168 - this.x1.setValue(x1);
52.169 - }
52.170 -
52.171 - public double getX2() {
52.172 - return x2.getValue();
52.173 - }
52.174 -
52.175 - public void setX2(double x2) {
52.176 - this.x2.setValue(x2);
52.177 - }
52.178 -
52.179 - public double getY1() {
52.180 - return y1.getValue();
52.181 - }
52.182 -
52.183 - public void setY1(double y1) {
52.184 - this.y1.setValue(y1);
52.185 - }
52.186 -
52.187 - public double getY2() {
52.188 - return y2.getValue();
52.189 - }
52.190 -
52.191 - public void setY2(double y2) {
52.192 - this.y2.setValue(y2);
52.193 - }
52.194 -
52.195 - // =================================================================================================================
52.196 - // SimpleShape Methods
52.197 -
52.198 - public Rectangle2D getBounds(double pixelSize) {
52.199 - double left = Math.min(x1.getValue(), x2.getValue());
52.200 - double right = Math.max(x1.getValue(), x2.getValue());
52.201 - double top = Math.min(y1.getValue(), y2.getValue());
52.202 - double bottom = Math.max(y1.getValue(), y2.getValue());
52.203 - return new Rectangle2D.Double(left, top, right - left, bottom - top);
52.204 - }
52.205 -
52.206 - public boolean isHit(Point2D p, double pixelSize) {
52.207 - return getShape().contains(p);
52.208 - }
52.209 -
52.210 - public void paint(Graphics2D g2, double pixelSize) {
52.211 - g2.setPaint(getPaint());
52.212 - g2.fill(getShape());
52.213 - }
52.214 -
52.215 - public void setFrame(double x1, double y1, double x2, double y2) {
52.216 - this.x1.setValue(x1);
52.217 - this.y1.setValue(y1);
52.218 - this.x2.setValue(x2);
52.219 - this.y2.setValue(y2);
52.220 - }
52.221 -
52.222 - @Override
52.223 - public String toString() {
52.224 - Rectangle2D bounds = getBounds(0);
52.225 - if (isRounded()) {
52.226 - return "ROUND RECT { x=" + bounds.getX() + ", y=" + bounds.getY() + ", w=" + bounds.getWidth() + ", h=" + bounds.getHeight() + ", rounding=" + getRounding() + " }";
52.227 - } else {
52.228 - return "ROUND RECT { x=" + bounds.getX() + ", y=" + bounds.getY() + ", w=" + bounds.getWidth() + ", h=" + bounds.getHeight() + " }";
52.229 - }
52.230 - }
52.231 -
52.232 - public List<ControlPoint> getControlPoints() {
52.233 - List<ControlPoint> points = new ArrayList<ControlPoint>();
52.234 - points.addAll(super.getControlPoints());
52.235 - points.add(tl);
52.236 - points.add(tr);
52.237 - points.add(bl);
52.238 - points.add(br);
52.239 - points.add(rounding);
52.240 - return points;
52.241 - }
52.242 -
52.243 - public void paintControls(Graphics2D g2, double pixelSize, boolean paintControlLines) {
52.244 - if (paintControlLines) {
52.245 - g2.setStroke(new BasicStroke((float) pixelSize));
52.246 - g2.setColor(GraphicsHelper.CONTROL_LINE);
52.247 - g2.draw(getShape());
52.248 - }
52.249 - tl.paintControls(g2, pixelSize, true);
52.250 - tr.paintControls(g2, pixelSize, true);
52.251 - bl.paintControls(g2, pixelSize, true);
52.252 - br.paintControls(g2, pixelSize, true);
52.253 - rounding.paintControls(g2, pixelSize, true);
52.254 - }
52.255 -
52.256 - public void move(double moveX, double moveY, boolean snapPixels) {
52.257 - if (snapPixels) {
52.258 - x1.setValue(Math.round(x1.getValue() + moveX));
52.259 - x2.setValue(Math.round(x2.getValue() + moveX));
52.260 - y1.setValue(Math.round(y1.getValue() + moveY));
52.261 - y2.setValue(Math.round(y2.getValue() + moveY));
52.262 - } else {
52.263 - x1.setValue(x1.getValue() + moveX);
52.264 - x2.setValue(x2.getValue() + moveX);
52.265 - y1.setValue(y1.getValue() + moveY);
52.266 - y2.setValue(y2.getValue() + moveY);
52.267 - }
52.268 - }
52.269 -}
53.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/SimpleShape.java Sun Sep 06 23:14:42 2009 -0700
53.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
53.3 @@ -1,81 +0,0 @@
53.4 -/*
53.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
53.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
53.7 - *
53.8 - * This code is free software; you can redistribute it and/or modify it
53.9 - * under the terms of the GNU General Public License version 2 only, as
53.10 - * published by the Free Software Foundation. Sun designates this
53.11 - * particular file as subject to the "Classpath" exception as provided
53.12 - * by Sun in the LICENSE file that accompanied this code.
53.13 - *
53.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
53.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
53.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
53.17 - * version 2 for more details (a copy is included in the LICENSE file that
53.18 - * accompanied this code).
53.19 - *
53.20 - * You should have received a copy of the GNU General Public License version
53.21 - * 2 along with this work; if not, write to the Free Software Foundation,
53.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
53.23 - *
53.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
53.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
53.26 - * have any questions.
53.27 - */
53.28 -package org.jdesktop.swingx.designer;
53.29 -
53.30 -import org.jdesktop.beans.AbstractBean;
53.31 -
53.32 -import java.awt.Graphics2D;
53.33 -import java.awt.Shape;
53.34 -import java.awt.geom.AffineTransform;
53.35 -import java.awt.geom.Point2D;
53.36 -import java.awt.geom.Rectangle2D;
53.37 -import java.util.List;
53.38 -
53.39 -/**
53.40 - * SimpleShape
53.41 - *
53.42 - * @author Created by Jasper Potts (May 22, 2007)
53.43 - */
53.44 -public abstract class SimpleShape extends AbstractBean {
53.45 -
53.46 - protected AffineTransform transform = new AffineTransform();
53.47 - protected LayerContainer parent = null;
53.48 -
53.49 - public void applyTransform(AffineTransform t) {
53.50 - transform.concatenate(t);
53.51 - }
53.52 -
53.53 - public abstract Rectangle2D getBounds(double pixelSize);
53.54 -
53.55 - public abstract void paint(Graphics2D g2, double pixelSize);
53.56 -
53.57 - public abstract boolean isHit(Point2D p, double pixelSize);
53.58 -
53.59 - public boolean intersects(Rectangle2D rect, double pixelSize) {
53.60 - return getBounds(pixelSize).intersects(rect);
53.61 - }
53.62 -
53.63 - public abstract List<? extends ControlPoint> getControlPoints();
53.64 -
53.65 - public abstract void paintControls(Graphics2D g2, double pixelSize, boolean paintControlLines);
53.66 -
53.67 - public void move(double moveX, double moveY, boolean snapPixels) {
53.68 - for (ControlPoint controlPoint : getControlPoints()) {
53.69 - controlPoint.move(moveX, moveY, snapPixels);
53.70 - }
53.71 - }
53.72 -
53.73 - public LayerContainer getParent() {
53.74 - return parent;
53.75 - }
53.76 -
53.77 - public void setParent(LayerContainer parent) {
53.78 - LayerContainer old = getParent();
53.79 - this.parent = parent;
53.80 - firePropertyChange("parent", old, getParent());
53.81 - }
53.82 -
53.83 - public abstract Shape getShape();
53.84 -}
54.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/TemplateLayer.java Sun Sep 06 23:14:42 2009 -0700
54.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
54.3 @@ -1,142 +0,0 @@
54.4 -/*
54.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
54.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
54.7 - *
54.8 - * This code is free software; you can redistribute it and/or modify it
54.9 - * under the terms of the GNU General Public License version 2 only, as
54.10 - * published by the Free Software Foundation. Sun designates this
54.11 - * particular file as subject to the "Classpath" exception as provided
54.12 - * by Sun in the LICENSE file that accompanied this code.
54.13 - *
54.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
54.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
54.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
54.17 - * version 2 for more details (a copy is included in the LICENSE file that
54.18 - * accompanied this code).
54.19 - *
54.20 - * You should have received a copy of the GNU General Public License version
54.21 - * 2 along with this work; if not, write to the Free Software Foundation,
54.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
54.23 - *
54.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
54.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
54.26 - * have any questions.
54.27 - */
54.28 -package org.jdesktop.swingx.designer;
54.29 -
54.30 -import org.jdesktop.swingx.designer.effects.Effect;
54.31 -
54.32 -import javax.imageio.ImageIO;
54.33 -import javax.swing.JOptionPane;
54.34 -import javax.swing.SwingUtilities;
54.35 -import java.awt.Color;
54.36 -import java.awt.FontMetrics;
54.37 -import java.awt.Graphics2D;
54.38 -import java.awt.GraphicsConfiguration;
54.39 -import java.awt.Image;
54.40 -import java.awt.geom.Rectangle2D;
54.41 -import java.awt.image.BufferedImage;
54.42 -import java.io.File;
54.43 -import java.io.IOException;
54.44 -import java.lang.ref.SoftReference;
54.45 -
54.46 -/**
54.47 - * TemplateLayer
54.48 - *
54.49 - * @author Created by Jasper Potts (Jul 2, 2007)
54.50 - */
54.51 -public class TemplateLayer extends Layer {
54.52 -
54.53 - private String fileName;
54.54 - private transient SoftReference<BufferedImage> imgRef = null;
54.55 -
54.56 - public TemplateLayer() {
54.57 - type = LayerType.template;
54.58 - }
54.59 -
54.60 - public TemplateLayer(String fileName, BufferedImage templateImage) {
54.61 - super("Template");
54.62 - this.fileName = fileName;
54.63 - type = LayerType.template;
54.64 - if (templateImage != null) {
54.65 - imgRef = new SoftReference<BufferedImage>(templateImage);
54.66 - }
54.67 - }
54.68 -
54.69 - // =================================================================================================================
54.70 - // Methods
54.71 -
54.72 - public String getName() {
54.73 - return super.getName();
54.74 - }
54.75 -
54.76 - /**
54.77 - * template layers are always locked
54.78 - *
54.79 - * @return <code>true</code>
54.80 - */
54.81 - public boolean isLocked() {
54.82 - return true;
54.83 - }
54.84 -
54.85 - public void add(SimpleShape shape) {
54.86 - throw new IllegalStateException("Template layers can't contain shapes");
54.87 - }
54.88 -
54.89 - public void addEffect(Effect effect) {
54.90 - throw new IllegalStateException("Template layers can't contain effects");
54.91 - }
54.92 -
54.93 - public void addLayer(int i, Layer layer) {
54.94 - throw new IllegalStateException("Template layers can't contain sub layers");
54.95 - }
54.96 -
54.97 - public void addLayer(Layer layer) {
54.98 - throw new IllegalStateException("Template layers can't contain sub layers");
54.99 - }
54.100 -
54.101 - public void paint(Graphics2D g2, double pixelSize) {
54.102 - if (isVisible()) {
54.103 - BufferedImage img = getTemplateImage();
54.104 - if (img != null) g2.drawImage(img, 0, 0, null);
54.105 - }
54.106 - }
54.107 -
54.108 -
54.109 - public Image getBuffer(GraphicsConfiguration graphicsConfiguration) {
54.110 - return getTemplateImage();
54.111 - }
54.112 -
54.113 - public BufferedImage getTemplateImage() {
54.114 - BufferedImage img = null;
54.115 - if (imgRef == null || (img = imgRef.get()) == null) {
54.116 -
54.117 - // can not access canvas
54.118 - final File templateImgFile = new File(getCanvas().getTemplatesDir(), fileName);
54.119 - System.out.println("templateImgFile = " + templateImgFile.getAbsolutePath());
54.120 - System.out.println("templateImgFile.exists = " + templateImgFile.exists());
54.121 - try {
54.122 - img = ImageIO.read(templateImgFile);
54.123 - imgRef = new SoftReference<BufferedImage>(img);
54.124 - } catch (IOException e) {
54.125 - e.printStackTrace();
54.126 - // create error image
54.127 - img = new BufferedImage(getCanvas().getSize().width, getCanvas().getSize().height,
54.128 - BufferedImage.TYPE_INT_RGB);
54.129 - Graphics2D g2 = img.createGraphics();
54.130 - g2.setColor(Color.RED);
54.131 - g2.fillRect(0, 0, img.getWidth(), img.getHeight());
54.132 - g2.setColor(Color.WHITE);
54.133 - g2.setFont(g2.getFont().deriveFont(8f));
54.134 - FontMetrics fontMetrics = g2.getFontMetrics();
54.135 - Rectangle2D stringBounds = fontMetrics.getStringBounds("Missing Image", g2);
54.136 - int offsetX = (int) ((img.getWidth() - stringBounds.getWidth()) / 2d);
54.137 - int offsetY = (int) (((img.getHeight() - stringBounds.getHeight()) / 2d) - stringBounds.getY());
54.138 - g2.drawString("Missing Image", offsetX, offsetY);
54.139 - g2.dispose();
54.140 - imgRef = new SoftReference<BufferedImage>(img);
54.141 - }
54.142 - }
54.143 - return img;
54.144 - }
54.145 -}
55.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/DropShadowEffect.java Sun Sep 06 23:14:42 2009 -0700
55.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
55.3 @@ -1,137 +0,0 @@
55.4 -/*
55.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
55.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55.7 - *
55.8 - * This code is free software; you can redistribute it and/or modify it
55.9 - * under the terms of the GNU General Public License version 2 only, as
55.10 - * published by the Free Software Foundation. Sun designates this
55.11 - * particular file as subject to the "Classpath" exception as provided
55.12 - * by Sun in the LICENSE file that accompanied this code.
55.13 - *
55.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
55.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
55.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
55.17 - * version 2 for more details (a copy is included in the LICENSE file that
55.18 - * accompanied this code).
55.19 - *
55.20 - * You should have received a copy of the GNU General Public License version
55.21 - * 2 along with this work; if not, write to the Free Software Foundation,
55.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
55.23 - *
55.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
55.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
55.26 - * have any questions.
55.27 - */
55.28 -package org.jdesktop.swingx.designer.effects;
55.29 -
55.30 -import org.jdesktop.swingx.designer.paint.Matte;
55.31 -
55.32 -import javax.swing.UIDefaults;
55.33 -import java.awt.Color;
55.34 -import java.awt.image.BufferedImage;
55.35 -import java.awt.image.Raster;
55.36 -import java.awt.image.WritableRaster;
55.37 -import java.util.Arrays;
55.38 -
55.39 -/**
55.40 - * DropShadowEffect
55.41 - *
55.42 - * @author Created by Jasper Potts (Jun 18, 2007)
55.43 - */
55.44 -public class DropShadowEffect extends ShadowEffect {
55.45 -
55.46 - protected DropShadowEffect() {}
55.47 -
55.48 - ;
55.49 -
55.50 - public DropShadowEffect(UIDefaults uiDefaults) {
55.51 - color = new Matte(Color.BLACK, uiDefaults);
55.52 - }
55.53 -
55.54 - // =================================================================================================================
55.55 - // Effect Methods
55.56 -
55.57 - /**
55.58 - * Get the display name for this effect
55.59 - *
55.60 - * @return The user displayable name
55.61 - */
55.62 - public String getDisplayName() {
55.63 - return "Drop Shadow";
55.64 - }
55.65 -
55.66 - /**
55.67 - * Get the type of this effect, one of UNDER,BLENDED,OVER. UNDER means the result of apply effect should be painted
55.68 - * under the src image. BLENDED means the result of apply sffect contains a modified src image so just it should be
55.69 - * painted. OVER means the result of apply effect should be painted over the src image.
55.70 - *
55.71 - * @return The effect type
55.72 - */
55.73 - public EffectType getEffectType() {
55.74 - return EffectType.UNDER;
55.75 - }
55.76 -
55.77 - /**
55.78 - * Apply the effect to the src image generating the result . The result image may or may not contain the source
55.79 - * image depending on what the effect type is.
55.80 - *
55.81 - * @param src The source image for applying the effect to
55.82 - * @param dst The dstination image to paint effect result into. If this is null then a new image will be created
55.83 - * @param w The width of the src image to apply effect to, this allow the src and dst buffers to be bigger than
55.84 - * the area the need effect applied to it
55.85 - * @param h The height of the src image to apply effect to, this allow the src and dst buffers to be bigger than
55.86 - * the area the need effect applied to it
55.87 - * @return The result of appl
55.88 - */
55.89 - public BufferedImage applyEffect(BufferedImage src, BufferedImage dst, int w, int h) {
55.90 - // calculate offset
55.91 - double trangleAngle = Math.toRadians(angle - 90);
55.92 - int offsetX = (int) (Math.sin(trangleAngle) * distance);
55.93 - int offsetY = (int) (Math.cos(trangleAngle) * distance);
55.94 - // clac expanded size
55.95 - int tmpOffX = offsetX + size;
55.96 - int tmpOffY = offsetY + size;
55.97 - int tmpW = w + offsetX + size + size;
55.98 - int tmpH = h + offsetY + size + size;
55.99 - // create tmp buffers
55.100 - int[] lineBuf = getTmpIntArray(w);
55.101 - byte[] tmpBuf1 = getTmpByteArray1(tmpW * tmpH);
55.102 - Arrays.fill(tmpBuf1, (byte) 0x00);
55.103 - byte[] tmpBuf2 = getTmpByteArray2(tmpW * tmpH);
55.104 - // extract src image alpha channel and inverse and offset
55.105 - Raster srcRaster = src.getRaster();
55.106 - for (int y = 0; y < h; y++) {
55.107 - int dy = (y + tmpOffY);
55.108 - int offset = dy * tmpW;
55.109 - srcRaster.getDataElements(0, y, w, 1, lineBuf);
55.110 - for (int x = 0; x < w; x++) {
55.111 - int dx = x + tmpOffX;
55.112 - tmpBuf1[offset + dx] = (byte) ((lineBuf[x] & 0xFF000000) >>> 24);
55.113 - }
55.114 - }
55.115 - // blur
55.116 - float[] kernel = EffectUtils.createGaussianKernel(size);
55.117 - EffectUtils.blur(tmpBuf1, tmpBuf2, tmpW, tmpH, kernel, size); // horizontal pass
55.118 - EffectUtils.blur(tmpBuf2, tmpBuf1, tmpH, tmpW, kernel, size);// vertical pass
55.119 - //rescale
55.120 - float spread = Math.min(1 / (1 - (0.01f * this.spread)), 255);
55.121 - for (int i = 0; i < tmpBuf1.length; i++) {
55.122 - int val = (int) (((int) tmpBuf1[i] & 0xFF) * spread);
55.123 - tmpBuf1[i] = (val > 255) ? (byte) 0xFF : (byte) val;
55.124 - }
55.125 - // create color image with shadow color and greyscale image as alpha
55.126 - if (dst == null) dst = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
55.127 - WritableRaster shadowRaster = dst.getRaster();
55.128 - int red = color.getRed(), green = color.getGreen(), blue = color.getBlue();
55.129 - for (int y = 0; y < h; y++) {
55.130 - int srcY = y + tmpOffY;
55.131 - int shadowOffset = (srcY - offsetY) * tmpW;
55.132 - for (int x = 0; x < w; x++) {
55.133 - int srcX = x + tmpOffX;
55.134 - lineBuf[x] = tmpBuf1[shadowOffset + (srcX - offsetX)] << 24 | red << 16 | green << 8 | blue;
55.135 - }
55.136 - shadowRaster.setDataElements(0, y, w, 1, lineBuf);
55.137 - }
55.138 - return dst;
55.139 - }
55.140 -}
56.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/Effect.java Sun Sep 06 23:14:42 2009 -0700
56.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
56.3 @@ -1,153 +0,0 @@
56.4 -/*
56.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
56.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
56.7 - *
56.8 - * This code is free software; you can redistribute it and/or modify it
56.9 - * under the terms of the GNU General Public License version 2 only, as
56.10 - * published by the Free Software Foundation. Sun designates this
56.11 - * particular file as subject to the "Classpath" exception as provided
56.12 - * by Sun in the LICENSE file that accompanied this code.
56.13 - *
56.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
56.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
56.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
56.17 - * version 2 for more details (a copy is included in the LICENSE file that
56.18 - * accompanied this code).
56.19 - *
56.20 - * You should have received a copy of the GNU General Public License version
56.21 - * 2 along with this work; if not, write to the Free Software Foundation,
56.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
56.23 - *
56.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
56.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
56.26 - * have any questions.
56.27 - */
56.28 -package org.jdesktop.swingx.designer.effects;
56.29 -
56.30 -import org.jdesktop.beans.AbstractBean;
56.31 -import org.jdesktop.swingx.designer.BlendingMode;
56.32 -
56.33 -import java.awt.image.BufferedImage;
56.34 -import java.lang.ref.SoftReference;
56.35 -
56.36 -/**
56.37 - * Effect
56.38 - *
56.39 - * @author Created by Jasper Potts (Jun 18, 2007)
56.40 - */
56.41 -public abstract class Effect extends AbstractBean {
56.42 - protected boolean visible = true;
56.43 -
56.44 - public enum EffectType {
56.45 - UNDER, BLENDED, OVER
56.46 - }
56.47 -
56.48 - public boolean isVisible() {
56.49 - return visible;
56.50 - }
56.51 -
56.52 - public void setVisible(boolean visible) {
56.53 - boolean old = isVisible();
56.54 - this.visible = visible;
56.55 - firePropertyChange("visible", old, isVisible());
56.56 - }
56.57 -
56.58 - public String toString() {
56.59 - return getDisplayName();
56.60 - }
56.61 -
56.62 - // =================================================================================================================
56.63 - // Abstract Methods
56.64 -
56.65 - /**
56.66 - * Get the display name for this effect
56.67 - *
56.68 - * @return The user displayable name
56.69 - */
56.70 - public abstract String getDisplayName();
56.71 -
56.72 - /**
56.73 - * Get the type of this effect, one of UNDER,BLENDED,OVER. UNDER means the result of apply effect should be painted
56.74 - * under the src image. BLENDED means the result of apply sffect contains a modified src image so just it should be
56.75 - * painted. OVER means the result of apply effect should be painted over the src image.
56.76 - *
56.77 - * @return The effect type
56.78 - */
56.79 - public abstract EffectType getEffectType();
56.80 -
56.81 - /**
56.82 - * Get the blending mode to use to paint the result effected image if the EffectType is UNDER or OVER.
56.83 - *
56.84 - * @return The blending mode for the effect
56.85 - */
56.86 - public abstract BlendingMode getBlendingMode();
56.87 -
56.88 - /**
56.89 - * Get the opacity to use to paint the result effected image if the EffectType is UNDER or OVER.
56.90 - *
56.91 - * @return The opactity for the effect, 0.0f -> 1.0f
56.92 - */
56.93 - public abstract float getOpacity();
56.94 -
56.95 - /**
56.96 - * Apply the effect to the src image generating the result . The result image may or may not contain the source
56.97 - * image depending on what the effect type is.
56.98 - *
56.99 - * @param src The source image for applying the effect to
56.100 - * @param dst The dstination image to paint effect result into. If this is null then a new image will be created
56.101 - * @param w The width of the src image to apply effect to, this allow the src and dst buffers to be bigger than
56.102 - * the area the need effect applied to it
56.103 - * @param h The height of the src image to apply effect to, this allow the src and dst buffers to be bigger than
56.104 - * the area the need effect applied to it
56.105 - * @return The result of appl
56.106 - */
56.107 - public abstract BufferedImage applyEffect(BufferedImage src, BufferedImage dst, int w, int h);
56.108 -
56.109 - // =================================================================================================================
56.110 - // Static data cache
56.111 -
56.112 - private static SoftReference<int[]> tmpIntArray = null;
56.113 - private static SoftReference<byte[]> tmpByteArray1 = null;
56.114 - private static SoftReference<byte[]> tmpByteArray2 = null;
56.115 - private static SoftReference<byte[]> tmpByteArray3 = null;
56.116 -
56.117 - protected static int[] getTmpIntArray(int size) {
56.118 - int[] tmp;
56.119 - if (tmpIntArray == null || (tmp = tmpIntArray.get()) == null || tmp.length < size) {
56.120 - // create new array
56.121 - tmp = new int[size];
56.122 - tmpIntArray = new SoftReference<int[]>(tmp);
56.123 - }
56.124 - return tmp;
56.125 - }
56.126 -
56.127 - protected static byte[] getTmpByteArray1(int size) {
56.128 - byte[] tmp;
56.129 - if (tmpByteArray1 == null || (tmp = tmpByteArray1.get()) == null || tmp.length < size) {
56.130 - // create new array
56.131 - tmp = new byte[size];
56.132 - tmpByteArray1 = new SoftReference<byte[]>(tmp);
56.133 - }
56.134 - return tmp;
56.135 - }
56.136 -
56.137 - protected static byte[] getTmpByteArray2(int size) {
56.138 - byte[] tmp;
56.139 - if (tmpByteArray2 == null || (tmp = tmpByteArray2.get()) == null || tmp.length < size) {
56.140 - // create new array
56.141 - tmp = new byte[size];
56.142 - tmpByteArray2 = new SoftReference<byte[]>(tmp);
56.143 - }
56.144 - return tmp;
56.145 - }
56.146 -
56.147 - protected static byte[] getTmpByteArray3(int size) {
56.148 - byte[] tmp;
56.149 - if (tmpByteArray3 == null || (tmp = tmpByteArray3.get()) == null || tmp.length < size) {
56.150 - // create new array
56.151 - tmp = new byte[size];
56.152 - tmpByteArray3 = new SoftReference<byte[]>(tmp);
56.153 - }
56.154 - return tmp;
56.155 - }
56.156 -}
57.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/EffectUtils.java Sun Sep 06 23:14:42 2009 -0700
57.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
57.3 @@ -1,99 +0,0 @@
57.4 -/*
57.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
57.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
57.7 - *
57.8 - * This code is free software; you can redistribute it and/or modify it
57.9 - * under the terms of the GNU General Public License version 2 only, as
57.10 - * published by the Free Software Foundation. Sun designates this
57.11 - * particular file as subject to the "Classpath" exception as provided
57.12 - * by Sun in the LICENSE file that accompanied this code.
57.13 - *
57.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
57.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
57.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
57.17 - * version 2 for more details (a copy is included in the LICENSE file that
57.18 - * accompanied this code).
57.19 - *
57.20 - * You should have received a copy of the GNU General Public License version
57.21 - * 2 along with this work; if not, write to the Free Software Foundation,
57.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
57.23 - *
57.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
57.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
57.26 - * have any questions.
57.27 - */
57.28 -package org.jdesktop.swingx.designer.effects;
57.29 -
57.30 -
57.31 -/**
57.32 - * EffectUtils
57.33 - *
57.34 - * @author Created by Jasper Potts (Jun 18, 2007)
57.35 - */
57.36 -public class EffectUtils {
57.37 -
57.38 - /**
57.39 - * <p>Blurs the source pixels into the destination pixels. The force of the blur is specified by the radius which
57.40 - * must be greater than 0.</p> <p>The source and destination pixels arrays are expected to be in the BYTE_GREY
57.41 - * format.</p> <p>After this method is executed, dstPixels contains a transposed and filtered copy of
57.42 - * srcPixels.</p>
57.43 - *
57.44 - * @param srcPixels the source pixels
57.45 - * @param dstPixels the destination pixels
57.46 - * @param width the width of the source picture
57.47 - * @param height the height of the source picture
57.48 - * @param kernel the kernel of the blur effect
57.49 - * @param radius the radius of the blur effect
57.50 - */
57.51 - public static void blur(byte[] srcPixels, byte[] dstPixels,
57.52 - int width, int height,
57.53 - float[] kernel, int radius) {
57.54 - float p;
57.55 - int cp;
57.56 - for (int y = 0; y < height; y++) {
57.57 - int index = y;
57.58 - int offset = y * width;
57.59 - for (int x = 0; x < width; x++) {
57.60 - p = 0.0f;
57.61 - for (int i = -radius; i <= radius; i++) {
57.62 - int subOffset = x + i;
57.63 - if (subOffset < 0 || subOffset >= width) {
57.64 - subOffset = (x + width) % width;
57.65 - }
57.66 - int pixel = srcPixels[offset + subOffset] & 0xFF;
57.67 - float blurFactor = kernel[radius + i];
57.68 - p += blurFactor * pixel;
57.69 - }
57.70 - cp = (int) (p + 0.5f);
57.71 - dstPixels[index] = (byte) (cp > 255 ? 255 : cp);
57.72 - index += height;
57.73 - }
57.74 - }
57.75 - }
57.76 -
57.77 - public static float[] createGaussianKernel(int radius) {
57.78 - if (radius < 1) {
57.79 - throw new IllegalArgumentException("Radius must be >= 1");
57.80 - }
57.81 -
57.82 - float[] data = new float[radius * 2 + 1];
57.83 -
57.84 - float sigma = radius / 3.0f;
57.85 - float twoSigmaSquare = 2.0f * sigma * sigma;
57.86 - float sigmaRoot = (float) Math.sqrt(twoSigmaSquare * Math.PI);
57.87 - float total = 0.0f;
57.88 -
57.89 - for (int i = -radius; i <= radius; i++) {
57.90 - float distance = i * i;
57.91 - int index = i + radius;
57.92 - data[index] = (float) Math.exp(-distance / twoSigmaSquare) / sigmaRoot;
57.93 - total += data[index];
57.94 - }
57.95 -
57.96 - for (int i = 0; i < data.length; i++) {
57.97 - data[i] /= total;
57.98 - }
57.99 -
57.100 - return data;
57.101 - }
57.102 -}
58.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/EffectUtilsTemp.java Sun Sep 06 23:14:42 2009 -0700
58.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
58.3 @@ -1,82 +0,0 @@
58.4 -/*
58.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
58.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
58.7 - *
58.8 - * This code is free software; you can redistribute it and/or modify it
58.9 - * under the terms of the GNU General Public License version 2 only, as
58.10 - * published by the Free Software Foundation. Sun designates this
58.11 - * particular file as subject to the "Classpath" exception as provided
58.12 - * by Sun in the LICENSE file that accompanied this code.
58.13 - *
58.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
58.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
58.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
58.17 - * version 2 for more details (a copy is included in the LICENSE file that
58.18 - * accompanied this code).
58.19 - *
58.20 - * You should have received a copy of the GNU General Public License version
58.21 - * 2 along with this work; if not, write to the Free Software Foundation,
58.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
58.23 - *
58.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
58.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
58.26 - * have any questions.
58.27 - */
58.28 -package org.jdesktop.swingx.designer.effects;
58.29 -
58.30 -import java.awt.Composite;
58.31 -import java.awt.CompositeContext;
58.32 -import java.awt.Graphics2D;
58.33 -import java.awt.RenderingHints;
58.34 -import java.awt.image.BufferedImage;
58.35 -import java.awt.image.ColorModel;
58.36 -import java.awt.image.Raster;
58.37 -import java.awt.image.WritableRaster;
58.38 -
58.39 -/**
58.40 - * EffectUtilsTemp - effect utils methods that are not being used for now but we might want later
58.41 - *
58.42 - * @author Created by Jasper Potts (Jun 18, 2007)
58.43 - */
58.44 -public class EffectUtilsTemp {
58.45 -
58.46 - /**
58.47 - * Extract the alpha channel of a image into new greyscale buffered image
58.48 - *
58.49 - * @param src Must but INT_ARGB buffered image
58.50 - * @return new TYPE_BYTE_GRAY image of just the alpha channel
58.51 - */
58.52 - public static BufferedImage extractAlpha(BufferedImage src) {
58.53 - int w = src.getWidth();
58.54 - int h = src.getHeight();
58.55 - // extract image alpha channel as greyscale image
58.56 - final BufferedImage greyImg = new BufferedImage(w, h, BufferedImage.TYPE_BYTE_GRAY);
58.57 - Graphics2D g2 = greyImg.createGraphics();
58.58 - g2.setComposite(new Composite() {
58.59 - public CompositeContext createContext(ColorModel srcColorModel, ColorModel dstColorModel,
58.60 - RenderingHints hints) {
58.61 - return new CompositeContext() {
58.62 - public void dispose() {}
58.63 -
58.64 - public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
58.65 - int width = Math.min(src.getWidth(), dstIn.getWidth());
58.66 - int height = Math.min(src.getHeight(), dstIn.getHeight());
58.67 - int[] srcPixels = new int[width];
58.68 - byte[] dstPixels = new byte[width];
58.69 - for (int y = 0; y < height; y++) {
58.70 - src.getDataElements(0, y, width, 1, srcPixels);
58.71 - for (int x = 0; x < width; x++) {
58.72 - dstPixels[x] = (byte) ((srcPixels[x] & 0xFF000000) >>> 24);
58.73 - }
58.74 - dstOut.setDataElements(0, y, width, 1, dstPixels);
58.75 - }
58.76 - }
58.77 - };
58.78 - }
58.79 - });
58.80 - g2.drawImage(src, 0, 0, null);
58.81 - g2.dispose();
58.82 - return greyImg;
58.83 - }
58.84 -
58.85 -}
59.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/InnerGlowEffect.java Sun Sep 06 23:14:42 2009 -0700
59.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
59.3 @@ -1,55 +0,0 @@
59.4 -/*
59.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
59.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
59.7 - *
59.8 - * This code is free software; you can redistribute it and/or modify it
59.9 - * under the terms of the GNU General Public License version 2 only, as
59.10 - * published by the Free Software Foundation. Sun designates this
59.11 - * particular file as subject to the "Classpath" exception as provided
59.12 - * by Sun in the LICENSE file that accompanied this code.
59.13 - *
59.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
59.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
59.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
59.17 - * version 2 for more details (a copy is included in the LICENSE file that
59.18 - * accompanied this code).
59.19 - *
59.20 - * You should have received a copy of the GNU General Public License version
59.21 - * 2 along with this work; if not, write to the Free Software Foundation,
59.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
59.23 - *
59.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
59.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
59.26 - * have any questions.
59.27 - */
59.28 -package org.jdesktop.swingx.designer.effects;
59.29 -
59.30 -import org.jdesktop.swingx.designer.paint.Matte;
59.31 -
59.32 -import javax.swing.UIDefaults;
59.33 -import java.awt.Color;
59.34 -
59.35 -/**
59.36 - * InnerGlowEffect
59.37 - *
59.38 - * @author Created by Jasper Potts (Jun 21, 2007)
59.39 - */
59.40 -public class InnerGlowEffect extends InnerShadowEffect {
59.41 -
59.42 - protected InnerGlowEffect() {
59.43 - distance = 0;
59.44 - }
59.45 -
59.46 - public InnerGlowEffect(UIDefaults uiDefaults) {
59.47 - color = new Matte(new Color(255, 255, 211), uiDefaults);
59.48 - }
59.49 -
59.50 - /**
59.51 - * Get the display name for this effect
59.52 - *
59.53 - * @return The user displayable name
59.54 - */
59.55 - public String getDisplayName() {
59.56 - return "Inner Glow";
59.57 - }
59.58 -}
60.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/InnerShadowEffect.java Sun Sep 06 23:14:42 2009 -0700
60.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
60.3 @@ -1,142 +0,0 @@
60.4 -/*
60.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
60.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
60.7 - *
60.8 - * This code is free software; you can redistribute it and/or modify it
60.9 - * under the terms of the GNU General Public License version 2 only, as
60.10 - * published by the Free Software Foundation. Sun designates this
60.11 - * particular file as subject to the "Classpath" exception as provided
60.12 - * by Sun in the LICENSE file that accompanied this code.
60.13 - *
60.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
60.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
60.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
60.17 - * version 2 for more details (a copy is included in the LICENSE file that
60.18 - * accompanied this code).
60.19 - *
60.20 - * You should have received a copy of the GNU General Public License version
60.21 - * 2 along with this work; if not, write to the Free Software Foundation,
60.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
60.23 - *
60.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
60.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
60.26 - * have any questions.
60.27 - */
60.28 -package org.jdesktop.swingx.designer.effects;
60.29 -
60.30 -import org.jdesktop.swingx.designer.paint.Matte;
60.31 -
60.32 -import javax.swing.UIDefaults;
60.33 -import java.awt.Color;
60.34 -import java.awt.image.BufferedImage;
60.35 -import java.awt.image.Raster;
60.36 -import java.awt.image.WritableRaster;
60.37 -import java.util.Arrays;
60.38 -
60.39 -/**
60.40 - * InnerShadowEffect
60.41 - *
60.42 - * @author Created by Jasper Potts (Jun 18, 2007)
60.43 - */
60.44 -public class InnerShadowEffect extends ShadowEffect {
60.45 -
60.46 - protected InnerShadowEffect() {}
60.47 -
60.48 - ;
60.49 -
60.50 - public InnerShadowEffect(UIDefaults uiDefaults) {
60.51 - color = new Matte(Color.BLACK, uiDefaults);
60.52 - }
60.53 -
60.54 - // =================================================================================================================
60.55 - // Effect Methods
60.56 -
60.57 - /**
60.58 - * Get the display name for this effect
60.59 - *
60.60 - * @return The user displayable name
60.61 - */
60.62 - public String getDisplayName() {
60.63 - return "Inner Shadow";
60.64 - }
60.65 -
60.66 - /**
60.67 - * Get the type of this effect, one of UNDER,BLENDED,OVER. UNDER means the result of apply effect should be painted
60.68 - * under the src image. BLENDED means the result of apply sffect contains a modified src image so just it should be
60.69 - * painted. OVER means the result of apply effect should be painted over the src image.
60.70 - *
60.71 - * @return The effect type
60.72 - */
60.73 - public Effect.EffectType getEffectType() {
60.74 - return Effect.EffectType.OVER;
60.75 - }
60.76 -
60.77 - /**
60.78 - * Apply the effect to the src image generating the result . The result image may or may not contain the source
60.79 - * image depending on what the effect type is.
60.80 - *
60.81 - * @param src The source image for applying the effect to
60.82 - * @param dst The dstination image to paint effect result into. If this is null then a new image will be created
60.83 - * @param w The width of the src image to apply effect to, this allow the src and dst buffers to be bigger than
60.84 - * the area the need effect applied to it
60.85 - * @param h The height of the src image to apply effect to, this allow the src and dst buffers to be bigger than
60.86 - * the area the need effect applied to it
60.87 - * @return The result of appl
60.88 - */
60.89 - public BufferedImage applyEffect(BufferedImage src, BufferedImage dst, int w, int h) {
60.90 - // calculate offset
60.91 - double trangleAngle = Math.toRadians(angle - 90);
60.92 - int offsetX = (int) (Math.sin(trangleAngle) * distance);
60.93 - int offsetY = (int) (Math.cos(trangleAngle) * distance);
60.94 - // clac expanded size
60.95 - int tmpOffX = offsetX + size;
60.96 - int tmpOffY = offsetY + size;
60.97 - int tmpW = w + offsetX + size + size;
60.98 - int tmpH = h + offsetY + size + size;
60.99 - // create tmp buffers
60.100 - int[] lineBuf = getTmpIntArray(w);
60.101 - byte[] srcAlphaBuf = getTmpByteArray1(tmpW * tmpH);
60.102 - Arrays.fill(srcAlphaBuf, (byte) 0xFF);
60.103 - byte[] tmpBuf1 = getTmpByteArray2(tmpW * tmpH);
60.104 - byte[] tmpBuf2 = getTmpByteArray3(tmpW * tmpH);
60.105 - // extract src image alpha channel and inverse and offset
60.106 - Raster srcRaster = src.getRaster();
60.107 - for (int y = 0; y < h; y++) {
60.108 - int dy = (y + tmpOffY);
60.109 - int offset = dy * tmpW;
60.110 - srcRaster.getDataElements(0, y, w, 1, lineBuf);
60.111 - for (int x = 0; x < w; x++) {
60.112 - int dx = x + tmpOffX;
60.113 - srcAlphaBuf[offset + dx] = (byte) ((255 - ((lineBuf[x] & 0xFF000000) >>> 24)) & 0xFF);
60.114 - }
60.115 - }
60.116 - // blur
60.117 - float[] kernel = EffectUtils.createGaussianKernel(size * 2);
60.118 - EffectUtils.blur(srcAlphaBuf, tmpBuf2, tmpW, tmpH, kernel, size * 2); // horizontal pass
60.119 - EffectUtils.blur(tmpBuf2, tmpBuf1, tmpH, tmpW, kernel, size * 2);// vertical pass
60.120 - //rescale
60.121 - float spread = Math.min(1 / (1 - (0.01f * this.spread)), 255);
60.122 - for (int i = 0; i < tmpBuf1.length; i++) {
60.123 - int val = (int) (((int) tmpBuf1[i] & 0xFF) * spread);
60.124 - tmpBuf1[i] = (val > 255) ? (byte) 0xFF : (byte) val;
60.125 - }
60.126 - // create color image with shadow color and greyscale image as alpha
60.127 - if (dst == null) dst = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
60.128 - WritableRaster shadowRaster = dst.getRaster();
60.129 - int red = color.getRed(), green = color.getGreen(), blue = color.getBlue();
60.130 - for (int y = 0; y < h; y++) {
60.131 - int srcY = y + tmpOffY;
60.132 - int offset = srcY * tmpW;
60.133 - int shadowOffset = (srcY - offsetY) * tmpW;
60.134 - for (int x = 0; x < w; x++) {
60.135 - int srcX = x + tmpOffX;
60.136 - int origianlAlphaVal = 255 - ((int) srcAlphaBuf[offset + srcX] & 0xFF);
60.137 - int shadowVal = (int) tmpBuf1[shadowOffset + (srcX - offsetX)] & 0xFF;
60.138 - int alphaVal = Math.min(origianlAlphaVal, shadowVal);
60.139 - lineBuf[x] = ((byte) alphaVal & 0xFF) << 24 | red << 16 | green << 8 | blue;
60.140 - }
60.141 - shadowRaster.setDataElements(0, y, w, 1, lineBuf);
60.142 - }
60.143 - return dst;
60.144 - }
60.145 -}
61.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/OuterGlowEffect.java Sun Sep 06 23:14:42 2009 -0700
61.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
61.3 @@ -1,55 +0,0 @@
61.4 -/*
61.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
61.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
61.7 - *
61.8 - * This code is free software; you can redistribute it and/or modify it
61.9 - * under the terms of the GNU General Public License version 2 only, as
61.10 - * published by the Free Software Foundation. Sun designates this
61.11 - * particular file as subject to the "Classpath" exception as provided
61.12 - * by Sun in the LICENSE file that accompanied this code.
61.13 - *
61.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
61.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
61.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
61.17 - * version 2 for more details (a copy is included in the LICENSE file that
61.18 - * accompanied this code).
61.19 - *
61.20 - * You should have received a copy of the GNU General Public License version
61.21 - * 2 along with this work; if not, write to the Free Software Foundation,
61.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
61.23 - *
61.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
61.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
61.26 - * have any questions.
61.27 - */
61.28 -package org.jdesktop.swingx.designer.effects;
61.29 -
61.30 -import org.jdesktop.swingx.designer.paint.Matte;
61.31 -
61.32 -import javax.swing.UIDefaults;
61.33 -import java.awt.Color;
61.34 -
61.35 -/**
61.36 - * OuterGlowEffect
61.37 - *
61.38 - * @author Created by Jasper Potts (Jun 21, 2007)
61.39 - */
61.40 -public class OuterGlowEffect extends DropShadowEffect {
61.41 -
61.42 - protected OuterGlowEffect() {
61.43 - distance = 0;
61.44 - }
61.45 -
61.46 - public OuterGlowEffect(UIDefaults uiDefaults) {
61.47 - color = new Matte(new Color(255, 255, 211), uiDefaults);
61.48 - }
61.49 -
61.50 - /**
61.51 - * Get the display name for this effect
61.52 - *
61.53 - * @return The user displayable name
61.54 - */
61.55 - public String getDisplayName() {
61.56 - return "Outer Glow";
61.57 - }
61.58 -}
62.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/ShadowEffect.java Sun Sep 06 23:14:42 2009 -0700
62.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
62.3 @@ -1,132 +0,0 @@
62.4 -/*
62.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
62.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
62.7 - *
62.8 - * This code is free software; you can redistribute it and/or modify it
62.9 - * under the terms of the GNU General Public License version 2 only, as
62.10 - * published by the Free Software Foundation. Sun designates this
62.11 - * particular file as subject to the "Classpath" exception as provided
62.12 - * by Sun in the LICENSE file that accompanied this code.
62.13 - *
62.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
62.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
62.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
62.17 - * version 2 for more details (a copy is included in the LICENSE file that
62.18 - * accompanied this code).
62.19 - *
62.20 - * You should have received a copy of the GNU General Public License version
62.21 - * 2 along with this work; if not, write to the Free Software Foundation,
62.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
62.23 - *
62.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
62.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
62.26 - * have any questions.
62.27 - */
62.28 -package org.jdesktop.swingx.designer.effects;
62.29 -
62.30 -import org.jdesktop.swingx.designer.BlendingMode;
62.31 -import org.jdesktop.swingx.designer.paint.Matte;
62.32 -
62.33 -import javax.swing.UIDefaults;
62.34 -import java.awt.Color;
62.35 -
62.36 -/**
62.37 - * ShadowEffect - base class with all the standard properties for shadow effects
62.38 - *
62.39 - * @author Created by Jasper Potts (Jun 18, 2007)
62.40 - */
62.41 -public abstract class ShadowEffect extends Effect {
62.42 - protected Matte color;
62.43 - protected BlendingMode blendingMode = BlendingMode.NORMAL;
62.44 - /** Opacity a float 0-1 for percentage */
62.45 - protected float opacity = 0.75f;
62.46 - /** Angle in degrees between 0-360 */
62.47 - protected int angle = 135;
62.48 - /** Distance in pixels */
62.49 - protected int distance = 5;
62.50 - /** The shadow spread between 0-100 % */
62.51 - protected int spread = 0;
62.52 - /** Size in pixels */
62.53 - protected int size = 5;
62.54 -
62.55 - protected ShadowEffect() {}
62.56 -
62.57 - ;
62.58 -
62.59 - public ShadowEffect(UIDefaults uiDefaults) {
62.60 - color = new Matte(Color.BLACK, uiDefaults);
62.61 - }
62.62 -
62.63 - // =================================================================================================================
62.64 - // Bean methods
62.65 -
62.66 - public Matte getColor() {
62.67 - return color;
62.68 - }
62.69 -
62.70 - public void setColor(Matte color) {
62.71 - Matte old = getColor();
62.72 - this.color = color;
62.73 - firePropertyChange("color", old, getColor());
62.74 - }
62.75 -
62.76 - public BlendingMode getBlendingMode() {
62.77 - return blendingMode;
62.78 - }
62.79 -
62.80 - public void setBlendingMode(BlendingMode blendingMode) {
62.81 - BlendingMode old = getBlendingMode();
62.82 - this.blendingMode = blendingMode;
62.83 - firePropertyChange("blendingMode", old, getBlendingMode());
62.84 - }
62.85 -
62.86 - public float getOpacity() {
62.87 - return opacity;
62.88 - }
62.89 -
62.90 - public void setOpacity(float opacity) {
62.91 - float old = getOpacity();
62.92 - this.opacity = opacity;
62.93 - firePropertyChange("opacity", old, getOpacity());
62.94 - }
62.95 -
62.96 - public int getAngle() {
62.97 - return angle;
62.98 - }
62.99 -
62.100 - public void setAngle(int angle) {
62.101 - int old = getAngle();
62.102 - this.angle = angle;
62.103 - firePropertyChange("angle", old, getAngle());
62.104 - }
62.105 -
62.106 - public int getDistance() {
62.107 - return distance;
62.108 - }
62.109 -
62.110 - public void setDistance(int distance) {
62.111 - int old = getDistance();
62.112 - this.distance = distance;
62.113 - firePropertyChange("distance", old, getDistance());
62.114 - }
62.115 -
62.116 - public int getSpread() {
62.117 - return spread;
62.118 - }
62.119 -
62.120 - public void setSpread(int spread) {
62.121 - int old = getSpread();
62.122 - this.spread = spread;
62.123 - firePropertyChange("spread", old, getSpread());
62.124 - }
62.125 -
62.126 - public int getSize() {
62.127 - return size;
62.128 - }
62.129 -
62.130 - public void setSize(int size) {
62.131 - int old = getSize();
62.132 - this.size = size;
62.133 - firePropertyChange("size", old, getSize());
62.134 - }
62.135 -}
63.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/font/Typeface.java Sun Sep 06 23:14:42 2009 -0700
63.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
63.3 @@ -1,484 +0,0 @@
63.4 -/*
63.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
63.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
63.7 - *
63.8 - * This code is free software; you can redistribute it and/or modify it
63.9 - * under the terms of the GNU General Public License version 2 only, as
63.10 - * published by the Free Software Foundation. Sun designates this
63.11 - * particular file as subject to the "Classpath" exception as provided
63.12 - * by Sun in the LICENSE file that accompanied this code.
63.13 - *
63.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
63.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
63.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
63.17 - * version 2 for more details (a copy is included in the LICENSE file that
63.18 - * accompanied this code).
63.19 - *
63.20 - * You should have received a copy of the GNU General Public License version
63.21 - * 2 along with this work; if not, write to the Free Software Foundation,
63.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
63.23 - *
63.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
63.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
63.26 - * have any questions.
63.27 - */
63.28 -package org.jdesktop.swingx.designer.font;
63.29 -
63.30 -import java.awt.Font;
63.31 -import java.beans.PropertyChangeEvent;
63.32 -import java.beans.PropertyChangeListener;
63.33 -import javax.swing.UIDefaults;
63.34 -import org.jdesktop.beans.AbstractBean;
63.35 -import org.jdesktop.swingx.designer.utils.HasUIDefaults;
63.36 -import org.jibx.runtime.IUnmarshallingContext;
63.37 -
63.38 -/**
63.39 - * I don't think the name is technically correct (ie: a typeface is not a font),
63.40 - * but I wanted something besides "font" so, here it is.
63.41 - *
63.42 - * This is a mutable font, much like Matte is a mutable color. Also like Matte,
63.43 - * Typeface can be derived.
63.44 - *
63.45 - * @author rbair
63.46 - */
63.47 -public class Typeface extends AbstractBean {
63.48 - //specifies whether to derive bold, or italic.
63.49 - //Default means, get my value from my parent.
63.50 - //Off means, leave bold/italic off.
63.51 - //On means, make bold/italic on.
63.52 - public enum DeriveStyle { Default, Off, On }
63.53 -
63.54 - private String uiDefaultParentName;
63.55 - /** This is a local UIDefaults that contains all the UIDefaults in the Model. */
63.56 - private transient UIDefaults uiDefaults = new UIDefaults();
63.57 - private PropertyChangeListener uiDefaultsChangeListener = new PropertyChangeListener() {
63.58 - public void propertyChange(PropertyChangeEvent evt) {
63.59 - if (uiDefaultParentName != null && uiDefaultParentName.equals(evt.getPropertyName())) {
63.60 - updateFontFromOffsets();
63.61 - }
63.62 - }
63.63 - };
63.64 -
63.65 - /**
63.66 - * The name of the font. If uiDefaultParentName is specified, then this name
63.67 - * will be set to be equal to the name of the parent font.
63.68 - */
63.69 - private String name;
63.70 - /**
63.71 - * The size of the font. If uiDefaultParentName is set, then this value is
63.72 - * updated to reflect the size of the parent font * the sizeOffset.
63.73 - */
63.74 - private int size;
63.75 -
63.76 - //this field is not publically accessible. Rather, it is updated based on
63.77 - //"bold" and "italic" as necessary.
63.78 - private int style = Font.PLAIN;
63.79 - private DeriveStyle bold = DeriveStyle.Default;
63.80 - private DeriveStyle italic = DeriveStyle.Default;
63.81 -
63.82 - /**
63.83 - * The size offset. Only used if uiDefaultParentName is specified. This offset
63.84 - * will be multiplied with the parent font's size to determine the size of this
63.85 - * typeface. The offset is specified as a percentage, either positive or negative.
63.86 - *
63.87 - * The reason a percentage was used, was so that things would look correctly
63.88 - * when scaled, such as with high DPI situations.
63.89 - */
63.90 - private float sizeOffset;
63.91 -
63.92 - /**
63.93 - * Create a new Typeface. Note that, without specifying the uiDefaults,
63.94 - * you cannot have font derivation. Thus, this constructor should never
63.95 - * be called, except for the XML binding stuff.
63.96 - */
63.97 - public Typeface() { }
63.98 -
63.99 - /**
63.100 - * Creates a new Typeface.
63.101 - *
63.102 - * @param f The font from which to get the font name, size, and style to use
63.103 - * to initialize this typeface. Note that this font is not used as a parent
63.104 - * font for derivation purposes. Rather, it is used as a source from which to
63.105 - * copy initial settings.
63.106 - *
63.107 - * @param uiDefaults The uiDefaults to use for font derivation purposes.
63.108 - * When the uiDefaultParentName is specified, then this Typeface will inspect
63.109 - * the given UIDefaults for that parent <em>font</em>. Note that the UIDefaults
63.110 - * should be populated with a font, and not with a typeface.
63.111 - */
63.112 - public Typeface(Font f, UIDefaults uiDefaults) {
63.113 - if (f != null) {
63.114 - this.name = f.getName();
63.115 - this.size = f.getSize();
63.116 - this.style = f.getStyle();
63.117 - }
63.118 - setUiDefaults(uiDefaults);
63.119 - }
63.120 -
63.121 - // =================================================================================================================
63.122 - // JIBX Methods
63.123 -
63.124 - /**
63.125 - * Called by JIBX after all fields have been set
63.126 - *
63.127 - * @param context The JIBX Unmarshalling Context
63.128 - */
63.129 - protected void postSet(IUnmarshallingContext context) {
63.130 - // walk up till we get synth model
63.131 - for (int i = 0; i < context.getStackDepth(); i++) {
63.132 - if (context.getStackObject(i) instanceof HasUIDefaults) {
63.133 - UIDefaults uiDefaults = ((HasUIDefaults) context.getStackObject(i)).getUiDefaults();
63.134 - if (uiDefaults != null) {
63.135 - setUiDefaults(uiDefaults);
63.136 - break;
63.137 - }
63.138 - }
63.139 - }
63.140 - }
63.141 -
63.142 - // =================================================================================================================
63.143 - // Typeface methods
63.144 -
63.145 - /**
63.146 - * Is the Typeface an absolute Font not derived from a parent ui default
63.147 - *
63.148 - * @return <code>true</code> if this is a absolute not uidefault derived font
63.149 - */
63.150 - public boolean isAbsolute() {
63.151 - return uiDefaultParentName == null;
63.152 - }
63.153 -
63.154 - /**
63.155 - * Set all properties of this Typeface to be the same as <code>src</code> and fire all the change events
63.156 - *
63.157 - * @param src the Typeface to copy properties from
63.158 - */
63.159 - public void copy(Typeface src) {
63.160 - // keep old values
63.161 - Font oldFont = getFont();
63.162 - String oldParentName = uiDefaultParentName;
63.163 - String oldName = name;
63.164 - int oldSize = size;
63.165 - float oldSizeOffset = sizeOffset;
63.166 - DeriveStyle oldBold = bold, oldItalic = italic;
63.167 -
63.168 - style = src.style;
63.169 -
63.170 - //Note, I don't just call the setters here, because I want to make
63.171 - //sure the "font" PCE is only fired once, at the end.
63.172 - name = src.name;
63.173 - firePropertyChange("name", oldName, name);
63.174 - size = src.size;
63.175 - firePropertyChange("size", oldSize, size);
63.176 - bold = src.bold;
63.177 - firePropertyChange("bold", oldBold, bold);
63.178 - italic = src.italic;
63.179 - firePropertyChange("italic", oldItalic, italic);
63.180 - sizeOffset = src.sizeOffset;
63.181 - firePropertyChange("sizeOffset", oldSizeOffset, sizeOffset);
63.182 - uiDefaultParentName = src.uiDefaultParentName;
63.183 - firePropertyChange("uiDefaultParentName", oldParentName, uiDefaultParentName);
63.184 - setUiDefaults(src.uiDefaults);
63.185 - firePropertyChange("font", oldFont, getFont());
63.186 - }
63.187 -
63.188 - // =================================================================================================================
63.189 - // Bean Methods
63.190 -
63.191 - /**
63.192 - * Get the local UIDefaults that contains all the UIDefaults in the Model.
63.193 - *
63.194 - * @return The UIDefaults for the model that contains this Typeface, can be null if this Typeface is not part of a bigger
63.195 - * model
63.196 - */
63.197 - public UIDefaults getUiDefaults() {
63.198 - return uiDefaults;
63.199 - }
63.200 -
63.201 - /**
63.202 - * Set the local UIDefaults that contains all the UIDefaults in the Model.
63.203 - *
63.204 - * @param uiDefaults The UIDefaults for the model that contains this Typeface, can be null if this Typeface is not part of
63.205 - * a bigger model
63.206 - */
63.207 - public void setUiDefaults(UIDefaults uiDefaults) {
63.208 - if (uiDefaults != this.uiDefaults) {
63.209 - UIDefaults old = getUiDefaults();
63.210 - if (old != null) old.removePropertyChangeListener(uiDefaultsChangeListener);
63.211 - this.uiDefaults = uiDefaults;
63.212 - if (uiDefaults != null) this.uiDefaults.addPropertyChangeListener(uiDefaultsChangeListener);
63.213 - firePropertyChange("uiDefaults", old, getUiDefaults());
63.214 - }
63.215 - }
63.216 -
63.217 - /**
63.218 - * Get the name if the uidefault font that is the parent that this Typeface is derived from. If null then this is a
63.219 - * absolute font.
63.220 - *
63.221 - * @return Parent font ui default name
63.222 - */
63.223 - public String getUiDefaultParentName() {
63.224 - return uiDefaultParentName;
63.225 - }
63.226 -
63.227 - /**
63.228 - * Set the name if the uidefault font that is the parent that this Typeface is derived from. If null then this is a
63.229 - * absolute font.
63.230 - *
63.231 - * @param uiDefaultParentName Parent font ui default name
63.232 - */
63.233 - public void setUiDefaultParentName(String uiDefaultParentName) {
63.234 - String old = getUiDefaultParentName();
63.235 - this.uiDefaultParentName = uiDefaultParentName;
63.236 - firePropertyChange("uiDefaultParentName", old, getUiDefaultParentName());
63.237 - if (isAbsolute()) {
63.238 - // reset offsets
63.239 - float oldSizeOffset = sizeOffset;
63.240 - sizeOffset = 0;
63.241 - firePropertyChange("sizeOffset", oldSizeOffset, sizeOffset);
63.242 - } else {
63.243 - updateFontFromOffsets();
63.244 - }
63.245 - }
63.246 -
63.247 - /**
63.248 - * @return Gets the name of the font
63.249 - */
63.250 - public final String getName() {
63.251 - return name;
63.252 - }
63.253 -
63.254 - /**
63.255 - * Sets the name of the font. This method call <em>only</em> works if
63.256 - * <code>isAbsolute</code> returns true. Otherwise, it is ignored.
63.257 - * @param name the name of the font
63.258 - */
63.259 - public void setName(String name) {
63.260 - if (isAbsolute()) {
63.261 - String old = this.name;
63.262 - Font oldF = getFont();
63.263 - this.name = name;
63.264 - firePropertyChange("name", old, this.name);
63.265 - firePropertyChange("font", oldF, getFont());
63.266 - }
63.267 - }
63.268 -
63.269 - /**
63.270 - * @return gets the size of the font.
63.271 - */
63.272 - public final int getSize() {
63.273 - return size;
63.274 - }
63.275 -
63.276 - /**
63.277 - * <p>Sets the size of the font. THis method call will work whether
63.278 - * <code>isAbsolute</code> returns true or false. If this is an absolute
63.279 - * typeface, then the size is set directly. Otherwise, if this is a
63.280 - * derived typeface, then the sizeOffset will be updated to reflect the
63.281 - * proper offset based on this size, and the size of the parent font.</p>
63.282 - *
63.283 - * <p>For example, if the parent font's size was 12, and the sizeOffset was
63.284 - * -2 (thus yielding as size on this typeface of 10), and you call setSize
63.285 - * passing in "14" as the size, then the sizeOffset will be updated to be
63.286 - * equal to "2".</p>
63.287 - *
63.288 - * @param size the new size for this typeface.
63.289 - */
63.290 - public void setSize(int size) {
63.291 - int old = this.size;
63.292 - Font oldF = getFont();
63.293 - this.size = size;
63.294 - firePropertyChange("size", old, this.size);
63.295 - firePropertyChange("font", oldF, getFont());
63.296 - updateOffsetsFromFont();
63.297 - }
63.298 -
63.299 - /**
63.300 - * @return the size offset
63.301 - */
63.302 - public final float getSizeOffset() {
63.303 - return sizeOffset;
63.304 - }
63.305 -
63.306 - /**
63.307 - * Sets the percentage by which the size of this font should be different
63.308 - * from its parent font. This property is kept in synch with the size property.
63.309 - *
63.310 - * @param sizeOffset the size offset. May be any float. The value "1" means,
63.311 - * 100%. -1 means "-100%". 2 means "200%", and so on.
63.312 - */
63.313 - public void setSizeOffset(float sizeOffset) {
63.314 - float old = this.sizeOffset;
63.315 - Font oldF = getFont();
63.316 - this.sizeOffset = sizeOffset;
63.317 - firePropertyChange("sizeOffset", old, this.sizeOffset);
63.318 - firePropertyChange("font", oldF, getFont());
63.319 - updateFontFromOffsets();
63.320 - }
63.321 -
63.322 - public DeriveStyle getBold() {
63.323 - return bold;
63.324 - }
63.325 -
63.326 - public void setBold(DeriveStyle bold) {
63.327 - DeriveStyle old = this.bold;
63.328 - this.bold = bold == null ? DeriveStyle.Default : bold;
63.329 - firePropertyChange("bold", old, this.bold);
63.330 - updateFontFromOffsets();
63.331 - }
63.332 -
63.333 - public DeriveStyle getItalic() {
63.334 - return italic;
63.335 - }
63.336 -
63.337 - public void setItalic(DeriveStyle italic) {
63.338 - DeriveStyle old = this.italic;
63.339 - this.italic = italic == null ? DeriveStyle.Default : italic;
63.340 - firePropertyChange("italic", old, this.italic);
63.341 - updateFontFromOffsets();
63.342 - }
63.343 -
63.344 - /**
63.345 - * @return whether or not the font represented by this typeface is supported
63.346 - * on this operating system platform.
63.347 - */
63.348 - public boolean isFontSupported() {
63.349 - return true;//Font.getFont(name) != null;
63.350 - }
63.351 -
63.352 - /**
63.353 - * @return Gets the font associated with this Typeface. If font derivation is
63.354 - * being used, then the Font returned is the result of that derivation.
63.355 - */
63.356 - public Font getFont() {
63.357 - return new Font(name, style, size);
63.358 - }
63.359 -
63.360 - /**
63.361 - * Sets the font from which this Typeface should extract the font name, style,
63.362 - * and size. If font derivation is being used, then the font name will be ignored,
63.363 - * the style will be used (and always override the parent font), and the size
63.364 - * will be set and the sizeOffset updated appropriately.
63.365 - *
63.366 - * @param f the Font
63.367 - */
63.368 - public void setFont(Font f) {
63.369 - Font oldFont = getFont();
63.370 - String oldName = name;
63.371 - int oldSize = size;
63.372 - DeriveStyle oldBold = bold, oldItalic = italic;
63.373 - name = f.getName();
63.374 - size = f.getSize();
63.375 - style = f.getStyle();
63.376 - updateOffsetsFromFont();
63.377 - firePropertyChange("name", oldName, name);
63.378 - firePropertyChange("size", oldSize, size);
63.379 - firePropertyChange("bold", oldBold, bold);
63.380 - firePropertyChange("italic", oldItalic, italic);
63.381 - firePropertyChange("font", oldFont, getFont());
63.382 - }
63.383 -
63.384 - /**
63.385 - * @inheritDoc
63.386 - *
63.387 - * @return A formatted string representing this Typeface. This String should
63.388 - * not be considered public API, as it may change in a future release.
63.389 - */
63.390 - @Override public String toString() {
63.391 - Font f = getFont();
63.392 - String strStyle;
63.393 - if (f.isBold()) {
63.394 - strStyle = f.isItalic() ? "bolditalic" : "bold";
63.395 - } else {
63.396 - strStyle = f.isItalic() ? "italic" : "plain";
63.397 - }
63.398 -
63.399 - if (isAbsolute()) {
63.400 - return Typeface.class.getName() + "[name=" + name + ", size=" + size + ", style=" + strStyle + "]";
63.401 - } else {
63.402 - return Typeface.class.getName() + "[base=" + uiDefaultParentName +
63.403 - ", name=" + name + ", size=" + size + "(offset " + sizeOffset + ")" +
63.404 - ", style=" + strStyle + "]";
63.405 - }
63.406 - }
63.407 -
63.408 - @Override public boolean equals(Object o) {
63.409 - if (this == o) return true;
63.410 - if (o == null || getClass() != o.getClass()) return false;
63.411 - Typeface typeface = (Typeface) o;
63.412 - if (!typeface.name.equals(name)) return false;
63.413 - if (size != typeface.size) return false;
63.414 - if (bold != typeface.bold) return false;
63.415 - if (italic != typeface.italic) return false;
63.416 - if (sizeOffset != typeface.sizeOffset) return false;
63.417 - if (uiDefaultParentName != null ? !uiDefaultParentName.equals(typeface.uiDefaultParentName) :
63.418 - typeface.uiDefaultParentName != null) return false;
63.419 - return true;
63.420 - }
63.421 -
63.422 - @Override public int hashCode() {
63.423 - int result;
63.424 - result = name.hashCode();
63.425 - result = 31 * result + size;
63.426 - result = 31 * result + bold.ordinal();
63.427 - result = 31 * result + italic.ordinal();
63.428 - result = 31 * result + (int)(sizeOffset*100);
63.429 - result = 31 * result + (uiDefaultParentName != null ? uiDefaultParentName.hashCode() : 0);
63.430 - return result;
63.431 - }
63.432 -
63.433 - @Override public Typeface clone() {
63.434 - Typeface clone = new Typeface();
63.435 - clone.name = name;
63.436 - clone.size = size;
63.437 - clone.style = style;
63.438 - clone.bold = bold;
63.439 - clone.italic = italic;
63.440 - clone.sizeOffset = sizeOffset;
63.441 - clone.uiDefaultParentName = uiDefaultParentName;
63.442 - clone.setUiDefaults(uiDefaults);
63.443 - return clone;
63.444 - }
63.445 -
63.446 - // =================================================================================================================
63.447 - // Private Helper Methods
63.448 -
63.449 - private void updateOffsetsFromFont() {
63.450 - if (!isAbsolute()) {
63.451 - float oldSizeOffset = sizeOffset;
63.452 - Font parentFont = uiDefaults.getFont(uiDefaultParentName);
63.453 - if (parentFont != null) {
63.454 - float s = size;
63.455 - float p = parentFont.getSize();
63.456 - sizeOffset = (s/p) - 1f;
63.457 - firePropertyChange("sizeOffset", oldSizeOffset, sizeOffset);
63.458 - }
63.459 - }
63.460 - }
63.461 -
63.462 - private void updateFontFromOffsets() {
63.463 - if (!isAbsolute()) {
63.464 - Font oldFont = getFont();
63.465 - // get parent font data
63.466 - Font parentFont = uiDefaults.getFont(uiDefaultParentName);
63.467 - if (parentFont != null) {
63.468 - String oldName = name;
63.469 - int oldSize = size;
63.470 -
63.471 - name = parentFont.getName();
63.472 - size = Math.round(parentFont.getSize() * (1f + sizeOffset));
63.473 -
63.474 - boolean isBold = (bold == DeriveStyle.Default && parentFont.isBold()) || bold == DeriveStyle.On;
63.475 - boolean isItalic = (italic == DeriveStyle.Default && parentFont.isItalic()) || italic == DeriveStyle.On;
63.476 - style = Font.PLAIN;
63.477 - if (isBold) style = style | Font.BOLD;
63.478 - if (isItalic) style = style | Font.ITALIC;
63.479 -
63.480 - // update fire events
63.481 - firePropertyChange("name", oldName, name);
63.482 - firePropertyChange("size", oldSize, size);
63.483 - firePropertyChange("font", oldFont, getFont());
63.484 - }
63.485 - }
63.486 - }
63.487 -}
64.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/jibxhelpers/CanvasMapper.java Sun Sep 06 23:14:42 2009 -0700
64.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
64.3 @@ -1,123 +0,0 @@
64.4 -/*
64.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
64.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
64.7 - *
64.8 - * This code is free software; you can redistribute it and/or modify it
64.9 - * under the terms of the GNU General Public License version 2 only, as
64.10 - * published by the Free Software Foundation. Sun designates this
64.11 - * particular file as subject to the "Classpath" exception as provided
64.12 - * by Sun in the LICENSE file that accompanied this code.
64.13 - *
64.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
64.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
64.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
64.17 - * version 2 for more details (a copy is included in the LICENSE file that
64.18 - * accompanied this code).
64.19 - *
64.20 - * You should have received a copy of the GNU General Public License version
64.21 - * 2 along with this work; if not, write to the Free Software Foundation,
64.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
64.23 - *
64.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
64.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
64.26 - * have any questions.
64.27 - */
64.28 -package org.jdesktop.swingx.designer.jibxhelpers;
64.29 -
64.30 -import org.jdesktop.swingx.designer.Canvas;
64.31 -import org.jdesktop.swingx.designer.utils.HasPath;
64.32 -import org.jdesktop.swingx.designer.utils.HasResources;
64.33 -import org.jdesktop.swingx.designer.utils.HasUIDefaults;
64.34 -import org.jibx.runtime.BindingDirectory;
64.35 -import org.jibx.runtime.IBindingFactory;
64.36 -import org.jibx.runtime.IMarshallable;
64.37 -import org.jibx.runtime.IMarshaller;
64.38 -import org.jibx.runtime.IMarshallingContext;
64.39 -import org.jibx.runtime.IUnmarshaller;
64.40 -import org.jibx.runtime.IUnmarshallingContext;
64.41 -import org.jibx.runtime.JiBXException;
64.42 -import org.jibx.runtime.impl.MarshallingContext;
64.43 -import org.jibx.runtime.impl.UnmarshallingContext;
64.44 -
64.45 -import javax.swing.UIDefaults;
64.46 -import java.io.File;
64.47 -
64.48 -/**
64.49 - * CanvasMapper
64.50 - *
64.51 - * @author Created by Jasper Potts (Jun 12, 2007)
64.52 - */
64.53 -public class CanvasMapper implements IMarshaller, IUnmarshaller {
64.54 - private static final String ELEMENT_NAME = "canvas";
64.55 - private IBindingFactory bindingFactory;
64.56 -
64.57 -
64.58 - public CanvasMapper() {
64.59 - try {
64.60 - bindingFactory = BindingDirectory.getFactory(Canvas.class);
64.61 - } catch (JiBXException e) {
64.62 - e.printStackTrace();
64.63 - }
64.64 - }
64.65 -
64.66 - public boolean isExtension(int i) {
64.67 - return false;
64.68 - }
64.69 -
64.70 - public boolean isPresent(IUnmarshallingContext iUnmarshallingContext) throws JiBXException {
64.71 - return iUnmarshallingContext.isAt(null, ELEMENT_NAME);
64.72 - }
64.73 -
64.74 - public void marshal(Object object, IMarshallingContext iMarshallingContext) throws JiBXException {
64.75 - if (!(object instanceof Canvas)) {
64.76 - throw new JiBXException("Invalid object type for marshaller");
64.77 - } else if (!(iMarshallingContext instanceof MarshallingContext)) {
64.78 - throw new JiBXException("Invalid object type for marshaller");
64.79 - } else {
64.80 - // version found, create marshaller for the associated binding
64.81 -// IBindingFactory bindingFactory = BindingDirectory.getFactory(object.getClass());
64.82 - MarshallingContext context = (MarshallingContext) bindingFactory.createMarshallingContext();
64.83 - // configure marshaller for writing document
64.84 - context.setXmlWriter(iMarshallingContext.getXmlWriter());
64.85 - // output object as document
64.86 - ((IMarshallable) object).marshal(context);
64.87 - }
64.88 - }
64.89 -
64.90 - public Object unmarshal(Object object, IUnmarshallingContext iUnmarshallingContext) throws JiBXException {
64.91 - // make sure we're at the appropriate start tag
64.92 - UnmarshallingContext ctx = (UnmarshallingContext) iUnmarshallingContext;
64.93 - if (!ctx.isAt(null, ELEMENT_NAME)) {
64.94 - ctx.throwStartTagNameError(null, ELEMENT_NAME);
64.95 - }
64.96 -
64.97 -// IBindingFactory bindingFactory = BindingDirectory.getFactory(Canvas.class);
64.98 - UnmarshallingContext uctx = (UnmarshallingContext) bindingFactory.createUnmarshallingContext();
64.99 - uctx.setFromContext(ctx);
64.100 - // get the uiDefaults from SynthModel and set them as user context
64.101 - UIDefaults uiDefaults = ((HasUIDefaults) ctx.getStackObject(ctx.getStackDepth() - 1)).getUiDefaults();
64.102 - uctx.setUserContext(uiDefaults);
64.103 - // get has resources
64.104 - HasResources hasResources = (HasResources) ctx.getStackObject(ctx.getStackDepth() - 1);
64.105 - // get path
64.106 - HasPath hasPath = null;
64.107 - for (int i = 0; i < ctx.getStackDepth(); i++) {
64.108 - if (ctx.getStackObject(i) instanceof HasPath) {
64.109 - hasPath = (HasPath) ctx.getStackObject(i);
64.110 - break;
64.111 - }
64.112 - }
64.113 - // Unmarshal the Canvas
64.114 - Canvas canvas = (Canvas) uctx.unmarshalElement();
64.115 - // set canvas's ui defaults
64.116 - canvas.setUiDefaults(uiDefaults);
64.117 - // get canvas path
64.118 - String canvasPath = hasPath.getPath();
64.119 - // calc and set resources
64.120 - canvas.setResourcesDir(new File(hasResources.getResourcesDir(), canvasPath));
64.121 - canvas.setTemplatesDir(new File(hasResources.getTemplatesDir(), canvasPath));
64.122 - canvas.setImagesDir(new File(hasResources.getImagesDir(), canvasPath));
64.123 - // return canvas
64.124 - return canvas;
64.125 - }
64.126 -}
65.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/jibxhelpers/ColorMapper.java Sun Sep 06 23:14:42 2009 -0700
65.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
65.3 @@ -1,89 +0,0 @@
65.4 -/*
65.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
65.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
65.7 - *
65.8 - * This code is free software; you can redistribute it and/or modify it
65.9 - * under the terms of the GNU General Public License version 2 only, as
65.10 - * published by the Free Software Foundation. Sun designates this
65.11 - * particular file as subject to the "Classpath" exception as provided
65.12 - * by Sun in the LICENSE file that accompanied this code.
65.13 - *
65.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
65.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
65.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
65.17 - * version 2 for more details (a copy is included in the LICENSE file that
65.18 - * accompanied this code).
65.19 - *
65.20 - * You should have received a copy of the GNU General Public License version
65.21 - * 2 along with this work; if not, write to the Free Software Foundation,
65.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
65.23 - *
65.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
65.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
65.26 - * have any questions.
65.27 - */
65.28 -package org.jdesktop.swingx.designer.jibxhelpers;
65.29 -
65.30 -import org.jibx.runtime.IMarshaller;
65.31 -import org.jibx.runtime.IMarshallingContext;
65.32 -import org.jibx.runtime.IUnmarshaller;
65.33 -import org.jibx.runtime.IUnmarshallingContext;
65.34 -import org.jibx.runtime.JiBXException;
65.35 -import org.jibx.runtime.impl.MarshallingContext;
65.36 -import org.jibx.runtime.impl.UnmarshallingContext;
65.37 -
65.38 -import java.awt.Color;
65.39 -
65.40 -/**
65.41 - * ColorMapper
65.42 - *
65.43 - * @author Created by Jasper Potts (Jun 8, 2007)
65.44 - */
65.45 -public class ColorMapper implements IMarshaller, IUnmarshaller {
65.46 - private static final String ELEMENT_NAME = "color";
65.47 - private static final String RED_NAME = "red";
65.48 - private static final String GREEN_NAME = "green";
65.49 - private static final String BLUE_NAME = "blue";
65.50 - private static final String ALPHA_NAME = "alpha";
65.51 -
65.52 - public boolean isExtension(int i) {
65.53 - return false;
65.54 - }
65.55 -
65.56 - public boolean isPresent(IUnmarshallingContext iUnmarshallingContext) throws JiBXException {
65.57 - return iUnmarshallingContext.isAt(null, ELEMENT_NAME);
65.58 - }
65.59 -
65.60 - public void marshal(Object object, IMarshallingContext iMarshallingContext) throws JiBXException {
65.61 - if (!(object instanceof Color)) {
65.62 - throw new JiBXException("Invalid object type for marshaller");
65.63 - } else if (!(iMarshallingContext instanceof MarshallingContext)) {
65.64 - throw new JiBXException("Invalid object type for marshaller");
65.65 - } else {
65.66 - MarshallingContext ctx = (MarshallingContext) iMarshallingContext;
65.67 - Color color = (Color) object;
65.68 - ctx.startTagAttributes(0, ELEMENT_NAME).
65.69 - attribute(0, RED_NAME, color.getRed()).
65.70 - attribute(0, GREEN_NAME, color.getGreen()).
65.71 - attribute(0, BLUE_NAME, color.getBlue()).
65.72 - attribute(0, ALPHA_NAME, color.getAlpha()).
65.73 - closeStartEmpty();
65.74 - }
65.75 - }
65.76 -
65.77 - public Object unmarshal(Object object, IUnmarshallingContext iUnmarshallingContext) throws JiBXException {
65.78 - // make sure we're at the appropriate start tag
65.79 - UnmarshallingContext ctx = (UnmarshallingContext) iUnmarshallingContext;
65.80 - if (!ctx.isAt(null, ELEMENT_NAME)) {
65.81 - ctx.throwStartTagNameError(null, ELEMENT_NAME);
65.82 - }
65.83 - // get values
65.84 - int red = ctx.attributeInt(null, RED_NAME, 0);
65.85 - int green = ctx.attributeInt(null, GREEN_NAME, 0);
65.86 - int blue = ctx.attributeInt(null, BLUE_NAME, 0);
65.87 - int alpha = ctx.attributeInt(null, ALPHA_NAME, 0);
65.88 - ctx.parsePastEndTag(null, ELEMENT_NAME);
65.89 - // create
65.90 - return new Color(red, green, blue, alpha);
65.91 - }
65.92 -}
66.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/jibxhelpers/DimensionMapper.java Sun Sep 06 23:14:42 2009 -0700
66.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
66.3 @@ -1,101 +0,0 @@
66.4 -/*
66.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
66.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
66.7 - *
66.8 - * This code is free software; you can redistribute it and/or modify it
66.9 - * under the terms of the GNU General Public License version 2 only, as
66.10 - * published by the Free Software Foundation. Sun designates this
66.11 - * particular file as subject to the "Classpath" exception as provided
66.12 - * by Sun in the LICENSE file that accompanied this code.
66.13 - *
66.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
66.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
66.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
66.17 - * version 2 for more details (a copy is included in the LICENSE file that
66.18 - * accompanied this code).
66.19 - *
66.20 - * You should have received a copy of the GNU General Public License version
66.21 - * 2 along with this work; if not, write to the Free Software Foundation,
66.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
66.23 - *
66.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
66.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
66.26 - * have any questions.
66.27 - */
66.28 -package org.jdesktop.swingx.designer.jibxhelpers;
66.29 -
66.30 -import org.jibx.runtime.IAliasable;
66.31 -import org.jibx.runtime.IMarshaller;
66.32 -import org.jibx.runtime.IMarshallingContext;
66.33 -import org.jibx.runtime.IUnmarshaller;
66.34 -import org.jibx.runtime.IUnmarshallingContext;
66.35 -import org.jibx.runtime.JiBXException;
66.36 -import org.jibx.runtime.impl.MarshallingContext;
66.37 -import org.jibx.runtime.impl.UnmarshallingContext;
66.38 -
66.39 -import java.awt.Dimension;
66.40 -
66.41 -/**
66.42 - * DimensionMapper
66.43 - *
66.44 - * @author Created by Jasper Potts (Jun 12, 2007)
66.45 - */
66.46 -public class DimensionMapper implements IMarshaller, IUnmarshaller, IAliasable {
66.47 - private static final String ELEMENT_NAME = "dimension";
66.48 - private static final String WIDTH_NAME = "width";
66.49 - private static final String HEIGHT_NAME = "height";
66.50 -
66.51 - private String uri;
66.52 - private int index;
66.53 - private String name;
66.54 -
66.55 - public DimensionMapper() {
66.56 - uri = null;
66.57 - index = 0;
66.58 - name = ELEMENT_NAME;
66.59 - }
66.60 -
66.61 - public DimensionMapper(String uri, int index, String name) {
66.62 - this.uri = uri;
66.63 - this.index = index;
66.64 - this.name = name;
66.65 - }
66.66 -
66.67 - public boolean isExtension(int i) {
66.68 - return false;
66.69 - }
66.70 -
66.71 - public boolean isPresent(IUnmarshallingContext iUnmarshallingContext) throws JiBXException {
66.72 - return iUnmarshallingContext.isAt(uri, ELEMENT_NAME);
66.73 - }
66.74 -
66.75 - public void marshal(Object object, IMarshallingContext iMarshallingContext) throws JiBXException {
66.76 - if (!(object instanceof Dimension)) {
66.77 - throw new JiBXException("Invalid object type for marshaller");
66.78 - } else if (!(iMarshallingContext instanceof MarshallingContext)) {
66.79 - throw new JiBXException("Invalid object type for marshaller");
66.80 - } else {
66.81 - MarshallingContext ctx = (MarshallingContext) iMarshallingContext;
66.82 - Dimension dimension = (Dimension) object;
66.83 - ctx.startTagAttributes(index, name).
66.84 - attribute(index, WIDTH_NAME, dimension.width).
66.85 - attribute(index, HEIGHT_NAME, dimension.height).
66.86 - closeStartEmpty();
66.87 - }
66.88 - }
66.89 -
66.90 - public Object unmarshal(Object object, IUnmarshallingContext iUnmarshallingContext) throws JiBXException {
66.91 - // make sure we're at the appropriate start tag
66.92 - UnmarshallingContext ctx = (UnmarshallingContext) iUnmarshallingContext;
66.93 - if (!ctx.isAt(uri, name)) {
66.94 - ctx.throwStartTagNameError(uri, name);
66.95 - }
66.96 - // get values
66.97 - int width = ctx.attributeInt(uri, WIDTH_NAME, index);
66.98 - int height = ctx.attributeInt(uri, HEIGHT_NAME, index);
66.99 - // state finished parsing
66.100 - ctx.parsePastEndTag(uri, name);
66.101 - // create
66.102 - return new Dimension(width, height);
66.103 - }
66.104 -}
67.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/jibxhelpers/InsetsMapper.java Sun Sep 06 23:14:42 2009 -0700
67.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
67.3 @@ -1,117 +0,0 @@
67.4 -/*
67.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
67.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
67.7 - *
67.8 - * This code is free software; you can redistribute it and/or modify it
67.9 - * under the terms of the GNU General Public License version 2 only, as
67.10 - * published by the Free Software Foundation. Sun designates this
67.11 - * particular file as subject to the "Classpath" exception as provided
67.12 - * by Sun in the LICENSE file that accompanied this code.
67.13 - *
67.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
67.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
67.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
67.17 - * version 2 for more details (a copy is included in the LICENSE file that
67.18 - * accompanied this code).
67.19 - *
67.20 - * You should have received a copy of the GNU General Public License version
67.21 - * 2 along with this work; if not, write to the Free Software Foundation,
67.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
67.23 - *
67.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
67.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
67.26 - * have any questions.
67.27 - */
67.28 -package org.jdesktop.swingx.designer.jibxhelpers;
67.29 -
67.30 -import org.jibx.runtime.IAliasable;
67.31 -import org.jibx.runtime.IMarshaller;
67.32 -import org.jibx.runtime.IMarshallingContext;
67.33 -import org.jibx.runtime.IUnmarshaller;
67.34 -import org.jibx.runtime.IUnmarshallingContext;
67.35 -import org.jibx.runtime.JiBXException;
67.36 -import org.jibx.runtime.impl.MarshallingContext;
67.37 -import org.jibx.runtime.impl.UnmarshallingContext;
67.38 -
67.39 -import java.awt.Insets;
67.40 -
67.41 -/**
67.42 - * InsetsMapper
67.43 - *
67.44 - * @author Created by Jasper Potts (Jun 8, 2007)
67.45 - */
67.46 -public class InsetsMapper implements IMarshaller, IUnmarshaller, IAliasable {
67.47 - private static final String ELEMENT_NAME = "insets";
67.48 - private static final String TOP_NAME = "top";
67.49 - private static final String BOTTOM_NAME = "bottom";
67.50 - private static final String LEFT_NAME = "left";
67.51 - private static final String RIGHT_NAME = "right";
67.52 -
67.53 - private String uri;
67.54 - private int index;
67.55 - private String name;
67.56 -
67.57 - public InsetsMapper() {
67.58 - uri = null;
67.59 - index = 0;
67.60 - name = ELEMENT_NAME;
67.61 - }
67.62 -
67.63 - public InsetsMapper(String uri, int index, String name) {
67.64 - this.uri = uri;
67.65 - this.index = index;
67.66 - this.name = name;
67.67 -// System.out.println("InsetsMapper.CONSTRCUTED with uri="+uri+" index="+index+" name="+name);
67.68 - }
67.69 -
67.70 - public boolean isExtension(int i) {
67.71 - return false;
67.72 - }
67.73 -
67.74 - public boolean isPresent(IUnmarshallingContext iUnmarshallingContext) throws JiBXException {
67.75 - return iUnmarshallingContext.isAt(uri, ELEMENT_NAME);
67.76 - }
67.77 -
67.78 - public void marshal(Object object, IMarshallingContext iMarshallingContext) throws JiBXException {
67.79 - if (!(object instanceof Insets)) {
67.80 - throw new JiBXException("Invalid object type for marshaller");
67.81 - } else if (!(iMarshallingContext instanceof MarshallingContext)) {
67.82 - throw new JiBXException("Invalid object type for marshaller");
67.83 - } else {
67.84 -// System.out.println("InsetsMapper.marshal name="+name);
67.85 - MarshallingContext ctx = (MarshallingContext) iMarshallingContext;
67.86 - Insets insets = (Insets) object;
67.87 - ctx.startTagAttributes(index, name).
67.88 - attribute(index, TOP_NAME, insets.top).
67.89 - attribute(index, BOTTOM_NAME, insets.bottom).
67.90 - attribute(index, LEFT_NAME, insets.left).
67.91 - attribute(index, RIGHT_NAME, insets.right).
67.92 - closeStartEmpty();
67.93 - }
67.94 - }
67.95 -
67.96 - public Object unmarshal(Object object, IUnmarshallingContext iUnmarshallingContext) throws JiBXException {
67.97 - // make sure we're at the appropriate start tag
67.98 - UnmarshallingContext ctx = (UnmarshallingContext) iUnmarshallingContext;
67.99 - if (!ctx.isAt(uri, name)) {
67.100 -// System.out.println("InsetsMapper.unmarshal name="+name+" uri="+uri+" currentNode="+ctx.getName());
67.101 - ctx.throwStartTagNameError(uri, name);
67.102 - } else {
67.103 -// System.out.println("InsetsMapper.unmarshal name="+name+" uri="+uri+" currentNode="+ctx.getName());
67.104 - }
67.105 - // get values
67.106 - int top = ctx.attributeInt(uri, TOP_NAME, index);
67.107 - int bottom = ctx.attributeInt(uri, BOTTOM_NAME, index);
67.108 - int left = ctx.attributeInt(uri, LEFT_NAME, index);
67.109 - int right = ctx.attributeInt(uri, RIGHT_NAME, index);
67.110 - // create new hashmap if needed
67.111 - Insets insets = (Insets) object;
67.112 - if (insets == null) {
67.113 - insets = new Insets(top, left, bottom, right);
67.114 - } else {
67.115 - insets.set(top, left, bottom, right);
67.116 - }
67.117 - ctx.parsePastEndTag(uri, name);
67.118 - return insets;
67.119 - }
67.120 -}
68.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/AbstractGradient.java Sun Sep 06 23:14:42 2009 -0700
68.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
68.3 @@ -1,280 +0,0 @@
68.4 -/*
68.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
68.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
68.7 - *
68.8 - * This code is free software; you can redistribute it and/or modify it
68.9 - * under the terms of the GNU General Public License version 2 only, as
68.10 - * published by the Free Software Foundation. Sun designates this
68.11 - * particular file as subject to the "Classpath" exception as provided
68.12 - * by Sun in the LICENSE file that accompanied this code.
68.13 - *
68.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
68.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
68.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
68.17 - * version 2 for more details (a copy is included in the LICENSE file that
68.18 - * accompanied this code).
68.19 - *
68.20 - * You should have received a copy of the GNU General Public License version
68.21 - * 2 along with this work; if not, write to the Free Software Foundation,
68.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
68.23 - *
68.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
68.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
68.26 - * have any questions.
68.27 - */
68.28 -package org.jdesktop.swingx.designer.paint;
68.29 -
68.30 -import java.awt.Color;
68.31 -import java.awt.MultipleGradientPaint.CycleMethod;
68.32 -import java.awt.Paint;
68.33 -import java.beans.PropertyChangeEvent;
68.34 -import java.beans.PropertyChangeListener;
68.35 -import java.util.ArrayList;
68.36 -import java.util.Collections;
68.37 -import java.util.Comparator;
68.38 -import java.util.List;
68.39 -
68.40 -/** @author rbair */
68.41 -public abstract class AbstractGradient extends PaintModel {
68.42 - private final Comparator<GradientStop> sorter = new Comparator<GradientStop>() {
68.43 - public int compare(GradientStop s1, GradientStop s2) {
68.44 - //since a float value may be -.001 or .001, and since casting
68.45 - //this to an int will round off to 0, I have to do a more direct
68.46 - //comparison
68.47 - float v = s1.getPosition() - s2.getPosition();
68.48 -
68.49 - if (v < 0) return -1;
68.50 - else if (v == 0) return 0;
68.51 - else return 1;
68.52 - }
68.53 - };
68.54 - private PropertyChangeListener stopListener = new PropertyChangeListener() {
68.55 - public void propertyChange(PropertyChangeEvent evt) {
68.56 - if (evt.getPropertyName().equals("position")) {
68.57 - if (stops.contains((GradientStop) evt.getSource())) {
68.58 - resortModel(true);
68.59 - } else {
68.60 - System.err.println("[WARNING] The position of an orphaned stop was changed.");
68.61 - }
68.62 - } else {
68.63 - firePropertyChange("paint", null, getPaint());
68.64 - }
68.65 - }
68.66 - };
68.67 -
68.68 - private List<GradientStop> stops = new ArrayList<GradientStop>();
68.69 - private List<GradientStop> unmodifiable;
68.70 - private CycleMethod cycleMethod;
68.71 -
68.72 - protected AbstractGradient() {
68.73 - unmodifiable = Collections.unmodifiableList(stops);
68.74 - cycleMethod = CycleMethod.NO_CYCLE;
68.75 - setStops(new GradientStop(0, new Matte(Color.BLUE, null)),
68.76 - new GradientStop(1, new Matte(Color.WHITE, null)));
68.77 - }
68.78 -
68.79 - /**
68.80 - * Copy stops and cycleMethod from src to dst
68.81 - *
68.82 - * @param dst The gradient to update to same stops and cycle method as this gradient
68.83 - */
68.84 - protected void copyTo(AbstractGradient dst) {
68.85 - dst.stops.clear();
68.86 - List<GradientStop> stops = new ArrayList<GradientStop>();
68.87 - for (GradientStop stop : this.stops) {
68.88 - stops.add(stop.clone());
68.89 - }
68.90 - dst.setStops(stops);
68.91 - dst.cycleMethod = this.cycleMethod;
68.92 - }
68.93 -
68.94 -
68.95 - public PaintControlType getPaintControlType() {
68.96 - return PaintControlType.control_line;
68.97 - }
68.98 -
68.99 - public void setCycleMethod(CycleMethod method) {
68.100 - CycleMethod old = cycleMethod;
68.101 - Paint oldp = getPaint();
68.102 - cycleMethod = method == null ? CycleMethod.NO_CYCLE : method;
68.103 - firePropertyChange("cycleMethod", old, cycleMethod);
68.104 - firePropertyChange("paint", oldp, getPaint());
68.105 - }
68.106 -
68.107 - public final CycleMethod getCycleMethod() {
68.108 - return cycleMethod;
68.109 - }
68.110 -
68.111 - public void setStops(GradientStop... stops) {
68.112 - if (stops == null || stops.length < 1) {
68.113 - throw new IllegalArgumentException("Must have more than one stop");
68.114 - }
68.115 - List<GradientStop> old = new ArrayList<GradientStop>(this.stops);
68.116 - for (GradientStop stop : old) {
68.117 - stop.removePropertyChangeListener(stopListener);
68.118 - }
68.119 - Paint oldp = getPaint();
68.120 - this.stops.clear();
68.121 - Collections.addAll(this.stops, stops);
68.122 - for (GradientStop stop : this.stops) {
68.123 - stop.addPropertyChangeListener(stopListener);
68.124 - }
68.125 - resortModel(false);
68.126 - firePropertyChange("stops", old, getStops());
68.127 - firePropertyChange("paint", oldp, getPaint());
68.128 - }
68.129 -
68.130 - public final void setStops(List<GradientStop> stops) {
68.131 - setStops(stops == null ? null : stops.toArray(new GradientStop[0]));
68.132 - }
68.133 -
68.134 - public final List<GradientStop> getStops() {
68.135 - return unmodifiable;
68.136 - }
68.137 -
68.138 - private void resortModel(boolean fireEvent) {
68.139 - Collections.sort(this.stops, sorter);
68.140 - if (fireEvent) {
68.141 - Paint oldp = getPaint();
68.142 - firePropertyChange("stops", null, getStops());
68.143 - firePropertyChange("paint", oldp, getPaint());
68.144 - }
68.145 - }
68.146 -
68.147 - //adds a new stop, and interoplates the proper color to use based on
68.148 - //its position
68.149 - public GradientStop addStop(float position) {
68.150 - GradientStop prevStop = null;
68.151 - GradientStop nextStop = null;
68.152 - for (GradientStop stop : stops) {
68.153 - if (stop.getPosition() <= position) {
68.154 - prevStop = stop;
68.155 - } else if (stop.getPosition() >= position) {
68.156 - nextStop = stop;
68.157 - }
68.158 - }
68.159 -
68.160 - Matte c = null;
68.161 - if (prevStop != null && nextStop != null) {
68.162 - //interpolate the value of c
68.163 - c = interpolate(prevStop.getColor(), nextStop.getColor(),
68.164 - position / (nextStop.getPosition() - prevStop.getPosition()));
68.165 - } else if (prevStop != null) {
68.166 - c = prevStop.getColor().clone();
68.167 - } else if (nextStop != null) {
68.168 - c = nextStop.getColor().clone();
68.169 - }
68.170 -
68.171 - return addStop(position, c);
68.172 - }
68.173 -
68.174 - public GradientStop addStop(float position, Matte color) {
68.175 - GradientStop s = new GradientStop(position, color);
68.176 - s.addPropertyChangeListener(stopListener);
68.177 - List<GradientStop> old = new ArrayList<GradientStop>(stops);
68.178 - Paint oldp = getPaint();
68.179 - stops.add(s);
68.180 - resortModel(false);
68.181 - firePropertyChange("stops", old, getStops());
68.182 - firePropertyChange("paint", oldp, getPaint());
68.183 -
68.184 - return s;
68.185 - }
68.186 -
68.187 - public GradientStop removeStop(GradientStop s) {
68.188 - List<GradientStop> old = new ArrayList<GradientStop>(stops);
68.189 - Paint oldp = getPaint();
68.190 - stops.remove(s);
68.191 - s.removePropertyChangeListener(stopListener);
68.192 - resortModel(false);
68.193 - firePropertyChange("stops", old, getStops());
68.194 - firePropertyChange("paint", oldp, getPaint());
68.195 - return s;
68.196 - }
68.197 -
68.198 - @Override public Paint getPaint() {
68.199 - if (stops.size() == 0) {
68.200 - return null;
68.201 - }
68.202 -
68.203 - //there are stops.size() number of main stops. Between each is
68.204 - //a fractional stop. Thus, there are:
68.205 - //stops.size() + stops.size() - 1
68.206 - //number of fractions and colors.
68.207 -
68.208 - float[] fractions = new float[stops.size() + stops.size() - 1];
68.209 - Matte[] colors = new Matte[fractions.length];
68.210 -
68.211 - //for each stop, create the stop and it's associated fraction
68.212 - int index = 0; // the index into fractions and colors
68.213 - for (int i = 0; i < stops.size(); i++) {
68.214 - GradientStop s = stops.get(i);
68.215 - //copy over the stop's data
68.216 - colors[index] = s.getColor();
68.217 - fractions[index] = s.getPosition();
68.218 -
68.219 - //If this isn't the last stop, then add in the fraction
68.220 - if (index < fractions.length - 1) {
68.221 - float f1 = s.getPosition();
68.222 - float f2 = stops.get(i + 1).getPosition();
68.223 -
68.224 - index++;
68.225 - fractions[index] = f1 + (f2 - f1) * s.getMidpoint();
68.226 - colors[index] = interpolate(colors[index - 1], stops.get(i + 1).getColor(), .5f);
68.227 - }
68.228 -
68.229 - index++;
68.230 - }
68.231 -
68.232 - for (int i = 1; i < fractions.length; i++) {
68.233 - //to avoid an error with LinearGradientPaint where two fractions
68.234 - //are identical, bump up the fraction value by a miniscule amount
68.235 - //if it is identical to the previous one
68.236 - //NOTE: The <= is critical because the previous value may already
68.237 - //have been bumped up
68.238 - if (fractions[i] <= fractions[i - 1]) {
68.239 - fractions[i] = fractions[i - 1] + .000001f;
68.240 - }
68.241 - }
68.242 -
68.243 - //another boundary condition where multiple stops are all at the end. The
68.244 - //previous loop bumped all but one of these past 1.0, which is bad.
68.245 - //so remove any fractions (and their colors!) that are beyond 1.0
68.246 - int outOfBoundsIndex = -1;
68.247 - for (int i = 0; i < fractions.length; i++) {
68.248 - if (fractions[i] > 1) {
68.249 - outOfBoundsIndex = i;
68.250 - break;
68.251 - }
68.252 - }
68.253 -
68.254 - if (outOfBoundsIndex >= 0) {
68.255 - float[] f = fractions;
68.256 - Matte[] c = colors;
68.257 - fractions = new float[outOfBoundsIndex];
68.258 - colors = new Matte[outOfBoundsIndex];
68.259 - System.arraycopy(f, 0, fractions, 0, outOfBoundsIndex);
68.260 - System.arraycopy(c, 0, colors, 0, outOfBoundsIndex);
68.261 - }
68.262 -
68.263 - return createPaint(fractions, colors, cycleMethod);
68.264 - }
68.265 -
68.266 - protected abstract Paint createPaint(float[] fractions, Matte[] colors, CycleMethod method);
68.267 -
68.268 - protected static Matte interpolate(Matte v0, Matte v1, float fraction) {
68.269 - return new Matte(interpolate(v0.getColor(), v1.getColor(), fraction), v0.getUiDefaults());
68.270 - }
68.271 -
68.272 - protected static Color interpolate(Color v0, Color v1, float fraction) {
68.273 - int r = v0.getRed() +
68.274 - (int) ((v1.getRed() - v0.getRed()) * fraction + 0.5f);
68.275 - int g = v0.getGreen() +
68.276 - (int) ((v1.getGreen() - v0.getGreen()) * fraction + 0.5f);
68.277 - int b = v0.getBlue() +
68.278 - (int) ((v1.getBlue() - v0.getBlue()) * fraction + 0.5f);
68.279 - int a = v0.getAlpha() +
68.280 - (int) ((v1.getAlpha() - v0.getAlpha()) * fraction + 0.5f);
68.281 - return new Color(r, g, b, a);
68.282 - }
68.283 -}
69.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/Gradient.java Sun Sep 06 23:14:42 2009 -0700
69.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
69.3 @@ -1,51 +0,0 @@
69.4 -/*
69.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
69.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
69.7 - *
69.8 - * This code is free software; you can redistribute it and/or modify it
69.9 - * under the terms of the GNU General Public License version 2 only, as
69.10 - * published by the Free Software Foundation. Sun designates this
69.11 - * particular file as subject to the "Classpath" exception as provided
69.12 - * by Sun in the LICENSE file that accompanied this code.
69.13 - *
69.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
69.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
69.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
69.17 - * version 2 for more details (a copy is included in the LICENSE file that
69.18 - * accompanied this code).
69.19 - *
69.20 - * You should have received a copy of the GNU General Public License version
69.21 - * 2 along with this work; if not, write to the Free Software Foundation,
69.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
69.23 - *
69.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
69.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
69.26 - * have any questions.
69.27 - */
69.28 -package org.jdesktop.swingx.designer.paint;
69.29 -
69.30 -import java.awt.Color;
69.31 -import java.awt.LinearGradientPaint;
69.32 -import java.awt.MultipleGradientPaint.CycleMethod;
69.33 -import java.awt.Paint;
69.34 -
69.35 -/**
69.36 - * Represents a GradientPaint or LinearGradientPaint.
69.37 - *
69.38 - * @author rbair
69.39 - */
69.40 -public class Gradient extends AbstractGradient implements Cloneable {
69.41 - protected Paint createPaint(float[] fractions, Matte[] mattes, CycleMethod method) {
69.42 - Color[] colors = new Color[mattes.length];
69.43 - for (int i = 0; i < colors.length; i++) {
69.44 - colors[i] = mattes[i].getColor();
69.45 - }
69.46 - return new LinearGradientPaint(0, 0, 1, 0, fractions, colors, method);
69.47 - }
69.48 -
69.49 - @Override public Gradient clone() {
69.50 - Gradient gradient = new Gradient();
69.51 - copyTo(gradient);
69.52 - return gradient;
69.53 - }
69.54 -}
70.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/GradientStop.java Sun Sep 06 23:14:42 2009 -0700
70.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
70.3 @@ -1,123 +0,0 @@
70.4 -/*
70.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
70.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
70.7 - *
70.8 - * This code is free software; you can redistribute it and/or modify it
70.9 - * under the terms of the GNU General Public License version 2 only, as
70.10 - * published by the Free Software Foundation. Sun designates this
70.11 - * particular file as subject to the "Classpath" exception as provided
70.12 - * by Sun in the LICENSE file that accompanied this code.
70.13 - *
70.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
70.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
70.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
70.17 - * version 2 for more details (a copy is included in the LICENSE file that
70.18 - * accompanied this code).
70.19 - *
70.20 - * You should have received a copy of the GNU General Public License version
70.21 - * 2 along with this work; if not, write to the Free Software Foundation,
70.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
70.23 - *
70.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
70.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
70.26 - * have any questions.
70.27 - */
70.28 -package org.jdesktop.swingx.designer.paint;
70.29 -
70.30 -import org.jdesktop.beans.AbstractBean;
70.31 -
70.32 -import java.beans.PropertyChangeEvent;
70.33 -import java.beans.PropertyChangeListener;
70.34 -
70.35 -/** Each stop is defined linearly, at positions between 0 and 1. */
70.36 -public final class GradientStop extends AbstractBean implements Cloneable {
70.37 - private float position;
70.38 - private Matte color;
70.39 - private PropertyChangeListener matteListener = new PropertyChangeListener() {
70.40 - public void propertyChange(PropertyChangeEvent evt) {
70.41 - firePropertyChange("color", null, color);
70.42 - }
70.43 - };
70.44 -
70.45 - /**
70.46 - * The midpoint to the right of the stop. Must be 0 <= midpoint <= 1. The midpoint value of the last Stop is
70.47 - * ignored.
70.48 - */
70.49 - private float midpoint;
70.50 -
70.51 - public GradientStop() {}
70.52 -
70.53 - public GradientStop(float position, Matte color) {
70.54 - if (color == null) {
70.55 - throw new IllegalArgumentException("Color must not be null");
70.56 - }
70.57 -
70.58 - this.position = clamp(0, 1, position);
70.59 - this.color = color;
70.60 - this.midpoint = .5f;
70.61 -
70.62 - if (this.color != null) {
70.63 - this.color.addPropertyChangeListener("color", matteListener);
70.64 - }
70.65 - }
70.66 -
70.67 -
70.68 - public GradientStop clone() {
70.69 - GradientStop clone = new GradientStop(this.position, this.color.clone());
70.70 - clone.midpoint = midpoint;
70.71 - return clone;
70.72 - }
70.73 -
70.74 - public final float getPosition() {
70.75 - return position;
70.76 - }
70.77 -
70.78 - public final void setPosition(float position) {
70.79 - float old = this.position;
70.80 - this.position = clamp(0, 1, position);
70.81 - firePropertyChange("position", old, this.position);
70.82 - }
70.83 -
70.84 - public final Matte getColor() {
70.85 - return color;
70.86 - }
70.87 -
70.88 - public final void setColor(Matte c) {
70.89 - if (c == null) throw new IllegalArgumentException("Color must not be null");
70.90 - Matte old = this.color;
70.91 - if (old != null) old.removePropertyChangeListener(matteListener);
70.92 - this.color = c;
70.93 - if (this.color != null) this.color.addPropertyChangeListener(matteListener);
70.94 - firePropertyChange("color", old, c);
70.95 - }
70.96 -
70.97 - public final void setOpacity(int opacity) {
70.98 - int old = getOpacity();
70.99 - color.setAlpha(opacity);
70.100 - firePropertyChange("opacity", old, getOpacity());
70.101 - }
70.102 -
70.103 - public final int getOpacity() {
70.104 - return color.getAlpha();
70.105 - }
70.106 -
70.107 - public final float getMidpoint() {
70.108 - return midpoint;
70.109 - }
70.110 -
70.111 - public final void setMidpoint(float midpoint) {
70.112 - float old = this.midpoint;
70.113 - this.midpoint = clamp(0, 1, midpoint);
70.114 - firePropertyChange("midpoint", old, this.midpoint);
70.115 - }
70.116 -
70.117 - private float clamp(float lo, float hi, float value) {
70.118 - if (value < lo) {
70.119 - return lo;
70.120 - } else if (value > hi) {
70.121 - return hi;
70.122 - } else {
70.123 - return value;
70.124 - }
70.125 - }
70.126 -}
71.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/Matte.java Sun Sep 06 23:14:42 2009 -0700
71.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
71.3 @@ -1,610 +0,0 @@
71.4 -/*
71.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
71.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
71.7 - *
71.8 - * This code is free software; you can redistribute it and/or modify it
71.9 - * under the terms of the GNU General Public License version 2 only, as
71.10 - * published by the Free Software Foundation. Sun designates this
71.11 - * particular file as subject to the "Classpath" exception as provided
71.12 - * by Sun in the LICENSE file that accompanied this code.
71.13 - *
71.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
71.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
71.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
71.17 - * version 2 for more details (a copy is included in the LICENSE file that
71.18 - * accompanied this code).
71.19 - *
71.20 - * You should have received a copy of the GNU General Public License version
71.21 - * 2 along with this work; if not, write to the Free Software Foundation,
71.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
71.23 - *
71.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
71.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
71.26 - * have any questions.
71.27 - */
71.28 -package org.jdesktop.swingx.designer.paint;
71.29 -
71.30 -import org.jdesktop.swingx.designer.utils.HasUIDefaults;
71.31 -import org.jibx.runtime.IUnmarshallingContext;
71.32 -
71.33 -import javax.swing.UIDefaults;
71.34 -import java.awt.Color;
71.35 -import java.awt.Paint;
71.36 -import java.beans.PropertyChangeEvent;
71.37 -import java.beans.PropertyChangeListener;
71.38 -
71.39 -/**
71.40 - * Representing a single uniform color. Basically, it represents the java.awt.Color. It can either be absolute or
71.41 - * derived from a UIDefault color.
71.42 - *
71.43 - * @author rbair & jasper potts
71.44 - */
71.45 -public class Matte extends PaintModel implements HasUIDefaults {
71.46 - private float[] tmpf1 = new float[3];
71.47 - private float[] tmpf2 = new float[3];
71.48 -
71.49 - private int red;
71.50 - private int green;
71.51 - private int blue;
71.52 - private int alpha;
71.53 - private Color cached = null;
71.54 -
71.55 - /**
71.56 - * The name of the ui default key to derive this color from.
71.57 - */
71.58 - private String uiDefaultParentName = null;
71.59 - /**
71.60 - * The name of the bean property, or client property, on this component
71.61 - * from which to extract a color used for painting. So for example the color
71.62 - * used in a painter could be the background of the component.
71.63 - */
71.64 - private String componentPropertyName = null;
71.65 - private float hueOffset = 0, saturationOffset = 0, brightnessOffset = 0;
71.66 - private int alphaOffset = 0;
71.67 - /**
71.68 - * When true this color will become a UIResource in the UIManager defaults
71.69 - * table. If false, then it will not be a UIResource. This is sometimes
71.70 - * required, such as with colors installed on renderers.
71.71 - */
71.72 - private boolean uiResource = true;
71.73 -
71.74 - /** This is a local UIDefaults that contains all the UIDefaults in the Model. */
71.75 - private transient UIDefaults uiDefaults = new UIDefaults();
71.76 - private PropertyChangeListener uiDefaultsChangeListener = new PropertyChangeListener() {
71.77 - public void propertyChange(PropertyChangeEvent evt) {
71.78 - if (uiDefaultParentName != null && uiDefaultParentName.equals(evt.getPropertyName())) {
71.79 - updateARGBFromOffsets();
71.80 - }
71.81 - }
71.82 - };
71.83 -
71.84 - // =================================================================================================================
71.85 - // Constructors
71.86 -
71.87 - /** propected constructor for JIBX */
71.88 - protected Matte() {}
71.89 -
71.90 - public Matte(Color c, UIDefaults uiDefaults) {
71.91 - if (c != null) {
71.92 - this.red = c.getRed();
71.93 - this.green = c.getGreen();
71.94 - this.blue = c.getBlue();
71.95 - this.alpha = c.getAlpha();
71.96 - }
71.97 - setUiDefaults(uiDefaults);
71.98 - }
71.99 -
71.100 - // =================================================================================================================
71.101 - // JIBX Methods
71.102 -
71.103 - /**
71.104 - * Called by JIBX after all fields have been set
71.105 - *
71.106 - * @param context The JIBX Unmarshalling Context
71.107 - */
71.108 - protected void postSet(IUnmarshallingContext context) {
71.109 - // walk up till we get synth model
71.110 - for (int i = 0; i < context.getStackDepth(); i++) {
71.111 - if (context.getStackObject(i) instanceof HasUIDefaults) {
71.112 - UIDefaults uiDefaults = ((HasUIDefaults) context.getStackObject(i)).getUiDefaults();
71.113 - if (uiDefaults != null) {
71.114 - setUiDefaults(uiDefaults);
71.115 - break;
71.116 - }
71.117 - }
71.118 - }
71.119 - }
71.120 -
71.121 - // =================================================================================================================
71.122 - // Matte methods
71.123 -
71.124 - /**
71.125 - * Is the matte an absolute color ot derived from a parent ui default
71.126 - *
71.127 - * @return <code>true</code> if this is a absolute not uidefault derived color
71.128 - */
71.129 - public boolean isAbsolute() {
71.130 - return uiDefaultParentName == null;
71.131 - }
71.132 -
71.133 - /**
71.134 - * Set all properties of this matte to be the same as <code>srcMatte</code> and fire all the change events
71.135 - *
71.136 - * @param srcMatte the matte to copy properties from
71.137 - */
71.138 - public void copy(Matte srcMatte) {
71.139 - // keep old values
71.140 - Color oldColor = getColor();
71.141 - String oldParentName = uiDefaultParentName;
71.142 - String oldComponentPropertyName = componentPropertyName;
71.143 - boolean oldUiResource = uiResource;
71.144 - int oldR = red, oldG = green, oldB = blue, oldA = alpha;
71.145 - float oldH = hueOffset, oldS = saturationOffset, oldBr = brightnessOffset;
71.146 - // set properties
71.147 - if (uiResource != srcMatte.uiResource) {
71.148 - uiResource = srcMatte.uiResource;
71.149 - firePropertyChange("uiResource", oldUiResource, isUiResource());
71.150 - }
71.151 - if (red != srcMatte.red) {
71.152 - red = srcMatte.red;
71.153 - firePropertyChange("red", oldR, getRed());
71.154 - }
71.155 - if (green != srcMatte.green) {
71.156 - green = srcMatte.green;
71.157 - firePropertyChange("green", oldG, getGreen());
71.158 - }
71.159 - if (blue != srcMatte.blue) {
71.160 - blue = srcMatte.blue;
71.161 - firePropertyChange("blue", oldB, getBlue());
71.162 - }
71.163 - if (alpha != srcMatte.alpha) {
71.164 - alpha = srcMatte.alpha;
71.165 - firePropertyChange("alpha", oldA, getAlpha());
71.166 - }
71.167 - if (hueOffset != srcMatte.hueOffset) {
71.168 - hueOffset = srcMatte.hueOffset;
71.169 - firePropertyChange("hueOffset", oldH, getHueOffset());
71.170 - }
71.171 - if (saturationOffset != srcMatte.saturationOffset) {
71.172 - saturationOffset = srcMatte.saturationOffset;
71.173 - firePropertyChange("saturationOffset", oldS, getSaturationOffset());
71.174 - }
71.175 - if (brightnessOffset != srcMatte.brightnessOffset) {
71.176 - brightnessOffset = srcMatte.brightnessOffset;
71.177 - firePropertyChange("brightnessOffset", oldBr, getBrightnessOffset());
71.178 - }
71.179 - if (alphaOffset != srcMatte.alphaOffset) {
71.180 - alphaOffset = srcMatte.alphaOffset;
71.181 - firePropertyChange("alphaOffset", oldA, getAlphaOffset());
71.182 - }
71.183 - if (uiDefaultParentName != srcMatte.uiDefaultParentName) {
71.184 - uiDefaultParentName = srcMatte.uiDefaultParentName;
71.185 - firePropertyChange("uiDefaultParentName", oldParentName, getUiDefaultParentName());
71.186 - }
71.187 - if (componentPropertyName != srcMatte.componentPropertyName) {
71.188 - componentPropertyName = srcMatte.componentPropertyName;
71.189 - firePropertyChange("componentPropertyName", oldComponentPropertyName, getComponentPropertyName());
71.190 - }
71.191 - if (uiDefaults != srcMatte.uiDefaults) {
71.192 - setUiDefaults(srcMatte.uiDefaults);
71.193 - }
71.194 - if (!oldColor.equals(srcMatte.getColor())) {
71.195 - firePropertyChange("paint", oldColor, getColor());
71.196 - firePropertyChange("color", oldColor, getColor());
71.197 - fireHSBChange(oldR, oldG, oldB);
71.198 - }
71.199 - }
71.200 -
71.201 - // =================================================================================================================
71.202 - // PaintModel methods
71.203 -
71.204 - public PaintControlType getPaintControlType() {
71.205 - return PaintControlType.none;
71.206 - }
71.207 -
71.208 - // =================================================================================================================
71.209 - // Bean Methods
71.210 -
71.211 - /**
71.212 - * Get the local UIDefaults that contains all the UIDefaults in the Model.
71.213 - *
71.214 - * @return The UIDefaults for the model that contains this Matte, can be null if this Matte is not part of a bigger
71.215 - * model
71.216 - */
71.217 - public UIDefaults getUiDefaults() {
71.218 - return uiDefaults;
71.219 - }
71.220 -
71.221 - /**
71.222 - * Set the local UIDefaults that contains all the UIDefaults in the Model.
71.223 - *
71.224 - * @param uiDefaults The UIDefaults for the model that contains this Matte, can be null if this Matte is not part of
71.225 - * a bigger model
71.226 - */
71.227 - public void setUiDefaults(UIDefaults uiDefaults) {
71.228 - if (uiDefaults != this.uiDefaults) {
71.229 - UIDefaults old = getUiDefaults();
71.230 - if (old != null) old.removePropertyChangeListener(uiDefaultsChangeListener);
71.231 - this.uiDefaults = uiDefaults;
71.232 - if (uiDefaults != null) this.uiDefaults.addPropertyChangeListener(uiDefaultsChangeListener);
71.233 - firePropertyChange("uiDefaults", old, getUiDefaults());
71.234 - }
71.235 - }
71.236 -
71.237 - /**
71.238 - * Get the name if the uidefault color that is the parent that this matte is derived from. If null then this is a
71.239 - * absolute color.
71.240 - *
71.241 - * @return Parent color ui default name
71.242 - */
71.243 - public String getUiDefaultParentName() {
71.244 - return uiDefaultParentName;
71.245 - }
71.246 -
71.247 - /**
71.248 - * Set the name if the uidefault color that is the parent that this matte is derived from. If null then this is a
71.249 - * absolute color.
71.250 - *
71.251 - * @param uiDefaultParentName Parent color ui default name
71.252 - */
71.253 - public void setUiDefaultParentName(String uiDefaultParentName) {
71.254 - String old = getUiDefaultParentName();
71.255 - this.uiDefaultParentName = uiDefaultParentName;
71.256 - firePropertyChange("uiDefaultParentName", old, getUiDefaultParentName());
71.257 - if (isAbsolute()) {
71.258 - // reset offsets
71.259 - float oldH = hueOffset, oldS = saturationOffset, oldB = brightnessOffset;
71.260 - int oldA = alphaOffset;
71.261 - hueOffset = 0;
71.262 - saturationOffset = 0;
71.263 - brightnessOffset = 0;
71.264 - alphaOffset = 0;
71.265 - firePropertyChange("hueOffset", oldH, getHueOffset());
71.266 - firePropertyChange("saturationOffset", oldS, getSaturationOffset());
71.267 - firePropertyChange("brightnessOffset", oldB, getBrightnessOffset());
71.268 - firePropertyChange("alphaOffset", oldA, getAlphaOffset());
71.269 - }
71.270 - updateARGBFromOffsets();
71.271 - }
71.272 -
71.273 - /**
71.274 - * Sets the property to use for extracting the color for whatever component
71.275 - * is passed to the painter. Can be a key in client properties. Can be null.
71.276 - * @param name
71.277 - */
71.278 - public void setComponentPropertyName(String name) {
71.279 - String old = componentPropertyName;
71.280 - firePropertyChange("componentPropertyName", old, componentPropertyName = name);
71.281 - }
71.282 -
71.283 - /**
71.284 - * Gets the name of the bean property, or client property, on this component
71.285 - * from which to extract a color used for painting. So for example the color
71.286 - * used in a painter could be the background of the component.
71.287 - *
71.288 - * @return
71.289 - */
71.290 - public String getComponentPropertyName() {
71.291 - return componentPropertyName;
71.292 - }
71.293 -
71.294 - /**
71.295 - * Sets whether this color should be represented as a UIResource in UIDefaults
71.296 - * @param b true if the color should be a ui resource
71.297 - */
71.298 - public void setUiResource(boolean b) {
71.299 - boolean old = uiResource;
71.300 - firePropertyChange("uiResource", old, uiResource = b);
71.301 - }
71.302 -
71.303 - /**
71.304 - * When false this color will become a non-UIResource in the UIManager defaults
71.305 - * table. This is sometimes required to force swing to use the given color,
71.306 - * such as with renderers.
71.307 - * @return false if the color should not be a uiresource
71.308 - */
71.309 - public boolean isUiResource() {
71.310 - return uiResource;
71.311 - }
71.312 -
71.313 - public float getHueOffset() {
71.314 - return hueOffset;
71.315 - }
71.316 -
71.317 - public void setHueOffset(float hueOffset) {
71.318 - float old = getHueOffset();
71.319 - this.hueOffset = hueOffset;
71.320 - firePropertyChange("hueOffset", old, getHueOffset());
71.321 - updateARGBFromOffsets();
71.322 - }
71.323 -
71.324 - public float getSaturationOffset() {
71.325 - return saturationOffset;
71.326 - }
71.327 -
71.328 - public void setSaturationOffset(float satOffset) {
71.329 - float old = getSaturationOffset();
71.330 - this.saturationOffset = satOffset;
71.331 - firePropertyChange("saturationOffset", old, getSaturationOffset());
71.332 - updateARGBFromOffsets();
71.333 - }
71.334 -
71.335 - public float getBrightnessOffset() {
71.336 - return brightnessOffset;
71.337 - }
71.338 -
71.339 - public void setBrightnessOffset(float brightOffset) {
71.340 - float old = getBrightnessOffset();
71.341 - this.brightnessOffset = brightOffset;
71.342 - firePropertyChange("brightnessOffset", old, getBrightnessOffset());
71.343 - updateARGBFromOffsets();
71.344 - }
71.345 -
71.346 - public int getAlphaOffset() {
71.347 - return alphaOffset;
71.348 - }
71.349 -
71.350 - public void setAlphaOffset(int alphaOffset) {
71.351 - int old = getAlphaOffset();
71.352 - this.alphaOffset = alphaOffset;
71.353 - firePropertyChange("alphaOffset", old, alphaOffset);
71.354 - updateARGBFromOffsets();
71.355 - }
71.356 -
71.357 -
71.358 - public void setRed(int red) {
71.359 - red = clamp(red);
71.360 - if (this.red != red) {
71.361 - Color old = getColor();
71.362 - int oldr = this.red;
71.363 - this.red = red;
71.364 - firePropertyChange("paint", old, getColor());
71.365 - firePropertyChange("color", old, getColor());
71.366 - firePropertyChange("red", oldr, red);
71.367 - fireHSBChange(oldr, green, blue);
71.368 - updateOffsetsFromARGB();
71.369 - }
71.370 - }
71.371 -
71.372 - public final int getRed() {
71.373 - return red;
71.374 - }
71.375 -
71.376 - public void setGreen(int green) {
71.377 - green = clamp(green);
71.378 - if (this.green != green) {
71.379 - Color old = getColor();
71.380 - int oldg = this.green;
71.381 - this.green = green;
71.382 - firePropertyChange("paint", old, getColor());
71.383 - firePropertyChange("color", old, getColor());
71.384 - firePropertyChange("green", oldg, green);
71.385 - fireHSBChange(red, oldg, blue);
71.386 - updateOffsetsFromARGB();
71.387 - }
71.388 - }
71.389 -
71.390 - public final int getGreen() {
71.391 - return green;
71.392 - }
71.393 -
71.394 - public void setBlue(int blue) {
71.395 - blue = clamp(blue);
71.396 - if (this.blue != blue) {
71.397 - Color old = getColor();
71.398 - int oldb = this.blue;
71.399 - this.blue = blue;
71.400 - firePropertyChange("paint", old, getColor());
71.401 - firePropertyChange("color", old, getColor());
71.402 - firePropertyChange("blue", oldb, blue);
71.403 - fireHSBChange(red, green, oldb);
71.404 - updateOffsetsFromARGB();
71.405 - }
71.406 - }
71.407 -
71.408 - public final int getBlue() {
71.409 - return blue;
71.410 - }
71.411 -
71.412 - public void setAlpha(int alpha) {
71.413 - alpha = clamp(alpha);
71.414 - if (this.alpha != alpha) {
71.415 - int old = getAlpha();
71.416 - this.alpha = alpha;
71.417 - firePropertyChange("alpha", old, alpha);
71.418 - firePropertyChange("paint", old, getColor());
71.419 - firePropertyChange("color", old, getColor());
71.420 - updateOffsetsFromARGB();
71.421 - }
71.422 - }
71.423 -
71.424 - public final int getAlpha() {
71.425 - return alpha;
71.426 - }
71.427 -
71.428 - public Color getColor() {
71.429 - if (cached == null || red != cached.getRed() || green != cached.getGreen() ||
71.430 - blue != cached.getBlue() || alpha != cached.getAlpha()) {
71.431 - cached = new Color(red, green, blue, alpha);
71.432 - }
71.433 - return cached;
71.434 - }
71.435 -
71.436 - public void setColor(Color c) {
71.437 - setColor(c, false);
71.438 - }
71.439 -
71.440 - public void setColor(Color c, boolean dontSetAlpha) {
71.441 - Color oldColor = getColor();
71.442 - int oldR = red, oldG = green, oldB = blue, oldA = alpha;
71.443 - cached = c;
71.444 - red = c.getRed();
71.445 - green = c.getGreen();
71.446 - blue = c.getBlue();
71.447 - if (!dontSetAlpha) alpha = c.getAlpha();
71.448 - updateOffsetsFromARGB();
71.449 - firePropertyChange("red", oldR, getRed());
71.450 - firePropertyChange("green", oldG, getGreen());
71.451 - firePropertyChange("blue", oldB, getBlue());
71.452 - fireHSBChange(oldR, oldG, oldB);
71.453 - if (!dontSetAlpha) firePropertyChange("alpha", oldA, getAlpha());
71.454 - firePropertyChange("paint", oldColor, getColor());
71.455 - firePropertyChange("color", oldColor, getColor());
71.456 - }
71.457 -
71.458 - @Override public Paint getPaint() {
71.459 - return getColor();
71.460 - }
71.461 -
71.462 -
71.463 - @Override public String toString() {
71.464 - if (isAbsolute()) {
71.465 - return Matte.class.getName() + "[r=" + red + ", g=" + green + ", b=" + blue + ", a=" + alpha + "]";
71.466 - } else {
71.467 - return Matte.class.getName() + "[base=" + uiDefaultParentName + ", H+" + hueOffset +
71.468 - ", S+" + saturationOffset + ", B+" + brightnessOffset + ", A+" + alphaOffset + "]";
71.469 - }
71.470 - }
71.471 -
71.472 - public boolean equals(Object o) {
71.473 - if (this == o) return true;
71.474 - if (o == null || getClass() != o.getClass()) return false;
71.475 - Matte matte = (Matte) o;
71.476 - if (alpha != matte.alpha) return false;
71.477 - if (alphaOffset != matte.alphaOffset) return false;
71.478 - if (Float.compare(matte.alpha, alpha) != 0) return false;
71.479 - if (blue != matte.blue) return false;
71.480 - if (Float.compare(matte.brightnessOffset, brightnessOffset) != 0)
71.481 - return false;
71.482 - if (green != matte.green) return false;
71.483 - if (Float.compare(matte.hueOffset, hueOffset) != 0) return false;
71.484 - if (red != matte.red) return false;
71.485 - if (uiResource != matte.uiResource) return false;
71.486 - if (Float.compare(matte.saturationOffset, saturationOffset) != 0)
71.487 - return false;
71.488 - if (componentPropertyName != null ?
71.489 - !componentPropertyName.equals(componentPropertyName) :
71.490 - matte.componentPropertyName != null) return false;
71.491 -
71.492 - if (uiDefaultParentName != null ?
71.493 - !uiDefaultParentName.equals(matte.uiDefaultParentName) :
71.494 - matte.uiDefaultParentName != null) return false;
71.495 - return true;
71.496 - }
71.497 -
71.498 - public int hashCode() {
71.499 - int result;
71.500 - result = red;
71.501 - result = 31 * result + green;
71.502 - result = 31 * result + blue;
71.503 - result = 31 * result + alpha;
71.504 - result = 31 * result + (uiDefaultParentName != null ?
71.505 - uiDefaultParentName.hashCode() : 0);
71.506 - result = 31 * result + (componentPropertyName != null ?
71.507 - componentPropertyName.hashCode() : 0);
71.508 - result = 31 * result + hueOffset != +0.0f ?
71.509 - Float.floatToIntBits(hueOffset) : 0;
71.510 - result = 31 * result + saturationOffset != +0.0f ?
71.511 - Float.floatToIntBits(saturationOffset) : 0;
71.512 - result = 31 * result + brightnessOffset != +0.0f ?
71.513 - Float.floatToIntBits(brightnessOffset) : 0;
71.514 - result = 31 * result + (uiResource ? 1 : 0);
71.515 - return result;
71.516 - }
71.517 -
71.518 - @Override public Matte clone() {
71.519 - Matte m = new Matte();
71.520 - m.red = red;
71.521 - m.green = green;
71.522 - m.blue = blue;
71.523 - m.alpha = alpha;
71.524 - m.brightnessOffset = brightnessOffset;
71.525 - m.hueOffset = hueOffset;
71.526 - m.saturationOffset = saturationOffset;
71.527 - m.alphaOffset = alphaOffset;
71.528 - m.uiDefaultParentName = uiDefaultParentName;
71.529 - m.componentPropertyName = componentPropertyName;
71.530 - m.uiResource = uiResource;
71.531 - m.setUiDefaults(uiDefaults);
71.532 - return m;
71.533 - }
71.534 -
71.535 - // =================================================================================================================
71.536 - // Private Helper Methods
71.537 -
71.538 - private void updateOffsetsFromARGB() {
71.539 - if (!isAbsolute()) {
71.540 - tmpf1 = Color.RGBtoHSB(red, green, blue, tmpf1);
71.541 - Color parentColor = uiDefaults.getColor(uiDefaultParentName);
71.542 - tmpf2 = Color.RGBtoHSB(parentColor.getRed(), parentColor.getGreen(), parentColor.getBlue(), tmpf2);
71.543 - // update offset properties and fire events
71.544 - float oldH = hueOffset, oldS = saturationOffset, oldB = brightnessOffset;
71.545 - int oldA = alphaOffset;
71.546 - hueOffset = tmpf1[0] - tmpf2[0];
71.547 - saturationOffset = tmpf1[1] - tmpf2[1];
71.548 - brightnessOffset = tmpf1[2] - tmpf2[2];
71.549 - alphaOffset = alpha - parentColor.getAlpha();
71.550 - firePropertyChange("hueOffset", oldH, getHueOffset());
71.551 - firePropertyChange("saturationOffset", oldS, getSaturationOffset());
71.552 - firePropertyChange("brightnessOffset", oldB, getBrightnessOffset());
71.553 - firePropertyChange("alphaOffset", oldA, getAlphaOffset());
71.554 - }
71.555 - }
71.556 -
71.557 - private void updateARGBFromOffsets() {
71.558 - if (!isAbsolute()) {
71.559 - Color oldColor = getColor();
71.560 - // get parent color HSB
71.561 - Color parentColor = uiDefaults.getColor(uiDefaultParentName);
71.562 - tmpf1 = Color.RGBtoHSB(parentColor.getRed(), parentColor.getGreen(), parentColor.getBlue(), tmpf1);
71.563 - // apply offsets
71.564 - tmpf1[0] = clamp(tmpf1[0] + hueOffset);
71.565 - tmpf1[1] = clamp(tmpf1[1] + saturationOffset);
71.566 - tmpf1[2] = clamp(tmpf1[2] + brightnessOffset);
71.567 - int oldA = getAlpha();
71.568 - alpha = clamp(parentColor.getAlpha() + alphaOffset);
71.569 - updateRGB(tmpf1);
71.570 - // update fire events
71.571 - firePropertyChange("alpha", oldA, getAlpha());
71.572 - firePropertyChange("paint", oldColor, getColor());
71.573 - firePropertyChange("color", oldColor, getColor());
71.574 - }
71.575 - }
71.576 -
71.577 - private void updateRGB(float[] hsb) {
71.578 - int oldR = red, oldG = green, oldB = blue;
71.579 - int rgb = Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]);
71.580 - red = (rgb >> 16) & 0xFF;
71.581 - green = (rgb >> 8) & 0xFF;
71.582 - blue = rgb & 0xFF;
71.583 - firePropertyChange("red", oldR, getRed());
71.584 - firePropertyChange("green", oldG, getGreen());
71.585 - firePropertyChange("blue", oldB, getBlue());
71.586 - }
71.587 -
71.588 - private void fireHSBChange(int oldR, int oldG, int oldB) {
71.589 - tmpf1 = Color.RGBtoHSB(oldR, oldG, oldB, tmpf1);
71.590 - tmpf2 = Color.RGBtoHSB(red, green, blue, tmpf2);
71.591 - firePropertyChange("hue", tmpf1[0], tmpf2[0]);
71.592 - firePropertyChange("saturation", tmpf1[1], tmpf2[1]);
71.593 - firePropertyChange("brightness", tmpf1[2], tmpf2[2]);
71.594 - }
71.595 -
71.596 - private float clamp(float value) {
71.597 - if (value < 0) {
71.598 - value = 0;
71.599 - } else if (value > 1) {
71.600 - value = 1;
71.601 - }
71.602 - return value;
71.603 - }
71.604 -
71.605 - private int clamp(int value) {
71.606 - if (value < 0) {
71.607 - value = 0;
71.608 - } else if (value > 255) {
71.609 - value = 255;
71.610 - }
71.611 - return value;
71.612 - }
71.613 -}
72.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/PaintModel.java Sun Sep 06 23:14:42 2009 -0700
72.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
72.3 @@ -1,64 +0,0 @@
72.4 -/*
72.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
72.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
72.7 - *
72.8 - * This code is free software; you can redistribute it and/or modify it
72.9 - * under the terms of the GNU General Public License version 2 only, as
72.10 - * published by the Free Software Foundation. Sun designates this
72.11 - * particular file as subject to the "Classpath" exception as provided
72.12 - * by Sun in the LICENSE file that accompanied this code.
72.13 - *
72.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
72.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
72.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
72.17 - * version 2 for more details (a copy is included in the LICENSE file that
72.18 - * accompanied this code).
72.19 - *
72.20 - * You should have received a copy of the GNU General Public License version
72.21 - * 2 along with this work; if not, write to the Free Software Foundation,
72.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
72.23 - *
72.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
72.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
72.26 - * have any questions.
72.27 - */
72.28 -package org.jdesktop.swingx.designer.paint;
72.29 -
72.30 -import org.jdesktop.beans.AbstractBean;
72.31 -
72.32 -import java.awt.Paint;
72.33 -
72.34 -/**
72.35 - * I'd have just called it Paint, but sadly, that name was already taken, and would have been too confusing.
72.36 - * <p/>
72.37 - * Whenever size or position values are required (for example with Texture or Gradient), they are specified in the unit
72.38 - * square: that is, between 0 and 1 inclusive. They can then later be scaled as necessary by any painting code.
72.39 - *
72.40 - * @author rbair
72.41 - */
72.42 -public abstract class PaintModel extends AbstractBean implements Cloneable {
72.43 - public static enum PaintControlType {
72.44 - none, control_line, control_rect
72.45 - }
72.46 -
72.47 - protected PaintModel() { }
72.48 -
72.49 - /**
72.50 - * @return an instance of Paint that is represented by this PaintModel. This is often not a reversable operation,
72.51 - * and hence there is no "setPaint" method. Rather, tweaking the exposed properties of the PaintModel fires,
72.52 - * when necessary, property change events for the "paint" property, and results in different values returned
72.53 - * from this method.
72.54 - */
72.55 - public abstract Paint getPaint();
72.56 -
72.57 - /**
72.58 - * Get the type of controls for this paint model
72.59 - *
72.60 - * @return The type of paint controls, one of PaintControlType.none, PaintControlType.control_line or
72.61 - * PaintControlType.control_rect
72.62 - */
72.63 - public abstract PaintControlType getPaintControlType();
72.64 -
72.65 -
72.66 - public abstract PaintModel clone();
72.67 -}
73.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/RadialGradient.java Sun Sep 06 23:14:42 2009 -0700
73.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
73.3 @@ -1,51 +0,0 @@
73.4 -/*
73.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
73.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
73.7 - *
73.8 - * This code is free software; you can redistribute it and/or modify it
73.9 - * under the terms of the GNU General Public License version 2 only, as
73.10 - * published by the Free Software Foundation. Sun designates this
73.11 - * particular file as subject to the "Classpath" exception as provided
73.12 - * by Sun in the LICENSE file that accompanied this code.
73.13 - *
73.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
73.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
73.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
73.17 - * version 2 for more details (a copy is included in the LICENSE file that
73.18 - * accompanied this code).
73.19 - *
73.20 - * You should have received a copy of the GNU General Public License version
73.21 - * 2 along with this work; if not, write to the Free Software Foundation,
73.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
73.23 - *
73.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
73.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
73.26 - * have any questions.
73.27 - */
73.28 -package org.jdesktop.swingx.designer.paint;
73.29 -
73.30 -import java.awt.Color;
73.31 -import java.awt.MultipleGradientPaint.CycleMethod;
73.32 -import java.awt.Paint;
73.33 -import java.awt.RadialGradientPaint;
73.34 -
73.35 -/**
73.36 - * Represents a RadialGradientPaint.
73.37 - *
73.38 - * @author rbair
73.39 - */
73.40 -public class RadialGradient extends AbstractGradient {
73.41 - protected Paint createPaint(float[] fractions, Matte[] mattes, CycleMethod method) {
73.42 - Color[] colors = new Color[mattes.length];
73.43 - for (int i = 0; i < colors.length; i++) {
73.44 - colors[i] = mattes[i].getColor();
73.45 - }
73.46 - return new RadialGradientPaint(.5f, .5f, 1, fractions, colors, method);
73.47 - }
73.48 -
73.49 - @Override public RadialGradient clone() {
73.50 - RadialGradient gradient = new RadialGradient();
73.51 - copyTo(gradient);
73.52 - return gradient;
73.53 - }
73.54 -}
74.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/Texture.java Sun Sep 06 23:14:42 2009 -0700
74.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
74.3 @@ -1,69 +0,0 @@
74.4 -/*
74.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
74.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
74.7 - *
74.8 - * This code is free software; you can redistribute it and/or modify it
74.9 - * under the terms of the GNU General Public License version 2 only, as
74.10 - * published by the Free Software Foundation. Sun designates this
74.11 - * particular file as subject to the "Classpath" exception as provided
74.12 - * by Sun in the LICENSE file that accompanied this code.
74.13 - *
74.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
74.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74.17 - * version 2 for more details (a copy is included in the LICENSE file that
74.18 - * accompanied this code).
74.19 - *
74.20 - * You should have received a copy of the GNU General Public License version
74.21 - * 2 along with this work; if not, write to the Free Software Foundation,
74.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
74.23 - *
74.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
74.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
74.26 - * have any questions.
74.27 - */
74.28 -package org.jdesktop.swingx.designer.paint;
74.29 -
74.30 -import java.awt.Paint;
74.31 -import java.awt.TexturePaint;
74.32 -import java.awt.geom.Rectangle2D;
74.33 -import java.awt.image.BufferedImage;
74.34 -
74.35 -/**
74.36 - * Represents a TexturePaint.
74.37 - *
74.38 - * @author rbair
74.39 - */
74.40 -public class Texture extends PaintModel {
74.41 - private static final Rectangle2D RECT = new Rectangle2D.Double(0, 0, 1, 1);
74.42 - private BufferedImage img;
74.43 -
74.44 - public Texture() {
74.45 - }
74.46 -
74.47 - public PaintControlType getPaintControlType() {
74.48 - return PaintControlType.control_rect;
74.49 - }
74.50 -
74.51 - public void setImage(BufferedImage img) {
74.52 - BufferedImage old = this.img;
74.53 - this.img = img;
74.54 - firePropertyChange("paint", old, this.img);
74.55 - firePropertyChange("image", old, this.img);
74.56 - }
74.57 -
74.58 - public final BufferedImage getImage() {
74.59 - return img;
74.60 - }
74.61 -
74.62 - public Paint getPaint() {
74.63 - return new TexturePaint(img, RECT);
74.64 - }
74.65 -
74.66 -
74.67 - public Texture clone() {
74.68 - Texture newTexture = new Texture();
74.69 - newTexture.img = this.img;
74.70 - return newTexture;
74.71 - }
74.72 -}
75.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/utils/HasPath.java Sun Sep 06 23:14:42 2009 -0700
75.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
75.3 @@ -1,34 +0,0 @@
75.4 -/*
75.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
75.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
75.7 - *
75.8 - * This code is free software; you can redistribute it and/or modify it
75.9 - * under the terms of the GNU General Public License version 2 only, as
75.10 - * published by the Free Software Foundation. Sun designates this
75.11 - * particular file as subject to the "Classpath" exception as provided
75.12 - * by Sun in the LICENSE file that accompanied this code.
75.13 - *
75.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
75.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
75.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
75.17 - * version 2 for more details (a copy is included in the LICENSE file that
75.18 - * accompanied this code).
75.19 - *
75.20 - * You should have received a copy of the GNU General Public License version
75.21 - * 2 along with this work; if not, write to the Free Software Foundation,
75.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
75.23 - *
75.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
75.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
75.26 - * have any questions.
75.27 - */
75.28 -package org.jdesktop.swingx.designer.utils;
75.29 -
75.30 -/**
75.31 - * HasPath - interface for model nodes that can provide there path in the tree
75.32 - *
75.33 - * @author Created by Jasper Potts (Jul 2, 2007)
75.34 - */
75.35 -public interface HasPath {
75.36 - public String getPath();
75.37 -}
76.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/utils/HasResources.java Sun Sep 06 23:14:42 2009 -0700
76.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
76.3 @@ -1,42 +0,0 @@
76.4 -/*
76.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
76.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
76.7 - *
76.8 - * This code is free software; you can redistribute it and/or modify it
76.9 - * under the terms of the GNU General Public License version 2 only, as
76.10 - * published by the Free Software Foundation. Sun designates this
76.11 - * particular file as subject to the "Classpath" exception as provided
76.12 - * by Sun in the LICENSE file that accompanied this code.
76.13 - *
76.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
76.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
76.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
76.17 - * version 2 for more details (a copy is included in the LICENSE file that
76.18 - * accompanied this code).
76.19 - *
76.20 - * You should have received a copy of the GNU General Public License version
76.21 - * 2 along with this work; if not, write to the Free Software Foundation,
76.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
76.23 - *
76.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
76.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
76.26 - * have any questions.
76.27 - */
76.28 -package org.jdesktop.swingx.designer.utils;
76.29 -
76.30 -import java.io.File;
76.31 -
76.32 -/**
76.33 - * HasResources - interface for model nodes that have resources
76.34 - *
76.35 - * @author Created by Jasper Potts (Jul 2, 2007)
76.36 - */
76.37 -public interface HasResources {
76.38 -
76.39 - public File getResourcesDir();
76.40 -
76.41 - public File getImagesDir();
76.42 -
76.43 - public File getTemplatesDir();
76.44 -
76.45 -}
77.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/utils/HasUIDefaults.java Sun Sep 06 23:14:42 2009 -0700
77.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
77.3 @@ -1,36 +0,0 @@
77.4 -/*
77.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
77.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
77.7 - *
77.8 - * This code is free software; you can redistribute it and/or modify it
77.9 - * under the terms of the GNU General Public License version 2 only, as
77.10 - * published by the Free Software Foundation. Sun designates this
77.11 - * particular file as subject to the "Classpath" exception as provided
77.12 - * by Sun in the LICENSE file that accompanied this code.
77.13 - *
77.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
77.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
77.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
77.17 - * version 2 for more details (a copy is included in the LICENSE file that
77.18 - * accompanied this code).
77.19 - *
77.20 - * You should have received a copy of the GNU General Public License version
77.21 - * 2 along with this work; if not, write to the Free Software Foundation,
77.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
77.23 - *
77.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
77.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
77.26 - * have any questions.
77.27 - */
77.28 -package org.jdesktop.swingx.designer.utils;
77.29 -
77.30 -import javax.swing.UIDefaults;
77.31 -
77.32 -/**
77.33 - * HasUIDefaults - A tagging interface for any class that has UIDefaults
77.34 - *
77.35 - * @author Created by Jasper Potts (Jun 22, 2007)
77.36 - */
77.37 -public interface HasUIDefaults {
77.38 - public UIDefaults getUiDefaults();
77.39 -}
78.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/generator/DefaultsGenerator.java Sun Sep 06 23:14:42 2009 -0700
78.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
78.3 @@ -1,726 +0,0 @@
78.4 -/*
78.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
78.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
78.7 - *
78.8 - * This code is free software; you can redistribute it and/or modify it
78.9 - * under the terms of the GNU General Public License version 2 only, as
78.10 - * published by the Free Software Foundation. Sun designates this
78.11 - * particular file as subject to the "Classpath" exception as provided
78.12 - * by Sun in the LICENSE file that accompanied this code.
78.13 - *
78.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
78.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78.17 - * version 2 for more details (a copy is included in the LICENSE file that
78.18 - * accompanied this code).
78.19 - *
78.20 - * You should have received a copy of the GNU General Public License version
78.21 - * 2 along with this work; if not, write to the Free Software Foundation,
78.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
78.23 - *
78.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
78.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
78.26 - * have any questions.
78.27 - */
78.28 -package org.jdesktop.synthdesigner.generator;
78.29 -
78.30 -import org.jdesktop.swingx.designer.Canvas;
78.31 -import org.jdesktop.swingx.designer.font.Typeface;
78.32 -import org.jdesktop.swingx.designer.paint.Matte;
78.33 -import org.jdesktop.swingx.designer.paint.PaintModel;
78.34 -import static org.jdesktop.synthdesigner.generator.GeneratorUtils.makePretty;
78.35 -import static org.jdesktop.synthdesigner.generator.GeneratorUtils.toConstantName;
78.36 -import static org.jdesktop.synthdesigner.generator.ObjectCodeConvertors.convert;
78.37 -import static org.jdesktop.synthdesigner.generator.TemplateWriter.read;
78.38 -import static org.jdesktop.synthdesigner.generator.TemplateWriter.writeSrcFile;
78.39 -import org.jdesktop.synthdesigner.synthmodel.SynthModel;
78.40 -import org.jdesktop.synthdesigner.synthmodel.UIComponent;
78.41 -import org.jdesktop.synthdesigner.synthmodel.UIFont;
78.42 -import org.jdesktop.synthdesigner.synthmodel.UIIconRegion;
78.43 -import org.jdesktop.synthdesigner.synthmodel.UIPaint;
78.44 -import org.jdesktop.synthdesigner.synthmodel.UIProperty;
78.45 -import org.jdesktop.synthdesigner.synthmodel.UIRegion;
78.46 -import org.jdesktop.synthdesigner.synthmodel.UIState;
78.47 -import org.jdesktop.synthdesigner.synthmodel.UIStateType;
78.48 -import org.jdesktop.synthdesigner.synthmodel.UIStyle;
78.49 -
78.50 -import javax.swing.border.BevelBorder;
78.51 -import javax.swing.border.Border;
78.52 -import javax.swing.border.CompoundBorder;
78.53 -import javax.swing.border.EmptyBorder;
78.54 -import javax.swing.border.EtchedBorder;
78.55 -import javax.swing.border.LineBorder;
78.56 -import javax.swing.border.MatteBorder;
78.57 -import java.awt.Dimension;
78.58 -import java.awt.Font;
78.59 -import java.awt.Insets;
78.60 -import java.io.File;
78.61 -import java.io.IOException;
78.62 -import java.util.List;
78.63 -import java.util.Map;
78.64 -import org.jdesktop.synthdesigner.synthmodel.PainterBorder;
78.65 -
78.66 -/**
78.67 - * DefaultsGenerator
78.68 - * <p/>
78.69 - * There are two main sets of defaults that must be configured. The first is
78.70 - * the actual UI defaults tree. The second is a map of components + regions, which
78.71 - * are used to decide what SynthStyle to use.
78.72 - *
78.73 - * @author Jasper Potts
78.74 - * @author Richard Bair
78.75 - */
78.76 -public class DefaultsGenerator {
78.77 - private static String stateTypeImplTemplate;
78.78 -
78.79 - private static String getStateTypeTemplate() {
78.80 - if (stateTypeImplTemplate == null) {
78.81 - //load the painter template file into an in-memory string to improve performance
78.82 - //when generating a lot of classes
78.83 - try {
78.84 - stateTypeImplTemplate = read("resources/StateImpl.template");
78.85 - } catch (IOException e) {
78.86 - System.err.println("Failed to read template files.");
78.87 - throw new RuntimeException(e);
78.88 - }
78.89 - }
78.90 - return stateTypeImplTemplate;
78.91 - }
78.92 -
78.93 - /**
78.94 - * Generate the defaults file and all painter files for a SynthModel. This method
78.95 - * is the main entry point, called by the Generator class.
78.96 - *
78.97 - * @param uiDefaultInit The buffer to write ui default put methods of the form <code>d.put("activeCaption", new
78.98 - * ColorUIResource(123, 45, 200));</code>
78.99 - * @param styleInit The buffer to write out code to generate Synth Style populating the styles map <code>m
78.100 - * = new HashMap<Key, LazyStyle>()</code>
78.101 - * @param model The Synth Model we are writing out defaults class for
78.102 - * @param variables The variables map pre populated with "PACKAGE" and "LAF_NAME"
78.103 - * @param packageNamePrefix The package name associated with this synth look and feel. For example,
78.104 - * org.mypackage.mylaf
78.105 - * @param painterPackageRoot The directory to write painters out to
78.106 - */
78.107 - public static void generateDefaults(StringBuilder uiDefaultInit, StringBuilder styleInit, SynthModel model,
78.108 - Map<String, String> variables, String packageNamePrefix,
78.109 - File painterPackageRoot) {
78.110 - // write color palette
78.111 - uiDefaultInit.append(" //Color palette\n");
78.112 - writeColorPalette(uiDefaultInit, model.getColorPalette());
78.113 - uiDefaultInit.append("\n");
78.114 - // write fonts palette
78.115 - uiDefaultInit.append(" //Font palette\n");
78.116 - uiDefaultInit.append(" d.put(\"defaultFont\", new FontUIResource(defaultFont));\n");
78.117 - writeFontPalette(uiDefaultInit, model.getFontPalette());
78.118 - uiDefaultInit.append("\n");
78.119 - // TODO: Other palettes
78.120 - uiDefaultInit.append(" //Border palette\n");
78.121 - uiDefaultInit.append("\n");
78.122 - // write global style
78.123 - uiDefaultInit.append(" //The global style definition\n");
78.124 - writeStyle(model.getStyle(), uiDefaultInit, "");
78.125 - uiDefaultInit.append("\n");
78.126 - // write components
78.127 - for (UIComponent c : model.getComponents()) {
78.128 - String prefix = escape(c.getKey());
78.129 - uiDefaultInit.append(" //Initialize ").append(prefix)
78.130 - .append("\n");
78.131 - writeRegion(c, c, prefix, uiDefaultInit,
78.132 - styleInit, variables, packageNamePrefix, painterPackageRoot);
78.133 - uiDefaultInit.append("\n");
78.134 - }
78.135 - }
78.136 -
78.137 - private static void writeColorPalette(StringBuilder uiDefaultInit, List<UIPaint> colors) {
78.138 - for (UIPaint color : colors) {
78.139 - uiDefaultInit.append(" d.put(\"")
78.140 - .append(color.getName())
78.141 - .append("\",")
78.142 - .append(convertPaint(color.getValue()))
78.143 - .append(");\n");
78.144 - }
78.145 - }
78.146 -
78.147 - private static void writeFontPalette(StringBuilder uiDefaultInit, List<UIFont> fonts) {
78.148 - for (UIFont font : fonts) {
78.149 - // We have no way of doing CSS style font lists yet so will just
78.150 - // just the first font
78.151 - if (!font.getFonts().isEmpty()){
78.152 - Typeface t = font.getFonts().get(0);
78.153 - if (t.isAbsolute()){
78.154 - Font f = t.getFont();
78.155 - uiDefaultInit.append(" d.put(\"")
78.156 - .append(font.getName())
78.157 - .append("\", new javax.swing.plaf.FontUIResource(\"")
78.158 - .append(f.getName())
78.159 - .append("\", ")
78.160 - .append(f.getStyle())
78.161 - .append(", ")
78.162 - .append(f.getSize())
78.163 - .append("));\n");
78.164 - } else {
78.165 - uiDefaultInit.append(" d.put(\"")
78.166 - .append(font.getName())
78.167 - .append("\", new DerivedFont(\"")
78.168 - .append(t.getUiDefaultParentName())
78.169 - .append("\", ")
78.170 - .append(t.getSizeOffset())
78.171 - .append("f, ");
78.172 - switch (t.getBold()){
78.173 - case Default:
78.174 - uiDefaultInit.append("null");
78.175 - break;
78.176 - case On:
78.177 - uiDefaultInit.append("true");
78.178 - break;
78.179 - case Off:
78.180 - uiDefaultInit.append("false");
78.181 - break;
78.182 - }
78.183 - uiDefaultInit.append(", ");
78.184 - switch (t.getItalic()){
78.185 - case Default:
78.186 - uiDefaultInit.append("null");
78.187 - break;
78.188 - case On:
78.189 - uiDefaultInit.append("true");
78.190 - break;
78.191 - case Off:
78.192 - uiDefaultInit.append("false");
78.193 - break;
78.194 - }
78.195 - uiDefaultInit.append("));\n");
78.196 - }
78.197 - }
78.198 - }
78.199 - }
78.200 -
78.201 - /**
78.202 - * Write out the UIDefaults entries for a style
78.203 - *
78.204 - * @param style The style to write defaults entries for
78.205 - * @param uiDefaultInit The buffer to write ui default put methods of the form <code>d.put("activeCaption", new
78.206 - * ColorUIResource(123, 45, 200));</code>
78.207 - * @param prefix The prefix for the style property names, for the model path where the style is from, should
78.208 - * end with a "."
78.209 - */
78.210 - private static void writeStyle(UIStyle style, StringBuilder uiDefaultInit, String prefix) {
78.211 - if (!style.isTextForegroundInherited()) writeMatte(prefix + "textForeground", style.getTextForeground(), uiDefaultInit);
78.212 - if (!style.isTextBackgroundInherited()) writeMatte(prefix + "textBackground", style.getTextBackground(), uiDefaultInit);
78.213 - if (!style.isBackgroundInherited()) writeMatte(prefix + "background", style.getBackground(), uiDefaultInit);
78.214 - if (!style.isFontInherited()) writeTypeFace(prefix + "font", style.getFont(), uiDefaultInit);
78.215 - for (UIProperty property : style.getUiProperties()) {
78.216 - switch (property.getType()) {
78.217 - case BOOLEAN:
78.218 - Boolean b = ((Boolean)property.getValue());
78.219 - if (b != null) {
78.220 - uiDefaultInit.append(" d.put(\"")
78.221 - .append(prefix)
78.222 - .append(property.getName())
78.223 - .append("\", ")
78.224 - .append(b ? "Boolean.TRUE" : "Boolean.FALSE")
78.225 - .append(");\n");
78.226 - }
78.227 - break;
78.228 - case STRING:
78.229 - uiDefaultInit.append(" d.put(\"")
78.230 - .append(prefix)
78.231 - .append(property.getName())
78.232 - .append("\", \"")
78.233 - .append(property.getValue().toString())
78.234 - .append("\");\n");
78.235 - break;
78.236 - case INT:
78.237 - uiDefaultInit.append(" d.put(\"")
78.238 - .append(prefix)
78.239 - .append(property.getName())
78.240 - .append("\", new Integer(")
78.241 - .append(((Integer) property.getValue()).intValue())
78.242 - .append("));\n");
78.243 - break;
78.244 - case FLOAT:
78.245 - uiDefaultInit.append(" d.put(\"")
78.246 - .append(prefix)
78.247 - .append(property.getName())
78.248 - .append("\", new Float(")
78.249 - .append(((Float) property.getValue()).floatValue())
78.250 - .append("f));\n");
78.251 - break;
78.252 - case DOUBLE:
78.253 - uiDefaultInit.append(" d.put(\"")
78.254 - .append(prefix)
78.255 - .append(property.getName())
78.256 - .append("\", new Double(")
78.257 - .append(((Double) property.getValue()).doubleValue())
78.258 - .append("));\n");
78.259 - break;
78.260 - case COLOR:
78.261 - uiDefaultInit.append(" d.put(\"")
78.262 - .append(prefix)
78.263 - .append(property.getName())
78.264 - .append("\", ")
78.265 - .append(convertPaint((Matte)property.getValue()))
78.266 - .append(");\n");
78.267 - break;
78.268 - case FONT:
78.269 - writeTypeFace(prefix.replace("\"", "\\\"") + property.getName(),
78.270 - (Typeface) property.getValue(), uiDefaultInit);
78.271 - break;
78.272 - case INSETS:
78.273 - Insets i = (Insets) property.getValue();
78.274 - uiDefaultInit.append(" d.put(\"")
78.275 - .append(prefix)
78.276 - .append(property.getName())
78.277 - .append("\", new InsetsUIResource(")
78.278 - .append(i.top).append(", ").append(i.left).append(", ").append(i.bottom).append(", ")
78.279 - .append(i.right)
78.280 - .append("));\n");
78.281 - break;
78.282 - case DIMENSION:
78.283 - Dimension d = (Dimension) property.getValue();
78.284 - uiDefaultInit.append(" d.put(\"")
78.285 - .append(prefix)
78.286 - .append(property.getName())
78.287 - .append("\", new DimensionUIResource(")
78.288 - .append(d.width).append(", ").append(d.height)
78.289 - .append("));\n");
78.290 - break;
78.291 - case BORDER:
78.292 - uiDefaultInit.append(" d.put(\"")
78.293 - .append(prefix)
78.294 - .append(property.getName())
78.295 - .append("\", new BorderUIResource(");
78.296 - uiDefaultInit.append(convertBorder(
78.297 - (Border)property.getValue()));
78.298 - uiDefaultInit.append("));\n");
78.299 - break;
78.300 - }
78.301 - }
78.302 - }
78.303 -
78.304 - private static void writeMatte(String propertyName, Matte matte, StringBuilder uiDefaultInit) {
78.305 - if (matte==null) System.err.println("Error matte is NULL for ["+propertyName+"]");
78.306 - uiDefaultInit.append(" d.put(\"")
78.307 - .append(propertyName)
78.308 - .append("\", ")
78.309 - .append(convertPaint(matte))
78.310 - .append(");\n");
78.311 - }
78.312 -
78.313 - private static void writeTypeFace(String propertyName, Typeface typeface, StringBuilder uiDefaultInit) {
78.314 - uiDefaultInit.append(" d.put(\"")
78.315 - .append(propertyName)
78.316 - .append("\", new DerivedFont(\"")
78.317 - .append(typeface.getUiDefaultParentName())
78.318 - .append("\", ")
78.319 - .append(typeface.getSizeOffset())
78.320 - .append("f, ");
78.321 - switch (typeface.getBold()) {
78.322 - case Default:
78.323 - uiDefaultInit.append("null,");
78.324 - break;
78.325 - case Off:
78.326 - uiDefaultInit.append("Boolean.FALSE,");
78.327 - break;
78.328 - case On:
78.329 - uiDefaultInit.append("Boolean.TRUE,");
78.330 - break;
78.331 - }
78.332 - switch (typeface.getItalic()) {
78.333 - case Default:
78.334 - uiDefaultInit.append("null");
78.335 - break;
78.336 - case Off:
78.337 - uiDefaultInit.append("Boolean.FALSE");
78.338 - break;
78.339 - case On:
78.340 - uiDefaultInit.append("Boolean.TRUE");
78.341 - break;
78.342 - }
78.343 - uiDefaultInit.append("));\n");
78.344 - }
78.345 -
78.346 -
78.347 - /**
78.348 - * Write out code for a Component or Region
78.349 - *
78.350 - * @param comp This may be the same as the region <code>reg</code> or is the parent component
78.351 - * containing the region
78.352 - * @param region The region we are writing out
78.353 - * @param prefix This is dot sperated path of component and sub regions to and including the region
78.354 - * <code>reg</code> of the form [Comp].[Region]......[Region] path
78.355 - * @param uiDefaultInit This is for inserting into org.mypackage.mylaf.MyDefaults#getDefaults() method
78.356 - * @param styleInit This is for inserting into org.mypackage.mylaf.MyDefaults#initialize() method
78.357 - * @param variables The variables map pre populated with "PACKAGE" and "LAF_NAME"
78.358 - * @param packageNamePrefix The package name associated with this synth look and feel. For example,
78.359 - * org.mypackage.mylaf
78.360 - * @param painterPackageRoot The directory to write painters out to
78.361 - */
78.362 - private static void writeRegion(UIComponent comp, UIRegion region, String prefix, StringBuilder uiDefaultInit,
78.363 - StringBuilder styleInit, Map<String, String> variables,
78.364 - String packageNamePrefix, File painterPackageRoot) {
78.365 - // register component with LAF
78.366 - String regionCode = GeneratorUtils.getRegionNameCaps(region.getName());
78.367 - if (regionCode == null) {
78.368 - throw new IllegalStateException("We were asked to encode a region we know nothing about: " + region.getName());
78.369 - } else {
78.370 - regionCode = "Region." + regionCode;
78.371 - }
78.372 -
78.373 - //construct the list of States that accompany this registration.
78.374 - StringBuffer regString = new StringBuffer(); //like: Enabled,Disabled,Foo,Default,Etc
78.375 - List<UIStateType> types = comp.getStateTypes(); //state types are only defined on the UIComponent level
78.376 - if (types != null && types.size() > 0) {
78.377 - for (UIStateType type : types) {
78.378 - regString.append(type.getKey());
78.379 - regString.append(",");
78.380 - }
78.381 - //remove the last ","
78.382 - regString.deleteCharAt(regString.length()-1);
78.383 - }
78.384 -
78.385 - styleInit.append(" register(")
78.386 - .append(regionCode)
78.387 - .append(", \"")
78.388 - .append(prefix);
78.389 - styleInit.append("\"");
78.390 - styleInit.append(");\n");
78.391 -
78.392 - // write content margins
78.393 - Insets i = (Insets) region.getContentMargins();
78.394 - uiDefaultInit.append(" d.put(\"")
78.395 - .append(prefix)
78.396 - .append(".contentMargins")
78.397 - .append("\", new InsetsUIResource(")
78.398 - .append(i.top).append(", ").append(i.left).append(", ").append(i.bottom).append(", ").append(i.right)
78.399 - .append("));\n");
78.400 - // write opaque if true
78.401 - if (region instanceof UIComponent && ((UIComponent)region).isOpaque()) {
78.402 - uiDefaultInit.append(" d.put(\"")
78.403 - .append(prefix)
78.404 - .append(".opaque")
78.405 - .append("\", Boolean.TRUE);\n");
78.406 - }
78.407 - //write the State, if necessary
78.408 - if (!regString.equals("Enabled,MouseOver,Pressed,Disabled,Focused,Selected,Default") && types.size() > 0) {
78.409 - //there were either custom states, or the normal states were in a custom order
78.410 - //so go ahead and write out prefix.State
78.411 - uiDefaultInit.append(" d.put(\"")
78.412 - .append(prefix)
78.413 - .append(".States")
78.414 - .append("\", \"")
78.415 - .append(regString)
78.416 - .append("\");\n");
78.417 - }
78.418 - //write out any custom states, if necessary
78.419 - for (UIStateType type : types) {
78.420 - String synthState = type.getKey();
78.421 - if (!"Enabled".equals(synthState) &&
78.422 - !"MouseOver".equals(synthState) &&
78.423 - !"Pressed".equals(synthState) &&
78.424 - !"Disabled".equals(synthState) &&
78.425 - !"Focused".equals(synthState) &&
78.426 - !"Selected".equals(synthState) &&
78.427 - !"Default".equals(synthState)) {
78.428 - //what we have here, gentlemen, is a bona-fide custom state.
78.429 - try {
78.430 - //if the type is not one of the standard types, then construct a name for
78.431 - //the new type, and write out a new subclass of State.
78.432 - java.lang.String className = makePretty(prefix) + synthState + "State";
78.433 - java.lang.String body = type.getCodeSnippet();
78.434 - variables.put("STATE_NAME", className);
78.435 - variables.put("STATE_KEY", synthState);
78.436 - variables.put("BODY", body);
78.437 -
78.438 - writeSrcFile(getStateTypeTemplate(), variables, new java.io.File(painterPackageRoot, className + ".java"));
78.439 -
78.440 - variables.remove("STATE_NAME");
78.441 - variables.remove("STATE_KEY");
78.442 - variables.remove("BODY");
78.443 -
78.444 - uiDefaultInit.append(" d.put(\"")
78.445 - .append(prefix)
78.446 - .append(".")
78.447 - .append(synthState)
78.448 - .append("\", new ")
78.449 - .append(className)
78.450 - .append("());\n");
78.451 - } catch (IOException ex) {
78.452 - ex.printStackTrace();
78.453 - }
78.454 - }
78.455 - }
78.456 - // write region style
78.457 - writeStyle(region.getStyle(), uiDefaultInit, prefix + ".");
78.458 -
78.459 - try {
78.460 - boolean hasCanvas = hasCanvas(region);
78.461 - if (hasCanvas) {
78.462 - PainterGenerator.writePainter(region, variables, painterPackageRoot, prefix);
78.463 - }
78.464 - String fileNamePrefix = makePretty(prefix) + "Painter";
78.465 - // write states ui defaults
78.466 - for (UIState state : region.getBackgroundStates()) {
78.467 - String statePrefix = prefix + "[" + state.getName() + "]";
78.468 - // write state style
78.469 - writeStyle(state.getStyle(), uiDefaultInit, statePrefix + ".");
78.470 - // write painter
78.471 - if (hasCanvas) {
78.472 - writeLazyPainter(state, uiDefaultInit, statePrefix, packageNamePrefix, fileNamePrefix, "background");
78.473 - }
78.474 - }
78.475 - for (UIState state : region.getForegroundStates()) {
78.476 - String statePrefix = prefix + "[" + state.getName() + "]";
78.477 - // write state style
78.478 - writeStyle(state.getStyle(), uiDefaultInit, statePrefix + ".");
78.479 - // write painter
78.480 - if (hasCanvas) {
78.481 - writeLazyPainter(state, uiDefaultInit, statePrefix, packageNamePrefix, fileNamePrefix, "foreground");
78.482 - }
78.483 - }
78.484 - for (UIState state : region.getBorderStates()) {
78.485 - String statePrefix = prefix + "[" + state.getName() + "]";
78.486 - // write state style
78.487 - writeStyle(state.getStyle(), uiDefaultInit, statePrefix + ".");
78.488 - // write painter
78.489 - if (hasCanvas) {
78.490 - writeLazyPainter(state, uiDefaultInit, statePrefix, packageNamePrefix, fileNamePrefix, "border");
78.491 - }
78.492 - }
78.493 - } catch (Exception e) {
78.494 - e.printStackTrace();
78.495 - }
78.496 -
78.497 - // handle sub regions
78.498 - for (UIRegion subRegion : region.getSubRegions()) {
78.499 - String subregionName = prefix + ":" + escape(subRegion.getKey());
78.500 - if (subRegion instanceof UIIconRegion) {
78.501 - writeIconRegion(comp, (UIIconRegion) subRegion, prefix, uiDefaultInit,
78.502 - variables, packageNamePrefix, painterPackageRoot);
78.503 - } else if (subRegion instanceof UIComponent) {
78.504 - // inner named component
78.505 - UIComponent subComponent = (UIComponent) subRegion;
78.506 - writeRegion(subComponent, subRegion, subregionName,
78.507 - uiDefaultInit, styleInit, variables, packageNamePrefix, painterPackageRoot);
78.508 - } else {
78.509 - writeRegion(comp, subRegion, subregionName, uiDefaultInit, styleInit, variables,
78.510 - packageNamePrefix, painterPackageRoot);
78.511 - }
78.512 - }
78.513 - }
78.514 -
78.515 - private static void writeLazyPainter(UIState state, StringBuilder uiDefaultInit, String statePrefix, String packageNamePrefix, String fileNamePrefix, String painterSuffix) {
78.516 - Canvas canvas = state.getCanvas();
78.517 - if (!canvas.isBlank()) {
78.518 - Insets si = canvas.getStretchingInsets();
78.519 - boolean inverted = state.isInverted();
78.520 - UIStyle.CacheMode cache = state.getStyle().getCacheMode();
78.521 - String cacheModeString = null;
78.522 - switch (cache) {
78.523 - case NO_CACHING: cacheModeString = "AbstractRegionPainter.PaintContext.CacheMode.NO_CACHING"; break;
78.524 - case FIXED_SIZES: cacheModeString = "AbstractRegionPainter.PaintContext.CacheMode.FIXED_SIZES"; break;
78.525 - case NINE_SQUARE_SCALE: cacheModeString = "AbstractRegionPainter.PaintContext.CacheMode.NINE_SQUARE_SCALE"; break;
78.526 - }
78.527 - double maxH = state.getStyle().getMaxHozCachedImgScaling();
78.528 - double maxV = state.getStyle().getMaxVertCachedImgScaling();
78.529 - String stateConstant = toConstantName(painterSuffix + "_" + UIState.keysToString(state.getStateKeys()));
78.530 -
78.531 - uiDefaultInit.append(" d.put(\"")
78.532 - .append(statePrefix)
78.533 - .append(".").append(painterSuffix).append("Painter\", new LazyPainter(\"")
78.534 - .append(packageNamePrefix).append(".").append(fileNamePrefix)
78.535 - .append("\", ")
78.536 - .append(fileNamePrefix).append(".").append(stateConstant).append(", ")
78.537 - .append(convert(si)).append(", ")
78.538 - .append(convert(canvas.getSize())).append(", ")
78.539 - .append(inverted).append(", ")
78.540 - .append(cacheModeString).append(", ")
78.541 - .append(maxH == Double.POSITIVE_INFINITY ? "Double.POSITIVE_INFINITY" : maxH).append(", ")
78.542 - .append(maxV == Double.POSITIVE_INFINITY ? "Double.POSITIVE_INFINITY" : maxV).append("));\n");
78.543 - }
78.544 - }
78.545 -
78.546 -
78.547 - /**
78.548 - * Write out code for a IconRegion
78.549 - *
78.550 - * @param comp This may be the same as the region <code>region</code> or is the parent component
78.551 - * containing the region
78.552 - * @param region The region we are writing out
78.553 - * @param prefix This is [Comp][Region]......[Region] path
78.554 - * @param key The key for this icon.
78.555 - * @param uiDefaultInit This is for inserting into org.mypackage.mylaf.MyDefaults#getDefaults() method
78.556 - * @param variables The variables map pre populated with "PACKAGE" and "LAF_NAME"
78.557 - * @param packageNamePrefix The package name associated with this synth look and feel. For example,
78.558 - * org.mypackage.mylaf
78.559 - * @param painterPackageRoot The directory to write painters out to
78.560 - */
78.561 - private static void writeIconRegion(UIComponent comp, UIIconRegion region, String prefix,
78.562 - StringBuilder uiDefaultInit, Map<String, String> variables,
78.563 - String packageNamePrefix, File painterPackageRoot) {
78.564 -
78.565 - Dimension size = null;
78.566 - String fileNamePrefix = makePretty(prefix) + "Painter";
78.567 - // write states ui defaults
78.568 - for (UIState state : region.getBackgroundStates()) {// TODO: Handle Background,Foreground and Borders States Lists? Actually not sure that IconRegions need support borders or foregrounds
78.569 - Canvas canvas = state.getCanvas();
78.570 - if (!canvas.isBlank()) {
78.571 - String statePrefix = prefix + "[" + state.getName() + "]";
78.572 - // Put Painter in UiDefaults
78.573 - writeLazyPainter(state, uiDefaultInit, statePrefix, packageNamePrefix, fileNamePrefix, region.getKey());
78.574 - size = canvas.getSize();
78.575 - }
78.576 - }
78.577 -
78.578 - if (size != null) {
78.579 - // Put SynthIconImpl wrapper in UiDefaults
78.580 - String key = region.getBasicKey() == null ? prefix + "." + region.getKey() : region.getBasicKey();
78.581 - uiDefaultInit.append(" d.put(\"")
78.582 - .append(key)
78.583 - .append("\", new NimbusIcon(\"") //TODO should this be wrapped in an IconUIResource?
78.584 - .append(prefix)
78.585 - .append("\", \"")
78.586 - .append(region.getKey())
78.587 - .append("Painter")
78.588 - .append("\", ")
78.589 - .append(size.width)
78.590 - .append(", ")
78.591 - .append(size.height)
78.592 - .append("));\n");
78.593 - }
78.594 -
78.595 - // handle sub regions
78.596 - if (region.getSubRegions().length > 0) {
78.597 - // there is no meaning to a sub region inside a IconRegion
78.598 - throw new IllegalStateException("You can not have sub regions inside UiIconRegions. \"" +
78.599 - comp.getSubRegions()[0].getName() + "\" is inside \""
78.600 - + prefix.substring(0, prefix.length() - 1) + "\"");
78.601 - }
78.602 - }
78.603 -
78.604 - /**
78.605 - * Utility method for escaping all double quotes with backslash double-quote.
78.606 - */
78.607 - private static String escape(String s) {
78.608 - return s.replace("\"", "\\\"");
78.609 - }
78.610 -
78.611 - private static String convertPaint(PaintModel paint){
78.612 - if (paint instanceof Matte){
78.613 - Matte matte = (Matte)paint;
78.614 - if (matte.isAbsolute()){
78.615 - String colorParams = convert(matte.getColor());
78.616 - if (matte.isUiResource()) {
78.617 - return "new ColorUIResource(" + colorParams + ")";
78.618 - } else {
78.619 - return colorParams;
78.620 - }
78.621 - } else {
78.622 - String s = "getDerivedColor(\"" +
78.623 - matte.getUiDefaultParentName()+"\","+
78.624 - matte.getHueOffset()+"f,"+matte.getSaturationOffset()+
78.625 - "f,"+matte.getBrightnessOffset()+"f,"+
78.626 - matte.getAlphaOffset();
78.627 - if (matte.isUiResource()) {
78.628 - return s + ")";
78.629 - } else {
78.630 - return s + ",false)";
78.631 - }
78.632 - }
78.633 - } else {
78.634 - //TODO: What about gradients etc here?
78.635 - System.err.println("Error: Could not write paint in " +
78.636 - "DefaultsGenerator as it was not a Matte. = "+
78.637 - paint.getClass().getName());
78.638 - return "";
78.639 - }
78.640 - }
78.641 -
78.642 - private static String convertBorder(Border val) {
78.643 - StringBuilder uiDefaultInit = new StringBuilder();
78.644 - Insets i;
78.645 - if (val instanceof PainterBorder) {
78.646 - PainterBorder pb = (PainterBorder) val;
78.647 - i = pb.getBorderInsets();
78.648 - uiDefaultInit.append("new PainterBorder(\"")
78.649 - .append(pb.getPainterName())
78.650 - .append("\", new Insets(")
78.651 - .append(i.top).append(", ")
78.652 - .append(i.left).append(", ")
78.653 - .append(i.bottom).append(", ")
78.654 - .append(i.right)
78.655 - .append("))");
78.656 - } else if (val instanceof EmptyBorder) {
78.657 - i = ((EmptyBorder) val).getBorderInsets();
78.658 - uiDefaultInit.append("BorderFactory.createEmptyBorder(")
78.659 - .append(i.top).append(", ")
78.660 - .append(i.left).append(", ")
78.661 - .append(i.bottom).append(", ")
78.662 - .append(i.right)
78.663 - .append(")");
78.664 - } else if (val instanceof LineBorder) {
78.665 - LineBorder border = (LineBorder) val;
78.666 - uiDefaultInit.append("BorderFactory.createLineBorder(")
78.667 - .append(convert(border.getLineColor()))
78.668 - .append(",")
78.669 - .append(border.getThickness())
78.670 - .append(")");
78.671 - } else if (val instanceof EtchedBorder) {
78.672 - EtchedBorder border = (EtchedBorder) val;
78.673 - uiDefaultInit.append("BorderFactory.createEtchedBorder(")
78.674 - .append(border.getEtchType())
78.675 - .append(",")
78.676 - .append(convert(border.getHighlightColor()))
78.677 - .append(",")
78.678 - .append(convert(border.getShadowColor()))
78.679 - .append(")");
78.680 - } else if (val instanceof BevelBorder) {
78.681 - BevelBorder border = (BevelBorder) val;
78.682 - uiDefaultInit.append("BorderFactory.createEtchedBorder(")
78.683 - .append(border.getBevelType())
78.684 - .append(",")
78.685 - .append(convert(border.getHighlightOuterColor()))
78.686 - .append(",")
78.687 - .append(convert(border.getHighlightInnerColor()))
78.688 - .append(",")
78.689 - .append(convert(border.getShadowOuterColor()))
78.690 - .append(",")
78.691 - .append(convert(border.getShadowInnerColor()))
78.692 - .append(")");
78.693 - } else if (val instanceof MatteBorder) {
78.694 - MatteBorder border = (MatteBorder) val;
78.695 - i = border.getBorderInsets();
78.696 - uiDefaultInit.append("BorderFactory.createEmptyBorder(")
78.697 - .append(i.top).append(", ")
78.698 - .append(i.left).append(", ")
78.699 - .append(i.bottom).append(", ")
78.700 - .append(i.right).append(", ")
78.701 - .append(convert(border.getMatteColor()))
78.702 - .append(")");
78.703 - } else if (val instanceof CompoundBorder) {
78.704 - CompoundBorder border = (CompoundBorder) val;
78.705 - uiDefaultInit.append("BorderFactory.createEmptyBorder(")
78.706 - .append(convertBorder(border.getOutsideBorder()))
78.707 - .append(",")
78.708 - .append(convertBorder(border.getInsideBorder()))
78.709 - .append(")");
78.710 - }
78.711 - return uiDefaultInit.toString();
78.712 - }
78.713 -
78.714 - private static boolean hasCanvas(UIRegion region) {
78.715 - for (UIState s : region.getBackgroundStates()) {
78.716 - if (!s.getCanvas().isBlank()) return true;
78.717 - }
78.718 - for (UIState s : region.getBorderStates()) {
78.719 - if (!s.getCanvas().isBlank()) return true;
78.720 - }
78.721 - for (UIState s : region.getForegroundStates()) {
78.722 - if (!s.getCanvas().isBlank()) return true;
78.723 - }
78.724 - for (UIRegion subregion : region.getSubRegions()) {
78.725 - if (hasCanvas(subregion)) return true;
78.726 - }
78.727 - return false;
78.728 - }
78.729 -}
79.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/generator/Generator.java Sun Sep 06 23:14:42 2009 -0700
79.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
79.3 @@ -1,289 +0,0 @@
79.4 -/*
79.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
79.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
79.7 - *
79.8 - * This code is free software; you can redistribute it and/or modify it
79.9 - * under the terms of the GNU General Public License version 2 only, as
79.10 - * published by the Free Software Foundation. Sun designates this
79.11 - * particular file as subject to the "Classpath" exception as provided
79.12 - * by Sun in the LICENSE file that accompanied this code.
79.13 - *
79.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
79.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
79.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
79.17 - * version 2 for more details (a copy is included in the LICENSE file that
79.18 - * accompanied this code).
79.19 - *
79.20 - * You should have received a copy of the GNU General Public License version
79.21 - * 2 along with this work; if not, write to the Free Software Foundation,
79.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
79.23 - *
79.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
79.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
79.26 - * have any questions.
79.27 - */
79.28 -package org.jdesktop.synthdesigner.generator;
79.29 -
79.30 -import static org.jdesktop.synthdesigner.generator.TemplateWriter.read;
79.31 -import static org.jdesktop.synthdesigner.generator.TemplateWriter.writeSrcFile;
79.32 -import org.jdesktop.synthdesigner.synthmodel.SynthModel;
79.33 -import org.jibx.runtime.BindingDirectory;
79.34 -import org.jibx.runtime.IBindingFactory;
79.35 -import org.jibx.runtime.IUnmarshallingContext;
79.36 -
79.37 -import java.io.File;
79.38 -import java.io.FileInputStream;
79.39 -import java.io.IOException;
79.40 -import java.util.HashMap;
79.41 -import java.util.Map;
79.42 -
79.43 -/**
79.44 - * Generates the various Java artifacts based on a SynthModel.
79.45 - * <p/>
79.46 - * Generated source files are split up among two different locations. There are those source files that are meant to be
79.47 - * edited (generally, only the LookAndFeel class itself) and those that are autogenerated (everything else).
79.48 - * <p/>
79.49 - * All autogenerated files are placed in "buildPackageRoot" and are package private. A LAF author (one who has access to
79.50 - * the generated sources) will be able to access any of the generated classes. Those referencing the library, however,
79.51 - * will only be able to access the main LookAndFeel class itself (since everything else is package private).
79.52 - *
79.53 - * @author Richard Bair
79.54 - * @author Jasper Potts
79.55 - */
79.56 -public class Generator {
79.57 - /** A map of variables that are used for variable substitution in the template files. */
79.58 - private Map<String, String> variables;
79.59 -
79.60 - private boolean full = false;
79.61 - private File buildPackageRoot;
79.62 - private File srcPackageRoot;
79.63 - private String packageNamePrefix;
79.64 - private String lafName;
79.65 - private SynthModel model;
79.66 -
79.67 - /**
79.68 - * MAIN APPLICATION
79.69 - * <p/>
79.70 - * This is for using the generator as part of the java build process
79.71 - *
79.72 - * @param args The commandline arguments
79.73 - */
79.74 - public static void main(String[] args) {
79.75 - if (args.length == 0 || (args.length % 2) != 0) {
79.76 - System.out.println("Usage: generator [-options]\n" +
79.77 - " -full <true|false> True if we should build the whole LAF or false for building just states and painters.\n" +
79.78 - " -skinFile <value> Path to the skin.laf file for the LAF to be generated from.\n" +
79.79 - " -buildDir <value> The directory beneath which the build-controlled artifacts (such as the Painters) should\n" +
79.80 - " be placed. This is the root directory beneath which the necessary packages and source\n" +
79.81 - " files will be created.\n" +
79.82 - " -srcDir <value> The directory beneath which the normal user-controlled artifacts (such as the core\n" +
79.83 - " LookAndFeel file) should be placed. These are one-time generated files. This is the root\n" +
79.84 - " directory beneath which the necessary packages and source files will be created.\n" +
79.85 - " -resourcesDir <value> The resources directory containing templates and images.\n" +
79.86 - " -packagePrefix <value> The package name associated with this synth look and feel. For example,\n" +
79.87 - " \"org.mypackage.mylaf\"\n" +
79.88 - " -lafName <value> The name of the laf, such as \"MyLAF\".\n");
79.89 - } else {
79.90 - boolean full = false;
79.91 - File skinFile = new File(System.getProperty("user.dir"));
79.92 - File buildDir = new File(System.getProperty("user.dir"));
79.93 - File srcDir = new File(System.getProperty("user.dir"));
79.94 - File resourcesDir = new File(System.getProperty("user.dir"));
79.95 - String packagePrefix = "org.mypackage.mylaf";
79.96 - String lafName = "MyLAF";
79.97 - for (int i = 0; i < args.length; i += 2) {
79.98 - String key = args[i].trim().toLowerCase();
79.99 - String value = args[i + 1].trim();
79.100 - if ("-full".equals(key)) {
79.101 - full = Boolean.parseBoolean(value);
79.102 - } else if ("-skinfile".equals(key)) {
79.103 - skinFile = new File(value);
79.104 - } else if ("-builddir".equals(key)) {
79.105 - buildDir = new File(value);
79.106 - } else if ("-srcdir".equals(key)) {
79.107 - srcDir = new File(value);
79.108 - } else if ("-resourcesdir".equals(key)) {
79.109 - resourcesDir = new File(value);
79.110 - } else if ("-packageprefix".equals(key)) {
79.111 - packagePrefix = value;
79.112 - } else if ("-lafname".equals(key)) {
79.113 - lafName = value;
79.114 - }
79.115 - }
79.116 - System.out.println("### GENERATING LAF CODE ################################");
79.117 - System.out.println(" full :" + full);
79.118 - System.out.println(" skinFile :" + skinFile.getAbsolutePath());
79.119 - System.out.println(" buildDir :" + buildDir.getAbsolutePath());
79.120 - System.out.println(" srcDir :" + srcDir.getAbsolutePath());
79.121 - System.out.println(" resourcesDir :" + resourcesDir.getAbsolutePath());
79.122 - System.out.println(" packagePrefix :" +packagePrefix);
79.123 - System.out.println(" lafName :" +lafName);
79.124 - try {
79.125 - // LOAD SKIN MODEL
79.126 - IBindingFactory bindingFactory = BindingDirectory.getFactory(SynthModel.class);
79.127 - IUnmarshallingContext mctx = bindingFactory.createUnmarshallingContext();
79.128 - mctx.setDocument(new FileInputStream(skinFile), "UTF-8");
79.129 - // pass resources directory in as user context so it can be used in SynthModel preSet
79.130 - mctx.setUserContext(resourcesDir);
79.131 - SynthModel model = (SynthModel) mctx.unmarshalElement();
79.132 - // create and run generator
79.133 - Generator generator = new Generator(full, buildDir, srcDir, packagePrefix, lafName, model);
79.134 - generator.generate();
79.135 - } catch (Exception e) {
79.136 - System.err.println("Error loading skin and generating java src:");
79.137 - e.printStackTrace();
79.138 - }
79.139 - }
79.140 - }
79.141 -
79.142 - /**
79.143 - * Creates a new Generator, capable of outputting the source code artifacts related to a given SynthModel. It is
79.144 - * capable of generating the one-time artifacts in addition to the regeneration of build-controlled artifacts.
79.145 - *
79.146 - * @param full True if we should build the whole LAF or false for building just states and painters.
79.147 - * @param buildDir The directory beneath which the build-controlled artifacts (such as the Painters) should
79.148 - * be placed. This is the root directory beneath which the necessary packages and source
79.149 - * files will be created.
79.150 - * @param srcDir The directory beneath which the normal user-controlled artifacts (such as the core
79.151 - * LookAndFeel file) should be placed. These are one-time generated files. This is the root
79.152 - * directory beneath which the necessary packages and source files will be created.
79.153 - * @param packageNamePrefix The package name associated with this synth look and feel. For example,
79.154 - * org.mypackage.mylaf
79.155 - * @param lafName The name of the laf, such as MyLAF.
79.156 - * @param model The actual SynthModel to base these generated files on.
79.157 - */
79.158 - public Generator(boolean full, File buildDir, File srcDir, String packageNamePrefix, String lafName,
79.159 - SynthModel model) {
79.160 - this.full = full;
79.161 - //validate the input variables
79.162 - if (packageNamePrefix == null) {
79.163 - throw new IllegalArgumentException("You must specify a package name prefix");
79.164 - }
79.165 - if (buildDir == null) {
79.166 - throw new IllegalArgumentException("You must specify the build directory");
79.167 - }
79.168 - if (srcDir == null) {
79.169 - throw new IllegalArgumentException("You must specify the source directory");
79.170 - }
79.171 - if (model == null) {
79.172 - throw new IllegalArgumentException("You must specify the SynthModel");
79.173 - }
79.174 - if (lafName == null) {
79.175 - throw new IllegalArgumentException("You must specify the name of the look and feel");
79.176 - }
79.177 -
79.178 - //construct the map which is used to do variable substitution of the template
79.179 - //files
79.180 - variables = new HashMap<String, String>();
79.181 - variables.put("PACKAGE", packageNamePrefix);
79.182 - variables.put("LAF_NAME", lafName);
79.183 -
79.184 - //generate and save references to the package-root directories.
79.185 - //(That is, given the buildDir and srcDir, generate references to the
79.186 - //org.mypackage.mylaf subdirectories)
79.187 - buildPackageRoot = new File(buildDir, packageNamePrefix.replaceAll("\\.", "\\/"));
79.188 - buildPackageRoot.mkdirs();
79.189 - srcPackageRoot = new File(srcDir, packageNamePrefix.replaceAll("\\.", "\\/"));
79.190 - srcPackageRoot.mkdirs();
79.191 -
79.192 - //save the variables
79.193 - this.packageNamePrefix = packageNamePrefix;
79.194 - this.lafName = lafName;
79.195 - this.model = model;
79.196 - }
79.197 -
79.198 - public void generate() {
79.199 - //Generate the one-time files. If these files already exist, skip the
79.200 - //ones that exist and create the missing ones. Register warnings for the
79.201 - //already existing files.
79.202 -
79.203 - //TODO Skip existing files, send warnings, etc.
79.204 - if (full) {
79.205 - try {
79.206 - //create the LookAndFeel file
79.207 - String template = read("resources/LookAndFeel.template");
79.208 - writeSrcFile(template, variables, new File(srcPackageRoot, lafName + "LookAndFeel.java"));
79.209 - } catch (IOException e) {
79.210 - e.printStackTrace();
79.211 - }
79.212 - }
79.213 - //create the painters and such.
79.214 - regenerate();
79.215 - }
79.216 -
79.217 - public void regenerate() {
79.218 - try {
79.219 - if (full) {
79.220 - //first, create the AbstractRegionPainter.java file.
79.221 - String template = read("resources/AbstractRegionPainter.template");
79.222 - writeSrcFile(template, variables, new File(buildPackageRoot, "AbstractRegionPainter.java"));
79.223 -
79.224 - //write out BlendingMode.java
79.225 - template = read("resources/BlendingMode.template");
79.226 - writeSrcFile(template, variables, new File(buildPackageRoot, "BlendingMode.java"));
79.227 -
79.228 - //create the SynthPainterImpl class
79.229 - template = read("resources/SynthPainterImpl.template");
79.230 - writeSrcFile(template, variables, new File(buildPackageRoot, "SynthPainterImpl.java"));
79.231 -
79.232 - //create the IconImpl class
79.233 - template = read("resources/IconImpl.template");
79.234 - writeSrcFile(template, variables, new File(buildPackageRoot, lafName + "Icon.java"));
79.235 -
79.236 - //create the StyleImpl class
79.237 - template = read("resources/StyleImpl.template");
79.238 - writeSrcFile(template, variables, new File(buildPackageRoot, lafName + "Style.java"));
79.239 -
79.240 - //write out Effect.java
79.241 - template = read("resources/Effect.template");
79.242 - writeSrcFile(template, variables, new File(buildPackageRoot, "Effect.java"));
79.243 -
79.244 - //write out EffectUtils.java
79.245 - template = read("resources/EffectUtils.template");
79.246 - writeSrcFile(template, variables, new File(buildPackageRoot, "EffectUtils.java"));
79.247 -
79.248 - //write out ShadowEffect.java
79.249 - template = read("resources/ShadowEffect.template");
79.250 - writeSrcFile(template, variables, new File(buildPackageRoot, "ShadowEffect.java"));
79.251 -
79.252 - //write out DropShadowEffect.java
79.253 - template = read("resources/DropShadowEffect.template");
79.254 - writeSrcFile(template, variables, new File(buildPackageRoot, "DropShadowEffect.java"));
79.255 -
79.256 - //write out InnerShadowEffect.java
79.257 - template = read("resources/InnerShadowEffect.template");
79.258 - writeSrcFile(template, variables, new File(buildPackageRoot, "InnerShadowEffect.java"));
79.259 -
79.260 - //write out InnerGlowEffect.java
79.261 - template = read("resources/InnerGlowEffect.template");
79.262 - writeSrcFile(template, variables, new File(buildPackageRoot, "InnerGlowEffect.java"));
79.263 -
79.264 - //write out OuterGlowEffect.java
79.265 - template = read("resources/OuterGlowEffect.template");
79.266 - writeSrcFile(template, variables, new File(buildPackageRoot, "OuterGlowEffect.java"));
79.267 -
79.268 - //write out State.java
79.269 - template = read("resources/State.template");
79.270 - writeSrcFile(template, variables, new File(buildPackageRoot, "State.java"));
79.271 -
79.272 - template = read("resources/ImageCache.template");
79.273 - writeSrcFile(template, variables, new File(buildPackageRoot, "ImageCache.java"));
79.274 -
79.275 - template = read("resources/ImageScalingHelper.template");
79.276 - writeSrcFile(template, variables, new File(buildPackageRoot, "ImageScalingHelper.java"));
79.277 - }
79.278 - //next, populate the first set of ui defaults based on what is in the
79.279 - //various palettes of the synth model
79.280 - StringBuilder uiDefaultInit = new StringBuilder();
79.281 - StringBuilder styleInit = new StringBuilder();
79.282 - DefaultsGenerator.generateDefaults(uiDefaultInit, styleInit, model, variables, packageNamePrefix,
79.283 - buildPackageRoot);
79.284 - variables.put("UI_DEFAULT_INIT", uiDefaultInit.toString());
79.285 - variables.put("STYLE_INIT", styleInit.toString());
79.286 - writeSrcFile(read("resources/Defaults.template"), variables,
79.287 - new File(buildPackageRoot, lafName + "Defaults.java"));
79.288 - } catch (IOException e) {
79.289 - e.printStackTrace();
79.290 - }
79.291 - }
79.292 -}
80.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/generator/GeneratorUtils.java Sun Sep 06 23:14:42 2009 -0700
80.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
80.3 @@ -1,295 +0,0 @@
80.4 -/*
80.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
80.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
80.7 - *
80.8 - * This code is free software; you can redistribute it and/or modify it
80.9 - * under the terms of the GNU General Public License version 2 only, as
80.10 - * published by the Free Software Foundation. Sun designates this
80.11 - * particular file as subject to the "Classpath" exception as provided
80.12 - * by Sun in the LICENSE file that accompanied this code.
80.13 - *
80.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
80.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
80.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
80.17 - * version 2 for more details (a copy is included in the LICENSE file that
80.18 - * accompanied this code).
80.19 - *
80.20 - * You should have received a copy of the GNU General Public License version
80.21 - * 2 along with this work; if not, write to the Free Software Foundation,
80.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
80.23 - *
80.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
80.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
80.26 - * have any questions.
80.27 - */
80.28 -package org.jdesktop.synthdesigner.generator;
80.29 -
80.30 -import javax.swing.plaf.synth.Region;
80.31 -import javax.swing.plaf.synth.SynthConstants;
80.32 -
80.33 -/**
80.34 - * GeneratorUtils
80.35 - *
80.36 - * @author Richard Bair
80.37 - * @author Jasper Potts
80.38 - */
80.39 -class GeneratorUtils {
80.40 - private GeneratorUtils() {}
80.41 -
80.42 - /**
80.43 - * Given a synth state, create the appropriate name as it would be used for a ui default key.
80.44 - * <p/>
80.45 - * For example:
80.46 - * <p/>
80.47 - * enabled enabled+over enabled+over+selected
80.48 - */
80.49 - static String toUIDefaultKey(int state) {
80.50 - StringBuffer buffer = new StringBuffer();
80.51 - if ((state & SynthConstants.DEFAULT) == SynthConstants.DEFAULT) {
80.52 - buffer.append("default");
80.53 - }
80.54 - if ((state & SynthConstants.DISABLED) == SynthConstants.DISABLED) {
80.55 - if (buffer.length() > 0) buffer.append("+");
80.56 - buffer.append("disabled");
80.57 - }
80.58 - if ((state & SynthConstants.ENABLED) == SynthConstants.ENABLED) {
80.59 - if (buffer.length() > 0) buffer.append("+");
80.60 - buffer.append("enabled");
80.61 - }
80.62 - if ((state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) {
80.63 - if (buffer.length() > 0) buffer.append("+");
80.64 - buffer.append("focused");
80.65 - }
80.66 - if ((state & SynthConstants.MOUSE_OVER) == SynthConstants.MOUSE_OVER) {
80.67 - if (buffer.length() > 0) buffer.append("+");
80.68 - buffer.append("over");
80.69 - }
80.70 - if ((state & SynthConstants.PRESSED) == SynthConstants.PRESSED) {
80.71 - if (buffer.length() > 0) buffer.append("+");
80.72 - buffer.append("down");
80.73 - }
80.74 - if ((state & SynthConstants.SELECTED) == SynthConstants.SELECTED) {
80.75 - if (buffer.length() > 0) buffer.append("+");
80.76 - buffer.append("selected");
80.77 - }
80.78 - return buffer.toString();
80.79 - }
80.80 -
80.81 - //takes a states string of the form Enabled+Foo+Bar.
80.82 - //removes any whitespace. Replaces the + signs with And.
80.83 - static String toClassName(String states) {
80.84 - String s = states.replace(" ", "");
80.85 - s = states.replace("+", "And");
80.86 - return s;
80.87 - }
80.88 -
80.89 - //takes a states string of the form Enabled+Foo+Bar.
80.90 - //removes any whitespace. Replaces the + signs with _.
80.91 - //capitalizes the whole lot
80.92 - static String toConstantName(String states) {
80.93 - String s = states.replace(" ", "");
80.94 - s = states.replace("+", "_");
80.95 - return s.toUpperCase();
80.96 - }
80.97 -
80.98 - /**
80.99 - * Given a string "s" of the form:
80.100 - *
80.101 - * A.\"A.a\".B
80.102 - *
80.103 - * Make it such that:
80.104 - *
80.105 - * AAAB
80.106 - *
80.107 - * For example, ComboBox.\"ComboBox.arrowButton\" would become
80.108 - * ComboBoxComboBoxArrowButton
80.109 - *
80.110 - * @param s
80.111 - * @return
80.112 - */
80.113 - static String makePretty(String s) {
80.114 - char[] src = s.toCharArray();
80.115 - char[] dst = new char[src.length];
80.116 - int dstIndex = 0;
80.117 - for (int i=0; i<src.length; i++) {
80.118 - //if the src char is a period and there is a following character,
80.119 - //make sure the character is capitalized.
80.120 - if ((src[i] == '.' || src[i] == ':') && i < src.length -1) {
80.121 - src[i+1] = Character.toUpperCase(src[i+1]);
80.122 - continue;
80.123 - }
80.124 - //if the src char is one that is to be removed, skip it.
80.125 - if (src[i] == '.' || src[i] == ':' || src[i] == '\\' || src[i] == '"') {
80.126 - continue;
80.127 - }
80.128 - //copy over the current char.
80.129 - dst[dstIndex++] = src[i];
80.130 - }
80.131 - //at this point, dstIndex is 1 greater than the last valid index position in dst
80.132 - //or in other words it represents the count.
80.133 - return new String(dst, 0, dstIndex);
80.134 - }
80.135 -
80.136 - /**
80.137 - * Encodes the given synth state as if it were specified in java code, such as
80.138 - * <p/>
80.139 - * SynthConstants.ENABLED | SynthConstants.MOUSE_OVER
80.140 - */
80.141 - static String toJavaList(int state) {
80.142 - StringBuffer buffer = new StringBuffer();
80.143 - if ((state & SynthConstants.DEFAULT) == SynthConstants.DEFAULT) {
80.144 - buffer.append("SynthConstants.DEFAULT");
80.145 - }
80.146 - if ((state & SynthConstants.DISABLED) == SynthConstants.DISABLED) {
80.147 - if (buffer.length() > 0) buffer.append(" | ");
80.148 - buffer.append("SynthConstants.DISABLED");
80.149 - }
80.150 - if ((state & SynthConstants.ENABLED) == SynthConstants.ENABLED) {
80.151 - if (buffer.length() > 0) buffer.append(" | ");
80.152 - buffer.append("SynthConstants.ENABLED");
80.153 - }
80.154 - if ((state & SynthConstants.FOCUSED) == SynthConstants.FOCUSED) {
80.155 - if (buffer.length() > 0) buffer.append(" | ");
80.156 - buffer.append("SynthConstants.FOCUSED");
80.157 - }
80.158 - if ((state & SynthConstants.MOUSE_OVER) == SynthConstants.MOUSE_OVER) {
80.159 - if (buffer.length() > 0) buffer.append(" | ");
80.160 - buffer.append("SynthConstants.MOUSE_OVER");
80.161 - }
80.162 - if ((state & SynthConstants.PRESSED) == SynthConstants.PRESSED) {
80.163 - if (buffer.length() > 0) buffer.append(" | ");
80.164 - buffer.append("SynthConstants.PRESSED");
80.165 - }
80.166 - if ((state & SynthConstants.SELECTED) == SynthConstants.SELECTED) {
80.167 - if (buffer.length() > 0) buffer.append(" | ");
80.168 - buffer.append("SynthConstants.SELECTED");
80.169 - }
80.170 - return buffer.toString();
80.171 - }
80.172 -
80.173 - /**
80.174 - * Checks the given region name to discover if it is one of the standard synth regions. If so, return the name in
80.175 - * caps and such. Otherwise, return a big fat null.
80.176 - * <p/>
80.177 - * I have to do this because, unfortunately, synth's Region doesn't implement equals.
80.178 - */
80.179 - static String getRegionNameCaps(String regionName) {
80.180 - if (Region.ARROW_BUTTON.getName().equals(regionName)) {
80.181 - return "ARROW_BUTTON";
80.182 - } else if (Region.BUTTON.getName().equals(regionName)) {
80.183 - return "BUTTON";
80.184 - } else if (Region.CHECK_BOX.getName().equals(regionName)) {
80.185 - return "CHECK_BOX";
80.186 - } else if (Region.CHECK_BOX_MENU_ITEM.getName().equals(regionName)) {
80.187 - return "CHECK_BOX_MENU_ITEM";
80.188 - } else if (Region.COLOR_CHOOSER.getName().equals(regionName)) {
80.189 - return "COLOR_CHOOSER";
80.190 - } else if (Region.COMBO_BOX.getName().equals(regionName)) {
80.191 - return "COMBO_BOX";
80.192 - } else if (Region.DESKTOP_ICON.getName().equals(regionName)) {
80.193 - return "DESKTOP_ICON";
80.194 - } else if (Region.DESKTOP_PANE.getName().equals(regionName)) {
80.195 - return "DESKTOP_PANE";
80.196 - } else if (Region.EDITOR_PANE.getName().equals(regionName)) {
80.197 - return "EDITOR_PANE";
80.198 - } else if (Region.FILE_CHOOSER.getName().equals(regionName)) {
80.199 - return "FILE_CHOOSER";
80.200 - } else if (Region.FORMATTED_TEXT_FIELD.getName().equals(regionName)) {
80.201 - return "FORMATTED_TEXT_FIELD";
80.202 - } else if (Region.INTERNAL_FRAME.getName().equals(regionName)) {
80.203 - return "INTERNAL_FRAME";
80.204 - } else if (Region.INTERNAL_FRAME_TITLE_PANE.getName().equals(regionName)) {
80.205 - return "INTERNAL_FRAME_TITLE_PANE";
80.206 - } else if (Region.LABEL.getName().equals(regionName)) {
80.207 - return "LABEL";
80.208 - } else if (Region.LIST.getName().equals(regionName)) {
80.209 - return "LIST";
80.210 - } else if (Region.MENU.getName().equals(regionName)) {
80.211 - return "MENU";
80.212 - } else if (Region.MENU_BAR.getName().equals(regionName)) {
80.213 - return "MENU_BAR";
80.214 - } else if (Region.MENU_ITEM.getName().equals(regionName)) {
80.215 - return "MENU_ITEM";
80.216 - } else if (Region.MENU_ITEM_ACCELERATOR.getName().equals(regionName)) {
80.217 - return "MENU_ITEM_ACCELERATOR";
80.218 - } else if (Region.OPTION_PANE.getName().equals(regionName)) {
80.219 - return "OPTION_PANE";
80.220 - } else if (Region.PANEL.getName().equals(regionName)) {
80.221 - return "PANEL";
80.222 - } else if (Region.PASSWORD_FIELD.getName().equals(regionName)) {
80.223 - return "PASSWORD_FIELD";
80.224 - } else if (Region.POPUP_MENU.getName().equals(regionName)) {
80.225 - return "POPUP_MENU";
80.226 - } else if (Region.POPUP_MENU_SEPARATOR.getName().equals(regionName)) {
80.227 - return "POPUP_MENU_SEPARATOR";
80.228 - } else if (Region.PROGRESS_BAR.getName().equals(regionName)) {
80.229 - return "PROGRESS_BAR";
80.230 - } else if (Region.RADIO_BUTTON.getName().equals(regionName)) {
80.231 - return "RADIO_BUTTON";
80.232 - } else if (Region.RADIO_BUTTON_MENU_ITEM.getName().equals(regionName)) {
80.233 - return "RADIO_BUTTON_MENU_ITEM";
80.234 - } else if (Region.ROOT_PANE.getName().equals(regionName)) {
80.235 - return "ROOT_PANE";
80.236 - } else if (Region.SCROLL_BAR.getName().equals(regionName)) {
80.237 - return "SCROLL_BAR";
80.238 - } else if (Region.SCROLL_BAR_THUMB.getName().equals(regionName)) {
80.239 - return "SCROLL_BAR_THUMB";
80.240 - } else if (Region.SCROLL_BAR_TRACK.getName().equals(regionName)) {
80.241 - return "SCROLL_BAR_TRACK";
80.242 - } else if (Region.SCROLL_PANE.getName().equals(regionName)) {
80.243 - return "SCROLL_PANE";
80.244 - } else if (Region.SEPARATOR.getName().equals(regionName)) {
80.245 - return "SEPARATOR";
80.246 - } else if (Region.SLIDER.getName().equals(regionName)) {
80.247 - return "SLIDER";
80.248 - } else if (Region.SLIDER_THUMB.getName().equals(regionName)) {
80.249 - return "SLIDER_THUMB";
80.250 - } else if (Region.SLIDER_TRACK.getName().equals(regionName)) {
80.251 - return "SLIDER_TRACK";
80.252 - } else if (Region.SPINNER.getName().equals(regionName)) {
80.253 - return "SPINNER";
80.254 - } else if (Region.SPLIT_PANE.getName().equals(regionName)) {
80.255 - return "SPLIT_PANE";
80.256 - } else if (Region.SPLIT_PANE_DIVIDER.getName().equals(regionName)) {
80.257 - return "SPLIT_PANE_DIVIDER";
80.258 - } else if (Region.TABBED_PANE.getName().equals(regionName)) {
80.259 - return "TABBED_PANE";
80.260 - } else if (Region.TABBED_PANE_CONTENT.getName().equals(regionName)) {
80.261 - return "TABBED_PANE_CONTENT";
80.262 - } else if (Region.TABBED_PANE_TAB.getName().equals(regionName)) {
80.263 - return "TABBED_PANE_TAB";
80.264 - } else if (Region.TABBED_PANE_TAB_AREA.getName().equals(regionName)) {
80.265 - return "TABBED_PANE_TAB_AREA";
80.266 - } else if (Region.TABLE.getName().equals(regionName)) {
80.267 - return "TABLE";
80.268 - } else if (Region.TABLE_HEADER.getName().equals(regionName)) {
80.269 - return "TABLE_HEADER";
80.270 - } else if (Region.TEXT_AREA.getName().equals(regionName)) {
80.271 - return "TEXT_AREA";
80.272 - } else if (Region.TEXT_FIELD.getName().equals(regionName)) {
80.273 - return "TEXT_FIELD";
80.274 - } else if (Region.TEXT_PANE.getName().equals(regionName)) {
80.275 - return "TEXT_PANE";
80.276 - } else if (Region.TOGGLE_BUTTON.getName().equals(regionName)) {
80.277 - return "TOGGLE_BUTTON";
80.278 - } else if (Region.TOOL_BAR.getName().equals(regionName)) {
80.279 - return "TOOL_BAR";
80.280 - } else if (Region.TOOL_BAR_CONTENT.getName().equals(regionName)) {
80.281 - return "TOOL_BAR_CONTENT";
80.282 - } else if (Region.TOOL_BAR_DRAG_WINDOW.getName().equals(regionName)) {
80.283 - return "TOOL_BAR_DRAG_WINDOW";
80.284 - } else if (Region.TOOL_BAR_SEPARATOR.getName().equals(regionName)) {
80.285 - return "TOOL_BAR_SEPARATOR";
80.286 - } else if (Region.TOOL_TIP.getName().equals(regionName)) {
80.287 - return "TOOL_TIP";
80.288 - } else if (Region.TREE.getName().equals(regionName)) {
80.289 - return "TREE";
80.290 - } else if (Region.TREE_CELL.getName().equals(regionName)) {
80.291 - return "TREE_CELL";
80.292 - } else if (Region.VIEWPORT.getName().equals(regionName)) {
80.293 - return "VIEWPORT";
80.294 - }
80.295 - System.err.println("[Info] Couldn't find a Region for " + regionName);
80.296 - return null;
80.297 - }
80.298 -}
81.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/generator/ObjectCodeConvertors.java Sun Sep 06 23:14:42 2009 -0700
81.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
81.3 @@ -1,108 +0,0 @@
81.4 -/*
81.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
81.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
81.7 - *
81.8 - * This code is free software; you can redistribute it and/or modify it
81.9 - * under the terms of the GNU General Public License version 2 only, as
81.10 - * published by the Free Software Foundation. Sun designates this
81.11 - * particular file as subject to the "Classpath" exception as provided
81.12 - * by Sun in the LICENSE file that accompanied this code.
81.13 - *
81.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
81.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
81.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
81.17 - * version 2 for more details (a copy is included in the LICENSE file that
81.18 - * accompanied this code).
81.19 - *
81.20 - * You should have received a copy of the GNU General Public License version
81.21 - * 2 along with this work; if not, write to the Free Software Foundation,
81.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
81.23 - *
81.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
81.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
81.26 - * have any questions.
81.27 - */
81.28 -package org.jdesktop.synthdesigner.generator;
81.29 -
81.30 -import java.awt.*;
81.31 -
81.32 -/**
81.33 - * ObjectCodeConvertors
81.34 - *
81.35 - * @author Richard Bair
81.36 - * @author Jasper Potts
81.37 - */
81.38 -public class ObjectCodeConvertors {
81.39 - static java.math.MathContext ctx = new java.math.MathContext(3);
81.40 -
81.41 - /**
81.42 - * 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
81.43 - * is to the right of b.
81.44 - *
81.45 - * @param w width in the case of the x axis, height in the case of the y axis.
81.46 - */
81.47 - static float encode(float x, float a, float b, float w) {
81.48 - float r = 0;
81.49 - if (x < a) {
81.50 - r = (x / a);
81.51 - } else if (x > b) {
81.52 - r = 2 + ((x - b) / (w - b));
81.53 - } else if (x == a && x == b) {
81.54 - return 1.5f;
81.55 - } else {
81.56 - r = 1 + ((x - a) / (b - a));
81.57 - }
81.58 -
81.59 - if (Float.isNaN(r)) {
81.60 - System.err.println("[Error] Encountered NaN: encode(" + x + ", " + a + ", " + b + ", " + w + ")");
81.61 - return 0;
81.62 - } else if (Float.isInfinite(r)) {
81.63 - System.err.println("[Error] Encountered Infinity: encode(" + x + ", " + a + ", " + b + ", " + w + ")");
81.64 - return 0;
81.65 - } else if (r < 0) {
81.66 - System.err.println("[Error] encoded value was less than 0: encode(" + x + ", " + a + ", " + b + ", " + w + ")");
81.67 - return 0;
81.68 - } else if (r > 3) {
81.69 - System.err.println("[Error] encoded value was greater than 3: encode(" + x + ", " + a + ", " + b + ", " + w + ")");
81.70 - return 3;
81.71 - } else {
81.72 - //for prettyness sake (and since we aren't really going to miss
81.73 - //any accuracy here) I'm rounding this to 3 decimal places
81.74 -// return java.math.BigDecimal.valueOf(r).round(ctx).doubleValue();
81.75 - return r;
81.76 - }
81.77 - }
81.78 -
81.79 - static String convert(Paint paint) {
81.80 - //TODO need to support writing out other Paints, such as gradients
81.81 - if (paint instanceof Color) {
81.82 - return convert((Color) paint);
81.83 - } else {
81.84 - System.err.println("[WARNING] Unable to encode a paint in the encode(Paint) method: " + paint);
81.85 - return "null";
81.86 - }
81.87 - }
81.88 -
81.89 - /**
81.90 - * Given a Color, write out the java code required to create a new Color.
81.91 - *
81.92 - * @param color The color to convert
81.93 - * @return String of the code for the color
81.94 - */
81.95 - static String convert(Color color) {
81.96 - return "new Color(" +
81.97 - color.getRed() + ", " +
81.98 - color.getGreen() + ", " +
81.99 - color.getBlue() + ", " +
81.100 - color.getAlpha() + ")";
81.101 - }
81.102 -
81.103 - static String convert(Insets i) {
81.104 - return "new Insets(" + i.top + ", " + i.left + ", " + i.bottom + ", " + i.right + ")";
81.105 - }
81.106 -
81.107 - static String convert(Dimension d) {
81.108 - return "new Dimension(" + d.width + ", " + d.height + ")";
81.109 - }
81.110 -
81.111 -}
82.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/generator/PainterGenerator.java Sun Sep 06 23:14:42 2009 -0700
82.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
82.3 @@ -1,758 +0,0 @@
82.4 -/*
82.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
82.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
82.7 - *
82.8 - * This code is free software; you can redistribute it and/or modify it
82.9 - * under the terms of the GNU General Public License version 2 only, as
82.10 - * published by the Free Software Foundation. Sun designates this
82.11 - * particular file as subject to the "Classpath" exception as provided
82.12 - * by Sun in the LICENSE file that accompanied this code.
82.13 - *
82.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
82.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
82.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
82.17 - * version 2 for more details (a copy is included in the LICENSE file that
82.18 - * accompanied this code).
82.19 - *
82.20 - * You should have received a copy of the GNU General Public License version
82.21 - * 2 along with this work; if not, write to the Free Software Foundation,
82.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
82.23 - *
82.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
82.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
82.26 - * have any questions.
82.27 - */
82.28 -package org.jdesktop.synthdesigner.generator;
82.29 -
82.30 -import org.jdesktop.swingx.designer.BezierControlPoint;
82.31 -import org.jdesktop.swingx.designer.Canvas;
82.32 -import org.jdesktop.swingx.designer.EllipseShape;
82.33 -import org.jdesktop.swingx.designer.Layer;
82.34 -import org.jdesktop.swingx.designer.PaintedShape;
82.35 -import org.jdesktop.swingx.designer.PathShape;
82.36 -import org.jdesktop.swingx.designer.RectangleShape;
82.37 -import org.jdesktop.swingx.designer.SimpleShape;
82.38 -import org.jdesktop.swingx.designer.TemplateLayer;
82.39 -import org.jdesktop.swingx.designer.paint.Gradient;
82.40 -import org.jdesktop.swingx.designer.paint.Matte;
82.41 -import org.jdesktop.swingx.designer.paint.PaintModel;
82.42 -import org.jdesktop.swingx.designer.paint.RadialGradient;
82.43 -import org.jdesktop.swingx.designer.paint.GradientStop;
82.44 -import org.jdesktop.swingx.designer.paint.AbstractGradient;
82.45 -import static org.jdesktop.synthdesigner.generator.GeneratorUtils.makePretty;
82.46 -import static org.jdesktop.synthdesigner.generator.GeneratorUtils.toClassName;
82.47 -import static org.jdesktop.synthdesigner.generator.GeneratorUtils.toConstantName;
82.48 -import static org.jdesktop.synthdesigner.generator.TemplateWriter.read;
82.49 -import static org.jdesktop.synthdesigner.generator.TemplateWriter.writeSrcFile;
82.50 -import org.jdesktop.synthdesigner.synthmodel.UIIconRegion;
82.51 -import org.jdesktop.synthdesigner.synthmodel.UIRegion;
82.52 -import org.jdesktop.synthdesigner.synthmodel.UIState;
82.53 -
82.54 -import java.awt.*;
82.55 -import java.awt.geom.Point2D;
82.56 -import java.beans.Beans;
82.57 -import java.io.File;
82.58 -import java.io.IOException;
82.59 -import java.lang.reflect.Method;
82.60 -import java.lang.reflect.InvocationTargetException;
82.61 -import java.util.ArrayList;
82.62 -import java.util.HashMap;
82.63 -import java.util.LinkedHashMap;
82.64 -import java.util.List;
82.65 -import java.util.Map;
82.66 -import javax.swing.JComponent;
82.67 -import javax.swing.SwingUtilities;
82.68 -import javax.swing.JList;
82.69 -import javax.swing.JTable;
82.70 -import javax.swing.text.JTextComponent;
82.71 -
82.72 -/**
82.73 - * PainterGenerator - Class for generating Painter class java source from a Canvas
82.74 - *
82.75 - * Following in the general theory that is used to generate a Painter file.
82.76 - *
82.77 - * Each Painter file represents a Region. So there is one painter file per region. In
82.78 - * skin.laf we support Icon subregions, which are really just hacked versions of the
82.79 - * parent region.
82.80 - *
82.81 - * In order to generate the most compact and efficient bytecode possible for the
82.82 - * Painters, we actually perform the generation sequence in two steps. The first
82.83 - * step is the analysis phase, where we walk through the SynthModel for the region
82.84 - * and discover commonality among the different states in the region. For example,
82.85 - * do they have common paths? Do they have common colors? Gradients? Is the painting
82.86 - * code for the different states identical other than for colors?
82.87 - *
82.88 - * We gather this information up. On the second pass, we use this data to determine the
82.89 - * methods that need to be generated, and the class variables that need to be generated.
82.90 - * We try to keep the actual bytecode count as small as possible so that we may reduce
82.91 - * the overall size of the look and feel significantly.
82.92 - *
82.93 - * @author Richard Bair
82.94 - * @author Jasper Potts
82.95 - */
82.96 -public class PainterGenerator {
82.97 - private static String painterImplTemplate;
82.98 - private static String getPainterImplTemplate() {
82.99 - if (painterImplTemplate == null) {
82.100 - //load the painter template file into an in-memory string to improve performance
82.101 - //when generating a lot of classes
82.102 - try {
82.103 - painterImplTemplate = read("resources/PainterImpl.template");
82.104 - } catch (IOException e) {
82.105 - System.err.println("Failed to read template files.");
82.106 - throw new RuntimeException(e);
82.107 - }
82.108 - }
82.109 - return painterImplTemplate;
82.110 - }
82.111 -
82.112 -
82.113 - //a handful of counters, incremented whenever the associated object type is encounted.
82.114 - //These counters form the basis of the field and method suffixes.
82.115 - //These are all 1 based, because I felt like it :-)
82.116 - private int colorCounter = 1;
82.117 - private int gradientCounter = 1;
82.118 - private int radialCounter = 1;
82.119 - private int pathCounter = 1;
82.120 - private int rectCounter = 1;
82.121 - private int roundRectCounter = 1;
82.122 - private int ellipseCounter = 1;
82.123 -
82.124 - private int stateTypeCounter = 1;
82.125 -
82.126 - //during the first pass, we will construct these maps
82.127 - private Map<String, String> colors = new HashMap<String, String>();
82.128 - /**
82.129 - * Code=>method name.
82.130 - */
82.131 - private Map<String, String> methods = new HashMap<String, String>();
82.132 -
82.133 - //these variables hold the generated code
82.134 - /**
82.135 - * The source code in this variable will be used to define the various state types
82.136 - */
82.137 - private StringBuilder stateTypeCode = new StringBuilder();
82.138 - /**
82.139 - * The source code in this variable will be used to define the switch statement for painting
82.140 - */
82.141 - private StringBuilder switchCode = new StringBuilder();
82.142 - /**
82.143 - * The source code in this variable will be used to define the methods for painting each state
82.144 - */
82.145 - private StringBuilder paintingCode = new StringBuilder();
82.146 - /**
82.147 - * The source code in this variable will be used to add getExtendedCacheKeys
82.148 - * implementation if needed.
82.149 - */
82.150 - private StringBuilder getExtendedCacheKeysCode = new StringBuilder();
82.151 - /**
82.152 - * The source code in this variable will be used to define the methods for decoding gradients
82.153 - * and shapes.
82.154 - */
82.155 - private StringBuilder gradientsCode = new StringBuilder();
82.156 - private StringBuilder colorCode = new StringBuilder();
82.157 - private StringBuilder shapesCode = new StringBuilder();
82.158 - /**
82.159 - * Map of component colors keyed by state constant name
82.160 - */
82.161 - private Map<String, List<ComponentColor>> componentColorsMap =
82.162 - new LinkedHashMap<String, List<ComponentColor>>();
82.163 - /**
82.164 - * For the current state the list of all component colors used by this
82.165 - * painter, the index in this list is also the index in the runtime array
82.166 - * of defaults and keys.
82.167 - */
82.168 - private List<ComponentColor> componentColors = null;
82.169 -
82.170 - PainterGenerator(UIRegion r) {
82.171 - generate(r);
82.172 - }
82.173 -
82.174 - private void generate(UIRegion r) {
82.175 - for (UIState state : r.getBackgroundStates()) {
82.176 - System.out.println("------>" + state.getName());
82.177 -
82.178 - Canvas canvas = state.getCanvas();
82.179 - String type = r instanceof UIIconRegion ? ((UIIconRegion)r).getKey() : "Background";
82.180 - generate(state, canvas, type);
82.181 - }
82.182 - for (UIState state : r.getForegroundStates()) {
82.183 - Canvas canvas = state.getCanvas();
82.184 - generate(state, canvas, "Foreground");
82.185 - }
82.186 - for (UIState state : r.getBorderStates()) {
82.187 - Canvas canvas = state.getCanvas();
82.188 - generate(state, canvas, "Border");
82.189 - }
82.190 - //now check for any uiIconRegions, since these are collapsed together.
82.191 - for (UIRegion sub : r.getSubRegions()) {
82.192 - if (sub instanceof UIIconRegion) {
82.193 - generate(sub);
82.194 - }
82.195 - }
82.196 - //generate all the code for component colors
82.197 - if (!componentColorsMap.isEmpty()) {
82.198 - getExtendedCacheKeysCode
82.199 - .append(" protected Object[] getExtendedCacheKeys(JComponent c) {\n")
82.200 - .append(" Object[] extendedCacheKeys = null;\n")
82.201 - .append(" switch(state) {\n");
82.202 - for (Map.Entry<String, List<ComponentColor>> entry : componentColorsMap.entrySet()) {
82.203 - getExtendedCacheKeysCode
82.204 - .append(" case ")
82.205 - .append(entry.getKey()).append(":\n")
82.206 - .append(" extendedCacheKeys = new Object[] {\n");
82.207 - for (int i=0; i<entry.getValue().size(); i++) {
82.208 - ComponentColor cc = entry.getValue().get(i);
82.209 - getExtendedCacheKeysCode
82.210 - .append(" getComponentColor(c, \"")
82.211 - .append(cc.propertyName).append("\", ")
82.212 - .append(cc.defaultColorVariableName).append(", ")
82.213 - .append(cc.saturationOffset).append("f, ")
82.214 - .append(cc.brightnessOffset).append("f, ")
82.215 - .append(cc.alphaOffset);
82.216 - if (i + 1 < entry.getValue().size()) {
82.217 - getExtendedCacheKeysCode.append("),\n");
82.218 - } else {
82.219 - getExtendedCacheKeysCode.append(")");
82.220 - }
82.221 - }
82.222 - getExtendedCacheKeysCode.append("};\n")
82.223 - .append(" break;\n");
82.224 - }
82.225 - getExtendedCacheKeysCode
82.226 - .append(" }\n")
82.227 - .append(" return extendedCacheKeys;\n")
82.228 - .append(" }");
82.229 - }
82.230 - }
82.231 -
82.232 - //type is background, foreground, border, upArrowIcon, etc.
82.233 - private void generate(UIState state, Canvas canvas, String type) {
82.234 - String states = UIState.keysToString(state.getStateKeys());
82.235 - String stateType = toConstantName(type + "_" + states);
82.236 - String paintMethodName = "paint" + type + toClassName(states);
82.237 - //create new array for component colors for this state
82.238 - componentColors = new ArrayList<ComponentColor>();
82.239 -
82.240 - stateTypeCode.append(" static final int ").append(stateType).append(" = ").append(stateTypeCounter++).append(";\n");
82.241 -
82.242 - if (canvas.isBlank()) {
82.243 - return;
82.244 - }
82.245 -
82.246 - switchCode.append(" case ").append(stateType).append(": ").append(paintMethodName).append("(g); break;\n");
82.247 - paintingCode.append(" private void ").append(paintMethodName).append("(Graphics2D g) {\n");
82.248 -
82.249 - //start by setting up common info needed to encode the control points
82.250 - Insets in = canvas.getStretchingInsets();
82.251 - float a = in.left;
82.252 - float b = canvas.getSize().width - in.right;
82.253 - float c = in.top;
82.254 - float d = canvas.getSize().height - in.bottom;
82.255 - float width = canvas.getSize().width;
82.256 - float height = canvas.getSize().height;
82.257 - float cw = b - a;
82.258 - float ch = d - c;
82.259 -
82.260 - Layer[] layers = canvas.getLayers().toArray(new Layer[0]);
82.261 - for (int index=layers.length-1; index >= 0; index--) {
82.262 - Layer layer = layers[index];
82.263 - if (layer instanceof TemplateLayer) {
82.264 - continue;
82.265 - }
82.266 - //shapes must be painted in reverse order
82.267 - List<SimpleShape> shapes = layer.getShapes();
82.268 - for (int i=shapes.size()-1; i>=0; i--) {
82.269 - SimpleShape s = shapes.get(i);
82.270 - if (s instanceof PaintedShape) {
82.271 - PaintedShape shape = (PaintedShape)s;
82.272 - PaintModel paint = shape.getPaintModel();
82.273 -
82.274 - /*
82.275 - We attempt to write the minimal number of bytecodes as possible when
82.276 - generating code. Due to the inherit complexities in determining what
82.277 - is extraneous, we use the following system:
82.278 -
82.279 - We first generate the code for the shape. Then, we check to see if
82.280 - this shape has already been generated. If so, then we defer to an
82.281 - existing method. If not, then we will create a new methods, stick
82.282 - the code in it, and refer to that method.
82.283 - */
82.284 -
82.285 - String shapeMethodName = null; // will contain the name of the method which creates the shape
82.286 - String shapeVariable = null; // will be one of rect, roundRect, ellipse, or path.
82.287 - String shapeMethodBody = null;
82.288 -
82.289 - if (shape instanceof RectangleShape) {
82.290 - RectangleShape rshape = (RectangleShape) shape;
82.291 - float x1 = encode((float)rshape.getX1(), a, b, width);
82.292 - float y1 = encode((float)rshape.getY1(), c, d, height);
82.293 - float x2 = encode((float)rshape.getX2(), a, b, width);
82.294 - float y2 = encode((float)rshape.getY2(), c, d, height);
82.295 - if (rshape.isRounded()) {
82.296 - //it is a rounded rectangle
82.297 - float rounding = (float)rshape.getRounding();
82.298 -
82.299 - shapeMethodBody =
82.300 - " roundRect.setRoundRect(" +
82.301 - writeDecodeX(x1) + ", //x\n" +
82.302 - " " + writeDecodeY(y1) + ", //y\n" +
82.303 - " " + writeDecodeX(x2) + " - " + writeDecodeX(x1) + ", //width\n" +
82.304 - " " + writeDecodeY(y2) + " - " + writeDecodeY(y1) + ", //height\n" +
82.305 - " " + rounding + "f, " + rounding + "f); //rounding";
82.306 - shapeVariable = "roundRect";
82.307 - } else {
82.308 - shapeMethodBody =
82.309 - " rect.setRect(" +
82.310 - writeDecodeX(x1) + ", //x\n" +
82.311 - " " + writeDecodeY(y1) + ", //y\n" +
82.312 - " " + writeDecodeX(x2) + " - " + writeDecodeX(x1) + ", //width\n" +
82.313 - " " + writeDecodeY(y2) + " - " + writeDecodeY(y1) + "); //height";
82.314 - shapeVariable = "rect";
82.315 - }
82.316 - } else if (shape instanceof EllipseShape) {
82.317 - EllipseShape eshape = (EllipseShape) shape;
82.318 - float x1 = encode((float)eshape.getX1(), a, b, width);
82.319 - float y1 = encode((float)eshape.getY1(), c, d, height);
82.320 - float x2 = encode((float)eshape.getX2(), a, b, width);
82.321 - float y2 = encode((float)eshape.getY2(), c, d, height);
82.322 - shapeMethodBody =
82.323 - " ellipse.setFrame(" +
82.324 - writeDecodeX(x1) + ", //x\n" +
82.325 - " " + writeDecodeY(y1) + ", //y\n" +
82.326 - " " + writeDecodeX(x2) + " - " + writeDecodeX(x1) + ", //width\n" +
82.327 - " " + writeDecodeY(y2) + " - " + writeDecodeY(y1) + "); //height";
82.328 - shapeVariable = "ellipse";
82.329 - } else if (shape instanceof PathShape) {
82.330 - PathShape pshape = (PathShape) shape;
82.331 - List<BezierControlPoint> controlPoints = pshape.getBezierControlPoints();
82.332 - BezierControlPoint first, last;
82.333 - first = last = controlPoints.get(0);
82.334 - StringBuilder buffer = new StringBuilder();
82.335 - buffer.append(" path.reset();\n");
82.336 - buffer.append(" path.moveTo(" + writeDecodeX(encode((float)first.getX(), a, b, width)) + ", " + writeDecodeY(encode((float)first.getY(), c, d, height)) + ");\n");
82.337 - for (int j=1; j<controlPoints.size(); j++) {
82.338 - BezierControlPoint cp = controlPoints.get(j);
82.339 - if (last.getCp2().isSharp() && cp.getCp1().isSharp()) {
82.340 - float x = encode((float)cp.getX(), a, b, width);
82.341 - float y = encode((float)cp.getY(), c, d, height);
82.342 - buffer.append(" path.lineTo(" + writeDecodeX(x) + ", " + writeDecodeY(y) + ");\n");
82.343 - } else {
82.344 - float x1 = encode((float)last.getX(), a, b, width);
82.345 - float y1 = encode((float)last.getY(), c, d, height);
82.346 - float x2 = encode((float)cp.getX(), a, b, width);
82.347 - float y2 = encode((float)cp.getY(), c, d, height);
82.348 - buffer.append(
82.349 - " path.curveTo(" + writeDecodeBezierX(x1, last.getX(), last.getCp2X()) + ", "
82.350 - + writeDecodeBezierY(y1, last.getY(), last.getCp2Y()) + ", "
82.351 - + writeDecodeBezierX(x2, cp.getX(), cp.getCp1X()) + ", "
82.352 - + writeDecodeBezierY(y2, cp.getY(), cp.getCp1Y()) + ", "
82.353 - + writeDecodeX(x2) + ", " + writeDecodeY(y2) + ");\n");
82.354 - }
82.355 - last = cp;
82.356 - }
82.357 - if (last.getCp2().isSharp() && first.getCp1().isSharp()) {
82.358 - float x = encode((float)first.getX(), a, b, width);
82.359 - float y = encode((float)first.getY(), c, d, height);
82.360 - buffer.append(" path.lineTo(" + writeDecodeX(x) + ", " + writeDecodeY(y) + ");\n");
82.361 - } else {
82.362 - float x1 = encode((float)last.getX(), a, b, width);
82.363 - float y1 = encode((float)last.getY(), c, d, height);
82.364 - float x2 = encode((float)first.getX(), a, b, width);
82.365 - float y2 = encode((float)first.getY(), c, d, height);
82.366 - buffer.append(
82.367 - " path.curveTo(" + writeDecodeBezierX(x1, last.getX(), last.getCp2X()) + ", "
82.368 - + writeDecodeBezierY(y1, last.getY(), last.getCp2Y()) + ", "
82.369 - + writeDecodeBezierX(x2, first.getX(), first.getCp1X()) + ", "
82.370 - + writeDecodeBezierY(y2, first.getY(), first.getCp1Y()) + ", "
82.371 - + writeDecodeX(x2) + ", " + writeDecodeY(y2) + ");\n");
82.372 - }
82.373 - buffer.append(" path.closePath();");
82.374 - shapeMethodBody = buffer.toString();
82.375 - shapeVariable = "path";
82.376 - } else {
82.377 - throw new RuntimeException("Cannot happen unless a new Shape has been defined");
82.378 - }
82.379 -
82.380 - //now that we have the shape defined in shapeMethodBody, and a shapeVariable name,
82.381 - //look to see if such a body has been previously defined.
82.382 - shapeMethodName = methods.get(shapeMethodBody);
82.383 - String returnType = null;
82.384 - if (shapeMethodName == null) {
82.385 - if ("rect".equals(shapeVariable)) {
82.386 - shapeMethodName = "decodeRect" + rectCounter++;
82.387 - returnType = "Rectangle2D";
82.388 - } else if ("roundRect".equals(shapeVariable)) {
82.389 - shapeMethodName = "decodeRoundRect" + roundRectCounter++;
82.390 - returnType = "RoundRectangle2D";
82.391 - } else if ("ellipse".equals(shapeVariable)) {
82.392 - shapeMethodName = "decodeEllipse" + ellipseCounter++;
82.393 - returnType = "Ellipse2D";
82.394 - } else {
82.395 - shapeMethodName = "decodePath" + pathCounter++;
82.396 - returnType = "Path2D";
82.397 - }
82.398 - methods.put(shapeMethodBody, shapeMethodName);
82.399 -
82.400 - //since the method wasn't previously defined, time to define it
82.401 - shapesCode.append(" private ").append(returnType).append(" ").append(shapeMethodName).append("() {\n");
82.402 - shapesCode.append(shapeMethodBody);
82.403 - shapesCode.append("\n");
82.404 - shapesCode.append(" return " + shapeVariable + ";\n");
82.405 - shapesCode.append(" }\n\n");
82.406 - }
82.407 -
82.408 - //now that the method has been defined, I can go on and decode the
82.409 - //paint. After the paint is decoded, I can write the g.fill() method call,
82.410 - //using the result of the shapeMethodName. Yay!
82.411 -
82.412 -// if (shapeVariable != null) {
82.413 - //first, calculate the bounds of the shape being painted and store in variables
82.414 - paintingCode.append(" ").append(shapeVariable).append(" = ").append(shapeMethodName).append("();\n");
82.415 -
82.416 - if (paint instanceof Matte) {
82.417 - String colorVariable = encodeMatte((Matte)paint);
82.418 - paintingCode.append(" g.setPaint(").append(colorVariable).append(");\n");
82.419 - } else if (paint instanceof Gradient) {
82.420 - String gradientMethodName = encodeGradient(shape, (Gradient)paint);
82.421 - paintingCode.append(" g.setPaint(").append(gradientMethodName).append("(").append(shapeVariable).append("));\n");
82.422 - } else if (paint instanceof RadialGradient) {
82.423 - String radialMethodName = encodeRadial(shape, (RadialGradient)paint);
82.424 - paintingCode.append(" g.setPaint(").append(radialMethodName).append("(").append(shapeVariable).append("));\n");
82.425 - }
82.426 - paintingCode.append(" g.fill(").append(shapeVariable).append(");\n");
82.427 - }
82.428 - }
82.429 - }
82.430 -
82.431 - paintingCode.append("\n }\n\n");
82.432 -
82.433 - //collect component colors
82.434 - if (!componentColors.isEmpty()) {
82.435 - componentColorsMap.put(stateType, componentColors);
82.436 - componentColors = null;
82.437 - }
82.438 - }
82.439 -
82.440 - private float encode(float x, float a, float b, float width) {
82.441 - return ObjectCodeConvertors.encode(x, a, b, width);
82.442 - }
82.443 -
82.444 - private String writeDecodeX(float encodedX) {
82.445 - return "decodeX(" + encodedX + "f)";
82.446 - }
82.447 -
82.448 - private String writeDecodeY(float encodedY) {
82.449 - return "decodeY(" + encodedY + "f)";
82.450 - }
82.451 -
82.452 - /**
82.453 - *
82.454 - * @param ex encoded x value
82.455 - * @param x unencoded x value
82.456 - * @param cpx unencoded cpx value
82.457 - * @return
82.458 - */
82.459 - private static String writeDecodeBezierX(double ex, double x, double cpx) {
82.460 - return "decodeAnchorX(" + ex + "f, " + (cpx - x) + "f)";
82.461 - }
82.462 -
82.463 - /**
82.464 - *
82.465 - * @param ey encoded y value
82.466 - * @param y unencoded y value
82.467 - * @param cpy unencoded cpy value
82.468 - * @return
82.469 - */
82.470 - private static String writeDecodeBezierY(double ey, double y, double cpy) {
82.471 - return "decodeAnchorY(" + ey + "f, " + (cpy - y) + "f)";
82.472 - }
82.473 -
82.474 - private String encodeMatte(Matte m) {
82.475 - String declaration = null;
82.476 - if (m.isAbsolute()) {
82.477 - Color c = m.getColor();
82.478 - declaration = ObjectCodeConvertors.convert(c);
82.479 - } else {
82.480 - declaration = "decodeColor(\"" + m.getUiDefaultParentName() +
82.481 - "\", " + m.getHueOffset() + "f, " +
82.482 - m.getSaturationOffset() + "f, " +
82.483 - m.getBrightnessOffset() + "f, " +
82.484 - m.getAlphaOffset() + ")";
82.485 - }
82.486 -
82.487 - String variableName = colors.get(declaration);
82.488 - if (variableName == null) {
82.489 - variableName = "color" + colorCounter++;
82.490 - colors.put(declaration, variableName);
82.491 - colorCode.append(" private Color ").append(variableName).append(" = ");
82.492 - colorCode.append(declaration).append(";\n");
82.493 - }
82.494 - // handle component colors
82.495 - if (m.getComponentPropertyName() != null) {
82.496 - ComponentColor cc = new ComponentColor(m.getComponentPropertyName(),
82.497 - variableName, m.getSaturationOffset(),
82.498 - m.getBrightnessOffset(), m.getAlphaOffset());
82.499 - int index = componentColors.indexOf(cc);
82.500 - if (index == -1) {
82.501 - index = componentColors.size();
82.502 - componentColors.add(cc);
82.503 - }
82.504 - return "(Color)componentColors[" + index + "]";
82.505 - } else {
82.506 - return variableName;
82.507 - }
82.508 - }
82.509 -
82.510 - private String encodeColor(Color c) {
82.511 - String declaration = ObjectCodeConvertors.convert(c);
82.512 - String variableName = colors.get(declaration);
82.513 - if (variableName == null) {
82.514 - variableName = "color" + colorCounter++;
82.515 - colors.put(declaration, variableName);
82.516 - colorCode.append(" private Color ").append(variableName).append(" = ");
82.517 - colorCode.append(declaration).append(";\n");
82.518 - }
82.519 -
82.520 - return variableName;
82.521 - }
82.522 -
82.523 - private String encodeGradient(PaintedShape ps, Gradient g) {
82.524 - StringBuilder b = new StringBuilder();
82.525 - float x1 = (float)ps.getPaintX1();
82.526 - float y1 = (float)ps.getPaintY1();
82.527 - float x2 = (float)ps.getPaintX2();
82.528 - float y2 = (float)ps.getPaintY2();
82.529 - b.append(" return decodeGradient((");
82.530 - b.append(x1);
82.531 - b.append("f * w) + x, (");
82.532 - b.append(y1);
82.533 - b.append("f * h) + y, (");
82.534 - b.append(x2);
82.535 - b.append("f * w) + x, (");
82.536 - b.append(y2);
82.537 - b.append("f * h) + y,\n");
82.538 - encodeGradientColorsAndFractions(g,b);
82.539 - b.append(");");
82.540 -
82.541 - String methodBody = b.toString();
82.542 - String methodName = methods.get(methodBody);
82.543 - if (methodName == null) {
82.544 - methodName = "decodeGradient" + gradientCounter++;
82.545 - gradientsCode.append(" private Paint ").append(methodName).append("(Shape s) {\n");
82.546 - gradientsCode.append(" Rectangle2D bounds = s.getBounds2D();\n");
82.547 - gradientsCode.append(" float x = (float)bounds.getX();\n");
82.548 - gradientsCode.append(" float y = (float)bounds.getY();\n");
82.549 - gradientsCode.append(" float w = (float)bounds.getWidth();\n");
82.550 - gradientsCode.append(" float h = (float)bounds.getHeight();\n");
82.551 - gradientsCode.append(methodBody);
82.552 - gradientsCode.append("\n }\n\n");
82.553 - methods.put(methodBody, methodName);
82.554 - }
82.555 - return methodName;
82.556 - }
82.557 -
82.558 - /**
82.559 - * Takes a abstract gradient and creates the code for the fractions float
82.560 - * array and the colors array that can be used in the constructors of linear
82.561 - * and radial gradients.
82.562 - *
82.563 - * @param g The abstract gradient to get stops from
82.564 - * @param b Append code string of the form "new float[]{...},
82.565 - * new Color[]{...}" to this StringBuilder
82.566 - */
82.567 - private void encodeGradientColorsAndFractions(AbstractGradient g,
82.568 - StringBuilder b) {
82.569 - List<GradientStop> stops = g.getStops();
82.570 - // there are stops.size() number of main stops. Between each is a
82.571 - // fractional stop. Thus, there are: stops.size() + stops.size() - 1
82.572 - // number of fractions and colors.
82.573 - float[] fractions = new float[stops.size() + stops.size() - 1];
82.574 - String[] colors = new String[fractions.length];
82.575 - //for each stop, create the stop and it's associated fraction
82.576 - int index = 0; // the index into fractions and colors
82.577 - for (int i = 0; i < stops.size(); i++) {
82.578 - GradientStop s = stops.get(i);
82.579 - //copy over the stop's data
82.580 - colors[index] = encodeMatte(s.getColor());
82.581 - fractions[index] = s.getPosition();
82.582 -
82.583 - //If this isn't the last stop, then add in the fraction
82.584 - if (index < fractions.length - 1) {
82.585 - float f1 = s.getPosition();
82.586 - float f2 = stops.get(i + 1).getPosition();
82.587 - index++;
82.588 - fractions[index] = f1 + (f2 - f1) * s.getMidpoint();
82.589 - colors[index] = "decodeColor("+
82.590 - colors[index - 1]+","+
82.591 - encodeMatte(stops.get(i + 1).getColor())+",0.5f)";
82.592 - }
82.593 - index++;
82.594 - }
82.595 - // Check boundry conditions
82.596 - for (int i = 1; i < fractions.length; i++) {
82.597 - //to avoid an error with LinearGradientPaint where two fractions
82.598 - //are identical, bump up the fraction value by a miniscule amount
82.599 - //if it is identical to the previous one
82.600 - //NOTE: The <= is critical because the previous value may already
82.601 - //have been bumped up
82.602 - if (fractions[i] <= fractions[i - 1]) {
82.603 - fractions[i] = fractions[i - 1] + .000001f;
82.604 - }
82.605 - }
82.606 - //another boundary condition where multiple stops are all at the end. The
82.607 - //previous loop bumped all but one of these past 1.0, which is bad.
82.608 - //so remove any fractions (and their colors!) that are beyond 1.0
82.609 - int outOfBoundsIndex = -1;
82.610 - for (int i = 0; i < fractions.length; i++) {
82.611 - if (fractions[i] > 1) {
82.612 - outOfBoundsIndex = i;
82.613 - break;
82.614 - }
82.615 - }
82.616 - if (outOfBoundsIndex >= 0) {
82.617 - float[] f = fractions;
82.618 - String[] c = colors;
82.619 - fractions = new float[outOfBoundsIndex];
82.620 - colors = new String[outOfBoundsIndex];
82.621 - System.arraycopy(f, 0, fractions, 0, outOfBoundsIndex);
82.622 - System.arraycopy(c, 0, colors, 0, outOfBoundsIndex);
82.623 - }
82.624 - // build string
82.625 - b.append(" new float[] { ");
82.626 - for (int i = 0; i < fractions.length; i++) {
82.627 - if (i>0)b.append(',');
82.628 - b.append(fractions[i]);
82.629 - b.append('f');
82.630 - }
82.631 - b.append(" },\n new Color[] { ");
82.632 - for (int i = 0; i < colors.length; i++) {
82.633 - if (i>0) b.append(",\n ");
82.634 - b.append(colors[i]);
82.635 - }
82.636 - b.append("}");
82.637 - }
82.638 -
82.639 - private String encodeRadial(PaintedShape ps, RadialGradient g) {
82.640 - float centerX1 = (float)ps.getPaintX1();
82.641 - float centerY1 = (float)ps.getPaintY1();
82.642 - float x2 = (float)ps.getPaintX2();
82.643 - float y2 = (float)ps.getPaintY2();
82.644 - float radius = (float)Point2D.distance(centerX1, centerY1, x2, y2);
82.645 - StringBuilder b = new StringBuilder();
82.646 -
82.647 - b.append(" return decodeRadialGradient((");
82.648 - b.append(centerX1);
82.649 - b.append("f * w) + x, (");
82.650 - b.append(centerY1);
82.651 - b.append("f * h) + y, ");
82.652 - b.append(radius);
82.653 - b.append("f,\n");
82.654 - encodeGradientColorsAndFractions(g,b);
82.655 - b.append(");");
82.656 -
82.657 - String methodBody = b.toString();
82.658 - String methodName = methods.get(methodBody);
82.659 - if (methodName == null) {
82.660 - methodName = "decodeRadial" + radialCounter++;
82.661 - gradientsCode.append(" private Paint ").append(methodName).append("(Shape s) {\n");
82.662 - gradientsCode.append(" Rectangle2D bounds = s.getBounds2D();\n");
82.663 - gradientsCode.append(" float x = (float)bounds.getX();\n");
82.664 - gradientsCode.append(" float y = (float)bounds.getY();\n");
82.665 - gradientsCode.append(" float w = (float)bounds.getWidth();\n");
82.666 - gradientsCode.append(" float h = (float)bounds.getHeight();\n");
82.667 - gradientsCode.append(methodBody);
82.668 - gradientsCode.append("\n }\n\n");
82.669 - methods.put(methodBody, methodName);
82.670 - }
82.671 - return methodName;
82.672 - }
82.673 -
82.674 - //note that this method is not thread-safe. In fact, none of this class is.
82.675 - static void writePainter(UIRegion r, Map<String, String> variables, File painterPackageRoot, String prefix) throws IOException {
82.676 - //Need only write out the stuff for this region, don't need to worry about subregions
82.677 - //since this method will be called for each of those (and they go in their own file, anyway).
82.678 - //The only subregion that we compound into this is the one for icons.
82.679 -
82.680 - String painterName = makePretty(prefix) + "Painter";
82.681 - PainterGenerator gen = new PainterGenerator(r);
82.682 - System.out.println("Generating source file: " + painterName + ".java");
82.683 - System.out.println(gen.stateTypeCode.toString());
82.684 - variables.put("PAINTER_NAME", painterName);
82.685 - variables.put("STATIC_DECL", gen.stateTypeCode.toString());
82.686 - variables.put("COLORS_DECL", gen.colorCode.toString());
82.687 - variables.put("DO_PAINT_SWITCH_BODY", gen.switchCode.toString());
82.688 - variables.put("PAINTING_DECL", gen.paintingCode.toString());
82.689 - variables.put("GET_EXTENDED_CACHE_KEYS", gen.getExtendedCacheKeysCode.toString());
82.690 - variables.put("SHAPES_DECL", gen.shapesCode.toString());
82.691 - variables.put("GRADIENTS_DECL", gen.gradientsCode.toString());
82.692 -
82.693 - writeSrcFile(getPainterImplTemplate(), variables, new File(painterPackageRoot, painterName + ".java"));
82.694 -
82.695 - variables.remove("PAINTER_NAME");
82.696 - variables.remove("STATIC_DECL");
82.697 - variables.remove("COLORS_DECL");
82.698 - variables.remove("DO_PAINT_SWITCH_BODY");
82.699 - variables.remove("PAINTING_DECL");
82.700 - variables.remove("SHAPES_DECL");
82.701 - variables.remove("GRADIENTS_DECL");
82.702 - }
82.703 -
82.704 - /**
82.705 - * Represents the usage of a color from a component within a painter. That
82.706 - * is, a painter can use colors from the component when it paints. This
82.707 - * class represents the usage of such a color, containing a reference to
82.708 - * the name of the property that contains the color, and the various
82.709 - * derivation offsets to apply to that color.
82.710 - */
82.711 - private static class ComponentColor {
82.712 - public String propertyName;
82.713 - public String defaultColorVariableName;
82.714 - private float saturationOffset = 0, brightnessOffset = 0;
82.715 - private int alphaOffset = 0;
82.716 -
82.717 - private ComponentColor(String propertyName,
82.718 - String defaultColorVariableName,
82.719 - float saturationOffset,
82.720 - float brightnessOffset,
82.721 - int alphaOffset) {
82.722 - this.propertyName = propertyName;
82.723 - this.defaultColorVariableName = defaultColorVariableName;
82.724 - this.saturationOffset = saturationOffset;
82.725 - this.brightnessOffset = brightnessOffset;
82.726 - this.alphaOffset = alphaOffset;
82.727 - }
82.728 -
82.729 - @Override
82.730 - public boolean equals(Object o) {
82.731 - if (this == o) return true;
82.732 - if (o == null || getClass() != o.getClass()) return false;
82.733 -
82.734 - ComponentColor c = (ComponentColor)o;
82.735 - if (alphaOffset != c.alphaOffset) return false;
82.736 - if (Float.compare(saturationOffset, c.saturationOffset) != 0)
82.737 - return false;
82.738 - if (Float.compare(brightnessOffset, c.brightnessOffset) != 0)
82.739 - return false;
82.740 - if (defaultColorVariableName != null ?
82.741 - !defaultColorVariableName.equals(c.defaultColorVariableName) :
82.742 - c.defaultColorVariableName != null) return false;
82.743 - if (propertyName != null ? !propertyName.equals(c.propertyName) :
82.744 - c.propertyName != null) return false;
82.745 - return true;
82.746 - }
82.747 -
82.748 - @Override
82.749 - public int hashCode() {
82.750 - int hash = 5;
82.751 - hash = 61 * hash + (this.propertyName != null ?
82.752 - this.propertyName.hashCode() : 0);
82.753 - hash = 61 * hash + (this.defaultColorVariableName != null ?
82.754 - this.defaultColorVariableName.hashCode() : 0);
82.755 - hash = 61 * hash + Float.floatToIntBits(this.saturationOffset);
82.756 - hash = 61 * hash + Float.floatToIntBits(this.brightnessOffset);
82.757 - hash = 61 * hash + this.alphaOffset;
82.758 - return hash;
82.759 - }
82.760 - }
82.761 -}
83.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/generator/TemplateWriter.java Sun Sep 06 23:14:42 2009 -0700
83.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
83.3 @@ -1,114 +0,0 @@
83.4 -/*
83.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
83.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
83.7 - *
83.8 - * This code is free software; you can redistribute it and/or modify it
83.9 - * under the terms of the GNU General Public License version 2 only, as
83.10 - * published by the Free Software Foundation. Sun designates this
83.11 - * particular file as subject to the "Classpath" exception as provided
83.12 - * by Sun in the LICENSE file that accompanied this code.
83.13 - *
83.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
83.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
83.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
83.17 - * version 2 for more details (a copy is included in the LICENSE file that
83.18 - * accompanied this code).
83.19 - *
83.20 - * You should have received a copy of the GNU General Public License version
83.21 - * 2 along with this work; if not, write to the Free Software Foundation,
83.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
83.23 - *
83.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
83.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
83.26 - * have any questions.
83.27 - */
83.28 -package org.jdesktop.synthdesigner.generator;
83.29 -
83.30 -import java.io.BufferedReader;
83.31 -import java.io.File;
83.32 -import java.io.FileWriter;
83.33 -import java.io.IOException;
83.34 -import java.io.InputStream;
83.35 -import java.io.PrintWriter;
83.36 -import java.io.StringReader;
83.37 -import java.util.Map;
83.38 -
83.39 -/**
83.40 - * TemplateWriter - Class for writing Java Source files using a src template and variable subsitution
83.41 - *
83.42 - * @author Richard Bair
83.43 - * @author Jasper Potts
83.44 - */
83.45 -public class TemplateWriter {
83.46 -
83.47 - /**
83.48 - * Write a Java source file by taking a template file and applying variable substitution and writing to the output
83.49 - * file.
83.50 - *
83.51 - * @param template The template to use
83.52 - * @param variables Map of the variable names and values to substitute in the template
83.53 - * @param output The file to write to
83.54 - * @throws IOException If there was a problem writing the Java source file
83.55 - */
83.56 - static void writeSrcFile(String template, Map<String, String> variables, File output) throws IOException {
83.57 - TemplateReader in = new TemplateReader(variables, template);
83.58 - PrintWriter out =
83.59 - new PrintWriter(new FileWriter(output));
83.60 -
83.61 - String line = in.readLine();
83.62 - while (line != null) {
83.63 - out.println(line);
83.64 - line = in.readLine();
83.65 - }
83.66 -
83.67 - out.close();
83.68 - }
83.69 -
83.70 - /**
83.71 - * Read a template file into a string
83.72 - *
83.73 - * @param name The template file path relative to Generator class
83.74 - * @return The contents of the template file as string
83.75 - * @throws IOException If there was a problem reading the template file
83.76 - */
83.77 - static String read(String name) throws IOException {
83.78 - InputStream in = Generator.class.getResourceAsStream(name);
83.79 - if (in==null) throw new IOException("Could not find template ["+name+
83.80 - "] relative to class ["+Generator.class.getName()+"]");
83.81 - byte[] data = new byte[4096];
83.82 - int length = -1;
83.83 - StringBuilder buffer = new StringBuilder();
83.84 - while ((length = in.read(data)) != -1) {
83.85 - buffer.append(new String(data, 0, length));
83.86 - }
83.87 - return buffer.toString();
83.88 - }
83.89 -
83.90 - /** A BufferedReader implementation that automatically performs string replacements as needed. */
83.91 - private static final class TemplateReader extends BufferedReader {
83.92 - private Map<String, String> variables;
83.93 -
83.94 - TemplateReader(Map<String, String> variables, String template) {
83.95 - super(new StringReader(template));
83.96 - this.variables = variables;
83.97 - }
83.98 -
83.99 - /**
83.100 - * @return a line of text from the template but with variables substituted. Other methods will return the text
83.101 - * sans substitution. Call this method.
83.102 - * @throws java.io.IOException
83.103 - */
83.104 - public String readLine() throws IOException {
83.105 - return substituteVariables(super.readLine());
83.106 - }
83.107 -
83.108 - private String substituteVariables(String input) {
83.109 - if (input == null) return null;
83.110 - for (Map.Entry<String, String> variable : variables.entrySet()) {
83.111 - input = input.replace("${" + variable.getKey() + "}", variable.getValue());
83.112 - }
83.113 - return input;
83.114 - }
83.115 - }
83.116 -
83.117 -}
84.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/CustomUIDefault.java Sun Sep 06 23:14:42 2009 -0700
84.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
84.3 @@ -1,43 +0,0 @@
84.4 -/*
84.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
84.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
84.7 - *
84.8 - * This code is free software; you can redistribute it and/or modify it
84.9 - * under the terms of the GNU General Public License version 2 only, as
84.10 - * published by the Free Software Foundation. Sun designates this
84.11 - * particular file as subject to the "Classpath" exception as provided
84.12 - * by Sun in the LICENSE file that accompanied this code.
84.13 - *
84.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
84.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
84.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
84.17 - * version 2 for more details (a copy is included in the LICENSE file that
84.18 - * accompanied this code).
84.19 - *
84.20 - * You should have received a copy of the GNU General Public License version
84.21 - * 2 along with this work; if not, write to the Free Software Foundation,
84.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
84.23 - *
84.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
84.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
84.26 - * have any questions.
84.27 - */
84.28 -package org.jdesktop.synthdesigner.synthmodel;
84.29 -
84.30 -/**
84.31 - * CustomUIDefault
84.32 - *
84.33 - * @author Richard Bair
84.34 - * @author Jasper Potts
84.35 - */
84.36 -public class CustomUIDefault<T> extends UIDefault<T> {
84.37 - private static int counter = -1;
84.38 -
84.39 - public CustomUIDefault() {
84.40 - super("Unnamed" + (++counter == 0 ? "" : counter), null);
84.41 - }
84.42 -
84.43 - public void setName(String id) {
84.44 - super.setName(id);
84.45 - }
84.46 -}
85.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/HasUIStyle.java Sun Sep 06 23:14:42 2009 -0700
85.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
85.3 @@ -1,36 +0,0 @@
85.4 -/*
85.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
85.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
85.7 - *
85.8 - * This code is free software; you can redistribute it and/or modify it
85.9 - * under the terms of the GNU General Public License version 2 only, as
85.10 - * published by the Free Software Foundation. Sun designates this
85.11 - * particular file as subject to the "Classpath" exception as provided
85.12 - * by Sun in the LICENSE file that accompanied this code.
85.13 - *
85.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
85.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
85.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
85.17 - * version 2 for more details (a copy is included in the LICENSE file that
85.18 - * accompanied this code).
85.19 - *
85.20 - * You should have received a copy of the GNU General Public License version
85.21 - * 2 along with this work; if not, write to the Free Software Foundation,
85.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
85.23 - *
85.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
85.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
85.26 - * have any questions.
85.27 - */
85.28 -package org.jdesktop.synthdesigner.synthmodel;
85.29 -
85.30 -/**
85.31 - * HasUIStyle - A marker interface for all classes that have a UIStyle
85.32 - *
85.33 - * @author Richard Bair
85.34 - * @author Jasper Potts
85.35 - */
85.36 -public interface HasUIStyle {
85.37 -
85.38 - public UIStyle getStyle();
85.39 -}
86.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/PainterBorder.java Sun Sep 06 23:14:42 2009 -0700
86.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
86.3 @@ -1,43 +0,0 @@
86.4 -/*
86.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
86.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
86.7 - *
86.8 - * This code is free software; you can redistribute it and/or modify it
86.9 - * under the terms of the GNU General Public License version 2 only, as
86.10 - * published by the Free Software Foundation. Sun designates this
86.11 - * particular file as subject to the "Classpath" exception as provided
86.12 - * by Sun in the LICENSE file that accompanied this code.
86.13 - *
86.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
86.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
86.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
86.17 - * version 2 for more details (a copy is included in the LICENSE file that
86.18 - * accompanied this code).
86.19 - *
86.20 - * You should have received a copy of the GNU General Public License version
86.21 - * 2 along with this work; if not, write to the Free Software Foundation,
86.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
86.23 - *
86.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
86.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
86.26 - * have any questions.
86.27 - */
86.28 -package org.jdesktop.synthdesigner.synthmodel;
86.29 -
86.30 -import javax.swing.border.EmptyBorder;
86.31 -
86.32 -/**
86.33 - * Represents a border that refers to a Painter to do it's work. This border
86.34 - * doesn't actually render -- it is just used as part of the model.
86.35 - *
86.36 - * @author Richard Bair
86.37 - */
86.38 -public class PainterBorder extends EmptyBorder {
86.39 - private String painterName;
86.40 - public PainterBorder(String painterName, int top, int left, int bottom, int right) {
86.41 - super(top, left, bottom, right);
86.42 - this.painterName = painterName;
86.43 - }
86.44 -
86.45 - public String getPainterName() { return painterName; }
86.46 -}
87.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/SynthModel.java Sun Sep 06 23:14:42 2009 -0700
87.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
87.3 @@ -1,530 +0,0 @@
87.4 -/*
87.5 - * Copyright 2002-2007 Sun Microsystems, Inc. All Rights Reserved.
87.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
87.7 - *
87.8 - * This code is free software; you can redistribute it and/or modify it
87.9 - * under the terms of the GNU General Public License version 2 only, as
87.10 - * published by the Free Software Foundation. Sun designates this
87.11 - * particular file as subject to the "Classpath" exception as provided
87.12 - * by Sun in the LICENSE file that accompanied this code.
87.13 - *
87.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
87.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
87.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
87.17 - * version 2 for more details (a copy is included in the LICENSE file that
87.18 - * accompanied this code).
87.19 - *
87.20 - * You should have received a copy of the GNU General Public License version
87.21 - * 2 along with this work; if not, write to the Free Software Foundation,
87.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
87.23 - *
87.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
87.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
87.26 - * have any questions.
87.27 - */
87.28 -package org.jdesktop.synthdesigner.synthmodel;
87.29 -
87.30 -import org.jdesktop.beans.AbstractBean;
87.31 -import org.jdesktop.swingx.designer.utils.HasResources;
87.32 -import org.jdesktop.swingx.designer.utils.HasUIDefaults;
87.33 -import org.jibx.runtime.IUnmarshallingContext;
87.34 -
87.35 -import javax.swing.JButton;
87.36 -import javax.swing.JCheckBox;
87.37 -import javax.swing.JCheckBoxMenuItem;
87.38 -import javax.swing.JColorChooser;
87.39 -import javax.swing.JComboBox;
87.40 -import javax.swing.JDesktopPane;
87.41 -import javax.swing.JEditorPane;
87.42 -import javax.swing.JFileChooser;
87.43 -import javax.swing.JFormattedTextField;
87.44 -import javax.swing.JInternalFrame;
87.45 -import javax.swing.JLabel;
87.46 -import javax.swing.JList;
87.47 -import javax.swing.JMenu;
87.48 -import javax.swing.JMenuBar;
87.49 -import javax.swing.JMenuItem;
87.50 -import javax.swing.JOptionPane;
87.51 -import javax.swing.JPanel;
87.52 -import javax.swing.JPasswordField;
87.53 -import javax.swing.JPopupMenu;
87.54 -import javax.swing.JProgressBar;
87.55 -import javax.swing.JRadioButton;
87.56 -import javax.swing.JRadioButtonMenuItem;
87.57 -import javax.swing.JRootPane;
87.58 -import javax.swing.JScrollBar;
87.59 -import javax.swing.JScrollPane;
87.60 -import javax.swing.JSeparator;
87.61 -import javax.swing.JSlider;
87.62 -import javax.swing.JSpinner;
87.63 -import javax.swing.JSplitPane;
87.64 -import javax.swing.JTabbedPane;
87.65 -import javax.swing.JTable;
87.66 -import javax.swing.JTextArea;
87.67 -import javax.swing.JTextField;
87.68 -import javax.swing.JTextPane;
87.69 -import javax.swing.JToggleButton;
87.70 -import javax.swing.JToolBar;
87.71 -import javax.swing.JToolTip;
87.72 -import javax.swing.JTree;
87.73 -import javax.swing.JViewport;
87.74 -import javax.swing.UIDefaults;
87.75 -import javax.swing.plaf.basic.BasicLookAndFeel;
87.76 -import javax.swing.plaf.metal.MetalLookAndFeel;
87.77 -import static javax.swing.plaf.synth.SynthConstants.*;
87.78 -import javax.swing.table.JTableHeader;
87.79 -import java.awt.Insets;
87.80 -import java.io.File;
87.81 -import java.util.ArrayList;
87.82 -import java.util.List;
87.83 -
87.84 -/**
87.85 - * Models a Synth look and feel. Contains all of the colors, fonts, painters, states, etc that compose a synth look and
87.86 - * feel.
87.87 - * <p/>
87.88 - * To model Synth properly, I need to both Model the way Synth works (with styles, and so forth) and the way a look and
87.89 - * feel works (UIDefaults table, etc) since both of these are supported ways of doing things in Synth.
87.90 - * <p/>
87.91 - * One important (but non-visual) thing that needs to be configurable is the support for InputMaps per component. In
87.92 - * Synth, an input map can be associated with the main Synth element, meaning it applies to everything. Or it can be
87.93 - * associated with a single style. An Inputmap can have an id, and it can contain multiple key/action pairs (where
87.94 - * actions are denoted by name).
87.95 - * <p/>
87.96 - * It looks like Regions can have InputMaps? Sounds fishy to me. I think only Components really have input maps.
87.97 - * <p/>
87.98 - * I would like some way of denoting special keys between mac and other platforms. For example, cut, copy, paste etc
87.99 - * should be different. In general, the ctrl key and apple (meta) key are reversed from what is typically on windows.
87.100 - *
87.101 - * @author Richard Bair
87.102 - * @author Jasper Potts
87.103 - */
87.104 -public class SynthModel extends AbstractBean implements HasUIDefaults, HasUIStyle, HasResources {
87.105 - //I'm going to want:
87.106 - //entries related to the Control color, and other colors of the Basic LAF
87.107 - //entries related to fonts (standard fonts) used in the Basic LAF
87.108 - //entries related to standard insets, borders, dimensions, icons
87.109 - //entries related to component specific entries in the LAF
87.110 - private List<UIPaint> colors;
87.111 - private List<UIFont> fonts;
87.112 - private List<UIInsets> insets;
87.113 - private List<UIBorder> borders;
87.114 - private List<UIDimension> dimensions;
87.115 - private List<UIIcon> icons;
87.116 - private List<UIComponent> components;
87.117 - /**
87.118 - * This is a local UIDefaults that contains all the UIDefaults in this synth model. It is kept uptodate by the
87.119 - * indervidual UIDefaults nodes
87.120 - */
87.121 - private transient UIDefaults modelDefaults = new UIDefaults();
87.122 - private transient UIStyle globalStyle = new UIStyle();
87.123 -
87.124 - private transient File resourcesDir;
87.125 - private transient File imagesDir;
87.126 - private transient File templatesDir;
87.127 -
87.128 - /** Default constructor used by JIBX to create new empty SynthModel */
87.129 - protected SynthModel() {
87.130 - this(false);
87.131 - }
87.132 -
87.133 - public SynthModel(boolean populateWithDefaults) {
87.134 - // create observable lists that fire changes on as property changes
87.135 - colors = new ArrayList<UIPaint>();
87.136 - fonts = new ArrayList<UIFont>();
87.137 - insets = new ArrayList<UIInsets>();
87.138 - borders = new ArrayList<UIBorder>();
87.139 - dimensions = new ArrayList<UIDimension>();
87.140 - icons = new ArrayList<UIIcon>();
87.141 - components = new ArrayList<UIComponent>();
87.142 -
87.143 - if (populateWithDefaults) {
87.144 - //get the ui defaults from the SynthLookAndFeel. Using the UIDefaults table,
87.145 - //pre initialize everything.
87.146 -// SynthLookAndFeel synth = new SynthLookAndFeel();
87.147 - BasicLookAndFeel synth = new MetalLookAndFeel();
87.148 - UIDefaults defaults = synth.getDefaults();
87.149 -
87.150 - //pre-init the palettes
87.151 - colors.add(new UIColor("desktop", defaults.getColor("desktop"), modelDefaults));
87.152 - colors.add(new UIColor("activeCaption", defaults.getColor("activeCaption"), modelDefaults));
87.153 - colors.add(new UIColor("activeCaptionText", defaults.getColor("activeCaptionText"), modelDefaults));
87.154 - colors.add(new UIColor("activeCaptionBorder", defaults.getColor("activeCaptionBorder"), modelDefaults));
87.155 - colors.add(new UIColor("inactiveCaption", defaults.getColor("inactiveCaption"), modelDefaults));
87.156 - colors.add(new UIColor("inactiveCaptionText", defaults.getColor("inactiveCaptionText"), modelDefaults));
87.157 - colors.add(new UIColor("inactiveCaptionBorder", defaults.getColor("inactiveCaptionBorder"), modelDefaults));
87.158 - colors.add(new UIColor("window", defaults.getColor("window"), modelDefaults));
87.159 - colors.add(new UIColor("windowBorder", defaults.getColor("windowBorder"), modelDefaults));
87.160 - colors.add(new UIColor("windowText", defaults.getColor("windowText"), modelDefaults));
87.161 - colors.add(new UIColor("menu", defaults.getColor("menu"), modelDefaults));
87.162 - colors.add(new UIColor("menuText", defaults.getColor("menuText"), modelDefaults));
87.163 - colors.add(new UIColor("text", defaults.getColor("text"), modelDefaults));
87.164 - colors.add(new UIColor("textText", defaults.getColor("textText"), modelDefaults));
87.165 - colors.add(new UIColor("textHighlight", defaults.getColor("textHighlight"), modelDefaults));
87.166 - colors.add(new UIColor("textHighlightText", defaults.getColor("textHighlightText"), modelDefaults));
87.167 - colors.add(new UIColor("textInactiveText", defaults.getColor("textInactiveText"), modelDefaults));
87.168 - colors.add(new UIColor("control", defaults.getColor("control"), modelDefaults));
87.169 - colors.add(new UIColor("controlText", defaults.getColor("controlText"), modelDefaults));
87.170 - colors.add(new UIColor("controlHighlight", defaults.getColor("controlHighlight"), modelDefaults));
87.171 - colors.add(new UIColor("controlLHighlight", defaults.getColor("controlLHighlight"), modelDefaults));
87.172 - colors.add(new UIColor("controlShadow", defaults.getColor("controlShadow"), modelDefaults));
87.173 - colors.add(new UIColor("controlDkShadow", defaults.getColor("controlDkShadow"), modelDefaults));
87.174 - colors.add(new UIColor("scrollbar", defaults.getColor("scrollbar"), modelDefaults));
87.175 - colors.add(new UIColor("info", defaults.getColor("info"), modelDefaults));
87.176 - colors.add(new UIColor("infoText", defaults.getColor("infoText"), modelDefaults));
87.177 -
87.178 - fonts.add(new UIFont("dialogPlain", defaults.getFont("Button.font"), modelDefaults));
87.179 - fonts.add(new UIFont("serifPlain", defaults.getFont("TextPane.font"), modelDefaults));
87.180 - fonts.add(new UIFont("sansSerifPlain", defaults.getFont("ToolTip.font"), modelDefaults));
87.181 - fonts.add(new UIFont("monospacedPlain", defaults.getFont("TextArea.font"), modelDefaults));
87.182 - fonts.add(new UIFont("dialogBold", defaults.getFont("InternalFrame.titleFont"), modelDefaults));
87.183 -
87.184 - insets.add(new UIInsets("zeroInsets", new Insets(0, 0, 0, 0)));
87.185 - insets.add(new UIInsets("twoInsets", new Insets(2, 2, 2, 2)));
87.186 - insets.add(new UIInsets("threeInsets", new Insets(3, 3, 3, 3)));
87.187 -
87.188 - borders.add(new UIBorder("marginBorder", defaults.getBorder("MenuItem.border")));
87.189 - borders.add(new UIBorder("etchedBorder", defaults.getBorder("TitledBorder.border")));
87.190 - borders.add(new UIBorder("loweredBevelBorder", defaults.getBorder("Table.scrollPaneBorder")));
87.191 - borders.add(new UIBorder("blackLineBorder", defaults.getBorder("ToolTip.border")));
87.192 -
87.193 - //TODO have to deal with the special arrow button region
87.194 -
87.195 - //pre-init the list of UI components
87.196 - UIComponent button = new UIComponent("Button", JButton.class.getName(), "ButtonUI");
87.197 - addStates(this, button, DEFAULT, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.198 - components.add(button);
87.199 -
87.200 - UIComponent toggleButton =
87.201 - new UIComponent("ToggleButton", JToggleButton.class.getName(), "ToggleButtonUI");
87.202 - addStates(this, toggleButton, DEFAULT, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED, SELECTED,
87.203 - SELECTED | PRESSED, SELECTED | MOUSE_OVER, DISABLED | SELECTED);
87.204 - components.add(toggleButton);
87.205 -
87.206 - UIComponent radioButton =
87.207 - new UIComponent("RadioButton", JRadioButton.class.getName(), "RadioButtonUI");
87.208 - addStates(this, radioButton, DEFAULT, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED, SELECTED,
87.209 - SELECTED | PRESSED, SELECTED | MOUSE_OVER, DISABLED | SELECTED);
87.210 - components.add(radioButton);
87.211 -
87.212 - UIComponent checkBox =
87.213 - new UIComponent("CheckBox", JCheckBox.class.getName(), "CheckBoxUI");
87.214 - addStates(this, checkBox, DEFAULT, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED, SELECTED,
87.215 - SELECTED | PRESSED, SELECTED | MOUSE_OVER, DISABLED | SELECTED);
87.216 - components.add(checkBox);
87.217 -
87.218 - UIComponent colorChooser =
87.219 - new UIComponent("ColorChooser", JColorChooser.class.getName(), "ColorChooserUI");
87.220 - addStates(this, colorChooser, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.221 - components.add(colorChooser);
87.222 -
87.223 - UIComponent comboBox =
87.224 - new UIComponent("ComboBox", JComboBox.class.getName(), "ComboBoxUI");
87.225 - addStates(this, comboBox, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.226 - components.add(comboBox);
87.227 -
87.228 - UIComponent fileChooser =
87.229 - new UIComponent("FileChooser", JFileChooser.class.getName(), "FileChooserUI");
87.230 - addStates(this, fileChooser, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.231 - components.add(fileChooser);
87.232 -
87.233 - //not represented in Synth
87.234 -// UIComponent fileView = new UIComponent ("FileView",
87.235 -// list(DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.236 -
87.237 - UIComponent internalFrame =
87.238 - new UIComponent("InternalFrame", JInternalFrame.class.getName(), "InternalFrameUI");
87.239 - addStates(this, internalFrame, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.240 - //has an internal frame title pane region
87.241 - components.add(internalFrame);
87.242 -
87.243 - //TODO DesktopIcon ???
87.244 -
87.245 - UIComponent desktop =
87.246 - new UIComponent("Desktop", JDesktopPane.class.getName(), "DesktopPaneUI");
87.247 - addStates(this, desktop, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.248 - components.add(desktop);
87.249 -
87.250 - UIComponent label = new UIComponent("Label", JLabel.class.getName(), "LabelUI");
87.251 - addStates(this, label, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.252 - components.add(label);
87.253 -
87.254 - UIComponent list = new UIComponent("List", JList.class.getName(), "ListUI");
87.255 - addStates(this, list, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.256 - components.add(list);
87.257 -
87.258 - UIComponent menuBar = new UIComponent("MenuBar", JMenuBar.class.getName(), "MenuBarUI");
87.259 - addStates(this, menuBar, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.260 - components.add(menuBar);
87.261 -
87.262 - UIComponent menuItem =
87.263 - new UIComponent("MenuItem", JMenuItem.class.getName(), "MenuItemUI");
87.264 - addStates(this, menuItem, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.265 - //has a menuItemAccelerator region
87.266 - components.add(menuItem);
87.267 -
87.268 - UIComponent radioButtonMenuItem =
87.269 - new UIComponent("RadioButtonMenuItem", JRadioButtonMenuItem.class.getName(),
87.270 - "RadioButtonMenuItemUI");
87.271 - addStates(this, radioButtonMenuItem, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.272 - components.add(radioButtonMenuItem);
87.273 -
87.274 - UIComponent checkBoxMenuItem =
87.275 - new UIComponent("CheckBoxMenuItem", JCheckBoxMenuItem.class.getName(),
87.276 - "CheckBoxMenuItemUI");
87.277 - addStates(this, checkBoxMenuItem, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.278 - components.add(checkBoxMenuItem);
87.279 -
87.280 - UIComponent menu = new UIComponent("Menu", JMenu.class.getName(), "MenuUI");
87.281 - addStates(this, menu, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.282 - components.add(menu);
87.283 -
87.284 - UIComponent popupMenu =
87.285 - new UIComponent("PopupMenu", JPopupMenu.class.getName(), "PopupMenuUI");
87.286 - addStates(this, popupMenu, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.287 - //has a popupMenuSeparator region
87.288 - components.add(popupMenu);
87.289 -
87.290 - UIComponent optionPane =
87.291 - new UIComponent("OptionPane", JOptionPane.class.getName(), "OptionPaneUI");
87.292 - addStates(this, optionPane, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.293 - components.add(optionPane);
87.294 -
87.295 - UIComponent panel = new UIComponent("Panel", JPanel.class.getName(), "PanelUI");
87.296 - addStates(this, panel, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.297 - components.add(panel);
87.298 -
87.299 - UIComponent progressBar =
87.300 - new UIComponent("ProgressBar", JProgressBar.class.getName(), "ProgressBarUI");
87.301 - addStates(this, progressBar, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.302 - components.add(progressBar);
87.303 -
87.304 - UIComponent separator =
87.305 - new UIComponent("Separator", JSeparator.class.getName(), "SeparatorUI");
87.306 - addStates(this, separator, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.307 - components.add(separator);
87.308 -
87.309 - UIRegion scrollBarThumb = new UIRegion("ScrollBar.Thumb");
87.310 - addStates(this, scrollBarThumb, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.311 - UIRegion scrollBarTrack = new UIRegion("ScrollBar.Track");
87.312 - addStates(this, scrollBarTrack, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.313 - UIComponent scrollBar =
87.314 - new UIComponent("ScrollBar", JScrollBar.class.getName(), "ScrollBarUI", scrollBarThumb,
87.315 - scrollBarTrack);
87.316 - addStates(this, scrollBar, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.317 - components.add(scrollBar);
87.318 -
87.319 - UIComponent scrollPane =
87.320 - new UIComponent("ScrollPane", JScrollPane.class.getName(), "ScrollPaneUI");
87.321 - addStates(this, scrollPane, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.322 - components.add(scrollPane);
87.323 -
87.324 - UIComponent viewport =
87.325 - new UIComponent("Viewport", JViewport.class.getName(), "ViewportUI");
87.326 - addStates(this, viewport, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.327 - components.add(viewport);
87.328 -
87.329 - UIComponent slider = new UIComponent("Slider", JSlider.class.getName(), "SliderUI");
87.330 - addStates(this, slider, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.331 - //has sliderThumb and sliderTrack sub regions
87.332 - components.add(slider);
87.333 -
87.334 - UIComponent spinner = new UIComponent("Spinner", JSpinner.class.getName(), "SpinnerUI");
87.335 - addStates(this, spinner, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.336 - components.add(spinner);
87.337 -
87.338 - UIComponent splitPane =
87.339 - new UIComponent("SplitPane", JSplitPane.class.getName(), "SplitPaneUI");
87.340 - addStates(this, splitPane, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.341 - //has splitPaneDivider sub region
87.342 - components.add(splitPane);
87.343 -
87.344 - UIComponent tabbedPane =
87.345 - new UIComponent("TabbedPane", JTabbedPane.class.getName(), "TabbedPaneUI");
87.346 - addStates(this, tabbedPane, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.347 - //has tabbedPaneContent and tabbedPaneTab and TabbedPaneTabArea sub regions
87.348 - components.add(tabbedPane);
87.349 -
87.350 - UIComponent table = new UIComponent("Table", JTable.class.getName(), "TableUI");
87.351 - addStates(this, table, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.352 - components.add(table);
87.353 -
87.354 - UIComponent tableHeader =
87.355 - new UIComponent("TableHeader", JTableHeader.class.getName(), "TableHeaderUI");
87.356 - addStates(this, tableHeader, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.357 - components.add(tableHeader);
87.358 -
87.359 - UIComponent textField =
87.360 - new UIComponent("TextField", JTextField.class.getName(), "TextFieldUI");
87.361 - addStates(this, textField, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.362 - components.add(textField);
87.363 -
87.364 - UIComponent formattedTextField =
87.365 - new UIComponent("FormattedTextField", JFormattedTextField.class.getName(),
87.366 - "FormattedTextFieldUI");
87.367 - addStates(this, formattedTextField, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.368 - components.add(formattedTextField);
87.369 -
87.370 - UIComponent passwordField =
87.371 - new UIComponent("PasswordField", JPasswordField.class.getName(), "PasswordFieldUI");
87.372 - addStates(this, passwordField, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.373 - components.add(passwordField);
87.374 -
87.375 - UIComponent textArea =
87.376 - new UIComponent("TextArea", JTextArea.class.getName(), "TextAreaUI");
87.377 - addStates(this, textArea, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.378 - components.add(textArea);
87.379 -
87.380 - UIComponent textPane =
87.381 - new UIComponent("TextPane", JTextPane.class.getName(), "TextPaneUI");
87.382 - addStates(this, textPane, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.383 - components.add(textPane);
87.384 -
87.385 - UIComponent editorPane =
87.386 - new UIComponent("EditorPane", JEditorPane.class.getName(), "EditorPaneUI");
87.387 - addStates(this, editorPane, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.388 - components.add(editorPane);
87.389 -
87.390 - /*
87.391 - * The only thing not represented in Synth as a region. I suppose we'll have
87.392 - * to make it a CustomUIComponent
87.393 - */
87.394 -// UIComponent titledBorder = new UIComponent ("TitledBorder",
87.395 -// list(DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.396 -
87.397 - UIComponent toolBar = new UIComponent("ToolBar", JToolBar.class.getName(), "ToolBarUI");
87.398 - addStates(this, toolBar, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.399 - //toolBarContent, toolBarDragWindow, toolBarSeparator sub regions
87.400 - components.add(toolBar);
87.401 -
87.402 - UIComponent toolTip = new UIComponent("ToolTip", JToolTip.class.getName(), "ToolTipUI");
87.403 - addStates(this, toolTip, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.404 - components.add(toolTip);
87.405 -
87.406 - //tooltip manager
87.407 -
87.408 - UIComponent tree = new UIComponent("Tree", JTree.class.getName(), "TreeUI");
87.409 - addStates(this, tree, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.410 - //treeCell sub region
87.411 - components.add(tree);
87.412 -
87.413 - UIComponent rootPane =
87.414 - new UIComponent("RootPane", JRootPane.class.getName(), "RootPaneUI");
87.415 - addStates(this, rootPane, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
87.416 - components.add(rootPane);
87.417 - }
87.418 - }
87.419 -
87.420 - public List<UIPaint> getColorPalette() {
87.421 - return colors;
87.422 - }
87.423 -
87.424 - public List<UIFont> getFontPalette() {
87.425 - return fonts;
87.426 - }
87.427 -
87.428 - public List<UIInsets> getInsetPalette() {
87.429 - return insets;
87.430 - }
87.431 -
87.432 - public List<UIBorder> getBorderPalette() {
87.433 - return borders;
87.434 - }
87.435 -
87.436 - public List<UIDimension> getDimensionPalette() {
87.437 - return dimensions;
87.438 - }
87.439 -
87.440 - public List<UIIcon> getIconPalette() {
87.441 - return icons;
87.442 - }
87.443 -
87.444 - public List<UIComponent> getComponents() {
87.445 - return components;
87.446 - }
87.447 -
87.448 - /**
87.449 - * Get the local UIDefaults that contains all the UIDefaults in this synth model. It is kept uptodate by the
87.450 - * indervidual UIDefaults nodes
87.451 - *
87.452 - * @return The UIDefaults for the synth model
87.453 - */
87.454 - public UIDefaults getUiDefaults() {
87.455 - return modelDefaults;
87.456 - }
87.457 -
87.458 - public UIStyle getStyle() {
87.459 - return globalStyle;
87.460 - }
87.461 -
87.462 - // by default there are no painters assigned to the various states
87.463 - private static void addStates(SynthModel model, UIRegion parentRegion, int... states) {
87.464 - for (int state : states) {
87.465 - List<String> stateList = new ArrayList<String>();
87.466 - if ((state & ENABLED) != 0) {
87.467 - stateList.add(UIStateType.ENABLED_KEY);
87.468 - }
87.469 - if ((state & MOUSE_OVER) != 0) {
87.470 - stateList.add(UIStateType.MOUSE_OVER_KEY);
87.471 - }
87.472 - if ((state & PRESSED) != 0) {
87.473 - stateList.add(UIStateType.PRESSED_KEY);
87.474 - }
87.475 - if ((state & DISABLED) != 0) {
87.476 - stateList.add(UIStateType.DISABLED_KEY);
87.477 - }
87.478 - if ((state & FOCUSED) != 0) {
87.479 - stateList.add(UIStateType.FOCUSED_KEY);
87.480 - }
87.481 - if ((state & SELECTED) != 0) {
87.482 - stateList.add(UIStateType.SELECTED_KEY);
87.483 - }
87.484 - if ((state & DEFAULT) != 0) {
87.485 - stateList.add(UIStateType.DEFAULT_KEY);
87.486 - }
87.487 - parentRegion.addBackgroundState(new UIState(model, parentRegion, stateList.toArray(new String[stateList.size()])));
87.488 - }
87.489 - }
87.490 -
87.491 - public File getResourcesDir() {
87.492 - return resourcesDir;
87.493 - }
87.494 -
87.495 - public void setResourcesDir(File resourcesDir) {
87.496 - System.out.println("SynthModel.setResourcesDir(" + resourcesDir + ")");
87.497 - File old = getResourcesDir();
87.498 - this.resourcesDir = resourcesDir;
87.499 - firePropertyChange("resourcesDir", old, getResourcesDir());
87.500 - }
87.501 -
87.502 - public File getImagesDir() {
87.503 - return imagesDir;
87.504 - }
87.505 -
87.506 - public void setImagesDir(File imagesDir) {
87.507 - System.out.println("SynthModel.setImagesDir(" + imagesDir + ")");
87.508 - File old = getImagesDir();
87.509 - this.imagesDir = imagesDir;
87.510 - firePropertyChange("imagesDir", old, getImagesDir());
87.511 - }
87.512 -
87.513 - public File getTemplatesDir() {
87.514 - return templatesDir;
87.515 - }
87.516 -
87.517 - public void setTemplatesDir(File templatesDir) {
87.518 - System.out.println("SynthModel.setTemplatesDir(" + templatesDir + ")");
87.519 - File old = getTemplatesDir();
87.520 - this.templatesDir = templatesDir;
87.521 - firePropertyChange("templatesDir", old, getTemplatesDir());
87.522 - }
87.523 -
87.524 - // =================================================================================================================
87.525 - // JIBX Methods
87.526 -
87.527 - public void preSet(IUnmarshallingContext context) {
87.528 - File resourcesDir = (File) context.getUserContext();
87.529 - this.resourcesDir = resourcesDir;
87.530 - this.imagesDir = new File(resourcesDir, "images");
87.531 - this.templatesDir = new File(resourcesDir, "templates");
87.532 - }
87.533 -}
88.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/SynthModel.jibx.xml Sun Sep 06 23:14:42 2009 -0700
88.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
88.3 @@ -1,181 +0,0 @@
88.4 -<?xml version="1.0" encoding="UTF-8"?>
88.5 -
88.6 -<!--
88.7 - Copyright 1998-2004 Sun Microsystems, Inc. All Rights Reserved.
88.8 - DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
88.9 -
88.10 - This code is free software; you can redistribute it and/or modify it
88.11 - under the terms of the GNU General Public License version 2 only, as
88.12 - published by the Free Software Foundation. Sun designates this
88.13 - particular file as subject to the "Classpath" exception as provided
88.14 - by Sun in the LICENSE file that accompanied this code.
88.15 -
88.16 - This code is distributed in the hope that it will be useful, but WITHOUT
88.17 - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
88.18 - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
88.19 - version 2 for more details (a copy is included in the LICENSE file that
88.20 - accompanied this code).
88.21 -
88.22 - You should have received a copy of the GNU General Public License version
88.23 - 2 along with this work; if not, write to the Free Software Foundation,
88.24 - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
88.25 -
88.26 - Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
88.27 - CA 95054 USA or visit www.sun.com if you need additional information or
88.28 - have any questions.
88.29 --->
88.30 -
88.31 -<!DOCTYPE binding SYSTEM "http://jibx.sourceforge.net">
88.32 -<binding>
88.33 - <mapping class="org.jdesktop.synthdesigner.synthmodel.UIDefault" abstract="true" post-set="postSet">
88.34 - <value name="name" field="name" style="attribute"/>
88.35 - </mapping>
88.36 - <!-- == AWT TYPES =========================================================================================== -->
88.37 - <mapping class="java.awt.Color"
88.38 - marshaller="org.jdesktop.swingx.designer.jibxhelpers.ColorMapper"
88.39 - unmarshaller="org.jdesktop.swingx.designer.jibxhelpers.ColorMapper"/>
88.40 - <mapping class="java.lang.Class"
88.41 - marshaller="org.jdesktop.synthdesigner.synthmodel.jibxhelpers.ClassMapper"
88.42 - unmarshaller="org.jdesktop.synthdesigner.synthmodel.jibxhelpers.ClassMapper"/>
88.43 - <!-- == UI FONT =========================================================================================== -->
88.44 - <mapping name="typeface" class="org.jdesktop.swingx.designer.font.Typeface" post-set="postSet">
88.45 - <value name="family" field="name" style="attribute" usage="optional"/>
88.46 - <value name="bold" field="bold" style="attribute" usage="optional" default="Default"/>
88.47 - <value name="italic" field="italic" style="attribute" usage="optional" default="Default"/>
88.48 - <value name="size" field="size" style="attribute" usage="optional"/>
88.49 - <value name="sizeOffset" field="sizeOffset" style="attribute" usage="optional" default="1"/>
88.50 - <value name="uiDefaultParentName" field="uiDefaultParentName" style="attribute" usage="optional"/>
88.51 - </mapping>
88.52 - <mapping name="uiFont" class="org.jdesktop.synthdesigner.synthmodel.UIFont"
88.53 - extends="org.jdesktop.synthdesigner.synthmodel.UIDefault">
88.54 - <structure map-as="org.jdesktop.synthdesigner.synthmodel.UIDefault"/>
88.55 - <collection get-method="getFonts" set-method="setFonts" create-type="java.util.ArrayList"/>
88.56 - </mapping>
88.57 - <!-- == UI INSETS =========================================================================================== -->
88.58 - <mapping name="uiInsets" class="org.jdesktop.synthdesigner.synthmodel.UIInsets"
88.59 - extends="org.jdesktop.synthdesigner.synthmodel.UIDefault">
88.60 - <structure map-as="org.jdesktop.synthdesigner.synthmodel.UIDefault"/>
88.61 - <structure name="insets" get-method="getInsets" set-method="setInsets"
88.62 - marshaller="org.jdesktop.swingx.designer.jibxhelpers.InsetsMapper"
88.63 - unmarshaller="org.jdesktop.swingx.designer.jibxhelpers.InsetsMapper"/>
88.64 - </mapping>
88.65 - <!-- == UI PAINT =========================================================================================== -->
88.66 - <mapping name="matte" class="org.jdesktop.swingx.designer.paint.Matte" post-set="postSet">
88.67 - <value name="red" field="red" style="attribute"/>
88.68 - <value name="green" field="green" style="attribute"/>
88.69 - <value name="blue" field="blue" style="attribute"/>
88.70 - <value name="alpha" field="alpha" style="attribute"/>
88.71 - <value name="uiDefaultParentName" field="uiDefaultParentName" style="attribute" usage="optional"/>
88.72 - <value name="componentPropertyName" field="componentPropertyName" style="attribute" usage="optional"/>
88.73 - <value name="hueOffset" field="hueOffset" style="attribute"/>
88.74 - <value name="saturationOffset" field="saturationOffset" style="attribute"/>
88.75 - <value name="brightnessOffset" field="brightnessOffset" style="attribute"/>
88.76 - <value name="alphaOffset" field="alphaOffset" style="attribute"/>
88.77 - <value name="uiResource" field="uiResource" style="attribute" usage="optional" default="true"/>
88.78 - </mapping>
88.79 - <mapping class="org.jdesktop.synthdesigner.synthmodel.UIPaint" abstract="true" type-name="uipaint"
88.80 - extends="org.jdesktop.synthdesigner.synthmodel.UIDefault">
88.81 - <structure map-as="org.jdesktop.synthdesigner.synthmodel.UIDefault"/>
88.82 - <structure get-method="getPaint" set-method="setPaint"/>
88.83 - </mapping>
88.84 - <mapping name="uiPaint" class="org.jdesktop.synthdesigner.synthmodel.UIPaint"
88.85 - extends="org.jdesktop.synthdesigner.synthmodel.UIDefault">
88.86 - <structure map-as="uipaint"/>
88.87 - </mapping>
88.88 - <mapping name="uiColor" class="org.jdesktop.synthdesigner.synthmodel.UIColor"
88.89 - extends="org.jdesktop.synthdesigner.synthmodel.UIPaint">
88.90 - <structure map-as="uipaint"/>
88.91 - </mapping>
88.92 - <!-- == UI STYLE =========================================================================================== -->
88.93 - <mapping class="org.jdesktop.synthdesigner.synthmodel.UIStyle" abstract="true" post-set="postSet">
88.94 - <structure field="font" usage="optional"/>
88.95 - <structure name="textForeground" usage="optional">
88.96 - <structure field="textForeground" usage="optional"/>
88.97 - </structure>
88.98 - <structure name="textBackground" usage="optional">
88.99 - <structure field="textBackground" usage="optional"/>
88.100 - </structure>
88.101 - <structure name="background" usage="optional">
88.102 - <structure field="background" usage="optional"/>
88.103 - </structure>
88.104 - <value name="inherit-font" field="fontInherited" usage="optional" default="true"/>
88.105 - <value name="inherit-textForeground" field="textForegroundInherited" usage="optional" default="true"/>
88.106 - <value name="inherit-textBackground" field="textBackgroundInherited" usage="optional" default="true"/>
88.107 - <value name="inherit-background" field="backgroundInherited" usage="optional" default="true"/>
88.108 - <value name="hintAlphaInterpolation" field="hintAlphaInterpolation" usage="optional"/>
88.109 - <value name="hintAntialiasing" field="hintAntialiasing" usage="optional"/>
88.110 - <value name="hintColorRendering" field="hintColorRendering" usage="optional"/>
88.111 - <value name="hintDithering" field="hintDithering" usage="optional"/>
88.112 - <value name="hintFractionalMetrics" field="hintFractionalMetrics" usage="optional"/>
88.113 - <value name="hintInterpolation" field="hintInterpolation" usage="optional"/>
88.114 - <value name="hintRendering" field="hintRendering" usage="optional"/>
88.115 - <value name="hintStrokeControl" field="hintStrokeControl" usage="optional"/>
88.116 - <value name="hintTextAntialiasing" field="hintTextAntialiasing" usage="optional"/>
88.117 - <value name="cacheSettingsInherited" field="cacheSettingsInherited" usage="optional" default="true"/>
88.118 - <value name="cacheMode" field="cacheMode" usage="optional" default="FIXED_SIZES"/>
88.119 - <value name="maxHozCachedImgScaling" field="maxHozCachedImgScaling" usage="optional" default="1"/>
88.120 - <value name="maxVertCachedImgScaling" field="maxVertCachedImgScaling" usage="optional" default="1"/>
88.121 - <collection name="uiproperties" field="uiProperties" create-type="java.util.ArrayList">
88.122 - <structure marshaller="org.jdesktop.synthdesigner.synthmodel.jibxhelpers.UIPropertyMapper"
88.123 - unmarshaller="org.jdesktop.synthdesigner.synthmodel.jibxhelpers.UIPropertyMapper"/>
88.124 - </collection>
88.125 - </mapping>
88.126 - <!-- == UI STATE =========================================================================================== -->
88.127 - <mapping name="stateType" class="org.jdesktop.synthdesigner.synthmodel.UIStateType">
88.128 - <value name="key" field="key" style="attribute"/>
88.129 - <structure name="codeSnippet" usage="optional" test-method="hasCodeSnippet">
88.130 - <value field="codeSnippet" style="cdata" usage="optional"/>
88.131 - </structure>
88.132 - </mapping>
88.133 - <mapping name="state" class="org.jdesktop.synthdesigner.synthmodel.UIState" post-set="postSet" pre-set="preSet">
88.134 - <value name="stateKeys" field="stateKeys" style="attribute" get-method="getStateKeys" set-method="setStateKeys"
88.135 - serializer="org.jdesktop.synthdesigner.synthmodel.UIState.keysToString"
88.136 - deserializer="org.jdesktop.synthdesigner.synthmodel.UIState.stringToKeys"/>
88.137 - <value name="inverted" field="inverted" style="attribute" usage="optional"/>
88.138 - <structure name="style" field="style"/>
88.139 - <structure field="canvas"
88.140 - marshaller="org.jdesktop.swingx.designer.jibxhelpers.CanvasMapper"
88.141 - unmarshaller="org.jdesktop.swingx.designer.jibxhelpers.CanvasMapper"/>
88.142 - </mapping>
88.143 - <!-- == REGIONS =========================================================================================== -->
88.144 - <mapping class="org.jdesktop.synthdesigner.synthmodel.UIRegion" abstract="true"
88.145 - type-name="region" pre-set="preSet">
88.146 - <value name="name" field="name" style="attribute"/>
88.147 - <value name="ui" field="ui" style="attribute" usage="optional"/>
88.148 - <value name="subregion" field="subregion" style="attribute"/>
88.149 - <value name="key" field="key" style="attribute" usage="optional"/>
88.150 - <value name="title" field="title" style="attribute" usage="optional"/>
88.151 - <structure name="contentMargins" field="contentMargins"
88.152 - marshaller="org.jdesktop.swingx.designer.jibxhelpers.InsetsMapper"
88.153 - unmarshaller="org.jdesktop.swingx.designer.jibxhelpers.InsetsMapper"/>
88.154 - <structure name="style" field="style"/>
88.155 - <collection name="backgroundStates" field="backgroundStates" create-type="java.util.ArrayList"/>
88.156 - <collection name="foregroundStates" field="foregroundStates" create-type="java.util.ArrayList"/>
88.157 - <collection name="borderStates" field="borderStates" create-type="java.util.ArrayList"/>
88.158 - <collection name="regions" field="subRegions" create-type="java.util.ArrayList"/>
88.159 - </mapping>
88.160 - <mapping name="region" class="org.jdesktop.synthdesigner.synthmodel.UIRegion">
88.161 - <structure map-as="region"/>
88.162 - </mapping>
88.163 - <mapping name="uiIconRegion" class="org.jdesktop.synthdesigner.synthmodel.UIIconRegion"
88.164 - extends="org.jdesktop.synthdesigner.synthmodel.UIRegion">
88.165 - <structure map-as="region"/>
88.166 - <value name="basicKey" field="basicKey" style="attribute" usage="optional"/>
88.167 - </mapping>
88.168 - <mapping name="uiComponent" class="org.jdesktop.synthdesigner.synthmodel.UIComponent"
88.169 - extends="org.jdesktop.synthdesigner.synthmodel.UIRegion">
88.170 - <value name="opaque" field="opaque" style="attribute"/>
88.171 - <value name="componentName" field="componentName" style="attribute" usage="optional"/>
88.172 - <value name="type" field="type" style="attribute"/>
88.173 - <collection name="stateTypes" field="stateTypes" create-type="java.util.ArrayList"/>
88.174 - <structure map-as="region"/>
88.175 - </mapping>
88.176 - <!-- == BASE MODEL =========================================================================================== -->
88.177 - <mapping name="synthModel" class="org.jdesktop.synthdesigner.synthmodel.SynthModel" pre-set="preSet">
88.178 - <collection name="insets" field="insets" create-type="java.util.ArrayList"/>
88.179 - <collection name="colors" field="colors" create-type="java.util.ArrayList"/>
88.180 - <collection name="fonts" field="fonts" create-type="java.util.ArrayList"/>
88.181 - <structure name="style" field="globalStyle"/>
88.182 - <collection name="components" field="components" create-type="java.util.ArrayList"/>
88.183 - </mapping>
88.184 -</binding>
89.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIBorder.java Sun Sep 06 23:14:42 2009 -0700
89.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
89.3 @@ -1,53 +0,0 @@
89.4 -/*
89.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
89.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
89.7 - *
89.8 - * This code is free software; you can redistribute it and/or modify it
89.9 - * under the terms of the GNU General Public License version 2 only, as
89.10 - * published by the Free Software Foundation. Sun designates this
89.11 - * particular file as subject to the "Classpath" exception as provided
89.12 - * by Sun in the LICENSE file that accompanied this code.
89.13 - *
89.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
89.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
89.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
89.17 - * version 2 for more details (a copy is included in the LICENSE file that
89.18 - * accompanied this code).
89.19 - *
89.20 - * You should have received a copy of the GNU General Public License version
89.21 - * 2 along with this work; if not, write to the Free Software Foundation,
89.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
89.23 - *
89.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
89.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
89.26 - * have any questions.
89.27 - */
89.28 -package org.jdesktop.synthdesigner.synthmodel;
89.29 -
89.30 -import javax.swing.border.Border;
89.31 -
89.32 -/**
89.33 - * UIBorder
89.34 - *
89.35 - * @author Richard Bair
89.36 - * @author Jasper Potts
89.37 - */
89.38 -public class UIBorder extends UIDefault<Border> {
89.39 -
89.40 - public UIBorder() {
89.41 - }
89.42 -
89.43 - public UIBorder(String id, Border b) {
89.44 - super(id, b);
89.45 - }
89.46 -
89.47 - public Border getBorder() {
89.48 - return super.getValue();
89.49 - }
89.50 -
89.51 - public void setBorder(Border b) {
89.52 - Border old = getBorder();
89.53 - super.setValue(b);
89.54 - firePropertyChange("border", old, b);
89.55 - }
89.56 -}
90.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIColor.java Sun Sep 06 23:14:42 2009 -0700
90.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
90.3 @@ -1,58 +0,0 @@
90.4 -/*
90.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
90.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90.7 - *
90.8 - * This code is free software; you can redistribute it and/or modify it
90.9 - * under the terms of the GNU General Public License version 2 only, as
90.10 - * published by the Free Software Foundation. Sun designates this
90.11 - * particular file as subject to the "Classpath" exception as provided
90.12 - * by Sun in the LICENSE file that accompanied this code.
90.13 - *
90.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
90.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
90.17 - * version 2 for more details (a copy is included in the LICENSE file that
90.18 - * accompanied this code).
90.19 - *
90.20 - * You should have received a copy of the GNU General Public License version
90.21 - * 2 along with this work; if not, write to the Free Software Foundation,
90.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90.23 - *
90.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
90.26 - * have any questions.
90.27 - */
90.28 -package org.jdesktop.synthdesigner.synthmodel;
90.29 -
90.30 -import org.jdesktop.swingx.designer.paint.Matte;
90.31 -
90.32 -import javax.swing.UIDefaults;
90.33 -import java.awt.Color;
90.34 -
90.35 -/**
90.36 - * UIColor
90.37 - *
90.38 - * @author Richard Bair
90.39 - * @author Jasper Potts
90.40 - */
90.41 -public class UIColor extends UIPaint {
90.42 -
90.43 - public UIColor() {
90.44 - }
90.45 -
90.46 - public UIColor(String id, Matte value) {
90.47 - super(id, value);
90.48 - }
90.49 -
90.50 - public UIColor(String id, Color color, UIDefaults modelDefaults) {
90.51 - this(id, new Matte(color, modelDefaults));
90.52 - }
90.53 -
90.54 - public Matte getPaint() {
90.55 - return (Matte) super.getPaint();
90.56 - }
90.57 -
90.58 - public void setPaint(Matte c) {
90.59 - super.setPaint(c);
90.60 - }
90.61 -}
91.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIComponent.java Sun Sep 06 23:14:42 2009 -0700
91.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
91.3 @@ -1,138 +0,0 @@
91.4 -/*
91.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
91.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
91.7 - *
91.8 - * This code is free software; you can redistribute it and/or modify it
91.9 - * under the terms of the GNU General Public License version 2 only, as
91.10 - * published by the Free Software Foundation. Sun designates this
91.11 - * particular file as subject to the "Classpath" exception as provided
91.12 - * by Sun in the LICENSE file that accompanied this code.
91.13 - *
91.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
91.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
91.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
91.17 - * version 2 for more details (a copy is included in the LICENSE file that
91.18 - * accompanied this code).
91.19 - *
91.20 - * You should have received a copy of the GNU General Public License version
91.21 - * 2 along with this work; if not, write to the Free Software Foundation,
91.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
91.23 - *
91.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
91.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
91.26 - * have any questions.
91.27 - */
91.28 -package org.jdesktop.synthdesigner.synthmodel;
91.29 -
91.30 -import org.jdesktop.swingx.designer.utils.HasUIDefaults;
91.31 -
91.32 -import java.util.List;
91.33 -import java.util.ArrayList;
91.34 -
91.35 -/**
91.36 - * UIComponent - model node that represents the designs for a single swing component
91.37 - *
91.38 - * @author Richard Bair
91.39 - * @author Jasper Potts
91.40 - */
91.41 -public class UIComponent extends UIRegion implements HasUIDefaults {
91.42 -
91.43 - /** The classname of the swing component that this UIComponent represents */
91.44 - private String type;
91.45 - /** The name of the component if its a named component or null if its a generic component */
91.46 - private String componentName = null;
91.47 - /** If this components is opaque which means that when it is painted all of its bounds are filled */
91.48 - private boolean opaque = false;
91.49 - /**
91.50 - * A list of state types that are available to this region and sub regions of this component but not subcomponents
91.51 - * of this component. If this list is empty then the standard synth set of state types are assumed.
91.52 - */
91.53 - private List<UIStateType> stateTypes;
91.54 -
91.55 - // =================================================================================================================
91.56 - // Contructors
91.57 -
91.58 - /** no-args contructor for JIBX */
91.59 - protected UIComponent() {
91.60 - super();
91.61 - // create new observable list for state types so we get events for when the model changes
91.62 - stateTypes = new ArrayList<UIStateType>();
91.63 - }
91.64 -
91.65 - public UIComponent(String name, String type, String ui, UIRegion... subRegions) {
91.66 - super(name, ui, subRegions);
91.67 - this.type = type;
91.68 - for (UIRegion r : subRegions) {
91.69 - r.setRegion(this);
91.70 - }
91.71 - // create new observable list for state types so we get events for when the model changes
91.72 - stateTypes = new ArrayList<UIStateType>();
91.73 - }
91.74 -
91.75 - // =================================================================================================================
91.76 - // Bean Methods
91.77 -
91.78 - public String getComponentName() {
91.79 - return componentName;
91.80 - }
91.81 -
91.82 - public void setComponentName(String componentName) {
91.83 - String old = getComponentName();
91.84 - this.componentName = componentName;
91.85 - firePropertyChange("componentName", old, getComponentName());
91.86 - }
91.87 -
91.88 - public boolean isOpaque() {
91.89 - return opaque;
91.90 - }
91.91 -
91.92 - public void setOpaque(boolean opaque) {
91.93 - boolean old = isOpaque();
91.94 - this.opaque = opaque;
91.95 - firePropertyChange("opaque", old, isOpaque());
91.96 - }
91.97 -
91.98 - public String getType() {
91.99 - return type;
91.100 - }
91.101 -
91.102 - public void setType(String type) {
91.103 - String old = getType();
91.104 - this.type = type;
91.105 - firePropertyChange("type", old, getType());
91.106 - }
91.107 -
91.108 - /**
91.109 - * Get the list of state types that are available to this region and sub regions of this component but not
91.110 - * subcomponents of this component. If this list is empty then the standard synth set of state types are assumed.
91.111 - *
91.112 - * @return List of available state types
91.113 - */
91.114 - public List<UIStateType> getStateTypes() {
91.115 - return stateTypes;
91.116 - }
91.117 -
91.118 - @Override public String getKey() {
91.119 - if (key == null || "".equals(key)) {
91.120 - if (componentName == null || "".equals(componentName)) {
91.121 - return getName();
91.122 - } else {
91.123 - return "\"" + componentName + "\"";
91.124 - }
91.125 - } else {
91.126 - return key;
91.127 - }
91.128 - }
91.129 -
91.130 - @Override public String getTitle() {
91.131 - if (title == null || "".equals(title)) {
91.132 - if (componentName == null || "".equals(componentName)) {
91.133 - return getName();
91.134 - } else {
91.135 - return componentName;
91.136 - }
91.137 - } else {
91.138 - return title;
91.139 - }
91.140 - }
91.141 -}
92.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIDefault.java Sun Sep 06 23:14:42 2009 -0700
92.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
92.3 @@ -1,116 +0,0 @@
92.4 -/*
92.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
92.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
92.7 - *
92.8 - * This code is free software; you can redistribute it and/or modify it
92.9 - * under the terms of the GNU General Public License version 2 only, as
92.10 - * published by the Free Software Foundation. Sun designates this
92.11 - * particular file as subject to the "Classpath" exception as provided
92.12 - * by Sun in the LICENSE file that accompanied this code.
92.13 - *
92.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
92.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
92.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
92.17 - * version 2 for more details (a copy is included in the LICENSE file that
92.18 - * accompanied this code).
92.19 - *
92.20 - * You should have received a copy of the GNU General Public License version
92.21 - * 2 along with this work; if not, write to the Free Software Foundation,
92.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
92.23 - *
92.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
92.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
92.26 - * have any questions.
92.27 - */
92.28 -package org.jdesktop.synthdesigner.synthmodel;
92.29 -
92.30 -import org.jdesktop.beans.AbstractBean;
92.31 -import org.jdesktop.swingx.designer.utils.HasUIDefaults;
92.32 -import org.jibx.runtime.IUnmarshallingContext;
92.33 -
92.34 -import javax.swing.UIDefaults;
92.35 -
92.36 -/**
92.37 - * Represents an entry in the UI defaults table.
92.38 - *
92.39 - * @author Richard Bair
92.40 - * @author Jasper Potts
92.41 - */
92.42 -public class UIDefault<T> extends AbstractBean implements HasUIDefaults {
92.43 - private String name;
92.44 - private T value;
92.45 - /**
92.46 - * This is a local UIDefaults that contains all the UIDefaults in the synth model. It is kept uptodate by the
92.47 - * indervidual UIDefaults nodes
92.48 - */
92.49 - private transient UIDefaults modelDefaults = null;
92.50 -
92.51 - public UIDefault() {
92.52 - }
92.53 -
92.54 - public UIDefault(String name, T value) {
92.55 - this.name = name;
92.56 - this.value = value;
92.57 - }
92.58 -
92.59 - public UIDefault(String name, T value, UIDefaults modelDefaults) {
92.60 - this.name = name;
92.61 - this.value = value;
92.62 - this.modelDefaults = modelDefaults;
92.63 - }
92.64 -
92.65 - // =================================================================================================================
92.66 - // JIBX Methods
92.67 -
92.68 - /**
92.69 - * Called by JIBX after all fields have been set
92.70 - *
92.71 - * @param context The JIBX Unmarshalling Context
92.72 - */
92.73 - private void postSet(IUnmarshallingContext context) {
92.74 - // walk up till we get synth model
92.75 - for (int i = 0; i < context.getStackDepth(); i++) {
92.76 - if (context.getStackObject(i) instanceof HasUIDefaults) {
92.77 - modelDefaults = ((HasUIDefaults) context.getStackObject(i)).getUiDefaults();
92.78 - if (modelDefaults != null) break;
92.79 - }
92.80 - }
92.81 - }
92.82 -
92.83 - // =================================================================================================================
92.84 - // Bean Methods
92.85 -
92.86 - /**
92.87 - * Get the local UIDefaults that contains all the UIDefaults in the synth model. It is kept uptodate by the
92.88 - * indervidual UIDefaults nodes
92.89 - *
92.90 - * @return The UIDefaults for the synth model
92.91 - */
92.92 - public UIDefaults getUiDefaults() {
92.93 - return modelDefaults;
92.94 - }
92.95 -
92.96 - public void setValue(T t) {
92.97 - T old = this.value;
92.98 - this.value = t;
92.99 - firePropertyChange("value", old, getValue());
92.100 - }
92.101 -
92.102 - public T getValue() {
92.103 - return value;
92.104 - }
92.105 -
92.106 - public final String getName() {
92.107 - return name;
92.108 - }
92.109 -
92.110 - public void setName(String name) {
92.111 - String old = this.name;
92.112 - firePropertyChange("name", old, name);
92.113 - this.name = name;
92.114 - // update model defaults
92.115 - if (old != null) modelDefaults.remove(old);
92.116 - modelDefaults.put(getName(), getValue());
92.117 - }
92.118 -
92.119 -}
93.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIDimension.java Sun Sep 06 23:14:42 2009 -0700
93.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
93.3 @@ -1,48 +0,0 @@
93.4 -/*
93.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
93.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
93.7 - *
93.8 - * This code is free software; you can redistribute it and/or modify it
93.9 - * under the terms of the GNU General Public License version 2 only, as
93.10 - * published by the Free Software Foundation. Sun designates this
93.11 - * particular file as subject to the "Classpath" exception as provided
93.12 - * by Sun in the LICENSE file that accompanied this code.
93.13 - *
93.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
93.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
93.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
93.17 - * version 2 for more details (a copy is included in the LICENSE file that
93.18 - * accompanied this code).
93.19 - *
93.20 - * You should have received a copy of the GNU General Public License version
93.21 - * 2 along with this work; if not, write to the Free Software Foundation,
93.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
93.23 - *
93.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
93.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
93.26 - * have any questions.
93.27 - */
93.28 -package org.jdesktop.synthdesigner.synthmodel;
93.29 -
93.30 -import java.awt.Dimension;
93.31 -
93.32 -/**
93.33 - * UIDimension
93.34 - *
93.35 - * @author Richard Bair
93.36 - * @author Jasper Potts
93.37 - */
93.38 -public class UIDimension extends UIDefault<Dimension> {
93.39 - public UIDimension() {
93.40 - }
93.41 -
93.42 - public Dimension getDimension() {
93.43 - return super.getValue();
93.44 - }
93.45 -
93.46 - public void setDimension(Dimension d) {
93.47 - Dimension old = getDimension();
93.48 - super.setValue(d);
93.49 - firePropertyChange("dimension", old, d);
93.50 - }
93.51 -}
94.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIFont.java Sun Sep 06 23:14:42 2009 -0700
94.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
94.3 @@ -1,79 +0,0 @@
94.4 -/*
94.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
94.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
94.7 - *
94.8 - * This code is free software; you can redistribute it and/or modify it
94.9 - * under the terms of the GNU General Public License version 2 only, as
94.10 - * published by the Free Software Foundation. Sun designates this
94.11 - * particular file as subject to the "Classpath" exception as provided
94.12 - * by Sun in the LICENSE file that accompanied this code.
94.13 - *
94.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
94.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
94.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
94.17 - * version 2 for more details (a copy is included in the LICENSE file that
94.18 - * accompanied this code).
94.19 - *
94.20 - * You should have received a copy of the GNU General Public License version
94.21 - * 2 along with this work; if not, write to the Free Software Foundation,
94.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
94.23 - *
94.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
94.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
94.26 - * have any questions.
94.27 - */
94.28 -package org.jdesktop.synthdesigner.synthmodel;
94.29 -
94.30 -import java.awt.Font;
94.31 -import org.jdesktop.swingx.designer.font.Typeface;
94.32 -import java.util.Arrays;
94.33 -import java.util.List;
94.34 -import java.util.ArrayList;
94.35 -import javax.swing.UIDefaults;
94.36 -
94.37 -/**
94.38 - * Represents a single font entry in the UIDefaults table. Each UIFont takes a
94.39 - * list of Typefaces. These typefaces are listed by order of preference. Thus,
94.40 - * when putting a font into UIDefaults, the code can check whether each font
94.41 - * exists, and when it finds the first font that does, insert it.
94.42 - *
94.43 - * @author Richard Bair
94.44 - * @author Jasper Potts
94.45 - */
94.46 -public class UIFont extends UIDefault<List<Typeface>> implements Cloneable {
94.47 -
94.48 - private void updateUIDefaults() {
94.49 - if (getUiDefaults() != null) {
94.50 - for (Typeface t : getFonts()) {
94.51 - if (t.isFontSupported()) {
94.52 - getUiDefaults().put(getName(), t.getFont());
94.53 - return;
94.54 - }
94.55 - }
94.56 - }
94.57 -
94.58 - //TODO must not have found any. Default to the Default platform font
94.59 - getUiDefaults().put(getName(), new Font("Arial", Font.PLAIN, 12));
94.60 - }
94.61 -
94.62 - public UIFont() {
94.63 - setValue(new ArrayList<Typeface>());
94.64 - }
94.65 -
94.66 - public UIFont(String id, List<Typeface> values, UIDefaults defaults) {
94.67 - super(id, values, defaults);
94.68 - updateUIDefaults();
94.69 - }
94.70 -
94.71 - public UIFont(String id, Font font, UIDefaults modelDefaults) {
94.72 - this(id, Arrays.asList(new Typeface(font, modelDefaults)), modelDefaults);
94.73 - }
94.74 -
94.75 - public List<Typeface> getFonts() {
94.76 - return super.getValue();
94.77 - }
94.78 -
94.79 - private void setFonts(List<Typeface> values) {
94.80 - super.setValue(values);
94.81 - }
94.82 -}
95.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIIcon.java Sun Sep 06 23:14:42 2009 -0700
95.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
95.3 @@ -1,49 +0,0 @@
95.4 -/*
95.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
95.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
95.7 - *
95.8 - * This code is free software; you can redistribute it and/or modify it
95.9 - * under the terms of the GNU General Public License version 2 only, as
95.10 - * published by the Free Software Foundation. Sun designates this
95.11 - * particular file as subject to the "Classpath" exception as provided
95.12 - * by Sun in the LICENSE file that accompanied this code.
95.13 - *
95.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
95.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
95.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
95.17 - * version 2 for more details (a copy is included in the LICENSE file that
95.18 - * accompanied this code).
95.19 - *
95.20 - * You should have received a copy of the GNU General Public License version
95.21 - * 2 along with this work; if not, write to the Free Software Foundation,
95.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
95.23 - *
95.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
95.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
95.26 - * have any questions.
95.27 - */
95.28 -package org.jdesktop.synthdesigner.synthmodel;
95.29 -
95.30 -import javax.swing.Icon;
95.31 -
95.32 -/**
95.33 - * UIIcon
95.34 - *
95.35 - * @author Richard Bair
95.36 - * @author Jasper Potts
95.37 - */
95.38 -public class UIIcon extends UIDefault<Icon> {
95.39 -
95.40 - public UIIcon() {
95.41 - }
95.42 -
95.43 - public Icon getIcon() {
95.44 - return super.getValue();
95.45 - }
95.46 -
95.47 - public void setIcon(Icon i) {
95.48 - Icon old = getIcon();
95.49 - super.setValue(i);
95.50 - firePropertyChange("icon", old, i);
95.51 - }
95.52 -}
96.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIIconRegion.java Sun Sep 06 23:14:42 2009 -0700
96.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
96.3 @@ -1,55 +0,0 @@
96.4 -/*
96.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
96.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
96.7 - *
96.8 - * This code is free software; you can redistribute it and/or modify it
96.9 - * under the terms of the GNU General Public License version 2 only, as
96.10 - * published by the Free Software Foundation. Sun designates this
96.11 - * particular file as subject to the "Classpath" exception as provided
96.12 - * by Sun in the LICENSE file that accompanied this code.
96.13 - *
96.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
96.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
96.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
96.17 - * version 2 for more details (a copy is included in the LICENSE file that
96.18 - * accompanied this code).
96.19 - *
96.20 - * You should have received a copy of the GNU General Public License version
96.21 - * 2 along with this work; if not, write to the Free Software Foundation,
96.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
96.23 - *
96.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
96.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
96.26 - * have any questions.
96.27 - */
96.28 -package org.jdesktop.synthdesigner.synthmodel;
96.29 -
96.30 -/**
96.31 - * A UIRegion subclass which is used for generating icons. For example, JRadioButton and JCheckBox represent themselves
96.32 - * mainly via their icons. However, from the designers perspective, the main design isn't an "icon", but just a region
96.33 - * on the button.
96.34 - * <p/>
96.35 - * That type of region is represented by a UIIconRegion. UIIconRegion contains a string which references the UIDefault
96.36 - * value associated with this icon. For example, RadioButton.icon.
96.37 - *
96.38 - * @author Richard Bair
96.39 - * @author Jasper Potts
96.40 - */
96.41 -public class UIIconRegion extends UIRegion {
96.42 - /** The UiDefaults key which this icon should be stored for basic LaF to find it. This is absolute */
96.43 - private String basicKey = null;
96.44 -
96.45 - public UIIconRegion() {
96.46 - super();
96.47 - }
96.48 -
96.49 - public String getBasicKey() {
96.50 - return basicKey;
96.51 - }
96.52 -
96.53 - public void setBasicKey(String basicKey) {
96.54 - String old = getBasicKey();
96.55 - this.basicKey = basicKey;
96.56 - firePropertyChange("basicKey",old,getBasicKey());
96.57 - }
96.58 -}
97.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIInsets.java Sun Sep 06 23:14:42 2009 -0700
97.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
97.3 @@ -1,62 +0,0 @@
97.4 -/*
97.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
97.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
97.7 - *
97.8 - * This code is free software; you can redistribute it and/or modify it
97.9 - * under the terms of the GNU General Public License version 2 only, as
97.10 - * published by the Free Software Foundation. Sun designates this
97.11 - * particular file as subject to the "Classpath" exception as provided
97.12 - * by Sun in the LICENSE file that accompanied this code.
97.13 - *
97.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
97.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
97.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
97.17 - * version 2 for more details (a copy is included in the LICENSE file that
97.18 - * accompanied this code).
97.19 - *
97.20 - * You should have received a copy of the GNU General Public License version
97.21 - * 2 along with this work; if not, write to the Free Software Foundation,
97.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
97.23 - *
97.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
97.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
97.26 - * have any questions.
97.27 - */
97.28 -package org.jdesktop.synthdesigner.synthmodel;
97.29 -
97.30 -import java.awt.Insets;
97.31 -
97.32 -/**
97.33 - * UIInsets
97.34 - *
97.35 - * @author Richard Bair
97.36 - * @author Jasper Potts
97.37 - */
97.38 -public class UIInsets extends UIDefault<Insets> {
97.39 -
97.40 - public UIInsets() {
97.41 - }
97.42 -
97.43 - public UIInsets(String id, Insets value) {
97.44 - super(id, value);
97.45 - }
97.46 -
97.47 - public Insets getInsets() {
97.48 - return super.getValue();
97.49 - }
97.50 -
97.51 - public void setInsets(Insets i) {
97.52 - Insets old = getInsets();
97.53 - super.setValue(i);
97.54 - firePropertyChange("insets", old, i);
97.55 - // update model defaults
97.56 - getUiDefaults().put(getName(), i);
97.57 - }
97.58 -
97.59 -
97.60 - public String toString() {
97.61 - return "UiInset(" + getName() + ")" +
97.62 - ((getInsets() == null) ? " NONE" : "(" + getInsets().top + "," + getInsets().left + "," +
97.63 - getInsets().bottom + "," + getInsets().right + ")");
97.64 - }
97.65 -}
98.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIPaint.java Sun Sep 06 23:14:42 2009 -0700
98.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
98.3 @@ -1,84 +0,0 @@
98.4 -/*
98.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
98.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
98.7 - *
98.8 - * This code is free software; you can redistribute it and/or modify it
98.9 - * under the terms of the GNU General Public License version 2 only, as
98.10 - * published by the Free Software Foundation. Sun designates this
98.11 - * particular file as subject to the "Classpath" exception as provided
98.12 - * by Sun in the LICENSE file that accompanied this code.
98.13 - *
98.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
98.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
98.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
98.17 - * version 2 for more details (a copy is included in the LICENSE file that
98.18 - * accompanied this code).
98.19 - *
98.20 - * You should have received a copy of the GNU General Public License version
98.21 - * 2 along with this work; if not, write to the Free Software Foundation,
98.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
98.23 - *
98.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
98.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
98.26 - * have any questions.
98.27 - */
98.28 -package org.jdesktop.synthdesigner.synthmodel;
98.29 -
98.30 -import org.jdesktop.swingx.designer.paint.Matte;
98.31 -import org.jdesktop.swingx.designer.paint.PaintModel;
98.32 -
98.33 -import java.beans.PropertyChangeEvent;
98.34 -import java.beans.PropertyChangeListener;
98.35 -
98.36 -/**
98.37 - * UIPaint
98.38 - *
98.39 - * @author Richard Bair
98.40 - * @author Jasper Potts
98.41 - */
98.42 -public class UIPaint extends UIDefault<PaintModel> {
98.43 -
98.44 - /** Listener to keep model UiDefaults up to date for this UiPaint */
98.45 - private PropertyChangeListener matteListener = new PropertyChangeListener() {
98.46 - public void propertyChange(PropertyChangeEvent evt) {
98.47 - PaintModel paintModel = getValue();
98.48 - if (paintModel instanceof Matte) {
98.49 - getUiDefaults().put(getName(), ((Matte) paintModel).getColor());
98.50 - }
98.51 - // propogate the paint change up as PaintModel is a mutable object
98.52 - if (evt.getPropertyName().equals("paint")) {
98.53 - firePropertyChange("paint", null, getPaint());
98.54 - firePropertyChange("value", null, getPaint());
98.55 - }
98.56 - }
98.57 - };
98.58 -
98.59 - public UIPaint() {}
98.60 -
98.61 - public UIPaint(String id, PaintModel value) {
98.62 - super(id, value, (value instanceof Matte) ? ((Matte) value).getUiDefaults() : null);
98.63 - // update model defaults
98.64 - if (value instanceof Matte) {
98.65 - Matte matte = (Matte) value;
98.66 - if (getUiDefaults() != null) getUiDefaults().put(getName(), matte.getColor());
98.67 - matte.addPropertyChangeListener(matteListener);
98.68 - }
98.69 - }
98.70 -
98.71 - public PaintModel getPaint() {
98.72 - return super.getValue();
98.73 - }
98.74 -
98.75 - public void setPaint(PaintModel c) {
98.76 - PaintModel old = getPaint();
98.77 - if (old instanceof Matte) old.removePropertyChangeListener(matteListener);
98.78 - super.setValue(c);
98.79 - firePropertyChange("paint", old, c);
98.80 - // update model defaults
98.81 - if (c instanceof Matte) {
98.82 - Matte matte = (Matte) c;
98.83 - getUiDefaults().put(getName(), matte.getColor());
98.84 - matte.addPropertyChangeListener(matteListener);
98.85 - }
98.86 - }
98.87 -}
99.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIProperty.java Sun Sep 06 23:14:42 2009 -0700
99.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
99.3 @@ -1,85 +0,0 @@
99.4 -/*
99.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
99.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
99.7 - *
99.8 - * This code is free software; you can redistribute it and/or modify it
99.9 - * under the terms of the GNU General Public License version 2 only, as
99.10 - * published by the Free Software Foundation. Sun designates this
99.11 - * particular file as subject to the "Classpath" exception as provided
99.12 - * by Sun in the LICENSE file that accompanied this code.
99.13 - *
99.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
99.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
99.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
99.17 - * version 2 for more details (a copy is included in the LICENSE file that
99.18 - * accompanied this code).
99.19 - *
99.20 - * You should have received a copy of the GNU General Public License version
99.21 - * 2 along with this work; if not, write to the Free Software Foundation,
99.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
99.23 - *
99.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
99.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
99.26 - * have any questions.
99.27 - */
99.28 -package org.jdesktop.synthdesigner.synthmodel;
99.29 -
99.30 -import org.jdesktop.beans.AbstractBean;
99.31 -
99.32 -/**
99.33 - * UIProperty
99.34 - *
99.35 - * @author Richard Bair
99.36 - * @author Jasper Potts
99.37 - */
99.38 -public class UIProperty extends AbstractBean {
99.39 - public static enum PropertyType {
99.40 - BOOLEAN, INT, FLOAT, DOUBLE, STRING, FONT, COLOR, INSETS, DIMENSION, BORDER
99.41 - }
99.42 -
99.43 - private String name;
99.44 - private PropertyType type;
99.45 - private Object value;
99.46 -
99.47 - protected UIProperty() {
99.48 - }
99.49 -
99.50 - public UIProperty(String name, PropertyType type, Object value) {
99.51 - this.name = name;
99.52 - this.type = type;
99.53 - this.value = value;
99.54 - }
99.55 -
99.56 - // =================================================================================================================
99.57 - // Bean Methods
99.58 -
99.59 - public String getName() {
99.60 - return name;
99.61 - }
99.62 -
99.63 - public void setName(String name) {
99.64 - String old = getName();
99.65 - this.name = name;
99.66 - firePropertyChange("name", old, getName());
99.67 - }
99.68 -
99.69 - public PropertyType getType() {
99.70 - return type;
99.71 - }
99.72 -
99.73 - public void setType(PropertyType type) {
99.74 - PropertyType old = getType();
99.75 - this.type = type;
99.76 - firePropertyChange("type", old, getType());
99.77 - }
99.78 -
99.79 - public Object getValue() {
99.80 - return value;
99.81 - }
99.82 -
99.83 - public void setValue(Object value) {
99.84 - Object old = getValue();
99.85 - this.value = value;
99.86 - firePropertyChange("value", old, getValue());
99.87 - }
99.88 -}
100.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIRegion.java Sun Sep 06 23:14:42 2009 -0700
100.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
100.3 @@ -1,253 +0,0 @@
100.4 -/*
100.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
100.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
100.7 - *
100.8 - * This code is free software; you can redistribute it and/or modify it
100.9 - * under the terms of the GNU General Public License version 2 only, as
100.10 - * published by the Free Software Foundation. Sun designates this
100.11 - * particular file as subject to the "Classpath" exception as provided
100.12 - * by Sun in the LICENSE file that accompanied this code.
100.13 - *
100.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
100.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
100.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
100.17 - * version 2 for more details (a copy is included in the LICENSE file that
100.18 - * accompanied this code).
100.19 - *
100.20 - * You should have received a copy of the GNU General Public License version
100.21 - * 2 along with this work; if not, write to the Free Software Foundation,
100.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
100.23 - *
100.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
100.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
100.26 - * have any questions.
100.27 - */
100.28 -package org.jdesktop.synthdesigner.synthmodel;
100.29 -
100.30 -import org.jdesktop.beans.AbstractBean;
100.31 -import org.jdesktop.swingx.designer.utils.HasUIDefaults;
100.32 -import org.jibx.runtime.IUnmarshallingContext;
100.33 -
100.34 -import javax.swing.UIDefaults;
100.35 -import java.awt.Insets;
100.36 -import java.beans.PropertyChangeEvent;
100.37 -import java.beans.PropertyChangeListener;
100.38 -import java.util.List;
100.39 -import java.util.ArrayList;
100.40 -
100.41 -/**
100.42 - * Represents a "Region" in synth, which also includes entire components.
100.43 - *
100.44 - * @author Richard Bair
100.45 - * @author Jasper Potts
100.46 - */
100.47 -public class UIRegion extends AbstractBean implements HasUIDefaults, HasUIStyle {
100.48 - private String name;//the code-wise name of the region
100.49 - protected String key; //the UIdefaults key for this region
100.50 - protected String title; //the user friendly name/title of this region
100.51 - /** List of background states */
100.52 - private List<UIState> backgroundStates;
100.53 - /** List of foreground states */
100.54 - private List<UIState> foregroundStates;
100.55 - /** List of border states */
100.56 - private List<UIState> borderStates;
100.57 - private UIStyle style = new UIStyle();
100.58 - protected Insets contentMargins = new Insets(0, 0, 0, 0);
100.59 - /** Sub regions, if any */
100.60 - private List<UIRegion> subRegions;
100.61 -
100.62 - //together with name, these two fields allow me to reconstruct, in
100.63 - //code, a synth Region, including a custom Region, if you make one.
100.64 - private String ui;
100.65 - private boolean subregion;
100.66 - /**
100.67 - * This is a local UIDefaults that contains all the UIDefaults in the synth model. It is kept uptodate by the
100.68 - * indervidual UIDefaults nodes
100.69 - */
100.70 - private transient UIDefaults modelDefaults = null;
100.71 -
100.72 - private UIRegion region; //the region that this region belongs to
100.73 -
100.74 - // =================================================================================================================
100.75 - // Constructors
100.76 -
100.77 - /** no-args contructor for JIBX */
100.78 - protected UIRegion() {
100.79 - subRegions = new ArrayList<UIRegion>();
100.80 - backgroundStates = new ArrayList<UIState>();
100.81 - foregroundStates = new ArrayList<UIState>();
100.82 - borderStates = new ArrayList<UIState>();
100.83 - style.addPropertyChangeListener(new PropertyChangeListener() {
100.84 - public void propertyChange(PropertyChangeEvent evt) {
100.85 - firePropertyChange("style." + evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
100.86 - }
100.87 - });
100.88 - }
100.89 -
100.90 - public UIRegion(String name, UIRegion... subRegions) {
100.91 - this(name, null, true, subRegions);
100.92 - }
100.93 -
100.94 - public UIRegion(String name, String ui, UIRegion... subRegions) {
100.95 - this(name, ui, false, subRegions);
100.96 - }
100.97 -
100.98 - public UIRegion(String name, String ui, boolean subregion, UIRegion... subRegions) {
100.99 - this();
100.100 - this.name = name;
100.101 - this.ui = ui;
100.102 - this.subregion = subregion;
100.103 - if (subRegions != null) {
100.104 - for (UIRegion r : subRegions) {
100.105 - if (r != null) {
100.106 - this.subRegions.add(r);
100.107 - r.getStyle().setParentStyle(getStyle());
100.108 - }
100.109 - }
100.110 - }
100.111 - }
100.112 -
100.113 - // =================================================================================================================
100.114 - // JIBX Methods
100.115 -
100.116 - /**
100.117 - * Called by JIBX after all fields have been set
100.118 - *
100.119 - * @param context The JIBX Unmarshalling Context
100.120 - */
100.121 - private void preSet(IUnmarshallingContext context) {
100.122 - // walk up till we get synth model
100.123 - for (int i = 0; i < context.getStackDepth(); i++) {
100.124 - if (context.getStackObject(i) instanceof HasUIDefaults) {
100.125 - modelDefaults = ((HasUIDefaults) context.getStackObject(i)).getUiDefaults();
100.126 - if (modelDefaults != null) break;
100.127 - }
100.128 - }
100.129 - for (int i = 0; i < context.getStackDepth(); i++) {
100.130 - if (context.getStackObject(i) instanceof UIRegion && context.getStackObject(i) != this) {
100.131 - region = (UIRegion) context.getStackObject(i);
100.132 - break;
100.133 - }
100.134 - }
100.135 - }
100.136 -
100.137 - // =================================================================================================================
100.138 - // Bean Methods
100.139 -
100.140 - public Insets getContentMargins() {
100.141 - return contentMargins;
100.142 - }
100.143 -
100.144 - public void setContentMargins(Insets contentMargins) {
100.145 - Insets old = getContentMargins();
100.146 - this.contentMargins = contentMargins;
100.147 - firePropertyChange("contentMargins", old, getContentMargins());
100.148 - }
100.149 -
100.150 - void setRegion(UIRegion r) {
100.151 - this.region = r;
100.152 - }
100.153 -
100.154 - public UIRegion getRegion() {
100.155 - return region;
100.156 - }
100.157 -
100.158 - /**
100.159 - * Get the local UIDefaults that contains all the UIDefaults in the synth model. It is kept uptodate by the
100.160 - * indervidual UIDefaults nodes
100.161 - *
100.162 - * @return The UIDefaults for the synth model
100.163 - */
100.164 - public UIDefaults getUiDefaults() {
100.165 - return modelDefaults;
100.166 - }
100.167 -
100.168 - public String getName() {
100.169 - return name;
100.170 - }
100.171 -
100.172 - public final UIRegion[] getSubRegions() {
100.173 - return subRegions.toArray(new UIRegion[0]);
100.174 - }
100.175 -
100.176 - public final UIState[] getBackgroundStates() {
100.177 - return backgroundStates.toArray(new UIState[0]);
100.178 - }
100.179 -
100.180 - public final UIState[] getForegroundStates() {
100.181 - return foregroundStates.toArray(new UIState[0]);
100.182 - }
100.183 -
100.184 - public final UIState[] getBorderStates() {
100.185 - return borderStates.toArray(new UIState[0]);
100.186 - }
100.187 -
100.188 - public UIStyle getStyle() {
100.189 - return style;
100.190 - }
100.191 -
100.192 - public final boolean isSubRegion() {
100.193 - return subregion;
100.194 - }
100.195 -
100.196 - public final String getUi() {
100.197 - return ui;
100.198 - }
100.199 -
100.200 - public void addBackgroundState(UIState state) {
100.201 - // check if we already have that state
100.202 - for (UIState uiState : backgroundStates) {
100.203 - if (uiState.getName().equals(state.getName())) return;
100.204 - }
100.205 - backgroundStates.add(state);
100.206 - state.setRegion(this);
100.207 - firePropertyChange("backgroundStates", null, backgroundStates);
100.208 - }
100.209 -
100.210 - public void removeBackgroundState(UIState state) {
100.211 - if (backgroundStates.remove(state)) {
100.212 - firePropertyChange("backgroundStates", null, backgroundStates);
100.213 - }
100.214 - }
100.215 -
100.216 - public void addForegroundState(UIState state) {
100.217 - // check if we already have that state
100.218 - for (UIState uiState : foregroundStates) {
100.219 - if (uiState.getName().equals(state.getName())) return;
100.220 - }
100.221 - foregroundStates.add(state);
100.222 - state.setRegion(this);
100.223 - firePropertyChange("foregroundStates", null, foregroundStates);
100.224 - }
100.225 -
100.226 - public void removeForegroundState(UIState state) {
100.227 - if (foregroundStates.remove(state)) {
100.228 - firePropertyChange("foregroundStates", null, foregroundStates);
100.229 - }
100.230 - }
100.231 -
100.232 - public void addBorderState(UIState state) {
100.233 - // check if we already have that state
100.234 - for (UIState uiState : borderStates) {
100.235 - if (uiState.getName().equals(state.getName())) return;
100.236 - }
100.237 - borderStates.add(state);
100.238 - state.setRegion(this);
100.239 - firePropertyChange("borderStates", null, borderStates);
100.240 - }
100.241 -
100.242 - public void removeBorderState(UIState state) {
100.243 - if (borderStates.remove(state)) {
100.244 - firePropertyChange("borderStates", null, borderStates);
100.245 - }
100.246 - }
100.247 -
100.248 -
100.249 - public String getKey() {
100.250 - return key == null || "".equals(key) ? name : key;
100.251 - }
100.252 -
100.253 - public String getTitle() {
100.254 - return title == null || "".equals(title) ? name : title;
100.255 - }
100.256 -}
101.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIState.java Sun Sep 06 23:14:42 2009 -0700
101.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
101.3 @@ -1,298 +0,0 @@
101.4 -/*
101.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
101.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
101.7 - *
101.8 - * This code is free software; you can redistribute it and/or modify it
101.9 - * under the terms of the GNU General Public License version 2 only, as
101.10 - * published by the Free Software Foundation. Sun designates this
101.11 - * particular file as subject to the "Classpath" exception as provided
101.12 - * by Sun in the LICENSE file that accompanied this code.
101.13 - *
101.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
101.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
101.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
101.17 - * version 2 for more details (a copy is included in the LICENSE file that
101.18 - * accompanied this code).
101.19 - *
101.20 - * You should have received a copy of the GNU General Public License version
101.21 - * 2 along with this work; if not, write to the Free Software Foundation,
101.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
101.23 - *
101.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
101.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
101.26 - * have any questions.
101.27 - */
101.28 -package org.jdesktop.synthdesigner.synthmodel;
101.29 -
101.30 -import org.jdesktop.beans.AbstractBean;
101.31 -import org.jdesktop.swingx.designer.Canvas;
101.32 -import org.jdesktop.swingx.designer.utils.HasPath;
101.33 -import org.jdesktop.swingx.designer.utils.HasUIDefaults;
101.34 -import org.jibx.runtime.IUnmarshallingContext;
101.35 -
101.36 -import javax.swing.UIDefaults;
101.37 -import java.beans.PropertyChangeEvent;
101.38 -import java.beans.PropertyChangeListener;
101.39 -import java.io.File;
101.40 -import java.util.ArrayList;
101.41 -import java.util.Arrays;
101.42 -import java.util.Collections;
101.43 -import java.util.Iterator;
101.44 -import java.util.List;
101.45 -
101.46 -/**
101.47 - * Represents a State in the Synth LAF.
101.48 - *
101.49 - * @author Richard Bair
101.50 - * @author Jasper Potts
101.51 - */
101.52 -public class UIState extends AbstractBean implements HasUIStyle, HasPath {
101.53 -
101.54 - private List<String> stateKeys;
101.55 - private boolean inverted; //indicates whether to invert the meaning of the 9-square stretching insets
101.56 - /** A cached string representing the list of stateKeys deliminated with "+" */
101.57 - private String cachedName = null;
101.58 - private Canvas canvas;
101.59 - private UIStyle style;
101.60 - /** the region that this state belongs to */
101.61 - private UIRegion region;
101.62 - /**
101.63 - * This is a local UIDefaults that contains all the UIDefaults in the synth model. It is kept uptodate by the
101.64 - * indervidual UIDefaults nodes
101.65 - */
101.66 - private transient UIDefaults modelDefaults = null;
101.67 -
101.68 - // =================================================================================================================
101.69 - // Contructors
101.70 -
101.71 - public UIState() {
101.72 - // Create state keys as event list so model changes are propogated
101.73 - stateKeys = new ArrayList<String>();
101.74 - }
101.75 -
101.76 - public UIState(SynthModel model, UIRegion parentRegion, String... stateTypeKeys) {
101.77 - // Create state keys as event list so model changes are propogated
101.78 - stateKeys = new ArrayList<String>();
101.79 - this.stateKeys.addAll(Arrays.asList(stateTypeKeys));
101.80 - //
101.81 - modelDefaults = model.getUiDefaults();
101.82 - region = parentRegion;
101.83 - // create new canvas
101.84 - canvas = new Canvas(100, 30);
101.85 - canvas.setUiDefaults(modelDefaults);
101.86 - String canvasPath = getPath();
101.87 - canvas.setResourcesDir(new File(model.getResourcesDir(), canvasPath));
101.88 - canvas.setTemplatesDir(new File(model.getTemplatesDir(), canvasPath));
101.89 - canvas.setImagesDir(new File(model.getImagesDir(), canvasPath));
101.90 - canvas.addPropertyChangeListener(new PropertyChangeListener() {
101.91 - public void propertyChange(PropertyChangeEvent evt) {
101.92 - firePropertyChange("canvas." + evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
101.93 - }
101.94 - });
101.95 - // create new style
101.96 - style = new UIStyle();
101.97 - style.setParentStyle(region.getStyle());
101.98 - style.addPropertyChangeListener(new PropertyChangeListener() {
101.99 - public void propertyChange(PropertyChangeEvent evt) {
101.100 - firePropertyChange("style." + evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
101.101 - }
101.102 - });
101.103 - }
101.104 -
101.105 - // =================================================================================================================
101.106 - // JIBX Methods
101.107 -
101.108 - /**
101.109 - * JIBX needs this
101.110 - *
101.111 - * @param stateKeys The new list of states
101.112 - */
101.113 - private void setStateKeys(List<String> stateKeys) {
101.114 - if (stateKeys != this.stateKeys) {
101.115 - this.stateKeys.clear();
101.116 - this.stateKeys.addAll(stateKeys);
101.117 - }
101.118 - }
101.119 -
101.120 - /**
101.121 - * Called by JIBX after all fields have been set
101.122 - *
101.123 - * @param context The JIBX Unmarshalling Context
101.124 - */
101.125 - private void preSet(IUnmarshallingContext context) {
101.126 - // walk up till we get synth model
101.127 - for (int i = 0; i < context.getStackDepth(); i++) {
101.128 - if (context.getStackObject(i) instanceof HasUIDefaults) {
101.129 - modelDefaults = ((HasUIDefaults) context.getStackObject(i)).getUiDefaults();
101.130 - if (modelDefaults != null) break;
101.131 - }
101.132 - }
101.133 - for (int i = 0; i < context.getStackDepth(); i++) {
101.134 - if (context.getStackObject(i) instanceof UIRegion) {
101.135 - region = (UIRegion) context.getStackObject(i);
101.136 - break;
101.137 - }
101.138 - }
101.139 - }
101.140 -
101.141 - /**
101.142 - * Called by JIBX after all fields have been set
101.143 - *
101.144 - * @param context The JIBX Unmarshalling Context
101.145 - */
101.146 - private void postSet(IUnmarshallingContext context) {
101.147 - // add listeners to pass canvas and style events up tree
101.148 - canvas.addPropertyChangeListener(new PropertyChangeListener() {
101.149 - public void propertyChange(PropertyChangeEvent evt) {
101.150 - firePropertyChange("canvas." + evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
101.151 - }
101.152 - });
101.153 - style.addPropertyChangeListener(new PropertyChangeListener() {
101.154 - public void propertyChange(PropertyChangeEvent evt) {
101.155 - firePropertyChange("style." + evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
101.156 - }
101.157 - });
101.158 - }
101.159 -
101.160 - // =================================================================================================================
101.161 - // Bean Methods
101.162 -
101.163 - /**
101.164 - * Get path to this UI State of the form /RegionA/RegionB/StateName
101.165 - *
101.166 - * @return Path to this state
101.167 - */
101.168 - public String getPath() {
101.169 - StringBuilder buf = new StringBuilder(getName());
101.170 - UIRegion region = getRegion();
101.171 - // check if we are foreground background or border
101.172 - boolean found = false;
101.173 - for (UIState state : region.getBackgroundStates()) {
101.174 - if (state == this) {
101.175 - buf.insert(0, "Background/");
101.176 - found = true;
101.177 - break;
101.178 - }
101.179 - }
101.180 - if (!found) {
101.181 - for (UIState state : region.getForegroundStates()) {
101.182 - if (state == this) {
101.183 - buf.insert(0, "Foreground/");
101.184 - found = true;
101.185 - break;
101.186 - }
101.187 - }
101.188 - }
101.189 - if (!found) {
101.190 - for (UIState state : region.getBorderStates()) {
101.191 - if (state == this) {
101.192 - buf.insert(0, "Border/");
101.193 - found = true;
101.194 - break;
101.195 - }
101.196 - }
101.197 - }
101.198 - // add parent regions
101.199 - while (region != null) {
101.200 - buf.insert(0, '/');
101.201 - if (region instanceof UIComponent && ((UIComponent) region).getComponentName() != null) {
101.202 - buf.insert(0, ((UIComponent) region).getComponentName());
101.203 - } else {
101.204 - buf.insert(0, region.getName());
101.205 - }
101.206 - region = region.getRegion();
101.207 - }
101.208 - return buf.toString();
101.209 - }
101.210 -
101.211 - void setRegion(UIRegion r) {
101.212 - this.region = r;
101.213 - this.style.setParentStyle(r.getStyle());
101.214 - }
101.215 -
101.216 - public UIRegion getRegion() {
101.217 - return region;
101.218 - }
101.219 -
101.220 - /**
101.221 - * Get the local UIDefaults that contains all the UIDefaults in the synth model. It is kept uptodate by the
101.222 - * indervidual UIDefaults nodes
101.223 - *
101.224 - * @return The UIDefaults for the synth model
101.225 - */
101.226 - public UIDefaults getUIDefaults() {
101.227 - return modelDefaults;
101.228 - }
101.229 -
101.230 -
101.231 - /**
101.232 - * Get the list of state type keys for this state. This state is applied when the current component state matches as
101.233 - * many as possible of these state types.
101.234 - *
101.235 - * @return List of state types that need to be true for this state. This is direct access to the data and changes to
101.236 - * the returned list will effect this UiState.
101.237 - */
101.238 - public List<String> getStateKeys() {
101.239 - return stateKeys;
101.240 - }
101.241 -
101.242 - public void setInverted(boolean b) {
101.243 - boolean old = inverted;
101.244 - inverted = b;
101.245 - firePropertyChange("invert", old, b);
101.246 - }
101.247 -
101.248 - public final boolean isInverted() {
101.249 - return inverted;
101.250 - }
101.251 -
101.252 - /**
101.253 - * Get the name of this state
101.254 - *
101.255 - * @return
101.256 - */
101.257 - public String getName() {
101.258 - if (cachedName == null) {
101.259 - StringBuilder buf = new StringBuilder();
101.260 - List<String> keys = new ArrayList<String>(stateKeys);
101.261 - Collections.sort(keys);
101.262 - for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
101.263 - buf.append(iter.next());
101.264 - if (iter.hasNext()) buf.append('+');
101.265 - }
101.266 - cachedName = buf.toString();
101.267 - }
101.268 - return cachedName;
101.269 - }
101.270 -
101.271 - public final Canvas getCanvas() {
101.272 - return canvas;
101.273 - }
101.274 -
101.275 - public void setCanvas(Canvas c) {
101.276 - Canvas old = canvas;
101.277 - canvas = c;
101.278 - firePropertyChange("canvas", old, c);
101.279 - }
101.280 -
101.281 - public UIStyle getStyle() {
101.282 - return style;
101.283 - }
101.284 -
101.285 - // =================================================================================================================
101.286 - // JIBX Helper Methods
101.287 -
101.288 - public static String keysToString(List<String> keys) {
101.289 - StringBuilder buf = new StringBuilder();
101.290 - for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
101.291 - buf.append(iter.next());
101.292 - if (iter.hasNext()) buf.append('+');
101.293 - }
101.294 - return buf.toString();
101.295 - }
101.296 -
101.297 - public static List<String> stringToKeys(String keysString) {
101.298 - return Arrays.asList(keysString.split("\\+"));
101.299 - }
101.300 -
101.301 -}
102.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIStateType.java Sun Sep 06 23:14:42 2009 -0700
102.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
102.3 @@ -1,129 +0,0 @@
102.4 -/*
102.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
102.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
102.7 - *
102.8 - * This code is free software; you can redistribute it and/or modify it
102.9 - * under the terms of the GNU General Public License version 2 only, as
102.10 - * published by the Free Software Foundation. Sun designates this
102.11 - * particular file as subject to the "Classpath" exception as provided
102.12 - * by Sun in the LICENSE file that accompanied this code.
102.13 - *
102.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
102.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
102.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
102.17 - * version 2 for more details (a copy is included in the LICENSE file that
102.18 - * accompanied this code).
102.19 - *
102.20 - * You should have received a copy of the GNU General Public License version
102.21 - * 2 along with this work; if not, write to the Free Software Foundation,
102.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
102.23 - *
102.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
102.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
102.26 - * have any questions.
102.27 - */
102.28 -package org.jdesktop.synthdesigner.synthmodel;
102.29 -
102.30 -import org.jdesktop.beans.AbstractBean;
102.31 -
102.32 -/**
102.33 - * UIStateType - A UIComponents has a collection of these which constitute the avilables states which can be chosen in
102.34 - * the components regions. A UIStateType can be either a custom state or one of the predefined standard states.
102.35 - *
102.36 - * @author Richard Bair
102.37 - * @author Jasper Potts
102.38 - */
102.39 -public class UIStateType extends AbstractBean {
102.40 - /* Keys for standard synth states */
102.41 - public static final String ENABLED_KEY = "Enabled";
102.42 - public static final String MOUSE_OVER_KEY = "MouseOver";
102.43 - public static final String PRESSED_KEY = "Pressed";
102.44 - public static final String DISABLED_KEY = "Disabled";
102.45 - public static final String FOCUSED_KEY = "Focused";
102.46 - public static final String SELECTED_KEY = "Selected";
102.47 - public static final String DEFAULT_KEY = "Default";
102.48 - public static final String[] STANDARD_SYNTH_STATE_KEYS = new String[]{
102.49 - ENABLED_KEY, MOUSE_OVER_KEY, PRESSED_KEY, DISABLED_KEY, FOCUSED_KEY, SELECTED_KEY, DEFAULT_KEY
102.50 - };
102.51 - public static final UIStateType[] STANDARD_SYNTH_STATES = new UIStateType[]{
102.52 - new UIStateType(ENABLED_KEY),
102.53 - new UIStateType(MOUSE_OVER_KEY),
102.54 - new UIStateType(PRESSED_KEY),
102.55 - new UIStateType(DISABLED_KEY),
102.56 - new UIStateType(FOCUSED_KEY),
102.57 - new UIStateType(SELECTED_KEY),
102.58 - new UIStateType(DEFAULT_KEY)
102.59 - };
102.60 -
102.61 - /** Unique string for the ui key for this state, must be unique within a components set of UiStateTypes */
102.62 - private String key;
102.63 - /**
102.64 - * Snippet of java code that defines calculates the value of this state for a particular component. The varaiable
102.65 - * <code>c</code> is the component. You end with a return statement returning boolean true/false for the current
102.66 - * value of this state for this component. This can be null if the key is one of that standard synth states defined
102.67 - * in constants in this class.
102.68 - */
102.69 - private String codeSnippet;
102.70 -
102.71 - /** JIBX no-args contructor */
102.72 - private UIStateType() {}
102.73 -
102.74 - private UIStateType(String key) {
102.75 - this.key = key;
102.76 - this.codeSnippet = null;
102.77 - }
102.78 -
102.79 - public UIStateType(String key, String codeSnippet) {
102.80 - this.key = key;
102.81 - this.codeSnippet = codeSnippet;
102.82 - }
102.83 -
102.84 - // =================================================================================================================
102.85 - // Bean Methods
102.86 -
102.87 - /**
102.88 - * Get the ui defaults key for this state type. Unique string for the ui key for this state, must be unique within a
102.89 - * components set of UiStateTypes.
102.90 - *
102.91 - * @return Unique ui default key
102.92 - */
102.93 - public String getKey() {
102.94 - return key;
102.95 - }
102.96 -
102.97 - /**
102.98 - * Get the snippet of java code that defines calculates the value of this state for a particular component. The
102.99 - * varaiable <code>c</code> is the component. You end with a return statement returning boolean true/false for the
102.100 - * current value of this state for this component. This can be null if the key is one of that standard synth states
102.101 - * defined in constants in this class.
102.102 - *
102.103 - * @return Snippet of java code or null if this is a synth standard state
102.104 - */
102.105 - public String getCodeSnippet() {
102.106 - return codeSnippet;
102.107 - }
102.108 -
102.109 - /**
102.110 - * Set the snippet of java code that defines calculates the value of this state for a particular component. The
102.111 - * varaiable <code>c</code> is the component. You end with a return statement returning boolean true/false for the
102.112 - * current value of this state for this component. This can be null if the key is one of that standard synth states
102.113 - * defined in constants in this class.
102.114 - *
102.115 - * @param codeSnippet Snippet of java code or null if this is a synth standard state
102.116 - */
102.117 - public void setCodeSnippet(String codeSnippet) {
102.118 - this.codeSnippet = codeSnippet;
102.119 - }
102.120 -
102.121 - /**
102.122 - * Returns if this state type is a standard synth type and has no code snippet or a custom type that has a code
102.123 - * snippet. It is used by JIBX to determin if the code snippet should be written to XML.
102.124 - *
102.125 - * @return <code>true</code> if codeSnippet is non null
102.126 - */
102.127 - public boolean hasCodeSnippet() {
102.128 - return codeSnippet != null;
102.129 - }
102.130 -
102.131 -
102.132 -}
103.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIStyle.java Sun Sep 06 23:14:42 2009 -0700
103.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
103.3 @@ -1,467 +0,0 @@
103.4 -/*
103.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
103.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
103.7 - *
103.8 - * This code is free software; you can redistribute it and/or modify it
103.9 - * under the terms of the GNU General Public License version 2 only, as
103.10 - * published by the Free Software Foundation. Sun designates this
103.11 - * particular file as subject to the "Classpath" exception as provided
103.12 - * by Sun in the LICENSE file that accompanied this code.
103.13 - *
103.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
103.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
103.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
103.17 - * version 2 for more details (a copy is included in the LICENSE file that
103.18 - * accompanied this code).
103.19 - *
103.20 - * You should have received a copy of the GNU General Public License version
103.21 - * 2 along with this work; if not, write to the Free Software Foundation,
103.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
103.23 - *
103.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
103.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
103.26 - * have any questions.
103.27 - */
103.28 -package org.jdesktop.synthdesigner.synthmodel;
103.29 -
103.30 -import org.jdesktop.beans.AbstractBean;
103.31 -import org.jdesktop.swingx.designer.font.Typeface;
103.32 -import org.jdesktop.swingx.designer.paint.Matte;
103.33 -import org.jibx.runtime.IUnmarshallingContext;
103.34 -
103.35 -import java.beans.PropertyChangeEvent;
103.36 -import java.beans.PropertyChangeListener;
103.37 -import java.util.List;
103.38 -import java.util.ArrayList;
103.39 -
103.40 -/**
103.41 - * UIStyle
103.42 - *
103.43 - * @author Richard Bair
103.44 - * @author Jasper Potts
103.45 - */
103.46 -public class UIStyle extends AbstractBean {
103.47 - public static enum CacheMode {NO_CACHING,FIXED_SIZES,NINE_SQUARE_SCALE}
103.48 - public static enum HintAlphaInterpolation {
103.49 - DEFAULT, QUALITY, SPEED
103.50 - }
103.51 -
103.52 - public static enum HintAntialiasing {
103.53 - DEFAULT, ON, OFF
103.54 - }
103.55 -
103.56 - public static enum HintColorRendering {
103.57 - DEFAULT, QUALITY, SPEED
103.58 - }
103.59 -
103.60 - public static enum HintDithering {
103.61 - DEFAULT, DISABLE, ENABLE
103.62 - }
103.63 -
103.64 - public static enum HintFractionalMetrics {
103.65 - DEFAULT, ON, OFF
103.66 - }
103.67 -
103.68 - public static enum HintInterpolation {
103.69 - NEAREST_NEIGHBOR, BILINEAR, BICUBIC
103.70 - }
103.71 -
103.72 - public static enum HintRendering {
103.73 - DEFAULT, QUALITY, SPEED
103.74 - }
103.75 -
103.76 - public static enum HintStrokeControl {
103.77 - DEFAULT, NORMALIZE, PURE
103.78 - }
103.79 -
103.80 - public static enum HintTextAntialiasing {
103.81 - DEFAULT, ON, OFF, GASP, LCD_HBGR, LCD_HRGB, LCD_VBGR, LCD_VRGB
103.82 - }
103.83 -
103.84 - private Typeface font = null;
103.85 - private boolean fontInherited = true;
103.86 - private Matte textForeground = null;
103.87 - private boolean textForegroundInherited = true;
103.88 - private Matte textBackground = null;
103.89 - private boolean textBackgroundInherited = true;
103.90 - private Matte background = null;
103.91 - private boolean backgroundInherited = true;
103.92 -
103.93 - private boolean cacheSettingsInherited = true;
103.94 - private CacheMode cacheMode = CacheMode.FIXED_SIZES;
103.95 - private double maxHozCachedImgScaling = 1;
103.96 - private double maxVertCachedImgScaling = 1;
103.97 -
103.98 - private HintAlphaInterpolation hintAlphaInterpolation = null;
103.99 - private HintAntialiasing hintAntialiasing = null;
103.100 - private HintColorRendering hintColorRendering = null;
103.101 - private HintDithering hintDithering = null;
103.102 - private HintFractionalMetrics hintFractionalMetrics = null;
103.103 - private HintInterpolation hintInterpolation = null;
103.104 - private HintRendering hintRendering = null;
103.105 - private HintStrokeControl hintStrokeControl = null;
103.106 - private HintTextAntialiasing hintTextAntialiasing = null;
103.107 - private List<UIProperty> uiProperties;
103.108 - private UIStyle parentStyle = null;
103.109 -
103.110 - private PropertyChangeListener textForegoundListener = new PropertyChangeListener() {
103.111 - public void propertyChange(PropertyChangeEvent evt) {
103.112 - firePropertyChange("textForeground." + evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
103.113 - }
103.114 - };
103.115 - private PropertyChangeListener textBackgroundListener = new PropertyChangeListener() {
103.116 - public void propertyChange(PropertyChangeEvent evt) {
103.117 - firePropertyChange("textBackground." + evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
103.118 - }
103.119 - };
103.120 - private PropertyChangeListener backgroundListener = new PropertyChangeListener() {
103.121 - public void propertyChange(PropertyChangeEvent evt) {
103.122 - firePropertyChange("background." + evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
103.123 - }
103.124 - };
103.125 -
103.126 - // =================================================================================================================
103.127 - // Constructors
103.128 -
103.129 - public UIStyle() {
103.130 - uiProperties = new ArrayList<UIProperty>();
103.131 - }
103.132 -
103.133 - // =================================================================================================================
103.134 - // JIBX Methods
103.135 -
103.136 - /**
103.137 - * Called by JIBX after all fields have been set
103.138 - *
103.139 - * @param context The JIBX Unmarshalling Context
103.140 - */
103.141 - private void postSet(IUnmarshallingContext context) {
103.142 - // walk up till we get a parent style
103.143 - for (int i = 0; i < context.getStackDepth(); i++) {
103.144 - if (context.getStackObject(i) instanceof HasUIStyle) {
103.145 - HasUIStyle hasStyle = (HasUIStyle) context.getStackObject(i);
103.146 - if (hasStyle.getStyle() != this) {
103.147 - parentStyle = hasStyle.getStyle();
103.148 - if (parentStyle != null) break;
103.149 - }
103.150 - }
103.151 - }
103.152 - }
103.153 -
103.154 - // =================================================================================================================
103.155 - // Bean Methods
103.156 -
103.157 - public UIStyle getParentStyle() {
103.158 - return parentStyle;
103.159 - }
103.160 -
103.161 - public void setParentStyle(UIStyle parentStyle) {
103.162 - UIStyle old = getParentStyle();
103.163 - this.parentStyle = parentStyle;
103.164 - firePropertyChange("parentStyle", old, getParentStyle());
103.165 - }
103.166 -
103.167 - public List<UIProperty> getUiProperties() {
103.168 - return uiProperties;
103.169 - }
103.170 -
103.171 - public void addUiProperty(UIProperty uiProperty) {
103.172 - uiProperties.add(uiProperty);
103.173 - // todo not quite sure what events we want here
103.174 - fireIndexedPropertyChange("uiProperties", uiProperties.size(), null, uiProperty);
103.175 -// firePropertyChange("uiProperties", null, uiProperties);
103.176 - }
103.177 -
103.178 - public void removeUiProperty(UIProperty uiProperty) {
103.179 - int index = uiProperties.indexOf(uiProperty);
103.180 - if (index != -1) {
103.181 - uiProperties.remove(uiProperty);
103.182 - // todo not quite sure what events we want here
103.183 - fireIndexedPropertyChange("uiProperties", index, null, uiProperty);
103.184 -// firePropertyChange("uiProperties", null, uiProperties);
103.185 - }
103.186 - }
103.187 -
103.188 - public Typeface getFont() {
103.189 - if (isFontInherited()) {
103.190 - return parentStyle == null ? font : parentStyle.getFont();
103.191 - } else {
103.192 - return font;
103.193 - }
103.194 - }
103.195 -
103.196 - public void setFont(Typeface font) {
103.197 - Typeface old = getFont();
103.198 - this.font = font;
103.199 - firePropertyChange("font", old, font);
103.200 - }
103.201 -
103.202 - public boolean isFontInherited() {
103.203 - return fontInherited;
103.204 - }
103.205 -
103.206 - public void setFontInherited(boolean b) {
103.207 - boolean old = isFontInherited();
103.208 - fontInherited = b;
103.209 - firePropertyChange("fontInherited", old, b);
103.210 -
103.211 - if (!fontInherited && font == null && parentStyle != null && parentStyle.getFont() != null) {
103.212 - font = parentStyle.getFont().clone();
103.213 - firePropertyChange("font", null, font);
103.214 - }
103.215 - }
103.216 -
103.217 - public Matte getTextForeground() {
103.218 - if (isTextForegroundInherited()) {
103.219 - return parentStyle == null ? null : parentStyle.getTextForeground();
103.220 - } else {
103.221 - return textForeground;
103.222 - }
103.223 - }
103.224 -
103.225 - public boolean isTextForegroundInherited() {
103.226 - return textForegroundInherited;
103.227 - }
103.228 -
103.229 - public void setTextForegroundInherited(boolean b) {
103.230 - boolean old = isTextForegroundInherited();
103.231 - textForegroundInherited = b;
103.232 - firePropertyChange("foregroundInherited", old, b);
103.233 -
103.234 - if (!textForegroundInherited && textForeground == null && parentStyle != null &&
103.235 - parentStyle.getTextForeground() != null) {
103.236 - textForeground = parentStyle.getTextForeground().clone();
103.237 - firePropertyChange("textForeground", null, textForeground);
103.238 - }
103.239 - }
103.240 -
103.241 - public void setTextForeground(Matte textForeground) {
103.242 - Matte old = this.textForeground;
103.243 - if (old != null) old.removePropertyChangeListener(textForegoundListener);
103.244 - this.textForeground = textForeground;
103.245 - if (this.textForeground != null) this.textForeground.addPropertyChangeListener(textForegoundListener);
103.246 - firePropertyChange("textForeground", old, this.textForeground);
103.247 - }
103.248 -
103.249 - public Matte getTextBackground() {
103.250 - if (isTextBackgroundInherited()) {
103.251 - return parentStyle == null ? null : parentStyle.getBackground();
103.252 - } else {
103.253 - return textBackground;
103.254 - }
103.255 - }
103.256 -
103.257 - public boolean isTextBackgroundInherited() {
103.258 - return textBackgroundInherited;
103.259 - }
103.260 -
103.261 - public void setTextBackgroundInherited(boolean b) {
103.262 - boolean old = isBackgroundInherited();
103.263 - textBackgroundInherited = b;
103.264 - firePropertyChange("textBackgroundInherited", old, b);
103.265 -
103.266 - if (!textBackgroundInherited && textBackground == null && parentStyle != null &&
103.267 - parentStyle.getTextBackground() != null) {
103.268 - textBackground = parentStyle.getTextBackground().clone();
103.269 - firePropertyChange("textBackground", null, textBackground);
103.270 - }
103.271 - }
103.272 -
103.273 - public void setTextBackground(Matte textBackground) {
103.274 - Matte old = this.textBackground;
103.275 - if (old != null) old.removePropertyChangeListener(textBackgroundListener);
103.276 - this.textBackground = textBackground;
103.277 - if (this.textBackground != null) this.textBackground.addPropertyChangeListener(textBackgroundListener);
103.278 - firePropertyChange("textBackground", old, this.textBackground);
103.279 - }
103.280 -
103.281 - public Matte getBackground() {
103.282 - if (isBackgroundInherited()) {
103.283 - return parentStyle == null ? null : parentStyle.getBackground();
103.284 - } else {
103.285 - return background;
103.286 - }
103.287 - }
103.288 -
103.289 - public boolean isBackgroundInherited() {
103.290 - return backgroundInherited;
103.291 - }
103.292 -
103.293 - public void setBackgroundInherited(boolean b) {
103.294 - boolean old = isBackgroundInherited();
103.295 - backgroundInherited = b;
103.296 - firePropertyChange("backgroundInherited", old, b);
103.297 -
103.298 - if (!backgroundInherited && background == null && parentStyle != null && parentStyle.getBackground() != null) {
103.299 - background = parentStyle.getBackground().clone();
103.300 - firePropertyChange("background", null, background);
103.301 - }
103.302 - }
103.303 -
103.304 - public void setBackground(Matte background) {
103.305 - Matte old = this.background;
103.306 - if (old != null) old.removePropertyChangeListener(backgroundListener);
103.307 - this.background = background;
103.308 - if (this.background != null) this.background.addPropertyChangeListener(backgroundListener);
103.309 - firePropertyChange("background", old, this.background);
103.310 - }
103.311 -
103.312 - public HintAlphaInterpolation getHintAlphaInterpolation() {
103.313 - return hintAlphaInterpolation;
103.314 - }
103.315 -
103.316 - public void setHintAlphaInterpolation(HintAlphaInterpolation hintAlphaInterpolation) {
103.317 - HintAlphaInterpolation old = getHintAlphaInterpolation();
103.318 - this.hintAlphaInterpolation = hintAlphaInterpolation;
103.319 - firePropertyChange("hintAlphaInterpolation", old, getHintAlphaInterpolation());
103.320 - }
103.321 -
103.322 - public HintAntialiasing getHintAntialiasing() {
103.323 - return hintAntialiasing;
103.324 - }
103.325 -
103.326 - public void setHintAntialiasing(HintAntialiasing hintAntialiasing) {
103.327 - HintAntialiasing old = getHintAntialiasing();
103.328 - this.hintAntialiasing = hintAntialiasing;
103.329 - firePropertyChange("hintAntialiasing", old, getHintAntialiasing());
103.330 - }
103.331 -
103.332 - public HintColorRendering getHintColorRendering() {
103.333 - return hintColorRendering;
103.334 - }
103.335 -
103.336 - public void setHintColorRendering(HintColorRendering hintColorRendering) {
103.337 - HintColorRendering old = getHintColorRendering();
103.338 - this.hintColorRendering = hintColorRendering;
103.339 - firePropertyChange("hintColorRendering", old, getHintColorRendering());
103.340 - }
103.341 -
103.342 - public HintDithering getHintDithering() {
103.343 - return hintDithering;
103.344 - }
103.345 -
103.346 - public void setHintDithering(HintDithering hintDithering) {
103.347 - HintDithering old = getHintDithering();
103.348 - this.hintDithering = hintDithering;
103.349 - firePropertyChange("hintDithering", old, getHintDithering());
103.350 - }
103.351 -
103.352 - public HintFractionalMetrics getHintFractionalMetrics() {
103.353 - return hintFractionalMetrics;
103.354 - }
103.355 -
103.356 - public void setHintFractionalMetrics(HintFractionalMetrics hintFractionalMetrics) {
103.357 - HintFractionalMetrics old = getHintFractionalMetrics();
103.358 - this.hintFractionalMetrics = hintFractionalMetrics;
103.359 - firePropertyChange("hintFractionalMetrics", old, getHintFractionalMetrics());
103.360 - }
103.361 -
103.362 - public HintInterpolation getHintInterpolation() {
103.363 - return hintInterpolation;
103.364 - }
103.365 -
103.366 - public void setHintInterpolation(HintInterpolation hintInterpolation) {
103.367 - HintInterpolation old = getHintInterpolation();
103.368 - this.hintInterpolation = hintInterpolation;
103.369 - firePropertyChange("hintInterpolation", old, getHintInterpolation());
103.370 - }
103.371 -
103.372 - public HintRendering getHintRendering() {
103.373 - return hintRendering;
103.374 - }
103.375 -
103.376 - public void setHintRendering(HintRendering hintRendering) {
103.377 - HintRendering old = getHintRendering();
103.378 - this.hintRendering = hintRendering;
103.379 - firePropertyChange("hintRendering", old, getHintRendering());
103.380 - }
103.381 -
103.382 - public HintStrokeControl getHintStrokeControl() {
103.383 - return hintStrokeControl;
103.384 - }
103.385 -
103.386 - public void setHintStrokeControl(HintStrokeControl hintStrokeControl) {
103.387 - HintStrokeControl old = getHintStrokeControl();
103.388 - this.hintStrokeControl = hintStrokeControl;
103.389 - firePropertyChange("hintStrokeControl", old, getHintStrokeControl());
103.390 - }
103.391 -
103.392 - public HintTextAntialiasing getHintTextAntialiasing() {
103.393 - return hintTextAntialiasing;
103.394 - }
103.395 -
103.396 - public void setHintTextAntialiasing(HintTextAntialiasing hintTextAntialiasing) {
103.397 - HintTextAntialiasing old = getHintTextAntialiasing();
103.398 - this.hintTextAntialiasing = hintTextAntialiasing;
103.399 - firePropertyChange("hintTextAntialiasing", old, getHintTextAntialiasing());
103.400 - }
103.401 -
103.402 - public boolean isCacheSettingsInherited() {
103.403 - return cacheSettingsInherited;
103.404 - }
103.405 -
103.406 - public void setCacheSettingsInherited(boolean cacheSettingsInherited) {
103.407 - boolean old = isCacheSettingsInherited();
103.408 - this.cacheSettingsInherited = cacheSettingsInherited;
103.409 - firePropertyChange("cacheSettingsInherited", old, isCacheSettingsInherited());
103.410 - }
103.411 -
103.412 - public CacheMode getCacheMode() {
103.413 - if (isCacheSettingsInherited()) {
103.414 - return (parentStyle == null)?CacheMode.FIXED_SIZES : parentStyle.getCacheMode();
103.415 - } else {
103.416 - return cacheMode;
103.417 - }
103.418 - }
103.419 -
103.420 - public void setCacheMode(CacheMode cacheMode) {
103.421 - CacheMode old = this.cacheMode;
103.422 - this.cacheMode = cacheMode;
103.423 - if (isCacheSettingsInherited()) {
103.424 - setCacheSettingsInherited(false);
103.425 - UIStyle parent = getParentStyle();
103.426 - setMaxHozCachedImgScaling(parent == null ? 1 : parent.getMaxHozCachedImgScaling());
103.427 - setMaxVertCachedImgScaling(parent == null ? 1 : parent.getMaxVertCachedImgScaling());
103.428 - }
103.429 - firePropertyChange("cacheMode",old,cacheMode);
103.430 - }
103.431 -
103.432 - public double getMaxHozCachedImgScaling() {
103.433 - if (isCacheSettingsInherited()) {
103.434 - return parentStyle == null ? 1 : parentStyle.getMaxHozCachedImgScaling();
103.435 - } else {
103.436 - return maxHozCachedImgScaling;
103.437 - }
103.438 - }
103.439 -
103.440 - public void setMaxHozCachedImgScaling(double maxHozCachedImgScaling) {
103.441 - double old = getMaxHozCachedImgScaling();
103.442 - this.maxHozCachedImgScaling = maxHozCachedImgScaling;
103.443 - if (isCacheSettingsInherited()) {
103.444 - setCacheSettingsInherited(false);
103.445 - setCacheMode((parentStyle == null)?CacheMode.FIXED_SIZES : parentStyle.getCacheMode());
103.446 - setMaxVertCachedImgScaling(parentStyle == null ? 1 : parentStyle.getMaxVertCachedImgScaling());
103.447 - }
103.448 - firePropertyChange("maxHozCachedImgScaling", old, getMaxHozCachedImgScaling());
103.449 - }
103.450 -
103.451 - public double getMaxVertCachedImgScaling() {
103.452 - if (isCacheSettingsInherited()) {
103.453 - return parentStyle == null ? 1 : parentStyle.getMaxVertCachedImgScaling();
103.454 - } else {
103.455 - return maxVertCachedImgScaling;
103.456 - }
103.457 - }
103.458 -
103.459 - public void setMaxVertCachedImgScaling(double maxVertCachedImgScaling) {
103.460 - double old = getMaxVertCachedImgScaling();
103.461 - this.maxVertCachedImgScaling = maxVertCachedImgScaling;
103.462 - if (isCacheSettingsInherited()) {
103.463 - setCacheSettingsInherited(false);
103.464 - setCacheMode((parentStyle == null)?CacheMode.FIXED_SIZES : parentStyle.getCacheMode());
103.465 - setMaxHozCachedImgScaling(parentStyle == null ? 1 : parentStyle.getMaxHozCachedImgScaling());
103.466 - }
103.467 - firePropertyChange("maxVertCachedImgScaling", old, getMaxVertCachedImgScaling());
103.468 - }
103.469 -}
103.470 -
104.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/jibxhelpers/BorderMapper.java Sun Sep 06 23:14:42 2009 -0700
104.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
104.3 @@ -1,285 +0,0 @@
104.4 -/*
104.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
104.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
104.7 - *
104.8 - * This code is free software; you can redistribute it and/or modify it
104.9 - * under the terms of the GNU General Public License version 2 only, as
104.10 - * published by the Free Software Foundation. Sun designates this
104.11 - * particular file as subject to the "Classpath" exception as provided
104.12 - * by Sun in the LICENSE file that accompanied this code.
104.13 - *
104.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
104.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
104.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
104.17 - * version 2 for more details (a copy is included in the LICENSE file that
104.18 - * accompanied this code).
104.19 - *
104.20 - * You should have received a copy of the GNU General Public License version
104.21 - * 2 along with this work; if not, write to the Free Software Foundation,
104.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
104.23 - *
104.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
104.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
104.26 - * have any questions.
104.27 - */
104.28 -package org.jdesktop.synthdesigner.synthmodel.jibxhelpers;
104.29 -
104.30 -import org.jibx.runtime.IMarshaller;
104.31 -import org.jibx.runtime.IUnmarshaller;
104.32 -import org.jibx.runtime.IAliasable;
104.33 -import org.jibx.runtime.IUnmarshallingContext;
104.34 -import org.jibx.runtime.JiBXException;
104.35 -import org.jibx.runtime.IMarshallingContext;
104.36 -import org.jibx.runtime.impl.MarshallingContext;
104.37 -import org.jibx.runtime.impl.UnmarshallingContext;
104.38 -import org.jdesktop.swingx.designer.jibxhelpers.ColorMapper;
104.39 -
104.40 -import javax.swing.border.LineBorder;
104.41 -import javax.swing.border.EmptyBorder;
104.42 -import javax.swing.border.EtchedBorder;
104.43 -import javax.swing.border.BevelBorder;
104.44 -import javax.swing.border.MatteBorder;
104.45 -import javax.swing.border.CompoundBorder;
104.46 -import javax.swing.border.Border;
104.47 -import javax.swing.BorderFactory;
104.48 -import java.awt.Insets;
104.49 -import java.awt.Color;
104.50 -import org.jdesktop.synthdesigner.synthmodel.PainterBorder;
104.51 -
104.52 -/**
104.53 - * BorderMapper - JIBX xml mapper for swing standard borders
104.54 - *
104.55 - * @author Jasper Potts
104.56 - */
104.57 -public class BorderMapper implements IMarshaller, IUnmarshaller, IAliasable {
104.58 - private static enum BorderType {
104.59 - empty, line, etched, bevel, matte, compound, painter
104.60 - }
104.61 - private static enum SubType {
104.62 - raised(EtchedBorder.RAISED), lowered(EtchedBorder.LOWERED);
104.63 - private int subtype;
104.64 -
104.65 - SubType(int type) {
104.66 - this.subtype = type;
104.67 - }
104.68 -
104.69 - public int getSubType() {
104.70 - return subtype;
104.71 - }
104.72 - }
104.73 - private static final String ELEMENT_NAME = "border";
104.74 - private static final String TYPE_NAME = "type";
104.75 - private static final String SUB_TYPE_NAME = "subtype";
104.76 - private static final String TOP_NAME = "top";
104.77 - private static final String BOTTOM_NAME = "bottom";
104.78 - private static final String LEFT_NAME = "left";
104.79 - private static final String RIGHT_NAME = "right";
104.80 - private static final String THICKNESS_NAME = "thickness";
104.81 - private static final String INSIDE_NAME = "inside";
104.82 - private static final String OUTSIDE_NAME = "outside";
104.83 - private static final String PAINTER_NAME = "painter";
104.84 -
104.85 - private String uri;
104.86 - private int index;
104.87 - private String name;
104.88 -
104.89 - public BorderMapper() {
104.90 - uri = null;
104.91 - index = 0;
104.92 - name = ELEMENT_NAME;
104.93 - }
104.94 -
104.95 - public BorderMapper(String uri, int index, String name) {
104.96 - this.uri = uri;
104.97 - this.index = index;
104.98 - this.name = name;
104.99 - }
104.100 -
104.101 - public boolean isExtension(int i) {
104.102 - return false;
104.103 - }
104.104 -
104.105 - public boolean isPresent(IUnmarshallingContext iUnmarshallingContext) throws
104.106 - JiBXException {
104.107 - return iUnmarshallingContext.isAt(uri, ELEMENT_NAME);
104.108 - }
104.109 -
104.110 - public void marshal(Object object, IMarshallingContext iMarshallingContext)
104.111 - throws JiBXException {
104.112 - if (!(iMarshallingContext instanceof MarshallingContext)) {
104.113 - throw new JiBXException("Invalid object type for marshaller");
104.114 - } else {
104.115 - MarshallingContext ctx = (MarshallingContext) iMarshallingContext;
104.116 - if (object instanceof PainterBorder) {
104.117 - PainterBorder border = (PainterBorder) object;
104.118 - Insets insets = border.getBorderInsets();
104.119 - ctx.startTagAttributes(index, name)
104.120 - .attribute(index, TYPE_NAME, BorderType.painter.toString())
104.121 - .attribute(index, PAINTER_NAME, border.getPainterName())
104.122 - .attribute(index, TOP_NAME, insets.top)
104.123 - .attribute(index, BOTTOM_NAME, insets.bottom)
104.124 - .attribute(index, LEFT_NAME, insets.left)
104.125 - .attribute(index, RIGHT_NAME, insets.right)
104.126 - .closeStartContent();
104.127 - ctx.endTag(index, name);
104.128 - } else if (object instanceof EmptyBorder) {
104.129 - Insets insets = ((EmptyBorder) object).getBorderInsets();
104.130 - ctx.startTagAttributes(index, name)
104.131 - .attribute(index, TYPE_NAME,
104.132 - BorderType.empty.toString())
104.133 - .attribute(index, TOP_NAME, insets.top)
104.134 - .attribute(index, BOTTOM_NAME, insets.bottom)
104.135 - .attribute(index, LEFT_NAME, insets.left)
104.136 - .attribute(index, RIGHT_NAME, insets.right)
104.137 - .closeStartEmpty();
104.138 - } else if (object instanceof LineBorder) {
104.139 - LineBorder border = (LineBorder) object;
104.140 - ctx.startTagAttributes(index, name).
104.141 - attribute(index, TYPE_NAME, BorderType.line.toString()).
104.142 - attribute(index, THICKNESS_NAME, border.getThickness()).
104.143 - closeStartContent();
104.144 - new ColorMapper().marshal(border.getLineColor(), ctx);
104.145 - ctx.endTag(index, name);
104.146 - } else if (object instanceof EtchedBorder) {
104.147 - EtchedBorder border = (EtchedBorder) object;
104.148 - ctx.startTagAttributes(index, name).
104.149 - attribute(index, TYPE_NAME,
104.150 - BorderType.etched.toString()).
104.151 - attribute(index, SUB_TYPE_NAME,
104.152 - border.getEtchType()==EtchedBorder.RAISED?
104.153 - SubType.raised.toString():
104.154 - SubType.lowered.toString()).
104.155 - closeStartContent();
104.156 - new ColorMapper().marshal(border.getHighlightColor(), ctx);
104.157 - new ColorMapper().marshal(border.getShadowColor(), ctx);
104.158 - ctx.endTag(index, name);
104.159 - } else if (object instanceof BevelBorder) {
104.160 - BevelBorder border = (BevelBorder) object;
104.161 - ctx.startTagAttributes(index, name).
104.162 - attribute(index, TYPE_NAME,
104.163 - BorderType.bevel.toString()).
104.164 - attribute(index, SUB_TYPE_NAME,
104.165 - border.getBevelType()==BevelBorder.RAISED?
104.166 - SubType.raised.toString():
104.167 - SubType.lowered.toString()).
104.168 - closeStartContent();
104.169 - new ColorMapper().marshal(border.getHighlightInnerColor(), ctx);
104.170 - new ColorMapper().marshal(border.getHighlightOuterColor(), ctx);
104.171 - new ColorMapper().marshal(border.getShadowInnerColor(), ctx);
104.172 - new ColorMapper().marshal(border.getHighlightOuterColor(), ctx);
104.173 - ctx.endTag(index, name);
104.174 - } else if (object instanceof MatteBorder) {
104.175 - MatteBorder border = (MatteBorder) object;
104.176 - Insets insets = ((EmptyBorder) object).getBorderInsets();
104.177 - ctx.startTagAttributes(index, name)
104.178 - .attribute(index, TYPE_NAME,
104.179 - BorderType.matte.toString())
104.180 - .attribute(index, TOP_NAME, insets.top)
104.181 - .attribute(index, BOTTOM_NAME, insets.bottom)
104.182 - .attribute(index, LEFT_NAME, insets.left)
104.183 - .attribute(index, RIGHT_NAME, insets.right)
104.184 - .closeStartContent();
104.185 - new ColorMapper().marshal(border.getMatteColor(), ctx);
104.186 - // todo: we should support tiled icons here to be 100% complete
104.187 - ctx.endTag(index, name);
104.188 - } else if (object instanceof CompoundBorder) {
104.189 - CompoundBorder border = (CompoundBorder) object;
104.190 - ctx.startTagAttributes(index, name)
104.191 - .attribute(index, TYPE_NAME,
104.192 - BorderType.compound.toString())
104.193 - .closeStartContent();
104.194 - new BorderMapper(null,0, INSIDE_NAME).marshal(border.getInsideBorder(),ctx);
104.195 - new BorderMapper(null,0, OUTSIDE_NAME).marshal(border.getOutsideBorder(),ctx);
104.196 - ctx.endTag(index, name);
104.197 - } else {
104.198 - throw new JiBXException("Invalid object type for marshaller");
104.199 - }
104.200 - }
104.201 - }
104.202 -
104.203 - public Object unmarshal(Object object,
104.204 - IUnmarshallingContext iUnmarshallingContext)
104.205 - throws JiBXException {
104.206 - Border border = null;
104.207 - // make sure we're at the appropriate start tag
104.208 - UnmarshallingContext ctx = (UnmarshallingContext) iUnmarshallingContext;
104.209 - if (!ctx.isAt(uri, name)) {
104.210 - ctx.throwStartTagNameError(uri, name);
104.211 - }
104.212 - // get type
104.213 - BorderType type = BorderType.valueOf(ctx.attributeText(uri, TYPE_NAME)
104.214 - .toLowerCase());
104.215 - int top,bottom,left,right;
104.216 - Color color;
104.217 - switch(type){
104.218 - case empty:
104.219 - top = ctx.attributeInt(uri, TOP_NAME, index);
104.220 - bottom = ctx.attributeInt(uri, BOTTOM_NAME, index);
104.221 - left = ctx.attributeInt(uri, LEFT_NAME, index);
104.222 - right = ctx.attributeInt(uri, RIGHT_NAME, index);
104.223 - border = BorderFactory.createEmptyBorder(top,left,bottom,right);
104.224 - break;
104.225 - case line:
104.226 - int thickness = ctx.attributeInt(uri, THICKNESS_NAME, index);
104.227 - ctx.parsePastStartTag(uri,name);
104.228 - color = (Color)new ColorMapper().unmarshal(null,ctx);
104.229 - border = BorderFactory.createLineBorder(color,thickness);
104.230 - break;
104.231 - case etched:
104.232 - SubType etchedType = SubType.valueOf(
104.233 - ctx.attributeText(uri, SUB_TYPE_NAME).toLowerCase());
104.234 - ctx.parsePastStartTag(uri,name);
104.235 - Color highColor = (Color)new ColorMapper()
104.236 - .unmarshal(null,ctx);
104.237 - Color shadowColor = (Color)new ColorMapper()
104.238 - .unmarshal(null,ctx);
104.239 - border = BorderFactory.createEtchedBorder(
104.240 - etchedType.getSubType(),highColor,shadowColor);
104.241 - break;
104.242 - case bevel:
104.243 - SubType bevelType = SubType.valueOf(
104.244 - ctx.attributeText(uri, SUB_TYPE_NAME).toLowerCase());
104.245 - ctx.parsePastStartTag(uri,name);
104.246 - Color innerHighColor = (Color)new ColorMapper()
104.247 - .unmarshal(null,ctx);
104.248 - Color outerHighColor = (Color)new ColorMapper()
104.249 - .unmarshal(null,ctx);
104.250 - Color innerShadowColor = (Color)new ColorMapper()
104.251 - .unmarshal(null,ctx);
104.252 - Color outerShadowColor = (Color)new ColorMapper()
104.253 - .unmarshal(null,ctx);
104.254 - border = BorderFactory.createBevelBorder(
104.255 - bevelType.getSubType(),outerHighColor,innerHighColor,
104.256 - outerShadowColor,innerShadowColor);
104.257 - break;
104.258 - case matte:
104.259 - top = ctx.attributeInt(uri, TOP_NAME, index);
104.260 - bottom = ctx.attributeInt(uri, BOTTOM_NAME, index);
104.261 - left = ctx.attributeInt(uri, LEFT_NAME, index);
104.262 - right = ctx.attributeInt(uri, RIGHT_NAME, index);
104.263 - ctx.parsePastStartTag(uri,name);
104.264 - color = (Color)new ColorMapper().unmarshal(null,ctx);
104.265 - border = BorderFactory.createMatteBorder(top,left,bottom,right,
104.266 - color);
104.267 - break;
104.268 - case compound:
104.269 - ctx.parsePastStartTag(uri,name);
104.270 - Border inside = (Border) new BorderMapper(null,0, INSIDE_NAME)
104.271 - .unmarshal(null,ctx);
104.272 - Border outside = (Border) new BorderMapper(null,0, OUTSIDE_NAME)
104.273 - .unmarshal(null,ctx);
104.274 - border = BorderFactory.createCompoundBorder(outside, inside);
104.275 - break;
104.276 - case painter:
104.277 - String painterName = ctx.attributeText(uri, PAINTER_NAME);
104.278 - top = ctx.attributeInt(uri, TOP_NAME, index);
104.279 - bottom = ctx.attributeInt(uri, BOTTOM_NAME, index);
104.280 - left = ctx.attributeInt(uri, LEFT_NAME, index);
104.281 - right = ctx.attributeInt(uri, RIGHT_NAME, index);
104.282 - border = new PainterBorder(painterName, top, left, bottom, right);
104.283 - }
104.284 - ctx.parsePastEndTag(uri, name);
104.285 - return border;
104.286 - }
104.287 -}
104.288 -
105.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/jibxhelpers/ClassConverter.java Sun Sep 06 23:14:42 2009 -0700
105.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
105.3 @@ -1,53 +0,0 @@
105.4 -/*
105.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
105.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
105.7 - *
105.8 - * This code is free software; you can redistribute it and/or modify it
105.9 - * under the terms of the GNU General Public License version 2 only, as
105.10 - * published by the Free Software Foundation. Sun designates this
105.11 - * particular file as subject to the "Classpath" exception as provided
105.12 - * by Sun in the LICENSE file that accompanied this code.
105.13 - *
105.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
105.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
105.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
105.17 - * version 2 for more details (a copy is included in the LICENSE file that
105.18 - * accompanied this code).
105.19 - *
105.20 - * You should have received a copy of the GNU General Public License version
105.21 - * 2 along with this work; if not, write to the Free Software Foundation,
105.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
105.23 - *
105.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
105.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
105.26 - * have any questions.
105.27 - */
105.28 -package org.jdesktop.synthdesigner.synthmodel.jibxhelpers;
105.29 -
105.30 -/**
105.31 - * ClassConverter
105.32 - *
105.33 - * @author Created by Jasper Potts (Jul 16, 2007)
105.34 - */
105.35 -public class ClassConverter {
105.36 -
105.37 - public static String classToString(Class c) {
105.38 - return c == null ? "" : c.getName();
105.39 - }
105.40 -
105.41 - public static Class stringToClass(String className) {
105.42 - if (className == null || className.length() == 0) {
105.43 - return null;
105.44 - }
105.45 - try {
105.46 - ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
105.47 - if (classLoader == null) classLoader = ClassConverter.class.getClassLoader();
105.48 - return classLoader.loadClass(className);
105.49 - } catch (ClassNotFoundException e) {
105.50 - System.err.println("Failed to find class with name [" + className + "] in ClassConverter");
105.51 - e.printStackTrace();
105.52 - return null;
105.53 - }
105.54 - }
105.55 -
105.56 -}
106.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/jibxhelpers/ClassMapper.java Sun Sep 06 23:14:42 2009 -0700
106.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
106.3 @@ -1,78 +0,0 @@
106.4 -/*
106.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
106.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
106.7 - *
106.8 - * This code is free software; you can redistribute it and/or modify it
106.9 - * under the terms of the GNU General Public License version 2 only, as
106.10 - * published by the Free Software Foundation. Sun designates this
106.11 - * particular file as subject to the "Classpath" exception as provided
106.12 - * by Sun in the LICENSE file that accompanied this code.
106.13 - *
106.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
106.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
106.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
106.17 - * version 2 for more details (a copy is included in the LICENSE file that
106.18 - * accompanied this code).
106.19 - *
106.20 - * You should have received a copy of the GNU General Public License version
106.21 - * 2 along with this work; if not, write to the Free Software Foundation,
106.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
106.23 - *
106.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
106.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
106.26 - * have any questions.
106.27 - */
106.28 -package org.jdesktop.synthdesigner.synthmodel.jibxhelpers;
106.29 -
106.30 -import org.jibx.runtime.IMarshaller;
106.31 -import org.jibx.runtime.IMarshallingContext;
106.32 -import org.jibx.runtime.IUnmarshaller;
106.33 -import org.jibx.runtime.IUnmarshallingContext;
106.34 -import org.jibx.runtime.JiBXException;
106.35 -import org.jibx.runtime.impl.MarshallingContext;
106.36 -import org.jibx.runtime.impl.UnmarshallingContext;
106.37 -
106.38 -
106.39 -public class ClassMapper implements IMarshaller, IUnmarshaller {
106.40 - private static final String ELEMENT_NAME = "type";
106.41 -
106.42 - public boolean isExtension(int i) {
106.43 - return false;
106.44 - }
106.45 -
106.46 - public boolean isPresent(IUnmarshallingContext iUnmarshallingContext) throws JiBXException {
106.47 - return iUnmarshallingContext.isAt(null, ELEMENT_NAME);
106.48 - }
106.49 -
106.50 - public void marshal(Object object, IMarshallingContext iMarshallingContext) throws JiBXException {
106.51 - if (!(object instanceof Class)) {
106.52 - throw new JiBXException("Invalid object type for marshaller");
106.53 - } else if (!(iMarshallingContext instanceof MarshallingContext)) {
106.54 - throw new JiBXException("Invalid object type for marshaller");
106.55 - } else {
106.56 - MarshallingContext ctx = (MarshallingContext) iMarshallingContext;
106.57 - Class clazz = (Class) object;
106.58 - ctx.startTagAttributes(0, ELEMENT_NAME).
106.59 - attribute(0, "value", clazz.getName()).
106.60 - closeStartEmpty();
106.61 - }
106.62 - }
106.63 -
106.64 - public Object unmarshal(Object object, IUnmarshallingContext iUnmarshallingContext) throws JiBXException {
106.65 - // make sure we're at the appropriate start tag
106.66 - UnmarshallingContext ctx = (UnmarshallingContext) iUnmarshallingContext;
106.67 - if (!ctx.isAt(null, ELEMENT_NAME)) {
106.68 - ctx.throwStartTagNameError(null, ELEMENT_NAME);
106.69 - }
106.70 - // get values
106.71 - String value = ctx.attributeText(null, "value", null);
106.72 - ctx.parsePastEndTag(null, ELEMENT_NAME);
106.73 - // create
106.74 - try {
106.75 - return Class.forName(value);
106.76 - } catch (Exception e) {
106.77 - e.printStackTrace();
106.78 - }
106.79 - return null;
106.80 - }
106.81 -}
107.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/jibxhelpers/FontMapper.java Sun Sep 06 23:14:42 2009 -0700
107.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
107.3 @@ -1,86 +0,0 @@
107.4 -/*
107.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
107.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
107.7 - *
107.8 - * This code is free software; you can redistribute it and/or modify it
107.9 - * under the terms of the GNU General Public License version 2 only, as
107.10 - * published by the Free Software Foundation. Sun designates this
107.11 - * particular file as subject to the "Classpath" exception as provided
107.12 - * by Sun in the LICENSE file that accompanied this code.
107.13 - *
107.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
107.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
107.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
107.17 - * version 2 for more details (a copy is included in the LICENSE file that
107.18 - * accompanied this code).
107.19 - *
107.20 - * You should have received a copy of the GNU General Public License version
107.21 - * 2 along with this work; if not, write to the Free Software Foundation,
107.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
107.23 - *
107.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
107.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
107.26 - * have any questions.
107.27 - */
107.28 -package org.jdesktop.synthdesigner.synthmodel.jibxhelpers;
107.29 -
107.30 -import org.jibx.runtime.IMarshaller;
107.31 -import org.jibx.runtime.IMarshallingContext;
107.32 -import org.jibx.runtime.IUnmarshaller;
107.33 -import org.jibx.runtime.IUnmarshallingContext;
107.34 -import org.jibx.runtime.JiBXException;
107.35 -import org.jibx.runtime.impl.MarshallingContext;
107.36 -import org.jibx.runtime.impl.UnmarshallingContext;
107.37 -
107.38 -import java.awt.Font;
107.39 -
107.40 -/**
107.41 - * FontMapper
107.42 - *
107.43 - * @author Created by Jasper Potts (Jun 8, 2007)
107.44 - */
107.45 -public class FontMapper implements IMarshaller, IUnmarshaller {
107.46 - private static final String ELEMENT_NAME = "font";
107.47 - private static final String FAMILY_NAME = "family";
107.48 - private static final String STYLE_NAME = "style";
107.49 - private static final String SIZE_NAME = "size";
107.50 -
107.51 - public boolean isExtension(int i) {
107.52 - return false;
107.53 - }
107.54 -
107.55 - public boolean isPresent(IUnmarshallingContext iUnmarshallingContext) throws JiBXException {
107.56 - return iUnmarshallingContext.isAt(null, ELEMENT_NAME);
107.57 - }
107.58 -
107.59 - public void marshal(Object object, IMarshallingContext iMarshallingContext) throws JiBXException {
107.60 - if (!(object instanceof Font)) {
107.61 - throw new JiBXException("Invalid object type for marshaller");
107.62 - } else if (!(iMarshallingContext instanceof MarshallingContext)) {
107.63 - throw new JiBXException("Invalid object type for marshaller");
107.64 - } else {
107.65 - MarshallingContext ctx = (MarshallingContext) iMarshallingContext;
107.66 - Font font = (Font) object;
107.67 - ctx.startTagAttributes(0, ELEMENT_NAME).
107.68 - attribute(0, FAMILY_NAME, font.getFamily()).
107.69 - attribute(0, STYLE_NAME, font.getStyle()).
107.70 - attribute(0, SIZE_NAME, font.getSize()).
107.71 - closeStartEmpty();
107.72 - }
107.73 - }
107.74 -
107.75 - public Object unmarshal(Object object, IUnmarshallingContext iUnmarshallingContext) throws JiBXException {
107.76 - // make sure we're at the appropriate start tag
107.77 - UnmarshallingContext ctx = (UnmarshallingContext) iUnmarshallingContext;
107.78 - if (!ctx.isAt(null, ELEMENT_NAME)) {
107.79 - ctx.throwStartTagNameError(null, ELEMENT_NAME);
107.80 - }
107.81 - // get values
107.82 - String name = ctx.attributeText(null, FAMILY_NAME, null);
107.83 - int style = ctx.attributeInt(null, STYLE_NAME, 0);
107.84 - int size = ctx.attributeInt(null, SIZE_NAME, 0);
107.85 - ctx.parsePastEndTag(null, ELEMENT_NAME);
107.86 - // create
107.87 - return new Font(name, style, size);
107.88 - }
107.89 -}
108.1 --- a/make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/jibxhelpers/UIPropertyMapper.java Sun Sep 06 23:14:42 2009 -0700
108.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
108.3 @@ -1,155 +0,0 @@
108.4 -/*
108.5 - * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
108.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
108.7 - *
108.8 - * This code is free software; you can redistribute it and/or modify it
108.9 - * under the terms of the GNU General Public License version 2 only, as
108.10 - * published by the Free Software Foundation. Sun designates this
108.11 - * particular file as subject to the "Classpath" exception as provided
108.12 - * by Sun in the LICENSE file that accompanied this code.
108.13 - *
108.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
108.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
108.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
108.17 - * version 2 for more details (a copy is included in the LICENSE file that
108.18 - * accompanied this code).
108.19 - *
108.20 - * You should have received a copy of the GNU General Public License version
108.21 - * 2 along with this work; if not, write to the Free Software Foundation,
108.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
108.23 - *
108.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
108.25 - * CA 95054 USA or visit www.sun.com if you need additional information or
108.26 - * have any questions.
108.27 - */
108.28 -package org.jdesktop.synthdesigner.synthmodel.jibxhelpers;
108.29 -
108.30 -import org.jdesktop.swingx.designer.jibxhelpers.DimensionMapper;
108.31 -import org.jdesktop.swingx.designer.jibxhelpers.InsetsMapper;
108.32 -import org.jdesktop.synthdesigner.synthmodel.UIProperty;
108.33 -import org.jibx.runtime.IMarshallable;
108.34 -import org.jibx.runtime.IMarshaller;
108.35 -import org.jibx.runtime.IMarshallingContext;
108.36 -import org.jibx.runtime.IUnmarshaller;
108.37 -import org.jibx.runtime.IUnmarshallingContext;
108.38 -import org.jibx.runtime.JiBXException;
108.39 -import org.jibx.runtime.impl.MarshallingContext;
108.40 -import org.jibx.runtime.impl.UnmarshallingContext;
108.41 -
108.42 -/**
108.43 - * UIPropertyMapper
108.44 - *
108.45 - * @author Created by Jasper Potts (Jul 10, 2007)
108.46 - */
108.47 -public class UIPropertyMapper implements IMarshaller, IUnmarshaller {
108.48 - private static final String ELEMENT_NAME = "uiProperty";
108.49 - private static final String NAME_NAME = "name";
108.50 - private static final String TYPE_NAME = "type";
108.51 - private static final String VALUE_NAME = "value";
108.52 -
108.53 - public boolean isExtension(int i) {
108.54 - return false;
108.55 - }
108.56 -
108.57 - public boolean isPresent(IUnmarshallingContext iUnmarshallingContext) throws JiBXException {
108.58 - return iUnmarshallingContext.isAt(null, ELEMENT_NAME);
108.59 - }
108.60 -
108.61 - public void marshal(Object object, IMarshallingContext iMarshallingContext) throws JiBXException {
108.62 - if (!(object instanceof UIProperty)) {
108.63 - throw new JiBXException("Invalid object type for marshaller");
108.64 - } else if (!(iMarshallingContext instanceof MarshallingContext)) {
108.65 - throw new JiBXException("Invalid object type for marshaller");
108.66 - } else {
108.67 - MarshallingContext ctx = (MarshallingContext) iMarshallingContext;
108.68 - UIProperty property = (UIProperty) object;
108.69 - ctx.startTagAttributes(0, ELEMENT_NAME);
108.70 - ctx.attribute(0, NAME_NAME, property.getName());
108.71 - ctx.attribute(0, TYPE_NAME, property.getType().toString());
108.72 - switch (property.getType()) {
108.73 - case BOOLEAN:
108.74 - case DOUBLE:
108.75 - case INT:
108.76 - case FLOAT:
108.77 - case STRING:
108.78 - ctx.attribute(0, VALUE_NAME, property.getValue().toString());
108.79 - ctx.closeStartEmpty();
108.80 - break;
108.81 - case INSETS:
108.82 - ctx.closeStartContent();
108.83 - new InsetsMapper().marshal(property.getValue(), ctx);
108.84 - ctx.endTag(0, ELEMENT_NAME);
108.85 - break;
108.86 - case COLOR:
108.87 - case FONT:
108.88 - ctx.closeStartContent();
108.89 - if (property.getValue() instanceof IMarshallable) {
108.90 - ((IMarshallable) property.getValue()).marshal(ctx);
108.91 - } else {
108.92 - throw new JiBXException("Mapped value is not marshallable");
108.93 - }
108.94 - ctx.endTag(0, ELEMENT_NAME);
108.95 - break;
108.96 - case DIMENSION:
108.97 - ctx.closeStartContent();
108.98 - new DimensionMapper().marshal(property.getValue(), ctx);
108.99 - ctx.endTag(0, ELEMENT_NAME);
108.100 - break;
108.101 - case BORDER:
108.102 - ctx.closeStartContent();
108.103 - new BorderMapper().marshal(property.getValue(), ctx);
108.104 - ctx.endTag(0, ELEMENT_NAME);
108.105 - break;
108.106 - }
108.107 - }
108.108 - }
108.109 -
108.110 - public Object unmarshal(Object object, IUnmarshallingContext iUnmarshallingContext) throws JiBXException {
108.111 - // make sure we're at the appropriate start tag
108.112 - UnmarshallingContext ctx = (UnmarshallingContext) iUnmarshallingContext;
108.113 - if (!ctx.isAt(null, ELEMENT_NAME)) {
108.114 - ctx.throwStartTagNameError(null, ELEMENT_NAME);
108.115 - }
108.116 - // get values
108.117 - Object value = null;
108.118 - String name = ctx.attributeText(null, NAME_NAME, null);
108.119 - UIProperty.PropertyType type = UIProperty.PropertyType.valueOf(ctx.attributeText(null, TYPE_NAME, null));
108.120 - switch (type) {
108.121 - case BOOLEAN:
108.122 - value = Boolean.parseBoolean(ctx.attributeText(null, VALUE_NAME, null));
108.123 - break;
108.124 - case DOUBLE:
108.125 - value = Double.parseDouble(ctx.attributeText(null, VALUE_NAME, null));
108.126 - break;
108.127 - case INT:
108.128 - value = Integer.parseInt(ctx.attributeText(null, VALUE_NAME, null));
108.129 - break;
108.130 - case FLOAT:
108.131 - value = Float.parseFloat(ctx.attributeText(null, VALUE_NAME, null));
108.132 - break;
108.133 - case STRING:
108.134 - value = ctx.attributeText(null, VALUE_NAME, null);
108.135 - break;
108.136 - case INSETS:
108.137 - ctx.parsePastStartTag(null, ELEMENT_NAME);
108.138 - value = new InsetsMapper().unmarshal(value, ctx);
108.139 - break;
108.140 - case COLOR:
108.141 - case FONT:
108.142 - ctx.parsePastStartTag(null, ELEMENT_NAME);
108.143 - value = ctx.unmarshalElement();
108.144 - break;
108.145 - case DIMENSION:
108.146 - ctx.parsePastStartTag(null, ELEMENT_NAME);
108.147 - value = new DimensionMapper().unmarshal(value, ctx);
108.148 - break;
108.149 - case BORDER:
108.150 - ctx.parsePastStartTag(null, ELEMENT_NAME);
108.151 - value = new BorderMapper().unmarshal(value, ctx);
108.152 - break;
108.153 - }
108.154 - ctx.parsePastEndTag(null, ELEMENT_NAME);
108.155 - // create
108.156 - return new UIProperty(name, type, value);
108.157 - }
108.158 -}
109.1 --- a/src/share/classes/com/sun/beans/finder/BeanInfoFinder.java Sun Sep 06 23:14:42 2009 -0700
109.2 +++ b/src/share/classes/com/sun/beans/finder/BeanInfoFinder.java Tue Sep 15 23:41:40 2009 -0700
109.3 @@ -52,8 +52,14 @@
109.4 }
109.5
109.6 @Override
109.7 - protected BeanInfo instantiate(Class<?> type, String name) {
109.8 - BeanInfo info = super.instantiate(type, name);
109.9 + protected BeanInfo instantiate(Class<?> type, String prefix, String name) {
109.10 + // this optimization will only use the BeanInfo search path
109.11 + // if is has changed from the original
109.12 + // or trying to get the ComponentBeanInfo
109.13 + BeanInfo info = !DEFAULT.equals(prefix) || "ComponentBeanInfo".equals(name)
109.14 + ? super.instantiate(type, prefix, name)
109.15 + : null;
109.16 +
109.17 if (info != null) {
109.18 // make sure that the returned BeanInfo matches the class
109.19 BeanDescriptor bd = info.getBeanDescriptor();
109.20 @@ -89,14 +95,4 @@
109.21 }
109.22 return null;
109.23 }
109.24 -
109.25 - @Override
109.26 - protected BeanInfo instantiate(Class<?> type, String prefix, String name) {
109.27 - // this optimization will only use the BeanInfo search path
109.28 - // if is has changed from the original
109.29 - // or trying to get the ComponentBeanInfo
109.30 - return !DEFAULT.equals(prefix) || "ComponentBeanInfo".equals(name)
109.31 - ? super.instantiate(type, prefix, name)
109.32 - : null;
109.33 - }
109.34 }
110.1 --- a/src/share/classes/com/sun/java/swing/plaf/windows/DesktopProperty.java Sun Sep 06 23:14:42 2009 -0700
110.2 +++ b/src/share/classes/com/sun/java/swing/plaf/windows/DesktopProperty.java Tue Sep 15 23:41:40 2009 -0700
110.3 @@ -1,5 +1,5 @@
110.4 /*
110.5 - * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
110.6 + * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
110.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
110.8 *
110.9 * This code is free software; you can redistribute it and/or modify it
110.10 @@ -49,7 +49,7 @@
110.11 /**
110.12 * ReferenceQueue of unreferenced WeakPCLs.
110.13 */
110.14 - private static ReferenceQueue<DesktopProperty> queue;
110.15 + private static final ReferenceQueue<DesktopProperty> queue = new ReferenceQueue<DesktopProperty>();
110.16
110.17 /**
110.18 * PropertyChangeListener attached to the Toolkit.
110.19 @@ -58,7 +58,7 @@
110.20 /**
110.21 * Key used to lookup value from desktop.
110.22 */
110.23 - private String key;
110.24 + private final String key;
110.25 /**
110.26 * Value to return.
110.27 */
110.28 @@ -66,17 +66,8 @@
110.29 /**
110.30 * Fallback value in case we get null from desktop.
110.31 */
110.32 - private Object fallback;
110.33 + private final Object fallback;
110.34
110.35 - /**
110.36 - * Toolkit.
110.37 - */
110.38 - private Toolkit toolkit;
110.39 -
110.40 -
110.41 - static {
110.42 - queue = new ReferenceQueue<DesktopProperty>();
110.43 - }
110.44
110.45 /**
110.46 * Cleans up any lingering state held by unrefeernced
110.47 @@ -138,13 +129,10 @@
110.48 *
110.49 * @param key Key used in looking up desktop value.
110.50 * @param fallback Value used if desktop property is null.
110.51 - * @param toolkit Toolkit used to fetch property from, can be null
110.52 - * in which default will be used.
110.53 */
110.54 - public DesktopProperty(String key, Object fallback, Toolkit toolkit) {
110.55 + public DesktopProperty(String key, Object fallback) {
110.56 this.key = key;
110.57 this.fallback = fallback;
110.58 - this.toolkit = toolkit;
110.59 // The only sure fire way to clear our references is to create a
110.60 // Thread and wait for a reference to be added to the queue.
110.61 // Because it is so rare that you will actually change the look
110.62 @@ -175,13 +163,14 @@
110.63 * Returns the value from the desktop.
110.64 */
110.65 protected Object getValueFromDesktop() {
110.66 - if (this.toolkit == null) {
110.67 - this.toolkit = Toolkit.getDefaultToolkit();
110.68 + Toolkit toolkit = Toolkit.getDefaultToolkit();
110.69 +
110.70 + if (pcl == null) {
110.71 + pcl = new WeakPCL(this, getKey(), UIManager.getLookAndFeel());
110.72 + toolkit.addPropertyChangeListener(getKey(), pcl);
110.73 }
110.74 - Object value = toolkit.getDesktopProperty(getKey());
110.75 - pcl = new WeakPCL(this, toolkit, getKey(), UIManager.getLookAndFeel());
110.76 - toolkit.addPropertyChangeListener(getKey(), pcl);
110.77 - return value;
110.78 +
110.79 + return toolkit.getDesktopProperty(getKey());
110.80 }
110.81
110.82 /**
110.83 @@ -205,12 +194,7 @@
110.84 * <code>createValue</code> will ask for the property again.
110.85 */
110.86 public void invalidate() {
110.87 - if (pcl != null) {
110.88 - toolkit.removePropertyChangeListener(getKey(), pcl);
110.89 - toolkit = null;
110.90 - pcl = null;
110.91 - value = null;
110.92 - }
110.93 + value = null;
110.94 }
110.95
110.96 /**
110.97 @@ -271,13 +255,11 @@
110.98 */
110.99 private static class WeakPCL extends WeakReference<DesktopProperty>
110.100 implements PropertyChangeListener {
110.101 - private Toolkit kit;
110.102 private String key;
110.103 private LookAndFeel laf;
110.104
110.105 - WeakPCL(DesktopProperty target, Toolkit kit, String key, LookAndFeel laf) {
110.106 + WeakPCL(DesktopProperty target, String key, LookAndFeel laf) {
110.107 super(target, queue);
110.108 - this.kit = kit;
110.109 this.key = key;
110.110 this.laf = laf;
110.111 }
110.112 @@ -297,7 +279,7 @@
110.113 }
110.114
110.115 void dispose() {
110.116 - kit.removePropertyChangeListener(key, this);
110.117 + Toolkit.getDefaultToolkit().removePropertyChangeListener(key, this);
110.118 }
110.119 }
110.120 }
111.1 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java Sun Sep 06 23:14:42 2009 -0700
111.2 +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java Tue Sep 15 23:41:40 2009 -0700
111.3 @@ -1,5 +1,5 @@
111.4 /*
111.5 - * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
111.6 + * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
111.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
111.8 *
111.9 * This code is free software; you can redistribute it and/or modify it
111.10 @@ -43,7 +43,6 @@
111.11 import java.security.PrivilegedAction;
111.12
111.13 import sun.awt.shell.ShellFolder;
111.14 -import sun.awt.OSInfo;
111.15 import sun.swing.*;
111.16
111.17 import javax.accessibility.*;
111.18 @@ -58,8 +57,6 @@
111.19 // The following are private because the implementation of the
111.20 // Windows FileChooser L&F is not complete yet.
111.21
111.22 - private static final OSInfo.WindowsVersion OS_VERSION = OSInfo.getWindowsVersion();
111.23 -
111.24 private JPanel centerPanel;
111.25
111.26 private JLabel lookInLabel;
111.27 @@ -118,18 +115,9 @@
111.28 private String upFolderToolTipText = null;
111.29 private String upFolderAccessibleName = null;
111.30
111.31 - private String homeFolderToolTipText = null;
111.32 - private String homeFolderAccessibleName = null;
111.33 -
111.34 private String newFolderToolTipText = null;
111.35 private String newFolderAccessibleName = null;
111.36
111.37 - private String listViewButtonToolTipText = null;
111.38 - private String listViewButtonAccessibleName = null;
111.39 -
111.40 - private String detailsViewButtonToolTipText = null;
111.41 - private String detailsViewButtonAccessibleName = null;
111.42 -
111.43 private String viewMenuButtonToolTipText = null;
111.44 private String viewMenuButtonAccessibleName = null;
111.45
111.46 @@ -231,9 +219,7 @@
111.47 // Directory manipulation buttons
111.48 JToolBar topPanel = new JToolBar();
111.49 topPanel.setFloatable(false);
111.50 - if (OS_VERSION.compareTo(OSInfo.WINDOWS_ME) >= 0) {
111.51 - topPanel.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
111.52 - }
111.53 + topPanel.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
111.54
111.55 // Add the top panel to the fileChooser
111.56 fc.add(topPanel, BorderLayout.NORTH);
111.57 @@ -287,218 +273,103 @@
111.58 topPanel.add(Box.createRigidArea(hstrut10));
111.59
111.60 // Up Button
111.61 - JButton upFolderButton = new JButton(getChangeToParentDirectoryAction());
111.62 - upFolderButton.setText(null);
111.63 - upFolderButton.setIcon(upFolderIcon);
111.64 - upFolderButton.setToolTipText(upFolderToolTipText);
111.65 - upFolderButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
111.66 - upFolderAccessibleName);
111.67 - upFolderButton.putClientProperty(WindowsLookAndFeel.HI_RES_DISABLED_ICON_CLIENT_KEY,
111.68 - Boolean.TRUE);
111.69 - upFolderButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
111.70 - upFolderButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
111.71 - upFolderButton.setMargin(shrinkwrap);
111.72 - upFolderButton.setFocusPainted(false);
111.73 + JButton upFolderButton = createToolButton(getChangeToParentDirectoryAction(), upFolderIcon,
111.74 + upFolderToolTipText, upFolderAccessibleName);
111.75 topPanel.add(upFolderButton);
111.76 - if (OS_VERSION.compareTo(OSInfo.WINDOWS_ME) < 0) {
111.77 - topPanel.add(Box.createRigidArea(hstrut10));
111.78 - }
111.79 -
111.80 - JButton b;
111.81 -
111.82 - if (OS_VERSION == OSInfo.WINDOWS_98) {
111.83 - // Desktop Button
111.84 - File homeDir = fsv.getHomeDirectory();
111.85 - String toolTipText = homeFolderToolTipText;
111.86 - if (fsv.isRoot(homeDir)) {
111.87 - toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop".
111.88 - }
111.89 - b = new JButton(getFileView(fc).getIcon(homeDir));
111.90 - b.setToolTipText(toolTipText);
111.91 - b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
111.92 - toolTipText);
111.93 - b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
111.94 - b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
111.95 - b.setMargin(shrinkwrap);
111.96 - b.setFocusPainted(false);
111.97 - b.addActionListener(getGoHomeAction());
111.98 - topPanel.add(b);
111.99 - topPanel.add(Box.createRigidArea(hstrut10));
111.100 - }
111.101
111.102 // New Directory Button
111.103 if (!UIManager.getBoolean("FileChooser.readOnly")) {
111.104 - b = new JButton(filePane.getNewFolderAction());
111.105 - b.setText(null);
111.106 - b.setIcon(newFolderIcon);
111.107 - b.setToolTipText(newFolderToolTipText);
111.108 - b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
111.109 - newFolderAccessibleName);
111.110 - b.putClientProperty(WindowsLookAndFeel.HI_RES_DISABLED_ICON_CLIENT_KEY,
111.111 - Boolean.TRUE);
111.112 - b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
111.113 - b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
111.114 - b.setMargin(shrinkwrap);
111.115 - b.setFocusPainted(false);
111.116 - topPanel.add(b);
111.117 + JButton newFolderButton = createToolButton(filePane.getNewFolderAction(), newFolderIcon,
111.118 + newFolderToolTipText, newFolderAccessibleName);
111.119 + topPanel.add(newFolderButton);
111.120 }
111.121 - if (OS_VERSION.compareTo(OSInfo.WINDOWS_ME) < 0) {
111.122 - topPanel.add(Box.createRigidArea(hstrut10));
111.123
111.124 - // View button group
111.125 - ButtonGroup viewButtonGroup = new ButtonGroup();
111.126 + // View button group
111.127 + ButtonGroup viewButtonGroup = new ButtonGroup();
111.128
111.129 - // List Button
111.130 - final JToggleButton listViewButton = new JToggleButton(listViewIcon);
111.131 - listViewButton.setToolTipText(listViewButtonToolTipText);
111.132 - listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
111.133 - listViewButtonAccessibleName);
111.134 - listViewButton.putClientProperty(WindowsLookAndFeel.HI_RES_DISABLED_ICON_CLIENT_KEY,
111.135 - Boolean.TRUE);
111.136 - listViewButton.setFocusPainted(false);
111.137 - listViewButton.setSelected(true);
111.138 - listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
111.139 - listViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
111.140 - listViewButton.setMargin(shrinkwrap);
111.141 - listViewButton.addActionListener(filePane.getViewTypeAction(FilePane.VIEWTYPE_LIST));
111.142 - topPanel.add(listViewButton);
111.143 - viewButtonGroup.add(listViewButton);
111.144 + // Popup Menu
111.145 + final JPopupMenu viewTypePopupMenu = new JPopupMenu();
111.146
111.147 - // Details Button
111.148 - final JToggleButton detailsViewButton = new JToggleButton(detailsViewIcon);
111.149 - detailsViewButton.setToolTipText(detailsViewButtonToolTipText);
111.150 - detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
111.151 - detailsViewButtonAccessibleName);
111.152 - detailsViewButton.putClientProperty(WindowsLookAndFeel.HI_RES_DISABLED_ICON_CLIENT_KEY,
111.153 - Boolean.TRUE);
111.154 - detailsViewButton.setFocusPainted(false);
111.155 - detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
111.156 - detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
111.157 - detailsViewButton.setMargin(shrinkwrap);
111.158 - detailsViewButton.addActionListener(filePane.getViewTypeAction(FilePane.VIEWTYPE_DETAILS));
111.159 - topPanel.add(detailsViewButton);
111.160 - viewButtonGroup.add(detailsViewButton);
111.161 + final JRadioButtonMenuItem listViewMenuItem = new JRadioButtonMenuItem(
111.162 + filePane.getViewTypeAction(FilePane.VIEWTYPE_LIST));
111.163 + listViewMenuItem.setSelected(filePane.getViewType() == FilePane.VIEWTYPE_LIST);
111.164 + viewTypePopupMenu.add(listViewMenuItem);
111.165 + viewButtonGroup.add(listViewMenuItem);
111.166
111.167 - topPanel.add(Box.createRigidArea(new Dimension(60, 0)));
111.168 + final JRadioButtonMenuItem detailsViewMenuItem = new JRadioButtonMenuItem(
111.169 + filePane.getViewTypeAction(FilePane.VIEWTYPE_DETAILS));
111.170 + detailsViewMenuItem.setSelected(filePane.getViewType() == FilePane.VIEWTYPE_DETAILS);
111.171 + viewTypePopupMenu.add(detailsViewMenuItem);
111.172 + viewButtonGroup.add(detailsViewMenuItem);
111.173
111.174 - filePane.addPropertyChangeListener(new PropertyChangeListener() {
111.175 - public void propertyChange(PropertyChangeEvent e) {
111.176 - if ("viewType".equals(e.getPropertyName())) {
111.177 - int viewType = filePane.getViewType();
111.178 + // Create icon for viewMenuButton
111.179 + BufferedImage image = new BufferedImage(viewMenuIcon.getIconWidth() + 7, viewMenuIcon.getIconHeight(),
111.180 + BufferedImage.TYPE_INT_ARGB);
111.181 + Graphics graphics = image.getGraphics();
111.182 + viewMenuIcon.paintIcon(filePane, graphics, 0, 0);
111.183 + int x = image.getWidth() - 5;
111.184 + int y = image.getHeight() / 2 - 1;
111.185 + graphics.setColor(Color.BLACK);
111.186 + graphics.fillPolygon(new int[]{x, x + 5, x + 2}, new int[]{y, y, y + 3}, 3);
111.187
111.188 - switch (viewType) {
111.189 - case FilePane.VIEWTYPE_LIST:
111.190 - listViewButton.setSelected(true);
111.191 - break;
111.192 + // Details Button
111.193 + final JButton viewMenuButton = createToolButton(null, new ImageIcon(image), viewMenuButtonToolTipText,
111.194 + viewMenuButtonAccessibleName);
111.195
111.196 - case FilePane.VIEWTYPE_DETAILS:
111.197 - detailsViewButton.setSelected(true);
111.198 - break;
111.199 - }
111.200 + viewMenuButton.addMouseListener(new MouseAdapter() {
111.201 + public void mousePressed(MouseEvent e) {
111.202 + if (SwingUtilities.isLeftMouseButton(e) && !viewMenuButton.isSelected()) {
111.203 + viewMenuButton.setSelected(true);
111.204 +
111.205 + viewTypePopupMenu.show(viewMenuButton, 0, viewMenuButton.getHeight());
111.206 + }
111.207 + }
111.208 + });
111.209 + viewMenuButton.addKeyListener(new KeyAdapter() {
111.210 + public void keyPressed(KeyEvent e) {
111.211 + // Forbid keyboard actions if the button is not in rollover state
111.212 + if (e.getKeyCode() == KeyEvent.VK_SPACE && viewMenuButton.getModel().isRollover()) {
111.213 + viewMenuButton.setSelected(true);
111.214 +
111.215 + viewTypePopupMenu.show(viewMenuButton, 0, viewMenuButton.getHeight());
111.216 + }
111.217 + }
111.218 + });
111.219 + viewTypePopupMenu.addPopupMenuListener(new PopupMenuListener() {
111.220 + public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
111.221 + }
111.222 +
111.223 + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
111.224 + SwingUtilities.invokeLater(new Runnable() {
111.225 + public void run() {
111.226 + viewMenuButton.setSelected(false);
111.227 + }
111.228 + });
111.229 + }
111.230 +
111.231 + public void popupMenuCanceled(PopupMenuEvent e) {
111.232 + }
111.233 + });
111.234 +
111.235 + topPanel.add(viewMenuButton);
111.236 +
111.237 + topPanel.add(Box.createRigidArea(new Dimension(80, 0)));
111.238 +
111.239 + filePane.addPropertyChangeListener(new PropertyChangeListener() {
111.240 + public void propertyChange(PropertyChangeEvent e) {
111.241 + if ("viewType".equals(e.getPropertyName())) {
111.242 + switch (filePane.getViewType()) {
111.243 + case FilePane.VIEWTYPE_LIST:
111.244 + listViewMenuItem.setSelected(true);
111.245 + break;
111.246 +
111.247 + case FilePane.VIEWTYPE_DETAILS:
111.248 + detailsViewMenuItem.setSelected(true);
111.249 + break;
111.250 }
111.251 }
111.252 - });
111.253 - } else { // After Windows Me
111.254 - // View button group
111.255 - ButtonGroup viewButtonGroup = new ButtonGroup();
111.256 -
111.257 - // Popup Menu
111.258 - final JPopupMenu viewTypePopupMenu = new JPopupMenu();
111.259 -
111.260 - final JRadioButtonMenuItem listViewMenuItem = new JRadioButtonMenuItem(
111.261 - filePane.getViewTypeAction(FilePane.VIEWTYPE_LIST));
111.262 - listViewMenuItem.setSelected(filePane.getViewType() == FilePane.VIEWTYPE_LIST);
111.263 - viewTypePopupMenu.add(listViewMenuItem);
111.264 - viewButtonGroup.add(listViewMenuItem);
111.265 -
111.266 - final JRadioButtonMenuItem detailsViewMenuItem = new JRadioButtonMenuItem(
111.267 - filePane.getViewTypeAction(FilePane.VIEWTYPE_DETAILS));
111.268 - detailsViewMenuItem.setSelected(filePane.getViewType() == FilePane.VIEWTYPE_DETAILS);
111.269 - viewTypePopupMenu.add(detailsViewMenuItem);
111.270 - viewButtonGroup.add(detailsViewMenuItem);
111.271 -
111.272 - // Create icon for viewMenuButton
111.273 - BufferedImage image = new BufferedImage(viewMenuIcon.getIconWidth() + 7, viewMenuIcon.getIconHeight(),
111.274 - BufferedImage.TYPE_INT_ARGB);
111.275 - Graphics graphics = image.getGraphics();
111.276 - viewMenuIcon.paintIcon(filePane, graphics, 0, 0);
111.277 - int x = image.getWidth() - 5;
111.278 - int y = image.getHeight() / 2 - 1;
111.279 - graphics.setColor(Color.BLACK);
111.280 - graphics.fillPolygon(new int[]{x, x + 5, x + 2}, new int[]{y, y, y + 3}, 3);
111.281 -
111.282 - // Details Button
111.283 - final JButton viewMenuButton = new JButton(new ImageIcon(image));
111.284 - viewMenuButton.setToolTipText(viewMenuButtonToolTipText);
111.285 - viewMenuButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, viewMenuButtonAccessibleName);
111.286 - viewMenuButton.putClientProperty(WindowsLookAndFeel.HI_RES_DISABLED_ICON_CLIENT_KEY, Boolean.TRUE);
111.287 - viewMenuButton.setFocusable(false);
111.288 - viewMenuButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
111.289 - viewMenuButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
111.290 - viewMenuButton.setMargin(shrinkwrap);
111.291 - viewMenuButton.setModel(new DefaultButtonModel() {
111.292 - public void setPressed(boolean b) {
111.293 - }
111.294 -
111.295 - public void setArmed(boolean b) {
111.296 - }
111.297 -
111.298 - public void setSelected(boolean b) {
111.299 - super.setSelected(b);
111.300 -
111.301 - if (b) {
111.302 - stateMask |= PRESSED | ARMED;
111.303 - } else {
111.304 - stateMask &= ~(PRESSED | ARMED);
111.305 - }
111.306 - }
111.307 - });
111.308 - viewMenuButton.addMouseListener(new MouseAdapter() {
111.309 - public void mousePressed(MouseEvent e) {
111.310 - if (SwingUtilities.isLeftMouseButton(e)) {
111.311 - viewMenuButton.setSelected(!viewMenuButton.isSelected());
111.312 -
111.313 - if (viewMenuButton.isSelected()) {
111.314 - viewTypePopupMenu.show(viewMenuButton, 0, viewMenuButton.getHeight());
111.315 - }
111.316 - }
111.317 - }
111.318 - });
111.319 - viewTypePopupMenu.addPopupMenuListener(new PopupMenuListener() {
111.320 - public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
111.321 - }
111.322 -
111.323 - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
111.324 - SwingUtilities.invokeLater(new Runnable() {
111.325 - public void run() {
111.326 - viewMenuButton.setSelected(false);
111.327 - }
111.328 - });
111.329 - }
111.330 -
111.331 - public void popupMenuCanceled(PopupMenuEvent e) {
111.332 - }
111.333 - });
111.334 - topPanel.add(viewMenuButton);
111.335 -
111.336 - topPanel.add(Box.createRigidArea(new Dimension(80, 0)));
111.337 -
111.338 - filePane.addPropertyChangeListener(new PropertyChangeListener() {
111.339 - public void propertyChange(PropertyChangeEvent e) {
111.340 - if ("viewType".equals(e.getPropertyName())) {
111.341 - switch (filePane.getViewType()) {
111.342 - case FilePane.VIEWTYPE_LIST:
111.343 - listViewMenuItem.setSelected(true);
111.344 - break;
111.345 -
111.346 - case FilePane.VIEWTYPE_DETAILS:
111.347 - detailsViewMenuItem.setSelected(true);
111.348 - break;
111.349 - }
111.350 - }
111.351 - }
111.352 - });
111.353 - }
111.354 + }
111.355 + });
111.356
111.357 // ************************************** //
111.358 // ******* Add the directory pane ******* //
111.359 @@ -622,19 +493,18 @@
111.360 // Decide whether to use the ShellFolder class to populate shortcut
111.361 // panel and combobox.
111.362 JFileChooser fc = getFileChooser();
111.363 - if (OS_VERSION.compareTo(OSInfo.WINDOWS_ME) >= 0) {
111.364 - if (FilePane.usesShellFolder(fc)) {
111.365 - if (placesBar == null && !UIManager.getBoolean("FileChooser.noPlacesBar")) {
111.366 - placesBar = new WindowsPlacesBar(fc, XPStyle.getXP() != null);
111.367 - fc.add(placesBar, BorderLayout.BEFORE_LINE_BEGINS);
111.368 - fc.addPropertyChangeListener(placesBar);
111.369 - }
111.370 - } else {
111.371 - if (placesBar != null) {
111.372 - fc.remove(placesBar);
111.373 - fc.removePropertyChangeListener(placesBar);
111.374 - placesBar = null;
111.375 - }
111.376 +
111.377 + if (FilePane.usesShellFolder(fc)) {
111.378 + if (placesBar == null && !UIManager.getBoolean("FileChooser.noPlacesBar")) {
111.379 + placesBar = new WindowsPlacesBar(fc, XPStyle.getXP() != null);
111.380 + fc.add(placesBar, BorderLayout.BEFORE_LINE_BEGINS);
111.381 + fc.addPropertyChangeListener(placesBar);
111.382 + }
111.383 + } else {
111.384 + if (placesBar != null) {
111.385 + fc.remove(placesBar);
111.386 + fc.removePropertyChangeListener(placesBar);
111.387 + placesBar = null;
111.388 }
111.389 }
111.390 }
111.391 @@ -673,18 +543,9 @@
111.392 upFolderToolTipText = UIManager.getString("FileChooser.upFolderToolTipText",l);
111.393 upFolderAccessibleName = UIManager.getString("FileChooser.upFolderAccessibleName",l);
111.394
111.395 - homeFolderToolTipText = UIManager.getString("FileChooser.homeFolderToolTipText",l);
111.396 - homeFolderAccessibleName = UIManager.getString("FileChooser.homeFolderAccessibleName",l);
111.397 -
111.398 newFolderToolTipText = UIManager.getString("FileChooser.newFolderToolTipText",l);
111.399 newFolderAccessibleName = UIManager.getString("FileChooser.newFolderAccessibleName",l);
111.400
111.401 - listViewButtonToolTipText = UIManager.getString("FileChooser.listViewButtonToolTipText",l);
111.402 - listViewButtonAccessibleName = UIManager.getString("FileChooser.listViewButtonAccessibleName",l);
111.403 -
111.404 - detailsViewButtonToolTipText = UIManager.getString("FileChooser.detailsViewButtonToolTipText",l);
111.405 - detailsViewButtonAccessibleName = UIManager.getString("FileChooser.detailsViewButtonAccessibleName",l);
111.406 -
111.407 viewMenuButtonToolTipText = UIManager.getString("FileChooser.viewMenuButtonToolTipText",l);
111.408 viewMenuButtonAccessibleName = UIManager.getString("FileChooser.viewMenuButtonAccessibleName",l);
111.409 }
111.410 @@ -1052,6 +913,65 @@
111.411 return new DirectoryComboBoxRenderer();
111.412 }
111.413
111.414 + private static JButton createToolButton(Action a, Icon defaultIcon, String toolTipText, String accessibleName) {
111.415 + final JButton result = new JButton(a);
111.416 +
111.417 + result.setText(null);
111.418 + result.setIcon(defaultIcon);
111.419 + result.setToolTipText(toolTipText);
111.420 + result.setRequestFocusEnabled(false);
111.421 + result.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, accessibleName);
111.422 + result.putClientProperty(WindowsLookAndFeel.HI_RES_DISABLED_ICON_CLIENT_KEY, Boolean.TRUE);
111.423 + result.setAlignmentX(JComponent.LEFT_ALIGNMENT);
111.424 + result.setAlignmentY(JComponent.CENTER_ALIGNMENT);
111.425 + result.setMargin(shrinkwrap);
111.426 + result.setFocusPainted(false);
111.427 +
111.428 + result.setModel(new DefaultButtonModel() {
111.429 + public void setPressed(boolean b) {
111.430 + // Forbid keyboard actions if the button is not in rollover state
111.431 + if (!b || isRollover()) {
111.432 + super.setPressed(b);
111.433 + }
111.434 + }
111.435 +
111.436 + public void setRollover(boolean b) {
111.437 + if (b && !isRollover()) {
111.438 + // Reset other buttons
111.439 + for (Component component : result.getParent().getComponents()) {
111.440 + if (component instanceof JButton && component != result) {
111.441 + ((JButton) component).getModel().setRollover(false);
111.442 + }
111.443 + }
111.444 + }
111.445 +
111.446 + super.setRollover(b);
111.447 + }
111.448 +
111.449 + public void setSelected(boolean b) {
111.450 + super.setSelected(b);
111.451 +
111.452 + if (b) {
111.453 + stateMask |= PRESSED | ARMED;
111.454 + } else {
111.455 + stateMask &= ~(PRESSED | ARMED);
111.456 + }
111.457 + }
111.458 + });
111.459 +
111.460 + result.addFocusListener(new FocusAdapter() {
111.461 + public void focusGained(FocusEvent e) {
111.462 + result.getModel().setRollover(true);
111.463 + }
111.464 +
111.465 + public void focusLost(FocusEvent e) {
111.466 + result.getModel().setRollover(false);
111.467 + }
111.468 + });
111.469 +
111.470 + return result;
111.471 + }
111.472 +
111.473 //
111.474 // Renderer for DirectoryComboBox
111.475 //
112.1 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Sun Sep 06 23:14:42 2009 -0700
112.2 +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Tue Sep 15 23:41:40 2009 -0700
112.3 @@ -1,5 +1,5 @@
112.4 /*
112.5 - * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
112.6 + * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
112.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
112.8 *
112.9 * This code is free software; you can redistribute it and/or modify it
112.10 @@ -104,7 +104,6 @@
112.11 new StringUIClientPropertyKey(
112.12 "WindowsLookAndFeel.generateHiResDisabledIcon");
112.13
112.14 - private Toolkit toolkit;
112.15 private boolean updatePending = false;
112.16
112.17 private boolean useSystemFontSettings = true;
112.18 @@ -149,7 +148,6 @@
112.19
112.20 public void initialize() {
112.21 super.initialize();
112.22 - toolkit = Toolkit.getDefaultToolkit();
112.23
112.24 // Set the flag which determines which version of Windows should
112.25 // be rendered. This flag only need to be set once.
112.26 @@ -470,80 +468,61 @@
112.27
112.28 Object ControlBackgroundColor = new DesktopProperty(
112.29 "win.3d.backgroundColor",
112.30 - table.get("control"),
112.31 - toolkit);
112.32 + table.get("control"));
112.33 Object ControlLightColor = new DesktopProperty(
112.34 "win.3d.lightColor",
112.35 - table.get("controlHighlight"),
112.36 - toolkit);
112.37 + table.get("controlHighlight"));
112.38 Object ControlHighlightColor = new DesktopProperty(
112.39 "win.3d.highlightColor",
112.40 - table.get("controlLtHighlight"),
112.41 - toolkit);
112.42 + table.get("controlLtHighlight"));
112.43 Object ControlShadowColor = new DesktopProperty(
112.44 "win.3d.shadowColor",
112.45 - table.get("controlShadow"),
112.46 - toolkit);
112.47 + table.get("controlShadow"));
112.48 Object ControlDarkShadowColor = new DesktopProperty(
112.49 "win.3d.darkShadowColor",
112.50 - table.get("controlDkShadow"),
112.51 - toolkit);
112.52 + table.get("controlDkShadow"));
112.53 Object ControlTextColor = new DesktopProperty(
112.54 "win.button.textColor",
112.55 - table.get("controlText"),
112.56 - toolkit);
112.57 + table.get("controlText"));
112.58 Object MenuBackgroundColor = new DesktopProperty(
112.59 "win.menu.backgroundColor",
112.60 - table.get("menu"),
112.61 - toolkit);
112.62 + table.get("menu"));
112.63 Object MenuBarBackgroundColor = new DesktopProperty(
112.64 "win.menubar.backgroundColor",
112.65 - table.get("menu"),
112.66 - toolkit);
112.67 + table.get("menu"));
112.68 Object MenuTextColor = new DesktopProperty(
112.69 "win.menu.textColor",
112.70 - table.get("menuText"),
112.71 - toolkit);
112.72 + table.get("menuText"));
112.73 Object SelectionBackgroundColor = new DesktopProperty(
112.74 "win.item.highlightColor",
112.75 - table.get("textHighlight"),
112.76 - toolkit);
112.77 + table.get("textHighlight"));
112.78 Object SelectionTextColor = new DesktopProperty(
112.79 "win.item.highlightTextColor",
112.80 - table.get("textHighlightText"),
112.81 - toolkit);
112.82 + table.get("textHighlightText"));
112.83 Object WindowBackgroundColor = new DesktopProperty(
112.84 "win.frame.backgroundColor",
112.85 - table.get("window"),
112.86 - toolkit);
112.87 + table.get("window"));
112.88 Object WindowTextColor = new DesktopProperty(
112.89 "win.frame.textColor",
112.90 - table.get("windowText"),
112.91 - toolkit);
112.92 + table.get("windowText"));
112.93 Object WindowBorderWidth = new DesktopProperty(
112.94 "win.frame.sizingBorderWidth",
112.95 - Integer.valueOf(1),
112.96 - toolkit);
112.97 + Integer.valueOf(1));
112.98 Object TitlePaneHeight = new DesktopProperty(
112.99 "win.frame.captionHeight",
112.100 - Integer.valueOf(18),
112.101 - toolkit);
112.102 + Integer.valueOf(18));
112.103 Object TitleButtonWidth = new DesktopProperty(
112.104 "win.frame.captionButtonWidth",
112.105 - Integer.valueOf(16),
112.106 - toolkit);
112.107 + Integer.valueOf(16));
112.108 Object TitleButtonHeight = new DesktopProperty(
112.109 "win.frame.captionButtonHeight",
112.110 - Integer.valueOf(16),
112.111 - toolkit);
112.112 + Integer.valueOf(16));
112.113 Object InactiveTextColor = new DesktopProperty(
112.114 "win.text.grayedTextColor",
112.115 - table.get("textInactiveText"),
112.116 - toolkit);
112.117 + table.get("textInactiveText"));
112.118 Object ScrollbarBackgroundColor = new DesktopProperty(
112.119 "win.scrollbar.backgroundColor",
112.120 - table.get("scrollbar"),
112.121 - toolkit);
112.122 + table.get("scrollbar"));
112.123
112.124 Object TextBackground = new XPColorValue(Part.EP_EDIT, null, Prop.FILLCOLOR,
112.125 WindowBackgroundColor);
112.126 @@ -566,32 +545,22 @@
112.127 Object ToolTipFont = sansSerifPlain12;
112.128 Object IconFont = ControlFont;
112.129
112.130 - Object scrollBarWidth = new DesktopProperty("win.scrollbar.width",
112.131 - Integer.valueOf(16), toolkit);
112.132 + Object scrollBarWidth = new DesktopProperty("win.scrollbar.width", Integer.valueOf(16));
112.133
112.134 - Object menuBarHeight = new DesktopProperty("win.menu.height",
112.135 - null, toolkit);
112.136 + Object menuBarHeight = new DesktopProperty("win.menu.height", null);
112.137
112.138 - Object hotTrackingOn = new DesktopProperty("win.item.hotTrackingOn",
112.139 - true, toolkit);
112.140 + Object hotTrackingOn = new DesktopProperty("win.item.hotTrackingOn", true);
112.141
112.142 - Object showMnemonics = new DesktopProperty("win.menu.keyboardCuesOn",
112.143 - Boolean.TRUE, toolkit);
112.144 + Object showMnemonics = new DesktopProperty("win.menu.keyboardCuesOn", Boolean.TRUE);
112.145
112.146 if (useSystemFontSettings) {
112.147 - MenuFont = getDesktopFontValue("win.menu.font", MenuFont, toolkit);
112.148 - FixedControlFont = getDesktopFontValue("win.ansiFixed.font",
112.149 - FixedControlFont, toolkit);
112.150 - ControlFont = getDesktopFontValue("win.defaultGUI.font",
112.151 - ControlFont, toolkit);
112.152 - MessageFont = getDesktopFontValue("win.messagebox.font",
112.153 - MessageFont, toolkit);
112.154 - WindowFont = getDesktopFontValue("win.frame.captionFont",
112.155 - WindowFont, toolkit);
112.156 - IconFont = getDesktopFontValue("win.icon.font",
112.157 - IconFont, toolkit);
112.158 - ToolTipFont = getDesktopFontValue("win.tooltip.font", ToolTipFont,
112.159 - toolkit);
112.160 + MenuFont = getDesktopFontValue("win.menu.font", MenuFont);
112.161 + FixedControlFont = getDesktopFontValue("win.ansiFixed.font", FixedControlFont);
112.162 + ControlFont = getDesktopFontValue("win.defaultGUI.font", ControlFont);
112.163 + MessageFont = getDesktopFontValue("win.messagebox.font", MessageFont);
112.164 + WindowFont = getDesktopFontValue("win.frame.captionFont", WindowFont);
112.165 + IconFont = getDesktopFontValue("win.icon.font", IconFont);
112.166 + ToolTipFont = getDesktopFontValue("win.tooltip.font", ToolTipFont);
112.167
112.168 /* Put the desktop AA settings in the defaults.
112.169 * JComponent.setUI() retrieves this and makes it available
112.170 @@ -605,26 +574,14 @@
112.171 new FontDesktopProperty(SunToolkit.DESKTOPFONTHINTS);
112.172 }
112.173 if (useSystemFontSizeSettings) {
112.174 - MenuFont = new WindowsFontSizeProperty("win.menu.font.height",
112.175 - toolkit, Font.DIALOG, Font.PLAIN, 12);
112.176 - FixedControlFont = new WindowsFontSizeProperty(
112.177 - "win.ansiFixed.font.height", toolkit, Font.MONOSPACED,
112.178 + MenuFont = new WindowsFontSizeProperty("win.menu.font.height", Font.DIALOG, Font.PLAIN, 12);
112.179 + FixedControlFont = new WindowsFontSizeProperty("win.ansiFixed.font.height", Font.MONOSPACED,
112.180 Font.PLAIN, 12);
112.181 - ControlFont = new WindowsFontSizeProperty(
112.182 - "win.defaultGUI.font.height", toolkit, Font.DIALOG,
112.183 - Font.PLAIN, 12);
112.184 - MessageFont = new WindowsFontSizeProperty(
112.185 - "win.messagebox.font.height",
112.186 - toolkit, Font.DIALOG, Font.PLAIN, 12);
112.187 - WindowFont = new WindowsFontSizeProperty(
112.188 - "win.frame.captionFont.height", toolkit,
112.189 - Font.DIALOG, Font.BOLD, 12);
112.190 - ToolTipFont = new WindowsFontSizeProperty(
112.191 - "win.tooltip.font.height", toolkit, Font.SANS_SERIF,
112.192 - Font.PLAIN, 12);
112.193 - IconFont = new WindowsFontSizeProperty(
112.194 - "win.icon.font.height", toolkit, Font.DIALOG,
112.195 - Font.PLAIN, 12);
112.196 + ControlFont = new WindowsFontSizeProperty("win.defaultGUI.font.height", Font.DIALOG, Font.PLAIN, 12);
112.197 + MessageFont = new WindowsFontSizeProperty("win.messagebox.font.height", Font.DIALOG, Font.PLAIN, 12);
112.198 + WindowFont = new WindowsFontSizeProperty("win.frame.captionFont.height", Font.DIALOG, Font.BOLD, 12);
112.199 + ToolTipFont = new WindowsFontSizeProperty("win.tooltip.font.height", Font.SANS_SERIF, Font.PLAIN, 12);
112.200 + IconFont = new WindowsFontSizeProperty("win.icon.font.height", Font.DIALOG, Font.PLAIN, 12);
112.201 }
112.202
112.203
112.204 @@ -752,8 +709,7 @@
112.205 // DeskTop.
112.206 "Desktop.background", new DesktopProperty(
112.207 "win.desktop.backgroundColor",
112.208 - table.get("desktop"),
112.209 - toolkit),
112.210 + table.get("desktop")),
112.211 "Desktop.ancestorInputMap",
112.212 new UIDefaults.LazyInputMap(new Object[] {
112.213 "ctrl F5", "restore",
112.214 @@ -819,7 +775,7 @@
112.215 "FileChooser.filesOfTypeLabelMnemonic", Integer.valueOf(KeyEvent.VK_T),
112.216 "FileChooser.usesSingleFilePane", Boolean.TRUE,
112.217 "FileChooser.noPlacesBar", new DesktopProperty("win.comdlg.noPlacesBar",
112.218 - Boolean.FALSE, toolkit),
112.219 + Boolean.FALSE),
112.220 "FileChooser.ancestorInputMap",
112.221 new UIDefaults.LazyInputMap(new Object[] {
112.222 "ESCAPE", "cancelSelection",
112.223 @@ -861,36 +817,28 @@
112.224 "InternalFrame.resizeIconShadow", ControlShadowColor,
112.225 "InternalFrame.activeBorderColor", new DesktopProperty(
112.226 "win.frame.activeBorderColor",
112.227 - table.get("windowBorder"),
112.228 - toolkit),
112.229 + table.get("windowBorder")),
112.230 "InternalFrame.inactiveBorderColor", new DesktopProperty(
112.231 "win.frame.inactiveBorderColor",
112.232 - table.get("windowBorder"),
112.233 - toolkit),
112.234 + table.get("windowBorder")),
112.235 "InternalFrame.activeTitleBackground", new DesktopProperty(
112.236 "win.frame.activeCaptionColor",
112.237 - table.get("activeCaption"),
112.238 - toolkit),
112.239 + table.get("activeCaption")),
112.240 "InternalFrame.activeTitleGradient", new DesktopProperty(
112.241 "win.frame.activeCaptionGradientColor",
112.242 - table.get("activeCaption"),
112.243 - toolkit),
112.244 + table.get("activeCaption")),
112.245 "InternalFrame.activeTitleForeground", new DesktopProperty(
112.246 "win.frame.captionTextColor",
112.247 - table.get("activeCaptionText"),
112.248 - toolkit),
112.249 + table.get("activeCaptionText")),
112.250 "InternalFrame.inactiveTitleBackground", new DesktopProperty(
112.251 "win.frame.inactiveCaptionColor",
112.252 - table.get("inactiveCaption"),
112.253 - toolkit),
112.254 + table.get("inactiveCaption")),
112.255 "InternalFrame.inactiveTitleGradient", new DesktopProperty(
112.256 "win.frame.inactiveCaptionGradientColor",
112.257 - table.get("inactiveCaption"),
112.258 - toolkit),
112.259 + table.get("inactiveCaption")),
112.260 "InternalFrame.inactiveTitleForeground", new DesktopProperty(
112.261 "win.frame.inactiveCaptionTextColor",
112.262 - table.get("inactiveCaptionText"),
112.263 - toolkit),
112.264 + table.get("inactiveCaptionText")),
112.265
112.266 "InternalFrame.maximizeIcon",
112.267 WindowsIconFactory.createFrameMaximizeIcon(),
112.268 @@ -1529,12 +1477,8 @@
112.269
112.270 // *** ToolTip
112.271 "ToolTip.font", ToolTipFont,
112.272 - "ToolTip.background", new DesktopProperty(
112.273 - "win.tooltip.backgroundColor",
112.274 - table.get("info"), toolkit),
112.275 - "ToolTip.foreground", new DesktopProperty(
112.276 - "win.tooltip.textColor",
112.277 - table.get("infoText"), toolkit),
112.278 + "ToolTip.background", new DesktopProperty("win.tooltip.backgroundColor", table.get("info")),
112.279 + "ToolTip.foreground", new DesktopProperty("win.tooltip.textColor", table.get("infoText")),
112.280
112.281 // *** ToolTipManager
112.282 "ToolTipManager.enableToolTipMode", "activeApplication",
112.283 @@ -1798,10 +1742,9 @@
112.284 * represented in the current encoding this will return null and
112.285 * turn off the use of system fonts.
112.286 */
112.287 - private Object getDesktopFontValue(String fontName, Object backup,
112.288 - Toolkit kit) {
112.289 + private Object getDesktopFontValue(String fontName, Object backup) {
112.290 if (useSystemFontSettings) {
112.291 - return new WindowsFontProperty(fontName, backup, kit);
112.292 + return new WindowsFontProperty(fontName, backup);
112.293 }
112.294 return null;
112.295 }
112.296 @@ -1989,7 +1932,6 @@
112.297
112.298 public void uninitialize() {
112.299 super.uninitialize();
112.300 - toolkit = null;
112.301
112.302 if (WindowsPopupMenuUI.mnemonicListener != null) {
112.303 MenuSelectionManager.defaultManager().
112.304 @@ -2309,8 +2251,8 @@
112.305 * is returned, it is mapped to 'Microsoft Sans Serif'.
112.306 */
112.307 private static class WindowsFontProperty extends DesktopProperty {
112.308 - WindowsFontProperty(String key, Object backup, Toolkit kit) {
112.309 - super(key, backup, kit);
112.310 + WindowsFontProperty(String key, Object backup) {
112.311 + super(key, backup);
112.312 }
112.313
112.314 public void invalidate(LookAndFeel laf) {
112.315 @@ -2372,9 +2314,9 @@
112.316 private int fontSize;
112.317 private int fontStyle;
112.318
112.319 - WindowsFontSizeProperty(String key, Toolkit toolkit, String fontName,
112.320 + WindowsFontSizeProperty(String key, String fontName,
112.321 int fontStyle, int fontSize) {
112.322 - super(key, null, toolkit);
112.323 + super(key, null);
112.324 this.fontName = fontName;
112.325 this.fontSize = fontSize;
112.326 this.fontStyle = fontStyle;
112.327 @@ -2508,7 +2450,7 @@
112.328
112.329 private class TriggerDesktopProperty extends DesktopProperty {
112.330 TriggerDesktopProperty(String key) {
112.331 - super(key, null, toolkit);
112.332 + super(key, null);
112.333 // This call adds a property change listener for the property,
112.334 // which triggers a call to updateUI(). The value returned
112.335 // is not interesting here.
113.1 --- a/src/share/classes/java/awt/Component.java Sun Sep 06 23:14:42 2009 -0700
113.2 +++ b/src/share/classes/java/awt/Component.java Tue Sep 15 23:41:40 2009 -0700
113.3 @@ -6665,6 +6665,9 @@
113.4 Container parent = this.parent;
113.5 if (parent != null && parent.peer instanceof LightweightPeer) {
113.6 relocateComponent();
113.7 + if (!isRecursivelyVisible()) {
113.8 + peer.setVisible(false);
113.9 + }
113.10 }
113.11 }
113.12 invalidate();
113.13 @@ -9572,6 +9575,13 @@
113.14 return comp.getPeer();
113.15 }
113.16 }
113.17 + // traversing the hierarchy up to the closest HW container;
113.18 + // further traversing may return a component that is not actually
113.19 + // a native sibling of this component and this kind of z-order
113.20 + // request may not be allowed by the underlying system (6852051).
113.21 + if (!cont.isLightweight()) {
113.22 + break;
113.23 + }
113.24
113.25 indexAbove = cont.getSiblingIndexAbove();
113.26 cont = cont.getContainer();
114.1 --- a/src/share/classes/java/util/SimpleTimeZone.java Sun Sep 06 23:14:42 2009 -0700
114.2 +++ b/src/share/classes/java/util/SimpleTimeZone.java Tue Sep 15 23:41:40 2009 -0700
114.3 @@ -1372,7 +1372,7 @@
114.4 throw new IllegalArgumentException(
114.5 "Illegal start month " + startMonth);
114.6 }
114.7 - if (startTime < 0 || startTime >= millisPerDay) {
114.8 + if (startTime < 0 || startTime > millisPerDay) {
114.9 throw new IllegalArgumentException(
114.10 "Illegal start time " + startTime);
114.11 }
114.12 @@ -1419,7 +1419,7 @@
114.13 throw new IllegalArgumentException(
114.14 "Illegal end month " + endMonth);
114.15 }
114.16 - if (endTime < 0 || endTime >= millisPerDay) {
114.17 + if (endTime < 0 || endTime > millisPerDay) {
114.18 throw new IllegalArgumentException(
114.19 "Illegal end time " + endTime);
114.20 }
115.1 --- a/src/share/classes/javax/swing/JEditorPane.java Sun Sep 06 23:14:42 2009 -0700
115.2 +++ b/src/share/classes/javax/swing/JEditorPane.java Tue Sep 15 23:41:40 2009 -0700
115.3 @@ -24,6 +24,8 @@
115.4 */
115.5 package javax.swing;
115.6
115.7 +import sun.swing.SwingUtilities2;
115.8 +
115.9 import java.awt.*;
115.10 import java.awt.event.*;
115.11 import java.lang.reflect.*;
115.12 @@ -1123,6 +1125,7 @@
115.13 * @param content the content to replace the selection with. This
115.14 * value can be <code>null</code>
115.15 */
115.16 + @Override
115.17 public void replaceSelection(String content) {
115.18 if (! isEditable()) {
115.19 UIManager.getLookAndFeel().provideErrorFeedback(JEditorPane.this);
115.20 @@ -1133,6 +1136,7 @@
115.21 try {
115.22 Document doc = getDocument();
115.23 Caret caret = getCaret();
115.24 + boolean composedTextSaved = saveComposedText(caret.getDot());
115.25 int p0 = Math.min(caret.getDot(), caret.getMark());
115.26 int p1 = Math.max(caret.getDot(), caret.getMark());
115.27 if (doc instanceof AbstractDocument) {
115.28 @@ -1148,6 +1152,9 @@
115.29 getInputAttributes());
115.30 }
115.31 }
115.32 + if (composedTextSaved) {
115.33 + restoreComposedText();
115.34 + }
115.35 } catch (BadLocationException e) {
115.36 UIManager.getLookAndFeel().provideErrorFeedback(JEditorPane.this);
115.37 }
115.38 @@ -1323,8 +1330,8 @@
115.39 */
115.40 public Dimension getPreferredSize() {
115.41 Dimension d = super.getPreferredSize();
115.42 - if (getParent() instanceof JViewport) {
115.43 - JViewport port = (JViewport)getParent();
115.44 + JViewport port = SwingUtilities2.getViewport(this);
115.45 + if (port != null) {
115.46 TextUI ui = getUI();
115.47 int prefWidth = d.width;
115.48 int prefHeight = d.height;
115.49 @@ -1445,8 +1452,8 @@
115.50 * match its own, false otherwise
115.51 */
115.52 public boolean getScrollableTracksViewportWidth() {
115.53 - if (getParent() instanceof JViewport) {
115.54 - JViewport port = (JViewport)getParent();
115.55 + JViewport port = SwingUtilities2.getViewport(this);
115.56 + if (port != null) {
115.57 TextUI ui = getUI();
115.58 int w = port.getWidth();
115.59 Dimension min = ui.getMinimumSize(this);
115.60 @@ -1467,8 +1474,8 @@
115.61 * false otherwise
115.62 */
115.63 public boolean getScrollableTracksViewportHeight() {
115.64 - if (getParent() instanceof JViewport) {
115.65 - JViewport port = (JViewport)getParent();
115.66 + JViewport port = SwingUtilities2.getViewport(this);
115.67 + if (port != null) {
115.68 TextUI ui = getUI();
115.69 int h = port.getHeight();
115.70 Dimension min = ui.getMinimumSize(this);
116.1 --- a/src/share/classes/javax/swing/JLayer.java Sun Sep 06 23:14:42 2009 -0700
116.2 +++ b/src/share/classes/javax/swing/JLayer.java Tue Sep 15 23:41:40 2009 -0700
116.3 @@ -1,6 +1,26 @@
116.4 /*
116.5 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
116.6 - * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
116.7 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
116.8 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
116.9 + *
116.10 + * This code is free software; you can redistribute it and/or modify it
116.11 + * under the terms of the GNU General Public License version 2 only, as
116.12 + * published by the Free Software Foundation. Sun designates this
116.13 + * particular file as subject to the "Classpath" exception as provided
116.14 + * by Sun in the LICENSE file that accompanied this code.
116.15 + *
116.16 + * This code is distributed in the hope that it will be useful, but WITHOUT
116.17 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
116.18 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
116.19 + * version 2 for more details (a copy is included in the LICENSE file that
116.20 + * accompanied this code).
116.21 + *
116.22 + * You should have received a copy of the GNU General Public License version
116.23 + * 2 along with this work; if not, write to the Free Software Foundation,
116.24 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
116.25 + *
116.26 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
116.27 + * CA 95054 USA or visit www.sun.com if you need additional information or
116.28 + * have any questions.
116.29 */
116.30
116.31 package javax.swing;
116.32 @@ -158,7 +178,7 @@
116.33 * @return the {@code JLayer}'s view component
116.34 * or {@code null} if none exists
116.35 *
116.36 - * @see #setView(V)
116.37 + * @see #setView(Component)
116.38 */
116.39 public V getView() {
116.40 return view;
116.41 @@ -259,7 +279,7 @@
116.42 * @throws UnsupportedOperationException this method is not supported
116.43 *
116.44 * @see #setView(Component)
116.45 - * @see #setGlassPane(Component)
116.46 + * @see #setGlassPane(JPanel)
116.47 */
116.48 protected void addImpl(Component comp, Object constraints, int index) {
116.49 throw new UnsupportedOperationException(
116.50 @@ -319,7 +339,7 @@
116.51 * @return false if {@code JLayer}'s {@code glassPane} is visible
116.52 */
116.53 public boolean isOptimizedDrawingEnabled() {
116.54 - return !glassPane.isVisible();
116.55 + return glassPane == null || !glassPane.isVisible();
116.56 }
116.57
116.58 /**
116.59 @@ -388,7 +408,10 @@
116.60 if (layerEventMask != oldEventMask) {
116.61 disableEvents(oldEventMask);
116.62 enableEvents(eventMask);
116.63 - eventController.updateAWTEventListener(this);
116.64 + if (isDisplayable()) {
116.65 + eventController.updateAWTEventListener(
116.66 + oldEventMask, layerEventMask);
116.67 + }
116.68 }
116.69 }
116.70
116.71 @@ -475,9 +498,6 @@
116.72 if (getUI() != null) {
116.73 return getUI().getScrollableTracksViewportHeight(this);
116.74 }
116.75 - if (getParent() instanceof JViewport) {
116.76 - return ((getParent()).getHeight() > getPreferredSize().height);
116.77 - }
116.78 return false;
116.79 }
116.80
116.81 @@ -498,9 +518,6 @@
116.82 if (getUI() != null) {
116.83 return getUI().getScrollableTracksViewportWidth(this);
116.84 }
116.85 - if (getParent() instanceof JViewport) {
116.86 - return ((getParent()).getWidth() > getPreferredSize().width);
116.87 - }
116.88 return false;
116.89 }
116.90
116.91 @@ -535,20 +552,36 @@
116.92 private void readObject(ObjectInputStream s)
116.93 throws IOException, ClassNotFoundException {
116.94 s.defaultReadObject();
116.95 - if (getUI() != null) {
116.96 - setUI(getUI());
116.97 + if (layerUI != null) {
116.98 + setUI(layerUI);
116.99 }
116.100 - if (getLayerEventMask() != 0) {
116.101 - eventController.updateAWTEventListener(this);
116.102 + if (eventMask != 0) {
116.103 + eventController.updateAWTEventListener(0, eventMask);
116.104 }
116.105 }
116.106
116.107 /**
116.108 + * {@inheritDoc}
116.109 + */
116.110 + public void addNotify() {
116.111 + super.addNotify();
116.112 + eventController.updateAWTEventListener(0, eventMask);
116.113 + }
116.114 +
116.115 + /**
116.116 + * {@inheritDoc}
116.117 + */
116.118 + public void removeNotify() {
116.119 + super.removeNotify();
116.120 + eventController.updateAWTEventListener(eventMask, 0);
116.121 + }
116.122 +
116.123 + /**
116.124 * static AWTEventListener to be shared with all AbstractLayerUIs
116.125 */
116.126 private static class LayerEventController implements AWTEventListener {
116.127 - private ArrayList<WeakReference<JLayer>> layerList =
116.128 - new ArrayList<WeakReference<JLayer>>();
116.129 + private ArrayList<Long> layerMaskList =
116.130 + new ArrayList<Long>();
116.131
116.132 private long currentEventMask;
116.133
116.134 @@ -572,37 +605,24 @@
116.135 }
116.136 }
116.137
116.138 - private boolean layerListContains(JLayer l) {
116.139 - for (WeakReference<JLayer> layerWeakReference : layerList) {
116.140 - if (layerWeakReference.get() == l) {
116.141 - return true;
116.142 - }
116.143 + private void updateAWTEventListener(long oldEventMask, long newEventMask) {
116.144 + if (oldEventMask != 0) {
116.145 + layerMaskList.remove(oldEventMask);
116.146 }
116.147 - return false;
116.148 - }
116.149 -
116.150 - private void updateAWTEventListener(JLayer layer) {
116.151 - if (!layerListContains(layer) && layer.getLayerEventMask() != 0) {
116.152 - layerList.add(new WeakReference<JLayer>(layer));
116.153 + if (newEventMask != 0) {
116.154 + layerMaskList.add(newEventMask);
116.155 }
116.156 long combinedMask = 0;
116.157 - Iterator<WeakReference<JLayer>> it = layerList.iterator();
116.158 - while (it.hasNext()) {
116.159 - WeakReference<JLayer> weakRef = it.next();
116.160 - JLayer currLayer = weakRef.get();
116.161 - if (currLayer == null) {
116.162 - it.remove();
116.163 - } else {
116.164 - combinedMask |= currLayer.getLayerEventMask();
116.165 - }
116.166 + for (Long mask : layerMaskList) {
116.167 + combinedMask |= mask;
116.168 }
116.169 if (combinedMask == 0) {
116.170 removeAWTEventListener();
116.171 - layerList.clear();
116.172 } else if (getCurrentEventMask() != combinedMask) {
116.173 removeAWTEventListener();
116.174 addAWTEventListener(combinedMask);
116.175 }
116.176 + currentEventMask = combinedMask;
116.177 }
116.178
116.179 private long getCurrentEventMask() {
116.180 @@ -617,7 +637,7 @@
116.181 return null;
116.182 }
116.183 });
116.184 - currentEventMask = eventMask;
116.185 +
116.186 }
116.187
116.188 private void removeAWTEventListener() {
116.189 @@ -628,7 +648,6 @@
116.190 return null;
116.191 }
116.192 });
116.193 - currentEventMask = 0;
116.194 }
116.195
116.196 private boolean isEventEnabled(long eventMask, int id) {
116.197 @@ -785,4 +804,4 @@
116.198 public void removeLayoutComponent(Component comp) {
116.199 }
116.200 }
116.201 -}
116.202 \ No newline at end of file
116.203 +}
117.1 --- a/src/share/classes/javax/swing/JList.java Sun Sep 06 23:14:42 2009 -0700
117.2 +++ b/src/share/classes/javax/swing/JList.java Tue Sep 15 23:41:40 2009 -0700
117.3 @@ -2722,8 +2722,9 @@
117.4 getVisibleRowCount() <= 0) {
117.5 return true;
117.6 }
117.7 - if (getParent() instanceof JViewport) {
117.8 - return (getParent().getWidth() > getPreferredSize().width);
117.9 + JViewport port = SwingUtilities2.getViewport(this);
117.10 + if (port != null) {
117.11 + return port.getWidth() > getPreferredSize().width;
117.12 }
117.13 return false;
117.14 }
117.15 @@ -2747,8 +2748,9 @@
117.16 getVisibleRowCount() <= 0) {
117.17 return true;
117.18 }
117.19 - if (getParent() instanceof JViewport) {
117.20 - return (getParent().getHeight() > getPreferredSize().height);
117.21 + JViewport port = SwingUtilities2.getViewport(this);
117.22 + if (port != null) {
117.23 + return port.getHeight() > getPreferredSize().height;
117.24 }
117.25 return false;
117.26 }
118.1 --- a/src/share/classes/javax/swing/JTable.java Sun Sep 06 23:14:42 2009 -0700
118.2 +++ b/src/share/classes/javax/swing/JTable.java Tue Sep 15 23:41:40 2009 -0700
118.3 @@ -718,9 +718,9 @@
118.4 * @see #addNotify
118.5 */
118.6 protected void configureEnclosingScrollPane() {
118.7 - Container p = getParent();
118.8 - if (p instanceof JViewport) {
118.9 - Container gp = p.getParent();
118.10 + JViewport port = SwingUtilities2.getViewport(this);
118.11 + if (port != null) {
118.12 + Container gp = port.getParent();
118.13 if (gp instanceof JScrollPane) {
118.14 JScrollPane scrollPane = (JScrollPane)gp;
118.15 // Make certain we are the viewPort's view and not, for
118.16 @@ -750,9 +750,9 @@
118.17 * from configureEnclosingScrollPane() and updateUI() in a safe manor.
118.18 */
118.19 private void configureEnclosingScrollPaneUI() {
118.20 - Container p = getParent();
118.21 - if (p instanceof JViewport) {
118.22 - Container gp = p.getParent();
118.23 + JViewport port = SwingUtilities2.getViewport(this);
118.24 + if (port != null) {
118.25 + Container gp = port.getParent();
118.26 if (gp instanceof JScrollPane) {
118.27 JScrollPane scrollPane = (JScrollPane)gp;
118.28 // Make certain we are the viewPort's view and not, for
118.29 @@ -819,9 +819,9 @@
118.30 * @since 1.3
118.31 */
118.32 protected void unconfigureEnclosingScrollPane() {
118.33 - Container p = getParent();
118.34 - if (p instanceof JViewport) {
118.35 - Container gp = p.getParent();
118.36 + JViewport port = SwingUtilities2.getViewport(this);
118.37 + if (port != null) {
118.38 + Container gp = port.getParent();
118.39 if (gp instanceof JScrollPane) {
118.40 JScrollPane scrollPane = (JScrollPane)gp;
118.41 // Make certain we are the viewPort's view and not, for
118.42 @@ -5215,9 +5215,10 @@
118.43 * @see #getFillsViewportHeight
118.44 */
118.45 public boolean getScrollableTracksViewportHeight() {
118.46 + JViewport port = SwingUtilities2.getViewport(this);
118.47 return getFillsViewportHeight()
118.48 - && getParent() instanceof JViewport
118.49 - && (getParent().getHeight() > getPreferredSize().height);
118.50 + && port != null
118.51 + && port.getHeight() > getPreferredSize().height;
118.52 }
118.53
118.54 /**
119.1 --- a/src/share/classes/javax/swing/JTextField.java Sun Sep 06 23:14:42 2009 -0700
119.2 +++ b/src/share/classes/javax/swing/JTextField.java Tue Sep 15 23:41:40 2009 -0700
119.3 @@ -24,6 +24,8 @@
119.4 */
119.5 package javax.swing;
119.6
119.7 +import sun.swing.SwingUtilities2;
119.8 +
119.9 import java.awt.*;
119.10 import java.awt.event.*;
119.11 import java.beans.*;
119.12 @@ -288,11 +290,7 @@
119.13 * @see JComponent#isValidateRoot
119.14 */
119.15 public boolean isValidateRoot() {
119.16 - Component parent = getParent();
119.17 - if (parent instanceof JViewport) {
119.18 - return false;
119.19 - }
119.20 - return true;
119.21 + return SwingUtilities2.getViewport(this) == null;
119.22 }
119.23
119.24
120.1 --- a/src/share/classes/javax/swing/JTextPane.java Sun Sep 06 23:14:42 2009 -0700
120.2 +++ b/src/share/classes/javax/swing/JTextPane.java Tue Sep 15 23:41:40 2009 -0700
120.3 @@ -170,6 +170,7 @@
120.4 *
120.5 * @param content the content to replace the selection with
120.6 */
120.7 + @Override
120.8 public void replaceSelection(String content) {
120.9 replaceSelection(content, true);
120.10 }
120.11 @@ -183,6 +184,7 @@
120.12 if (doc != null) {
120.13 try {
120.14 Caret caret = getCaret();
120.15 + boolean composedTextSaved = saveComposedText(caret.getDot());
120.16 int p0 = Math.min(caret.getDot(), caret.getMark());
120.17 int p1 = Math.max(caret.getDot(), caret.getMark());
120.18 AttributeSet attr = getInputAttributes().copyAttributes();
120.19 @@ -197,6 +199,9 @@
120.20 doc.insertString(p0, content, attr);
120.21 }
120.22 }
120.23 + if (composedTextSaved) {
120.24 + restoreComposedText();
120.25 + }
120.26 } catch (BadLocationException e) {
120.27 UIManager.getLookAndFeel().provideErrorFeedback(JTextPane.this);
120.28 }
121.1 --- a/src/share/classes/javax/swing/JTree.java Sun Sep 06 23:14:42 2009 -0700
121.2 +++ b/src/share/classes/javax/swing/JTree.java Tue Sep 15 23:41:40 2009 -0700
121.3 @@ -3498,8 +3498,9 @@
121.4 * @see Scrollable#getScrollableTracksViewportWidth
121.5 */
121.6 public boolean getScrollableTracksViewportWidth() {
121.7 - if (getParent() instanceof JViewport) {
121.8 - return getParent().getWidth() > getPreferredSize().width;
121.9 + JViewport port = SwingUtilities2.getViewport(this);
121.10 + if (port != null) {
121.11 + return port.getWidth() > getPreferredSize().width;
121.12 }
121.13 return false;
121.14 }
121.15 @@ -3514,8 +3515,9 @@
121.16 * @see Scrollable#getScrollableTracksViewportHeight
121.17 */
121.18 public boolean getScrollableTracksViewportHeight() {
121.19 - if (getParent() instanceof JViewport) {
121.20 - return getParent().getHeight() > getPreferredSize().height;
121.21 + JViewport port = SwingUtilities2.getViewport(this);
121.22 + if (port != null) {
121.23 + return port.getHeight() > getPreferredSize().height;
121.24 }
121.25 return false;
121.26 }
122.1 --- a/src/share/classes/javax/swing/SwingUtilities.java Sun Sep 06 23:14:42 2009 -0700
122.2 +++ b/src/share/classes/javax/swing/SwingUtilities.java Tue Sep 15 23:41:40 2009 -0700
122.3 @@ -999,24 +999,20 @@
122.4 textR.height = (int) v.getPreferredSpan(View.Y_AXIS);
122.5 } else {
122.6 textR.width = SwingUtilities2.stringWidth(c, fm, text);
122.7 -
122.8 - // Take into account the left and right side bearings.
122.9 - // This gives more space than it is actually needed,
122.10 - // but there are two reasons:
122.11 - // 1. If we set the width to the actual bounds,
122.12 - // all callers would have to account for the bearings
122.13 - // themselves. NOTE: all pref size calculations don't do it.
122.14 - // 2. You can do a drawString at the returned location
122.15 - // and the text won't be clipped.
122.16 lsb = SwingUtilities2.getLeftSideBearing(c, fm, text);
122.17 if (lsb < 0) {
122.18 + // If lsb is negative, add it to the width and later
122.19 + // adjust the x location. This gives more space than is
122.20 + // actually needed.
122.21 + // This is done like this for two reasons:
122.22 + // 1. If we set the width to the actual bounds all
122.23 + // callers would have to account for negative lsb
122.24 + // (pref size calculations ONLY look at width of
122.25 + // textR)
122.26 + // 2. You can do a drawString at the returned location
122.27 + // and the text won't be clipped.
122.28 textR.width -= lsb;
122.29 }
122.30 - rsb = SwingUtilities2.getRightSideBearing(c, fm, text);
122.31 - if (rsb > 0) {
122.32 - textR.width += rsb;
122.33 - }
122.34 -
122.35 if (textR.width > availTextWidth) {
122.36 text = SwingUtilities2.clipString(c, fm, text,
122.37 availTextWidth);
123.1 --- a/src/share/classes/javax/swing/plaf/LayerUI.java Sun Sep 06 23:14:42 2009 -0700
123.2 +++ b/src/share/classes/javax/swing/plaf/LayerUI.java Tue Sep 15 23:41:40 2009 -0700
123.3 @@ -1,6 +1,26 @@
123.4 /*
123.5 - * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
123.6 - * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
123.7 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
123.8 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
123.9 + *
123.10 + * This code is free software; you can redistribute it and/or modify it
123.11 + * under the terms of the GNU General Public License version 2 only, as
123.12 + * published by the Free Software Foundation. Sun designates this
123.13 + * particular file as subject to the "Classpath" exception as provided
123.14 + * by Sun in the LICENSE file that accompanied this code.
123.15 + *
123.16 + * This code is distributed in the hope that it will be useful, but WITHOUT
123.17 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
123.18 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
123.19 + * version 2 for more details (a copy is included in the LICENSE file that
123.20 + * accompanied this code).
123.21 + *
123.22 + * You should have received a copy of the GNU General Public License version
123.23 + * 2 along with this work; if not, write to the Free Software Foundation,
123.24 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
123.25 + *
123.26 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
123.27 + * CA 95054 USA or visit www.sun.com if you need additional information or
123.28 + * have any questions.
123.29 */
123.30
123.31 package javax.swing.plaf;
123.32 @@ -202,6 +222,7 @@
123.33 * Returns an array of all the listeners which have been associated
123.34 * with the named property.
123.35 *
123.36 + * @param propertyName The name of the property being listened to
123.37 * @return all of the {@code PropertyChangeListener}s associated with
123.38 * the named property; if no such listeners have been added or
123.39 * if {@code propertyName} is {@code null}, an empty
123.40 @@ -242,6 +263,7 @@
123.41 /**
123.42 * Returns the preferred size of the viewport for a view component.
123.43 *
123.44 + * @param l the {@code JLayer} component where this UI delegate is being installed
123.45 * @return the preferred size of the viewport for a view component
123.46 * @see Scrollable#getPreferredScrollableViewportSize()
123.47 */
123.48 @@ -257,6 +279,10 @@
123.49 * that display logical rows or columns in order to completely expose
123.50 * one block of rows or columns, depending on the value of orientation.
123.51 *
123.52 + * @param l the {@code JLayer} component where this UI delegate is being installed
123.53 + * @param visibleRect The view area visible within the viewport
123.54 + * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
123.55 + * @param direction Less than zero to scroll up/left, greater than zero for down/right.
123.56 * @return the "block" increment for scrolling in the specified direction
123.57 * @see Scrollable#getScrollableBlockIncrement(Rectangle, int, int)
123.58 */
123.59 @@ -276,6 +302,7 @@
123.60 * determine the height of the layer, unless the preferred height
123.61 * of the layer is smaller than the height of the viewport.
123.62 *
123.63 + * @param l the {@code JLayer} component where this UI delegate is being installed
123.64 * @return whether the layer should track the height of the viewport
123.65 * @see Scrollable#getScrollableTracksViewportHeight()
123.66 */
123.67 @@ -283,9 +310,6 @@
123.68 if (l.getView() instanceof Scrollable) {
123.69 return ((Scrollable)l.getView()).getScrollableTracksViewportHeight();
123.70 }
123.71 - if (l.getParent() instanceof JViewport) {
123.72 - return (((JViewport)l.getParent()).getHeight() > l.getPreferredSize().height);
123.73 - }
123.74 return false;
123.75 }
123.76
123.77 @@ -294,6 +318,7 @@
123.78 * determine the width of the layer, unless the preferred width
123.79 * of the layer is smaller than the width of the viewport.
123.80 *
123.81 + * @param l the {@code JLayer} component where this UI delegate is being installed
123.82 * @return whether the layer should track the width of the viewport
123.83 * @see Scrollable
123.84 * @see LayerUI#getScrollableTracksViewportWidth(JLayer)
123.85 @@ -302,9 +327,6 @@
123.86 if (l.getView() instanceof Scrollable) {
123.87 return ((Scrollable)l.getView()).getScrollableTracksViewportWidth();
123.88 }
123.89 - if (l.getParent() instanceof JViewport) {
123.90 - return (((JViewport)l.getParent()).getWidth() > l.getPreferredSize().width);
123.91 - }
123.92 return false;
123.93 }
123.94
123.95 @@ -318,6 +340,10 @@
123.96 * Scrolling containers, like JScrollPane, will use this method
123.97 * each time the user requests a unit scroll.
123.98 *
123.99 + * @param l the {@code JLayer} component where this UI delegate is being installed
123.100 + * @param visibleRect The view area visible within the viewport
123.101 + * @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
123.102 + * @param direction Less than zero to scroll up/left, greater than zero for down/right.
123.103 * @return The "unit" increment for scrolling in the specified direction.
123.104 * This value should always be positive.
123.105 * @see Scrollable#getScrollableUnitIncrement(Rectangle, int, int)
123.106 @@ -367,4 +393,4 @@
123.107 }
123.108 return super.getBaselineResizeBehavior(c);
123.109 }
123.110 -}
123.111 \ No newline at end of file
123.112 +}
124.1 --- a/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java Sun Sep 06 23:14:42 2009 -0700
124.2 +++ b/src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java Tue Sep 15 23:41:40 2009 -0700
124.3 @@ -1507,7 +1507,8 @@
124.4 propertyName == "paintTicks" ||
124.5 propertyName == "paintTrack" ||
124.6 propertyName == "font" ||
124.7 - propertyName == "paintLabels") {
124.8 + propertyName == "paintLabels" ||
124.9 + propertyName == "Slider.paintThumbArrowShape") {
124.10 checkedLabelBaselines = false;
124.11 calculateGeometry();
124.12 slider.repaint();
125.1 --- a/src/share/classes/javax/swing/plaf/metal/MetalFontDesktopProperty.java Sun Sep 06 23:14:42 2009 -0700
125.2 +++ b/src/share/classes/javax/swing/plaf/metal/MetalFontDesktopProperty.java Tue Sep 15 23:41:40 2009 -0700
125.3 @@ -1,5 +1,5 @@
125.4 /*
125.5 - * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
125.6 + * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
125.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
125.8 *
125.9 * This code is free software; you can redistribute it and/or modify it
125.10 @@ -25,8 +25,6 @@
125.11 package javax.swing.plaf.metal;
125.12
125.13 import java.awt.*;
125.14 -import java.beans.*;
125.15 -import javax.swing.*;
125.16
125.17 /**
125.18 * DesktopProperty that only uses font height in configuring font. This
125.19 @@ -60,7 +58,7 @@
125.20 * @param type MetalTheme font type.
125.21 */
125.22 MetalFontDesktopProperty(int type) {
125.23 - this(propertyMapping[type], Toolkit.getDefaultToolkit(), type);
125.24 + this(propertyMapping[type], type);
125.25 }
125.26
125.27 /**
125.28 @@ -72,8 +70,8 @@
125.29 * @param type Type of font being used, corresponds to MetalTheme font
125.30 * type.
125.31 */
125.32 - MetalFontDesktopProperty(String key, Toolkit kit, int type) {
125.33 - super(key, null, kit);
125.34 + MetalFontDesktopProperty(String key, int type) {
125.35 + super(key, null);
125.36 this.type = type;
125.37 }
125.38
126.1 --- a/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java Sun Sep 06 23:14:42 2009 -0700
126.2 +++ b/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java Tue Sep 15 23:41:40 2009 -0700
126.3 @@ -1,5 +1,5 @@
126.4 /*
126.5 - * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
126.6 + * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
126.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
126.8 *
126.9 * This code is free software; you can redistribute it and/or modify it
126.10 @@ -1541,10 +1541,8 @@
126.11 table.putDefaults(defaults);
126.12
126.13 if (isWindows() && useSystemFonts() && theme.isSystemTheme()) {
126.14 - Toolkit kit = Toolkit.getDefaultToolkit();
126.15 Object messageFont = new MetalFontDesktopProperty(
126.16 - "win.messagebox.font.height", kit, MetalTheme.
126.17 - CONTROL_TEXT_FONT);
126.18 + "win.messagebox.font.height", MetalTheme.CONTROL_TEXT_FONT);
126.19
126.20 defaults = new Object[] {
126.21 "OptionPane.messageFont", messageFont,
127.1 --- a/src/share/classes/javax/swing/plaf/nimbus/Defaults.template Sun Sep 06 23:14:42 2009 -0700
127.2 +++ b/src/share/classes/javax/swing/plaf/nimbus/Defaults.template Tue Sep 15 23:41:40 2009 -0700
127.3 @@ -101,14 +101,7 @@
127.4 */
127.5 private FontUIResource defaultFont;
127.6
127.7 - /**
127.8 - * Map of lists of derived colors keyed by the DerivedColorKeys
127.9 - */
127.10 - private Map<DerivedColorKey, DerivedColor> derivedColorsMap =
127.11 - new HashMap<DerivedColorKey, DerivedColor>();
127.12 -
127.13 - /** Tempory key used for fetching from the derivedColorsMap */
127.14 - private final DerivedColorKey tmpDCKey = new DerivedColorKey();
127.15 + private ColorTree colorTree = new ColorTree();
127.16
127.17 /** Listener for changes to user defaults table */
127.18 private DefaultsListener defaultsListener = new DefaultsListener();
127.19 @@ -117,14 +110,14 @@
127.20 void initialize() {
127.21 // add listener for derived colors
127.22 UIManager.addPropertyChangeListener(defaultsListener);
127.23 - UIManager.getDefaults().addPropertyChangeListener(defaultsListener);
127.24 + UIManager.getDefaults().addPropertyChangeListener(colorTree);
127.25 }
127.26
127.27 /** Called by UIManager when this look and feel is uninstalled. */
127.28 void uninitialize() {
127.29 // remove listener for derived colors
127.30 - UIManager.getDefaults().removePropertyChangeListener(defaultsListener);
127.31 UIManager.removePropertyChangeListener(defaultsListener);
127.32 + UIManager.getDefaults().removePropertyChangeListener(colorTree);
127.33 }
127.34
127.35 /**
127.36 @@ -663,22 +656,23 @@
127.37 }
127.38 }
127.39
127.40 - /**
127.41 - * Get a derived color, derived colors are shared instances and will be
127.42 - * updated when its parent UIDefault color changes.
127.43 - *
127.44 - * @param uiDefaultParentName The parent UIDefault key
127.45 - * @param hOffset The hue offset
127.46 - * @param sOffset The saturation offset
127.47 - * @param bOffset The brightness offset
127.48 - * @param aOffset The alpha offset
127.49 - * @return The stored derived color
127.50 - */
127.51 - public DerivedColor getDerivedColor(String uiDefaultParentName,
127.52 - float hOffset, float sOffset,
127.53 - float bOffset, int aOffset){
127.54 - return getDerivedColor(uiDefaultParentName, hOffset, sOffset,
127.55 - bOffset, aOffset, true);
127.56 + private void addColor(UIDefaults d, String uin, int r, int g, int b, int a) {
127.57 + Color color = new ColorUIResource(new Color(r, g, b, a));
127.58 + colorTree.addColor(uin, color);
127.59 + d.put(uin, color);
127.60 + }
127.61 +
127.62 + private void addColor(UIDefaults d, String uin, String parentUin,
127.63 + float hOffset, float sOffset, float bOffset, int aOffset) {
127.64 + addColor(d, uin, parentUin, hOffset, sOffset, bOffset, aOffset, true);
127.65 + }
127.66 +
127.67 + private void addColor(UIDefaults d, String uin, String parentUin,
127.68 + float hOffset, float sOffset, float bOffset,
127.69 + int aOffset, boolean uiResource) {
127.70 + Color color = getDerivedColor(uin, parentUin,
127.71 + hOffset, sOffset, bOffset, aOffset, uiResource);
127.72 + d.put(uin, color);
127.73 }
127.74
127.75 /**
127.76 @@ -694,89 +688,110 @@
127.77 * false if it should not be a UIResource
127.78 * @return The stored derived color
127.79 */
127.80 - public DerivedColor getDerivedColor(String uiDefaultParentName,
127.81 + public DerivedColor getDerivedColor(String parentUin,
127.82 float hOffset, float sOffset,
127.83 float bOffset, int aOffset,
127.84 boolean uiResource){
127.85 - tmpDCKey.set(uiDefaultParentName, hOffset, sOffset, bOffset, aOffset,
127.86 - uiResource);
127.87 - DerivedColor color = derivedColorsMap.get(tmpDCKey);
127.88 - if (color == null){
127.89 - if (uiResource) {
127.90 - color = new DerivedColor.UIResource(uiDefaultParentName,
127.91 - hOffset, sOffset, bOffset, aOffset);
127.92 - } else {
127.93 - color = new DerivedColor(uiDefaultParentName, hOffset, sOffset,
127.94 - bOffset, aOffset);
127.95 - }
127.96 - // calculate the initial value
127.97 - color.rederiveColor();
127.98 - // add the listener so that if the color changes we'll propogate it
127.99 - color.addPropertyChangeListener(defaultsListener);
127.100 - // add to the derived colors table
127.101 - derivedColorsMap.put(new DerivedColorKey(uiDefaultParentName,
127.102 - hOffset, sOffset, bOffset, aOffset, uiResource),color);
127.103 - }
127.104 - return color;
127.105 + return getDerivedColor(null, parentUin,
127.106 + hOffset, sOffset, bOffset, aOffset, uiResource);
127.107 }
127.108
127.109 - /**
127.110 - * Key class for derived colors
127.111 - */
127.112 - private class DerivedColorKey {
127.113 - private String uiDefaultParentName;
127.114 - private float hOffset, sOffset, bOffset;
127.115 - private int aOffset;
127.116 - private boolean uiResource;
127.117 -
127.118 - DerivedColorKey(){}
127.119 -
127.120 - DerivedColorKey(String uiDefaultParentName, float hOffset,
127.121 - float sOffset, float bOffset, int aOffset,
127.122 - boolean uiResource) {
127.123 - set(uiDefaultParentName, hOffset, sOffset, bOffset, aOffset, uiResource);
127.124 + private DerivedColor getDerivedColor(String uin, String parentUin,
127.125 + float hOffset, float sOffset,
127.126 + float bOffset, int aOffset,
127.127 + boolean uiResource) {
127.128 + DerivedColor color;
127.129 + if (uiResource) {
127.130 + color = new DerivedColor.UIResource(parentUin,
127.131 + hOffset, sOffset, bOffset, aOffset);
127.132 + } else {
127.133 + color = new DerivedColor(parentUin, hOffset, sOffset,
127.134 + bOffset, aOffset);
127.135 }
127.136
127.137 - void set (String uiDefaultParentName, float hOffset,
127.138 - float sOffset, float bOffset, int aOffset,
127.139 - boolean uiResource) {
127.140 - this.uiDefaultParentName = uiDefaultParentName;
127.141 - this.hOffset = hOffset;
127.142 - this.sOffset = sOffset;
127.143 - this.bOffset = bOffset;
127.144 - this.aOffset = aOffset;
127.145 - this.uiResource = uiResource;
127.146 + if (derivedColors.containsKey(color)) {
127.147 + return derivedColors.get(color);
127.148 + } else {
127.149 + derivedColors.put(color, color);
127.150 + color.rederiveColor(); /// move to ARP.decodeColor() ?
127.151 + colorTree.addColor(uin, color);
127.152 + return color;
127.153 + }
127.154 + }
127.155 +
127.156 + private Map<DerivedColor, DerivedColor> derivedColors =
127.157 + new HashMap<DerivedColor, DerivedColor>();
127.158 +
127.159 + private class ColorTree implements PropertyChangeListener {
127.160 + private Node root = new Node(null, null);
127.161 + private Map<String, Node> nodes = new HashMap<String, Node>();
127.162 +
127.163 + public Color getColor(String uin) {
127.164 + return nodes.get(uin).color;
127.165 + }
127.166 +
127.167 + public void addColor(String uin, Color color) {
127.168 + Node parent = getParentNode(color);
127.169 + Node node = new Node(color, parent);
127.170 + parent.children.add(node);
127.171 + if (uin != null) {
127.172 + nodes.put(uin, node);
127.173 + }
127.174 + }
127.175 +
127.176 + private Node getParentNode(Color color) {
127.177 + Node parent = root;
127.178 + if (color instanceof DerivedColor) {
127.179 + String parentUin = ((DerivedColor)color).getUiDefaultParentName();
127.180 + Node p = nodes.get(parentUin);
127.181 + if (p != null) {
127.182 + parent = p;
127.183 + }
127.184 + }
127.185 + return parent;
127.186 + }
127.187 +
127.188 + public void update() {
127.189 + root.update();
127.190 }
127.191
127.192 @Override
127.193 - public boolean equals(Object o) {
127.194 - if (this == o) return true;
127.195 - if (!(o instanceof DerivedColorKey)) return false;
127.196 - DerivedColorKey that = (DerivedColorKey) o;
127.197 - if (aOffset != that.aOffset) return false;
127.198 - if (Float.compare(that.bOffset, bOffset) != 0) return false;
127.199 - if (Float.compare(that.hOffset, hOffset) != 0) return false;
127.200 - if (Float.compare(that.sOffset, sOffset) != 0) return false;
127.201 - if (uiDefaultParentName != null ?
127.202 - !uiDefaultParentName.equals(that.uiDefaultParentName) :
127.203 - that.uiDefaultParentName != null) return false;
127.204 - if (this.uiResource != that.uiResource) return false;
127.205 - return true;
127.206 + public void propertyChange(PropertyChangeEvent ev) {
127.207 + String name = ev.getPropertyName();
127.208 + Node node = nodes.get(name);
127.209 + if (node != null) {
127.210 + // this is a registered color
127.211 + node.parent.children.remove(node);
127.212 + Color color = (Color) ev.getNewValue();
127.213 + Node parent = getParentNode(color);
127.214 + node.set(color, parent);
127.215 + parent.children.add(node);
127.216 + node.update();
127.217 + }
127.218 }
127.219
127.220 - @Override
127.221 - public int hashCode() {
127.222 - int result = super.hashCode();
127.223 - result = 31 * result + uiDefaultParentName.hashCode();
127.224 - result = 31 * result + hOffset != +0.0f ?
127.225 - Float.floatToIntBits(hOffset) : 0;
127.226 - result = 31 * result + sOffset != +0.0f ?
127.227 - Float.floatToIntBits(sOffset) : 0;
127.228 - result = 31 * result + bOffset != +0.0f ?
127.229 - Float.floatToIntBits(bOffset) : 0;
127.230 - result = 31 * result + aOffset;
127.231 - result = 31 * result + (uiResource ? 1 : 0);
127.232 - return result;
127.233 + class Node {
127.234 + Color color;
127.235 + Node parent;
127.236 + List<Node> children = new LinkedList<Node>();
127.237 +
127.238 + Node(Color color, Node parent) {
127.239 + set(color, parent);
127.240 + }
127.241 +
127.242 + public void set(Color color, Node parent) {
127.243 + this.color = color;
127.244 + this.parent = parent;
127.245 + }
127.246 +
127.247 + public void update() {
127.248 + if (color instanceof DerivedColor) {
127.249 + ((DerivedColor)color).rederiveColor();
127.250 + }
127.251 + for (Node child: children) {
127.252 + child.update();
127.253 + }
127.254 + }
127.255 }
127.256 }
127.257
127.258 @@ -786,49 +801,12 @@
127.259 private class DefaultsListener implements PropertyChangeListener {
127.260 @Override
127.261 public void propertyChange(PropertyChangeEvent evt) {
127.262 - Object src = evt.getSource();
127.263 - String key = evt.getPropertyName();
127.264 - if (key.equals("lookAndFeel")){
127.265 + if ("lookAndFeel".equals(evt.getPropertyName())) {
127.266 // LAF has been installed, this is the first point at which we
127.267 // can access our defaults table via UIManager so before now
127.268 // all derived colors will be incorrect.
127.269 // First we need to update
127.270 - for (DerivedColor color : derivedColorsMap.values()) {
127.271 - color.rederiveColor();
127.272 - }
127.273 - } else if (src instanceof DerivedColor && key.equals("rgb")) {
127.274 - // derived color that is in UIManager defaults has changed
127.275 - // update all its dependent colors. Don't worry about doing
127.276 - // this recursively since calling rederiveColor will cause
127.277 - // another PCE to be fired, ending up here and essentially
127.278 - // recursing
127.279 - DerivedColor parentColor = (DerivedColor)src;
127.280 - String parentKey = null;
127.281 - Set<Map.Entry<Object,Object>> entries =
127.282 - UIManager.getDefaults().entrySet();
127.283 -
127.284 - for (Map.Entry entry : entries) {
127.285 - Object value = entry.getValue();
127.286 - if (value == parentColor) {
127.287 - parentKey = entry.getKey().toString();
127.288 - }
127.289 - }
127.290 -
127.291 - if (parentKey == null) {
127.292 - //couldn't find the DerivedColor in the UIDefaults map,
127.293 - //so we just bail.
127.294 - return;
127.295 - }
127.296 -
127.297 - for (Map.Entry entry : entries) {
127.298 - Object value = entry.getValue();
127.299 - if (value instanceof DerivedColor) {
127.300 - DerivedColor color = (DerivedColor)entry.getValue();
127.301 - if (parentKey.equals(color.getUiDefaultParentName())) {
127.302 - color.rederiveColor();
127.303 - }
127.304 - }
127.305 - }
127.306 + colorTree.update();
127.307 }
127.308 }
127.309 }
127.310 @@ -875,4 +853,3 @@
127.311 }
127.312 }
127.313 }
127.314 -
128.1 --- a/src/share/classes/javax/swing/plaf/nimbus/DerivedColor.java Sun Sep 06 23:14:42 2009 -0700
128.2 +++ b/src/share/classes/javax/swing/plaf/nimbus/DerivedColor.java Tue Sep 15 23:41:40 2009 -0700
128.3 @@ -39,8 +39,6 @@
128.4 * @author Jasper Potts
128.5 */
128.6 class DerivedColor extends Color {
128.7 - private final PropertyChangeSupport changeSupport =
128.8 - new PropertyChangeSupport(this);
128.9 private final String uiDefaultParentName;
128.10 private final float hOffset, sOffset, bOffset;
128.11 private final int aOffset;
128.12 @@ -79,7 +77,6 @@
128.13 * Recalculate the derived color from the UIManager parent color and offsets
128.14 */
128.15 public void rederiveColor() {
128.16 - int old = argbValue;
128.17 Color src = UIManager.getColor(uiDefaultParentName);
128.18 if (src != null) {
128.19 float[] tmp = Color.RGBtoHSB(src.getRed(), src.getGreen(), src.getBlue(), null);
128.20 @@ -97,7 +94,6 @@
128.21 int alpha = clamp(aOffset);
128.22 argbValue = (Color.HSBtoRGB(tmp[0], tmp[1], tmp[2]) & 0xFFFFFF) | (alpha << 24);
128.23 }
128.24 - changeSupport.firePropertyChange("rgb", old, argbValue);
128.25 }
128.26
128.27 /**
128.28 @@ -141,35 +137,6 @@
128.29 return result;
128.30 }
128.31
128.32 - /**
128.33 - * Add a PropertyChangeListener to the listener list.
128.34 - * The listener is registered for all properties.
128.35 - * The same listener object may be added more than once, and will be called
128.36 - * as many times as it is added.
128.37 - * If <code>listener</code> is null, no exception is thrown and no action
128.38 - * is taken.
128.39 - *
128.40 - * @param listener The PropertyChangeListener to be added
128.41 - */
128.42 - public void addPropertyChangeListener(PropertyChangeListener listener) {
128.43 - changeSupport.addPropertyChangeListener(listener);
128.44 - }
128.45 -
128.46 - /**
128.47 - * Remove a PropertyChangeListener from the listener list.
128.48 - * This removes a PropertyChangeListener that was registered
128.49 - * for all properties.
128.50 - * If <code>listener</code> was added more than once to the same event
128.51 - * source, it will be notified one less time after being removed.
128.52 - * If <code>listener</code> is null, or was never added, no exception is
128.53 - * thrown and no action is taken.
128.54 - *
128.55 - * @param listener The PropertyChangeListener to be removed
128.56 - */
128.57 - public void removePropertyChangeListener(PropertyChangeListener listener) {
128.58 - changeSupport.removePropertyChangeListener(listener);
128.59 - }
128.60 -
128.61 private float clamp(float value) {
128.62 if (value < 0) {
128.63 value = 0;
128.64 @@ -211,5 +178,15 @@
128.65 float bOffset, int aOffset) {
128.66 super(uiDefaultParentName, hOffset, sOffset, bOffset, aOffset);
128.67 }
128.68 +
128.69 + @Override
128.70 + public boolean equals(Object o) {
128.71 + return (o instanceof UIResource) && super.equals(o);
128.72 + }
128.73 +
128.74 + @Override
128.75 + public int hashCode() {
128.76 + return super.hashCode() + 7;
128.77 + }
128.78 }
128.79 }
129.1 --- a/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java Sun Sep 06 23:14:42 2009 -0700
129.2 +++ b/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java Tue Sep 15 23:41:40 2009 -0700
129.3 @@ -40,6 +40,9 @@
129.4 import java.awt.Graphics2D;
129.5 import java.awt.LayoutManager;
129.6 import java.awt.image.BufferedImage;
129.7 +import java.beans.PropertyChangeEvent;
129.8 +import java.beans.PropertyChangeListener;
129.9 +import java.util.*;
129.10 import javax.swing.GrayFilter;
129.11 import javax.swing.Icon;
129.12 import javax.swing.JToolBar;
129.13 @@ -87,6 +90,8 @@
129.14 */
129.15 private UIDefaults uiDefaults;
129.16
129.17 + private DefaultsListener defaultsListener = new DefaultsListener();
129.18 +
129.19 /**
129.20 * Create a new NimbusLookAndFeel.
129.21 */
129.22 @@ -115,8 +120,7 @@
129.23 defaults.uninitialize();
129.24 // clear all cached images to free memory
129.25 ImageCache.getInstance().flush();
129.26 - // remove the listeners and things installed by NimbusStyle
129.27 - NimbusStyle.uninitialize();
129.28 + UIManager.getDefaults().removePropertyChangeListener(defaultsListener);
129.29 }
129.30
129.31 /**
129.32 @@ -515,4 +519,62 @@
129.33 return obj;
129.34 }
129.35 }
129.36 +
129.37 + private Map<String, Map<String, Object>> compiledDefaults = null;
129.38 + private boolean defaultListenerAdded = false;
129.39 +
129.40 + static String parsePrefix(String key) {
129.41 + if (key == null) {
129.42 + return null;
129.43 + }
129.44 + boolean inquotes = false;
129.45 + for (int i = 0; i < key.length(); i++) {
129.46 + char c = key.charAt(i);
129.47 + if (c == '"') {
129.48 + inquotes = !inquotes;
129.49 + } else if ((c == '[' || c == '.') && !inquotes) {
129.50 + return key.substring(0, i);
129.51 + }
129.52 + }
129.53 + return null;
129.54 + }
129.55 +
129.56 + Map<String, Object> getDefaultsForPrefix(String prefix) {
129.57 + if (compiledDefaults == null) {
129.58 + compiledDefaults = new HashMap<String, Map<String, Object>>();
129.59 + for (Map.Entry<Object, Object> entry: UIManager.getDefaults().entrySet()) {
129.60 + if (entry.getKey() instanceof String) {
129.61 + addDefault((String) entry.getKey(), entry.getValue());
129.62 + }
129.63 + }
129.64 + if (! defaultListenerAdded) {
129.65 + UIManager.getDefaults().addPropertyChangeListener(defaultsListener);
129.66 + defaultListenerAdded = true;
129.67 + }
129.68 + }
129.69 + return compiledDefaults.get(prefix);
129.70 + }
129.71 +
129.72 + private void addDefault(String key, Object value) {
129.73 + String prefix = parsePrefix(key);
129.74 + if (prefix != null) {
129.75 + Map<String, Object> keys = compiledDefaults.get(prefix);
129.76 + if (keys == null) {
129.77 + keys = new HashMap<String, Object>();
129.78 + compiledDefaults.put(prefix, keys);
129.79 + }
129.80 + keys.put(key, value);
129.81 + }
129.82 + }
129.83 +
129.84 + private class DefaultsListener implements PropertyChangeListener {
129.85 + @Override public void propertyChange(PropertyChangeEvent ev) {
129.86 + String key = ev.getPropertyName();
129.87 + if ("UIDefaults".equals(key)) {
129.88 + compiledDefaults = null;
129.89 + } else {
129.90 + addDefault(key, ev.getNewValue());
129.91 + }
129.92 + }
129.93 + }
129.94 }
130.1 --- a/src/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java Sun Sep 06 23:14:42 2009 -0700
130.2 +++ b/src/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java Tue Sep 15 23:41:40 2009 -0700
130.3 @@ -26,7 +26,6 @@
130.4
130.5 import javax.swing.Painter;
130.6
130.7 -import java.beans.PropertyChangeEvent;
130.8 import javax.swing.JComponent;
130.9 import javax.swing.UIDefaults;
130.10 import javax.swing.UIManager;
130.11 @@ -39,16 +38,13 @@
130.12 import java.awt.Color;
130.13 import java.awt.Font;
130.14 import java.awt.Insets;
130.15 -import java.beans.PropertyChangeListener;
130.16 import java.util.ArrayList;
130.17 import java.util.Collections;
130.18 import java.util.Comparator;
130.19 import java.util.HashMap;
130.20 -import java.util.HashSet;
130.21 import java.util.List;
130.22 import java.util.Map;
130.23 import java.util.TreeMap;
130.24 -import sun.awt.AppContext;
130.25
130.26 /**
130.27 * <p>A SynthStyle implementation used by Nimbus. Each Region that has been
130.28 @@ -232,42 +228,6 @@
130.29 super.installDefaults(ctx);
130.30 }
130.31
130.32 - static String parsePrefix(String key) {
130.33 - if (key == null) return null;
130.34 - boolean inquotes = false;
130.35 - for (int i=0; i<key.length(); i++) {
130.36 - char c = key.charAt(i);
130.37 - if (c == '"') {
130.38 - inquotes = !inquotes;
130.39 - } else if ((c == '[' || c == '.') && !inquotes) {
130.40 - return key.substring(0, i);
130.41 - }
130.42 - }
130.43 - return null;
130.44 - }
130.45 -
130.46 - /**
130.47 - * Called by NimbusLookAndFeel when the look and feel is being uninstalled.
130.48 - * Performs general cleanup of any app-context specific data.
130.49 - */
130.50 - static void uninitialize() {
130.51 - // get the appcontext that we've stored data in
130.52 - AppContext ctx = AppContext.getAppContext();
130.53 -
130.54 - // get the pcl stored in app context
130.55 - PropertyChangeListener pcl = (PropertyChangeListener)
130.56 - ctx.get("NimbusStyle.defaults.pcl");
130.57 -
130.58 - // if the pcl exists, uninstall it from the UIDefaults tables
130.59 - if (pcl != null) {
130.60 - UIManager.getDefaults().removePropertyChangeListener(pcl);
130.61 - UIManager.getLookAndFeelDefaults().removePropertyChangeListener(pcl);
130.62 - }
130.63 -
130.64 - // clear out the compiled defaults
130.65 - ctx.put("NimbusStyle.defaults", null);
130.66 - }
130.67 -
130.68 /**
130.69 * Pulls data out of UIDefaults, if it has not done so already, and sets
130.70 * up the internal state.
130.71 @@ -283,66 +243,9 @@
130.72 // any Nimbus.Overrides)
130.73 values = new Values();
130.74
130.75 - // the profiler revealed that a great deal of CPU time and useless
130.76 - // garbage was being produced by this method and the init method. One
130.77 - // culprit was the creation and reparsing of the entire UIDefaults
130.78 - // map on each call to this method where "values" was null. It turns
130.79 - // out this was happening a lot.
130.80 - // To remove this bottleneck, we store the compiled TreeMaps of defaults
130.81 - // in the appContext for reuse. It is nulled whenever the UIDefaults
130.82 - // changes and recomputed when necessary.
130.83 - final AppContext ctx = AppContext.getAppContext();
130.84 -
130.85 - // fetch the defaults from the app context. If null, then create and
130.86 - // store the compiled defaults
130.87 - Map<String, TreeMap<String, Object>> compiledDefaults =
130.88 - (Map<String, TreeMap<String, Object>>)
130.89 - ctx.get("NimbusStyle.defaults");
130.90 -
130.91 - if (compiledDefaults == null) {
130.92 - // the entire UIDefaults tables are parsed and compiled into
130.93 - // this map of maps. The key of the compiledDefaults is the
130.94 - // prefix for each style, while the value is a map of
130.95 - // keys->values for that prefix.
130.96 - compiledDefaults = new HashMap<String, TreeMap<String, Object>>();
130.97 -
130.98 - // get all the defaults from UIManager.getDefaults() and put them
130.99 - // into the compiledDefaults
130.100 - compileDefaults(compiledDefaults, UIManager.getDefaults());
130.101 -
130.102 - // This second statement pulls defaults from the laf defaults
130.103 - UIDefaults lafDefaults = UIManager.getLookAndFeelDefaults();
130.104 - compileDefaults(compiledDefaults, lafDefaults);
130.105 -
130.106 - // if it has not already been done, add a listener to both
130.107 - // UIManager.getDefaults() and UIManager.getLookAndFeelDefaults().
130.108 - PropertyChangeListener pcl = (PropertyChangeListener)
130.109 - ctx.get("NimbusStyle.defaults.pcl");
130.110 -
130.111 - // if pcl is null, then it has not yet been registered with
130.112 - // the UIManager defaults for this app context
130.113 - if (pcl == null) {
130.114 - // create a PCL which will simply clear out the compiled
130.115 - // defaults from the app context, causing it to be recomputed
130.116 - // on subsequent passes
130.117 - pcl = new DefaultsListener();
130.118 - // add the PCL to both defaults tables that we pay attention
130.119 - // to, so that if the UIDefaults are updated, then the
130.120 - // precompiled defaults will be cleared from the app context
130.121 - // and recomputed on subsequent passes
130.122 - UIManager.getDefaults().addPropertyChangeListener(pcl);
130.123 - UIManager.getLookAndFeelDefaults().addPropertyChangeListener(pcl);
130.124 - // save the PCL to the app context as a marker indicating
130.125 - // that the PCL has been registered so we don't end up adding
130.126 - // more than one listener to the UIDefaults tables.
130.127 - ctx.put("NimbusStyle.defaults.pcl", pcl);
130.128 - }
130.129 -
130.130 - // store the defaults for reuse
130.131 - ctx.put("NimbusStyle.defaults", compiledDefaults);
130.132 - }
130.133 -
130.134 - TreeMap<String, Object> defaults = compiledDefaults.get(prefix);
130.135 + Map<String, Object> defaults =
130.136 + ((NimbusLookAndFeel) UIManager.getLookAndFeel()).
130.137 + getDefaultsForPrefix(prefix);
130.138
130.139 // inspect the client properties for the key "Nimbus.Overrides". If the
130.140 // value is an instance of UIDefaults, then these defaults are used
130.141 @@ -371,52 +274,6 @@
130.142 }
130.143 }
130.144
130.145 - // Now that I've accumulated all the defaults pertaining to this
130.146 - // style, call init which will read these defaults and configure
130.147 - // the default "values".
130.148 - init(values, defaults);
130.149 - }
130.150 -
130.151 - /**
130.152 - * Iterates over all the keys in the specified UIDefaults and compiles
130.153 - * those keys into the comiledDefaults data structure. It relies on
130.154 - * parsing the "prefix" out of the key. If the key is not a String or is
130.155 - * null then it is ignored. In all other cases a prefix is parsed out
130.156 - * (even if that prefix is the empty String or is a "fake" prefix. That
130.157 - * is, suppose you had a key Foo~~MySpecial.KeyThing~~. In this case this
130.158 - * is not a Nimbus formatted key, but we don't care, we treat it as if it
130.159 - * is. This doesn't pose any harm, it will simply never be used).
130.160 - *
130.161 - * @param compiledDefaults
130.162 - * @param d
130.163 - */
130.164 - private void compileDefaults(
130.165 - Map<String, TreeMap<String,Object>> compiledDefaults,
130.166 - UIDefaults d) {
130.167 - for (Object obj : new HashSet(d.keySet())) {
130.168 - if (obj instanceof String) {
130.169 - String key = (String)obj;
130.170 - String kp = parsePrefix(key);
130.171 - if (kp == null) continue;
130.172 - TreeMap<String,Object> map = compiledDefaults.get(kp);
130.173 - if (map == null) {
130.174 - map = new TreeMap<String,Object>();
130.175 - compiledDefaults.put(kp, map);
130.176 - }
130.177 - map.put(key, d.get(key));
130.178 - }
130.179 - }
130.180 - }
130.181 -
130.182 - /**
130.183 - * Initializes the given <code>Values</code> object with the defaults
130.184 - * contained in the given TreeMap.
130.185 - *
130.186 - * @param v The Values object to be initialized
130.187 - * @param myDefaults a map of UIDefaults to use in initializing the Values.
130.188 - * This map must contain only keys associated with this Style.
130.189 - */
130.190 - private void init(Values v, TreeMap<String, Object> myDefaults) {
130.191 //a list of the different types of states used by this style. This
130.192 //list may contain only "standard" states (those defined by Synth),
130.193 //or it may contain custom states, or it may contain only "standard"
130.194 @@ -433,7 +290,7 @@
130.195 //"values" stateTypes to be a non-null array.
130.196 //Otherwise, let the "values" stateTypes be null to indicate that
130.197 //there are no custom states or custom state ordering
130.198 - String statesString = (String)myDefaults.get(prefix + ".States");
130.199 + String statesString = (String)defaults.get(prefix + ".States");
130.200 if (statesString != null) {
130.201 String s[] = statesString.split(",");
130.202 for (int i=0; i<s.length; i++) {
130.203 @@ -442,7 +299,7 @@
130.204 //this is a non-standard state name, so look for the
130.205 //custom state associated with it
130.206 String stateName = prefix + "." + s[i];
130.207 - State customState = (State)myDefaults.get(stateName);
130.208 + State customState = (State)defaults.get(stateName);
130.209 if (customState != null) {
130.210 states.add(customState);
130.211 }
130.212 @@ -455,7 +312,7 @@
130.213 //to be non-null. Otherwise, leave it null (meaning, use the
130.214 //standard synth states).
130.215 if (states.size() > 0) {
130.216 - v.stateTypes = states.toArray(new State[states.size()]);
130.217 + values.stateTypes = states.toArray(new State[states.size()]);
130.218 }
130.219
130.220 //assign codes for each of the state types
130.221 @@ -490,7 +347,7 @@
130.222 }
130.223
130.224 //Now iterate over all the keys in the defaults table
130.225 - for (String key : myDefaults.keySet()) {
130.226 + for (String key : defaults.keySet()) {
130.227 //The key is something like JButton.Enabled.backgroundPainter,
130.228 //or JButton.States, or JButton.background.
130.229 //Remove the "JButton." portion of the key
130.230 @@ -528,11 +385,11 @@
130.231 //otherwise, assume it is a property and install it on the
130.232 //values object
130.233 if ("contentMargins".equals(property)) {
130.234 - v.contentMargins = (Insets)myDefaults.get(key);
130.235 + values.contentMargins = (Insets)defaults.get(key);
130.236 } else if ("States".equals(property)) {
130.237 //ignore
130.238 } else {
130.239 - v.defaults.put(property, myDefaults.get(key));
130.240 + values.defaults.put(property, defaults.get(key));
130.241 }
130.242 } else {
130.243 //it is possible that the developer has a malformed UIDefaults
130.244 @@ -582,13 +439,13 @@
130.245 //so put it in the UIDefaults associated with that runtime
130.246 //state
130.247 if ("backgroundPainter".equals(property)) {
130.248 - rs.backgroundPainter = (Painter)myDefaults.get(key);
130.249 + rs.backgroundPainter = getPainter(defaults, key);
130.250 } else if ("foregroundPainter".equals(property)) {
130.251 - rs.foregroundPainter = (Painter) myDefaults.get(key);
130.252 + rs.foregroundPainter = getPainter(defaults, key);
130.253 } else if ("borderPainter".equals(property)) {
130.254 - rs.borderPainter = (Painter) myDefaults.get(key);
130.255 + rs.borderPainter = getPainter(defaults, key);
130.256 } else {
130.257 - rs.defaults.put(property, myDefaults.get(key));
130.258 + rs.defaults.put(property, defaults.get(key));
130.259 }
130.260 }
130.261 }
130.262 @@ -598,7 +455,15 @@
130.263 Collections.sort(runtimeStates, STATE_COMPARATOR);
130.264
130.265 //finally, set the array of runtime states on the values object
130.266 - v.states = runtimeStates.toArray(new RuntimeState[runtimeStates.size()]);
130.267 + values.states = runtimeStates.toArray(new RuntimeState[runtimeStates.size()]);
130.268 + }
130.269 +
130.270 + private Painter getPainter(Map<String, Object> defaults, String key) {
130.271 + Object p = defaults.get(key);
130.272 + if (p instanceof UIDefaults.LazyValue) {
130.273 + p = ((UIDefaults.LazyValue)p).createValue(UIManager.getDefaults());
130.274 + }
130.275 + return (p instanceof Painter ? (Painter)p : null);
130.276 }
130.277
130.278 /**
130.279 @@ -1245,15 +1110,4 @@
130.280 return hash;
130.281 }
130.282 }
130.283 -
130.284 - /**
130.285 - * This listener is used to listen to the UIDefaults tables and clear out
130.286 - * the cached-precompiled map of defaults in that case.
130.287 - */
130.288 - private static final class DefaultsListener implements PropertyChangeListener {
130.289 - @Override
130.290 - public void propertyChange(PropertyChangeEvent evt) {
130.291 - AppContext.getAppContext().put("NimbusStyle.defaults", null);
130.292 - }
130.293 - }
130.294 }
131.1 --- a/src/share/classes/javax/swing/plaf/synth/SynthMenuItemLayoutHelper.java Sun Sep 06 23:14:42 2009 -0700
131.2 +++ b/src/share/classes/javax/swing/plaf/synth/SynthMenuItemLayoutHelper.java Tue Sep 15 23:41:40 2009 -0700
131.3 @@ -195,7 +195,7 @@
131.4 getHorizontalAlignment(), getVerticalAlignment(),
131.5 getHorizontalTextPosition(), getVerticalTextPosition(),
131.6 getViewRect(), iconRect, textRect, getGap());
131.7 - textRect.width += getLeftTextExtraWidth() + getRightTextExtraWidth();
131.8 + textRect.width += getLeftTextExtraWidth();
131.9 Rectangle labelRect = iconRect.union(textRect);
131.10 getLabelSize().setHeight(labelRect.height);
131.11 getLabelSize().setWidth(labelRect.width);
132.1 --- a/src/share/classes/javax/swing/text/JTextComponent.java Sun Sep 06 23:14:42 2009 -0700
132.2 +++ b/src/share/classes/javax/swing/text/JTextComponent.java Tue Sep 15 23:41:40 2009 -0700
132.3 @@ -2069,8 +2069,9 @@
132.4 * width to match its own
132.5 */
132.6 public boolean getScrollableTracksViewportWidth() {
132.7 - if (getParent() instanceof JViewport) {
132.8 - return (getParent().getWidth() > getPreferredSize().width);
132.9 + JViewport port = SwingUtilities2.getViewport(this);
132.10 + if (port != null) {
132.11 + return port.getWidth() > getPreferredSize().width;
132.12 }
132.13 return false;
132.14 }
132.15 @@ -2089,8 +2090,9 @@
132.16 * to match its own
132.17 */
132.18 public boolean getScrollableTracksViewportHeight() {
132.19 - if (getParent() instanceof JViewport) {
132.20 - return (getParent().getHeight() > getPreferredSize().height);
132.21 + JViewport port = SwingUtilities2.getViewport(this);
132.22 + if (port != null) {
132.23 + return (port.getHeight() > getPreferredSize().height);
132.24 }
132.25 return false;
132.26 }
132.27 @@ -4813,7 +4815,18 @@
132.28 new AttributedString(text, composedIndex, text.getEndIndex()));
132.29 }
132.30
132.31 - private boolean saveComposedText(int pos) {
132.32 + /**
132.33 + * Saves composed text around the specified position.
132.34 + *
132.35 + * The composed text (if any) around the specified position is saved
132.36 + * in a backing store and removed from the document.
132.37 + *
132.38 + * @param pos document position to identify the composed text location
132.39 + * @return {@code true} if the composed text exists and is saved,
132.40 + * {@code false} otherwise
132.41 + * @see #restoreComposedText
132.42 + */
132.43 + protected boolean saveComposedText(int pos) {
132.44 if (composedTextExists()) {
132.45 int start = composedTextStart.getOffset();
132.46 int len = composedTextEnd.getOffset() -
132.47 @@ -4828,7 +4841,15 @@
132.48 return false;
132.49 }
132.50
132.51 - private void restoreComposedText() {
132.52 + /**
132.53 + * Restores composed text previously saved by {@code saveComposedText}.
132.54 + *
132.55 + * The saved composed text is inserted back into the document. This method
132.56 + * should be invoked only if {@code saveComposedText} returns {@code true}.
132.57 + *
132.58 + * @see #saveComposedText
132.59 + */
132.60 + protected void restoreComposedText() {
132.61 Document doc = getDocument();
132.62 try {
132.63 doc.insertString(caret.getDot(),
133.1 --- a/src/share/classes/javax/swing/tree/DefaultTreeSelectionModel.java Sun Sep 06 23:14:42 2009 -0700
133.2 +++ b/src/share/classes/javax/swing/tree/DefaultTreeSelectionModel.java Tue Sep 15 23:41:40 2009 -0700
133.3 @@ -1067,10 +1067,13 @@
133.4 }
133.5
133.6 /**
133.7 - * Notifies listeners of a change in path. changePaths should contain
133.8 - * instances of PathPlaceHolder.
133.9 - */
133.10 - protected void notifyPathChange(Vector<PathPlaceHolder> changedPaths,
133.11 + * Notifies listeners of a change in path. changePaths should contain
133.12 + * instances of PathPlaceHolder.
133.13 + *
133.14 + * @deprecated As of JDK version 1.7
133.15 + */
133.16 + @Deprecated
133.17 + protected void notifyPathChange(Vector changedPaths,
133.18 TreePath oldLeadSelection) {
133.19 int cPathCount = changedPaths.size();
133.20 boolean[] newness = new boolean[cPathCount];
133.21 @@ -1078,7 +1081,7 @@
133.22 PathPlaceHolder placeholder;
133.23
133.24 for(int counter = 0; counter < cPathCount; counter++) {
133.25 - placeholder = changedPaths.elementAt(counter);
133.26 + placeholder = (PathPlaceHolder) changedPaths.elementAt(counter);
133.27 newness[counter] = placeholder.isNew;
133.28 paths[counter] = placeholder.path;
133.29 }
134.1 --- a/src/share/classes/sun/swing/MenuItemLayoutHelper.java Sun Sep 06 23:14:42 2009 -0700
134.2 +++ b/src/share/classes/sun/swing/MenuItemLayoutHelper.java Tue Sep 15 23:41:40 2009 -0700
134.3 @@ -84,7 +84,6 @@
134.4 private int minTextOffset;
134.5
134.6 private int leftTextExtraWidth;
134.7 - private int rightTextExtraWidth;
134.8
134.9 private Rectangle viewRect;
134.10
134.11 @@ -157,7 +156,6 @@
134.12
134.13 private void calcExtraWidths() {
134.14 leftTextExtraWidth = getLeftExtraWidth(text);
134.15 - rightTextExtraWidth = getRightExtraWidth(text);
134.16 }
134.17
134.18 private int getLeftExtraWidth(String str) {
134.19 @@ -169,15 +167,6 @@
134.20 }
134.21 }
134.22
134.23 - private int getRightExtraWidth(String str) {
134.24 - int rsb = SwingUtilities2.getRightSideBearing(mi, fm, str);
134.25 - if (rsb > 0) {
134.26 - return rsb;
134.27 - } else {
134.28 - return 0;
134.29 - }
134.30 - }
134.31 -
134.32 private void setOriginalWidths() {
134.33 iconSize.origWidth = iconSize.width;
134.34 textSize.origWidth = textSize.width;
134.35 @@ -313,7 +302,7 @@
134.36 verticalAlignment, horizontalAlignment,
134.37 verticalTextPosition, horizontalTextPosition,
134.38 viewRect, iconRect, textRect, gap);
134.39 - textRect.width += leftTextExtraWidth + rightTextExtraWidth;
134.40 + textRect.width += leftTextExtraWidth;
134.41 Rectangle labelRect = iconRect.union(textRect);
134.42 labelSize.height = labelRect.height;
134.43 labelSize.width = labelRect.width;
134.44 @@ -1121,10 +1110,6 @@
134.45 return leftTextExtraWidth;
134.46 }
134.47
134.48 - public int getRightTextExtraWidth() {
134.49 - return rightTextExtraWidth;
134.50 - }
134.51 -
134.52 /**
134.53 * Returns false if the component is a JMenu and it is a top
134.54 * level menu (on the menubar).
135.1 --- a/src/share/classes/sun/swing/SwingUtilities2.java Sun Sep 06 23:14:42 2009 -0700
135.2 +++ b/src/share/classes/sun/swing/SwingUtilities2.java Tue Sep 15 23:41:40 2009 -0700
135.3 @@ -27,7 +27,6 @@
135.4
135.5 import java.security.*;
135.6 import java.lang.reflect.*;
135.7 -import java.lang.ref.SoftReference;
135.8 import java.awt.*;
135.9 import static java.awt.RenderingHints.*;
135.10 import java.awt.event.*;
135.11 @@ -78,17 +77,23 @@
135.12 public static final Object LAF_STATE_KEY =
135.13 new StringBuffer("LookAndFeel State");
135.14
135.15 - // Most of applications use 10 or less fonts simultaneously
135.16 - private static final int STRONG_BEARING_CACHE_SIZE = 10;
135.17 - // Strong cache for the left and right side bearings
135.18 - // for STRONG_BEARING_CACHE_SIZE most recently used fonts.
135.19 - private static BearingCacheEntry[] strongBearingCache =
135.20 - new BearingCacheEntry[STRONG_BEARING_CACHE_SIZE];
135.21 - // Next index to insert an entry into the strong bearing cache
135.22 - private static int strongBearingCacheNextIndex = 0;
135.23 - // Soft cache for the left and right side bearings
135.24 - private static Set<SoftReference<BearingCacheEntry>> softBearingCache =
135.25 - new HashSet<SoftReference<BearingCacheEntry>>();
135.26 + // Maintain a cache of CACHE_SIZE fonts and the left side bearing
135.27 + // of the characters falling into the range MIN_CHAR_INDEX to
135.28 + // MAX_CHAR_INDEX. The values in fontCache are created as needed.
135.29 + private static LSBCacheEntry[] fontCache;
135.30 + // Windows defines 6 font desktop properties, we will therefore only
135.31 + // cache the metrics for 6 fonts.
135.32 + private static final int CACHE_SIZE = 6;
135.33 + // nextIndex in fontCache to insert a font into.
135.34 + private static int nextIndex;
135.35 + // LSBCacheEntry used to search in fontCache to see if we already
135.36 + // have an entry for a particular font
135.37 + private static LSBCacheEntry searchKey;
135.38 +
135.39 + // getLeftSideBearing will consult all characters that fall in the
135.40 + // range MIN_CHAR_INDEX to MAX_CHAR_INDEX.
135.41 + private static final int MIN_CHAR_INDEX = (int)'W';
135.42 + private static final int MAX_CHAR_INDEX = (int)'W' + 1;
135.43
135.44 public static final FontRenderContext DEFAULT_FRC =
135.45 new FontRenderContext(null, false, false);
135.46 @@ -183,6 +188,10 @@
135.47 private static final Object charsBufferLock = new Object();
135.48 private static char[] charsBuffer = new char[CHAR_BUFFER_SIZE];
135.49
135.50 + static {
135.51 + fontCache = new LSBCacheEntry[CACHE_SIZE];
135.52 + }
135.53 +
135.54 /**
135.55 * checks whether TextLayout is required to handle characters.
135.56 *
135.57 @@ -226,7 +235,9 @@
135.58
135.59 /**
135.60 * Returns the left side bearing of the first character of string. The
135.61 - * left side bearing is calculated from the passed in FontMetrics.
135.62 + * left side bearing is calculated from the passed in
135.63 + * FontMetrics. If the passed in String is less than one
135.64 + * character, this will throw a StringIndexOutOfBoundsException exception.
135.65 *
135.66 * @param c JComponent that will display the string
135.67 * @param fm FontMetrics used to measure the String width
135.68 @@ -234,14 +245,11 @@
135.69 */
135.70 public static int getLeftSideBearing(JComponent c, FontMetrics fm,
135.71 String string) {
135.72 - if ((string == null) || (string.length() == 0)) {
135.73 - return 0;
135.74 - }
135.75 return getLeftSideBearing(c, fm, string.charAt(0));
135.76 }
135.77
135.78 /**
135.79 - * Returns the left side bearing of the specified character. The
135.80 + * Returns the left side bearing of the first character of string. The
135.81 * left side bearing is calculated from the passed in FontMetrics.
135.82 *
135.83 * @param c JComponent that will display the string
135.84 @@ -250,105 +258,37 @@
135.85 */
135.86 public static int getLeftSideBearing(JComponent c, FontMetrics fm,
135.87 char firstChar) {
135.88 - return getBearing(c, fm, firstChar, true);
135.89 - }
135.90 + int charIndex = (int) firstChar;
135.91 + if (charIndex < MAX_CHAR_INDEX && charIndex >= MIN_CHAR_INDEX) {
135.92 + byte[] lsbs = null;
135.93
135.94 - /**
135.95 - * Returns the right side bearing of the last character of string. The
135.96 - * right side bearing is calculated from the passed in FontMetrics.
135.97 - *
135.98 - * @param c JComponent that will display the string
135.99 - * @param fm FontMetrics used to measure the String width
135.100 - * @param string String to get the right side bearing for.
135.101 - */
135.102 - public static int getRightSideBearing(JComponent c, FontMetrics fm,
135.103 - String string) {
135.104 - if ((string == null) || (string.length() == 0)) {
135.105 - return 0;
135.106 - }
135.107 - return getRightSideBearing(c, fm, string.charAt(string.length() - 1));
135.108 - }
135.109 -
135.110 - /**
135.111 - * Returns the right side bearing of the specified character. The
135.112 - * right side bearing is calculated from the passed in FontMetrics.
135.113 - *
135.114 - * @param c JComponent that will display the string
135.115 - * @param fm FontMetrics used to measure the String width
135.116 - * @param lastChar Character to get the right side bearing for.
135.117 - */
135.118 - public static int getRightSideBearing(JComponent c, FontMetrics fm,
135.119 - char lastChar) {
135.120 - return getBearing(c, fm, lastChar, false);
135.121 - }
135.122 -
135.123 - /* Calculates the left and right side bearing for a character.
135.124 - * Strongly caches bearings for STRONG_BEARING_CACHE_SIZE
135.125 - * most recently used Fonts and softly caches as many as GC allows.
135.126 - */
135.127 - private static int getBearing(JComponent comp, FontMetrics fm, char c,
135.128 - boolean isLeftBearing) {
135.129 - if (fm == null) {
135.130 - if (comp == null) {
135.131 - return 0;
135.132 - } else {
135.133 - fm = comp.getFontMetrics(comp.getFont());
135.134 - }
135.135 - }
135.136 - synchronized (SwingUtilities2.class) {
135.137 - BearingCacheEntry entry = null;
135.138 - BearingCacheEntry searchKey = new BearingCacheEntry(fm);
135.139 - // See if we already have an entry in the strong cache
135.140 - for (BearingCacheEntry cacheEntry : strongBearingCache) {
135.141 - if (searchKey.equals(cacheEntry)) {
135.142 - entry = cacheEntry;
135.143 - break;
135.144 + FontRenderContext frc = getFontRenderContext(c, fm);
135.145 + Font font = fm.getFont();
135.146 + synchronized (SwingUtilities2.class) {
135.147 + LSBCacheEntry entry = null;
135.148 + if (searchKey == null) {
135.149 + searchKey = new LSBCacheEntry(frc, font);
135.150 + } else {
135.151 + searchKey.reset(frc, font);
135.152 }
135.153 - }
135.154 - // See if we already have an entry in the soft cache
135.155 - if (entry == null) {
135.156 - Iterator<SoftReference<BearingCacheEntry>> iter =
135.157 - softBearingCache.iterator();
135.158 - while (iter.hasNext()) {
135.159 - BearingCacheEntry cacheEntry = iter.next().get();
135.160 - if (cacheEntry == null) {
135.161 - // Remove discarded soft reference from the cache
135.162 - iter.remove();
135.163 - continue;
135.164 - }
135.165 + // See if we already have an entry for this pair
135.166 + for (LSBCacheEntry cacheEntry : fontCache) {
135.167 if (searchKey.equals(cacheEntry)) {
135.168 entry = cacheEntry;
135.169 - putEntryInStrongCache(entry);
135.170 break;
135.171 }
135.172 }
135.173 + if (entry == null) {
135.174 + // No entry for this pair, add it.
135.175 + entry = searchKey;
135.176 + fontCache[nextIndex] = searchKey;
135.177 + searchKey = null;
135.178 + nextIndex = (nextIndex + 1) % CACHE_SIZE;
135.179 + }
135.180 + return entry.getLeftSideBearing(firstChar);
135.181 }
135.182 - if (entry == null) {
135.183 - // No entry, add it
135.184 - entry = searchKey;
135.185 - cacheEntry(entry);
135.186 - }
135.187 - return (isLeftBearing)
135.188 - ? entry.getLeftSideBearing(c)
135.189 - : entry.getRightSideBearing(c);
135.190 }
135.191 - }
135.192 -
135.193 - private synchronized static void cacheEntry(BearingCacheEntry entry) {
135.194 - // Move the oldest entry from the strong cache into the soft cache
135.195 - BearingCacheEntry oldestEntry =
135.196 - strongBearingCache[strongBearingCacheNextIndex];
135.197 - if (oldestEntry != null) {
135.198 - softBearingCache.add(new SoftReference<BearingCacheEntry>(oldestEntry));
135.199 - }
135.200 - // Put entry in the strong cache
135.201 - putEntryInStrongCache(entry);
135.202 - }
135.203 -
135.204 - private synchronized static void putEntryInStrongCache(BearingCacheEntry entry) {
135.205 - strongBearingCache[strongBearingCacheNextIndex] = entry;
135.206 - strongBearingCacheNextIndex = (strongBearingCacheNextIndex + 1)
135.207 - % STRONG_BEARING_CACHE_SIZE;
135.208 + return 0;
135.209 }
135.210
135.211 /**
135.212 @@ -1063,99 +1003,72 @@
135.213 }
135.214
135.215 /**
135.216 - * BearingCacheEntry is used to cache left and right character bearings
135.217 - * for a particular <code>Font</code> and <code>FontRenderContext</code>.
135.218 + * LSBCacheEntry is used to cache the left side bearing (lsb) for
135.219 + * a particular <code>Font</code> and <code>FontRenderContext</code>.
135.220 + * This only caches characters that fall in the range
135.221 + * <code>MIN_CHAR_INDEX</code> to <code>MAX_CHAR_INDEX</code>.
135.222 */
135.223 - private static class BearingCacheEntry {
135.224 - private FontMetrics fontMetrics;
135.225 + private static class LSBCacheEntry {
135.226 + // Used to indicate a particular entry in lsb has not been set.
135.227 + private static final byte UNSET = Byte.MAX_VALUE;
135.228 + // Used in creating a GlyphVector to get the lsb
135.229 + private static final char[] oneChar = new char[1];
135.230 +
135.231 + private byte[] lsbCache;
135.232 private Font font;
135.233 private FontRenderContext frc;
135.234 - private Map<Character, Short> cache;
135.235 - // Used for the creation of a GlyphVector
135.236 - private static final char[] oneChar = new char[1];
135.237
135.238 - public BearingCacheEntry(FontMetrics fontMetrics) {
135.239 - this.fontMetrics = fontMetrics;
135.240 - this.font = fontMetrics.getFont();
135.241 - this.frc = fontMetrics.getFontRenderContext();
135.242 - this.cache = new HashMap<Character, Short>();
135.243 - assert (font != null && frc != null);
135.244 +
135.245 + public LSBCacheEntry(FontRenderContext frc, Font font) {
135.246 + lsbCache = new byte[MAX_CHAR_INDEX - MIN_CHAR_INDEX];
135.247 + reset(frc, font);
135.248 +
135.249 + }
135.250 +
135.251 + public void reset(FontRenderContext frc, Font font) {
135.252 + this.font = font;
135.253 + this.frc = frc;
135.254 + for (int counter = lsbCache.length - 1; counter >= 0; counter--) {
135.255 + lsbCache[counter] = UNSET;
135.256 + }
135.257 }
135.258
135.259 public int getLeftSideBearing(char aChar) {
135.260 - Short bearing = cache.get(aChar);
135.261 - if (bearing == null) {
135.262 - bearing = calcBearing(aChar);
135.263 - cache.put(aChar, bearing);
135.264 + int index = aChar - MIN_CHAR_INDEX;
135.265 + assert (index >= 0 && index < (MAX_CHAR_INDEX - MIN_CHAR_INDEX));
135.266 + byte lsb = lsbCache[index];
135.267 + if (lsb == UNSET) {
135.268 + oneChar[0] = aChar;
135.269 + GlyphVector gv = font.createGlyphVector(frc, oneChar);
135.270 + lsb = (byte) gv.getGlyphPixelBounds(0, frc, 0f, 0f).x;
135.271 + if (lsb < 0) {
135.272 + /* HRGB/HBGR LCD glyph images will always have a pixel
135.273 + * on the left used in colour fringe reduction.
135.274 + * Text rendering positions this correctly but here
135.275 + * we are using the glyph image to adjust that position
135.276 + * so must account for it.
135.277 + */
135.278 + Object aaHint = frc.getAntiAliasingHint();
135.279 + if (aaHint == VALUE_TEXT_ANTIALIAS_LCD_HRGB ||
135.280 + aaHint == VALUE_TEXT_ANTIALIAS_LCD_HBGR) {
135.281 + lsb++;
135.282 + }
135.283 + }
135.284 + lsbCache[index] = lsb;
135.285 }
135.286 - return ((0xFF00 & bearing) >>> 8) - 127;
135.287 - }
135.288 + return lsb;
135.289
135.290 - public int getRightSideBearing(char aChar) {
135.291 - Short bearing = cache.get(aChar);
135.292 - if (bearing == null) {
135.293 - bearing = calcBearing(aChar);
135.294 - cache.put(aChar, bearing);
135.295 - }
135.296 - return (0xFF & bearing) - 127;
135.297 - }
135.298
135.299 - /* Calculates left and right side bearings for a character.
135.300 - * Makes an assumption that bearing is a value between -127 and +127.
135.301 - * Stores LSB and RSB as single two-byte number (short):
135.302 - * LSB is the high byte, RSB is the low byte.
135.303 - */
135.304 - private short calcBearing(char aChar) {
135.305 - oneChar[0] = aChar;
135.306 - GlyphVector gv = font.createGlyphVector(frc, oneChar);
135.307 - Rectangle pixelBounds = gv.getGlyphPixelBounds(0, frc, 0f, 0f);
135.308 -
135.309 - // Get bearings
135.310 - int lsb = pixelBounds.x;
135.311 - int rsb = pixelBounds.width - fontMetrics.charWidth(aChar);
135.312 -
135.313 - /* HRGB/HBGR LCD glyph images will always have a pixel
135.314 - * on the left and a pixel on the right
135.315 - * used in colour fringe reduction.
135.316 - * Text rendering positions this correctly but here
135.317 - * we are using the glyph image to adjust that position
135.318 - * so must account for it.
135.319 - */
135.320 - if (lsb < 0) {
135.321 - Object aaHint = frc.getAntiAliasingHint();
135.322 - if (aaHint == VALUE_TEXT_ANTIALIAS_LCD_HRGB ||
135.323 - aaHint == VALUE_TEXT_ANTIALIAS_LCD_HBGR) {
135.324 - lsb++;
135.325 - }
135.326 - }
135.327 - if (rsb > 0) {
135.328 - Object aaHint = frc.getAntiAliasingHint();
135.329 - if (aaHint == VALUE_TEXT_ANTIALIAS_LCD_HRGB ||
135.330 - aaHint == VALUE_TEXT_ANTIALIAS_LCD_HBGR) {
135.331 - rsb--;
135.332 - }
135.333 - }
135.334 -
135.335 - // Make sure that LSB and RSB are valid (see 6472972)
135.336 - if (lsb < -127 || lsb > 127) {
135.337 - lsb = 0;
135.338 - }
135.339 - if (rsb < -127 || rsb > 127) {
135.340 - rsb = 0;
135.341 - }
135.342 -
135.343 - int bearing = ((lsb + 127) << 8) + (rsb + 127);
135.344 - return (short)bearing;
135.345 }
135.346
135.347 public boolean equals(Object entry) {
135.348 if (entry == this) {
135.349 return true;
135.350 }
135.351 - if (!(entry instanceof BearingCacheEntry)) {
135.352 + if (!(entry instanceof LSBCacheEntry)) {
135.353 return false;
135.354 }
135.355 - BearingCacheEntry oEntry = (BearingCacheEntry)entry;
135.356 + LSBCacheEntry oEntry = (LSBCacheEntry) entry;
135.357 return (font.equals(oEntry.font) &&
135.358 frc.equals(oEntry.frc));
135.359 }
135.360 @@ -1172,7 +1085,6 @@
135.361 }
135.362 }
135.363
135.364 -
135.365 /*
135.366 * here goes the fix for 4856343 [Problem with applet interaction
135.367 * with system selection clipboard]
135.368 @@ -1181,36 +1093,34 @@
135.369 * are to be performed
135.370 */
135.371
135.372 -
135.373 /**
135.374 - * checks the security permissions for accessing system clipboard
135.375 - *
135.376 - * for untrusted context (see isTrustedContext) checks the
135.377 - * permissions for the current event being handled
135.378 - *
135.379 - */
135.380 - public static boolean canAccessSystemClipboard() {
135.381 - boolean canAccess = false;
135.382 - if (!GraphicsEnvironment.isHeadless()) {
135.383 - SecurityManager sm = System.getSecurityManager();
135.384 - if (sm == null) {
135.385 - canAccess = true;
135.386 - } else {
135.387 - try {
135.388 - sm.checkSystemClipboardAccess();
135.389 - canAccess = true;
135.390 - } catch (SecurityException e) {
135.391 - }
135.392 - if (canAccess && ! isTrustedContext()) {
135.393 - canAccess = canCurrentEventAccessSystemClipboard(true);
135.394 - }
135.395 - }
135.396 - }
135.397 - return canAccess;
135.398 - }
135.399 -
135.400 + * checks the security permissions for accessing system clipboard
135.401 + *
135.402 + * for untrusted context (see isTrustedContext) checks the
135.403 + * permissions for the current event being handled
135.404 + *
135.405 + */
135.406 + public static boolean canAccessSystemClipboard() {
135.407 + boolean canAccess = false;
135.408 + if (!GraphicsEnvironment.isHeadless()) {
135.409 + SecurityManager sm = System.getSecurityManager();
135.410 + if (sm == null) {
135.411 + canAccess = true;
135.412 + } else {
135.413 + try {
135.414 + sm.checkSystemClipboardAccess();
135.415 + canAccess = true;
135.416 + } catch (SecurityException e) {
135.417 + }
135.418 + if (canAccess && ! isTrustedContext()) {
135.419 + canAccess = canCurrentEventAccessSystemClipboard(true);
135.420 + }
135.421 + }
135.422 + }
135.423 + return canAccess;
135.424 + }
135.425 /**
135.426 - * Returns true if EventQueue.getCurrentEvent() has the permissions to
135.427 + * Returns true if EventQueue.getCurrentEvent() has the permissions to
135.428 * access the system clipboard
135.429 */
135.430 public static boolean canCurrentEventAccessSystemClipboard() {
135.431 @@ -1844,4 +1754,22 @@
135.432 boolean three) {
135.433 return liesIn(rect, p, false, false, three);
135.434 }
135.435 +
135.436 + /**
135.437 + * Returns the {@code JViewport} instance for the {@code component}
135.438 + * or {@code null}.
135.439 + *
135.440 + * @return the {@code JViewport} instance for the {@code component}
135.441 + * or {@code null}
135.442 + * @throws NullPointerException if {@code component} is {@code null}
135.443 + */
135.444 + public static JViewport getViewport(Component component) {
135.445 + do {
135.446 + component = component.getParent();
135.447 + if (component instanceof JViewport) {
135.448 + return (JViewport) component;
135.449 + }
135.450 + } while(component instanceof JLayer);
135.451 + return null;
135.452 + }
135.453 }
136.1 --- a/src/solaris/classes/sun/awt/X11/XErrorHandler.java Sun Sep 06 23:14:42 2009 -0700
136.2 +++ b/src/solaris/classes/sun/awt/X11/XErrorHandler.java Tue Sep 15 23:41:40 2009 -0700
136.3 @@ -71,8 +71,8 @@
136.4 return super.handleError(display, err);
136.5 }
136.6 // Shared instance
136.7 - private static IgnoreBadWindowHandler theInstance = new IgnoreBadWindowHandler();
136.8 - public static IgnoreBadWindowHandler getInstance() {
136.9 + private static VerifyChangePropertyHandler theInstance = new VerifyChangePropertyHandler();
136.10 + public static VerifyChangePropertyHandler getInstance() {
136.11 return theInstance;
136.12 }
136.13 }
137.1 --- a/src/solaris/classes/sun/awt/X11/XKeysym.java Sun Sep 06 23:14:42 2009 -0700
137.2 +++ b/src/solaris/classes/sun/awt/X11/XKeysym.java Tue Sep 15 23:41:40 2009 -0700
137.3 @@ -354,6 +354,7 @@
137.4 keysym2UCSHash.put( (long)0xFFB7, (char)0x0037); // XK_KP_7 --> DIGIT SEVEN
137.5 keysym2UCSHash.put( (long)0xFFB8, (char)0x0038); // XK_KP_8 --> DIGIT EIGHT
137.6 keysym2UCSHash.put( (long)0xFFB9, (char)0x0039); // XK_KP_9 --> DIGIT NINE
137.7 + keysym2UCSHash.put( (long)0xFE20, (char)0x0009); // XK_ISO_Left_Tab --> <control>
137.8 keysym2UCSHash.put( (long)0x1a1, (char)0x0104); // XK_Aogonek --> LATIN CAPITAL LETTER A WITH OGONEK
137.9 keysym2UCSHash.put( (long)0x1a2, (char)0x02d8); // XK_breve --> BREVE
137.10 keysym2UCSHash.put( (long)0x1a3, (char)0x0141); // XK_Lstroke --> LATIN CAPITAL LETTER L WITH STROKE
138.1 --- a/src/solaris/classes/sun/awt/X11/XToolkit.java Sun Sep 06 23:14:42 2009 -0700
138.2 +++ b/src/solaris/classes/sun/awt/X11/XToolkit.java Tue Sep 15 23:41:40 2009 -0700
138.3 @@ -166,6 +166,9 @@
138.4 }
138.5
138.6 public static void RESTORE_XERROR_HANDLER() {
138.7 + // wait until all requests are processed by the X server
138.8 + // and only then uninstall the error handler
138.9 + XSync();
138.10 current_error_handler = null;
138.11 }
138.12
139.1 --- a/src/solaris/classes/sun/awt/X11/keysym2ucs.h Sun Sep 06 23:14:42 2009 -0700
139.2 +++ b/src/solaris/classes/sun/awt/X11/keysym2ucs.h Tue Sep 15 23:41:40 2009 -0700
139.3 @@ -649,7 +649,7 @@
139.4 0x0000 #define XK_ISO_Last_Group 0xFE0E
139.5 0x0000 #define XK_ISO_Last_Group_Lock 0xFE0F
139.6
139.7 -0x0000 #define XK_ISO_Left_Tab 0xFE20
139.8 +0x0009 #define XK_ISO_Left_Tab 0xFE20
139.9 0x0000 #define XK_ISO_Move_Line_Up 0xFE21
139.10 0x0000 #define XK_ISO_Move_Line_Down 0xFE22
139.11 0x0000 #define XK_ISO_Partial_Line_Up 0xFE23
140.1 --- a/src/solaris/native/java/util/TimeZone_md.c Sun Sep 06 23:14:42 2009 -0700
140.2 +++ b/src/solaris/native/java/util/TimeZone_md.c Tue Sep 15 23:41:40 2009 -0700
140.3 @@ -51,9 +51,9 @@
140.4
140.5 #ifdef __linux__
140.6
140.7 -static const char *sysconfig_clock_file = "/etc/sysconfig/clock";
140.8 -static const char *zoneinfo_dir = "/usr/share/zoneinfo";
140.9 -static const char *defailt_zoneinfo_file = "/etc/localtime";
140.10 +static const char *ETC_TIMEZONE_FILE = "/etc/timezone";
140.11 +static const char *ZONEINFO_DIR = "/usr/share/zoneinfo";
140.12 +static const char *DEFAULT_ZONEINFO_FILE = "/etc/localtime";
140.13
140.14 /*
140.15 * Returns a point to the zone ID portion of the given zoneinfo file
140.16 @@ -201,53 +201,22 @@
140.17 size_t size;
140.18
140.19 /*
140.20 - * First, try the ZONE entry in /etc/sysconfig/clock. However, the
140.21 - * ZONE entry is not set up after initial Red Hat Linux
140.22 - * installation. In case that /etc/localtime is set up without
140.23 - * using timeconfig, there might be inconsistency between
140.24 - * /etc/localtime and the ZONE entry. The inconsistency between
140.25 - * timeconfig and linuxconf is reported as a bug in the Red Hat
140.26 - * web page as of May 1, 2000.
140.27 + * Try reading the /etc/timezone file for Debian distros. There's
140.28 + * no spec of the file format available. This parsing assumes that
140.29 + * there's one line of an Olson tzid followed by a '\n', no
140.30 + * leading or trailing spaces, no comments.
140.31 */
140.32 - if ((fp = fopen(sysconfig_clock_file, "r")) != NULL) {
140.33 + if ((fp = fopen(ETC_TIMEZONE_FILE, "r")) != NULL) {
140.34 char line[256];
140.35
140.36 - while (fgets(line, sizeof(line), fp) != NULL) {
140.37 - char *p = line;
140.38 - char *s;
140.39 -
140.40 - SKIP_SPACE(p);
140.41 - if (*p != 'Z') {
140.42 - continue;
140.43 + if (fgets(line, sizeof(line), fp) != NULL) {
140.44 + char *p = strchr(line, '\n');
140.45 + if (p != NULL) {
140.46 + *p = '\0';
140.47 }
140.48 - if (strncmp(p, "ZONE=\"", 6) == 0) {
140.49 - p += 6;
140.50 - } else {
140.51 - /*
140.52 - * In case we need to parse it token by token.
140.53 - */
140.54 - if (strncmp(p, "ZONE", 4) != 0) {
140.55 - continue;
140.56 - }
140.57 - p += 4;
140.58 - SKIP_SPACE(p);
140.59 - if (*p++ != '=') {
140.60 - break;
140.61 - }
140.62 - SKIP_SPACE(p);
140.63 - if (*p++ != '"') {
140.64 - break;
140.65 - }
140.66 + if (strlen(line) > 0) {
140.67 + tz = strdup(line);
140.68 }
140.69 - for (s = p; *s && *s != '"'; s++)
140.70 - ;
140.71 - if (*s != '"') {
140.72 - /* this ZONE entry is broken. */
140.73 - break;
140.74 - }
140.75 - *s = '\0';
140.76 - tz = strdup(p);
140.77 - break;
140.78 }
140.79 (void) fclose(fp);
140.80 if (tz != NULL) {
140.81 @@ -258,7 +227,7 @@
140.82 /*
140.83 * Next, try /etc/localtime to find the zone ID.
140.84 */
140.85 - if (lstat(defailt_zoneinfo_file, &statbuf) == -1) {
140.86 + if (lstat(DEFAULT_ZONEINFO_FILE, &statbuf) == -1) {
140.87 return NULL;
140.88 }
140.89
140.90 @@ -273,9 +242,9 @@
140.91 char linkbuf[PATH_MAX+1];
140.92 int len;
140.93
140.94 - if ((len = readlink(defailt_zoneinfo_file, linkbuf, sizeof(linkbuf)-1)) == -1) {
140.95 + if ((len = readlink(DEFAULT_ZONEINFO_FILE, linkbuf, sizeof(linkbuf)-1)) == -1) {
140.96 jio_fprintf(stderr, (const char *) "can't get a symlink of %s\n",
140.97 - defailt_zoneinfo_file);
140.98 + DEFAULT_ZONEINFO_FILE);
140.99 return NULL;
140.100 }
140.101 linkbuf[len] = '\0';
140.102 @@ -295,7 +264,7 @@
140.103 if (buf == NULL) {
140.104 return NULL;
140.105 }
140.106 - if ((fd = open(defailt_zoneinfo_file, O_RDONLY)) == -1) {
140.107 + if ((fd = open(DEFAULT_ZONEINFO_FILE, O_RDONLY)) == -1) {
140.108 free((void *) buf);
140.109 return NULL;
140.110 }
140.111 @@ -307,7 +276,7 @@
140.112 }
140.113 (void) close(fd);
140.114
140.115 - tz = findZoneinfoFile(buf, size, zoneinfo_dir);
140.116 + tz = findZoneinfoFile(buf, size, ZONEINFO_DIR);
140.117 free((void *) buf);
140.118 return tz;
140.119 }
141.1 --- a/src/windows/classes/sun/awt/windows/fontconfig.properties Sun Sep 06 23:14:42 2009 -0700
141.2 +++ b/src/windows/classes/sun/awt/windows/fontconfig.properties Tue Sep 15 23:41:40 2009 -0700
141.3 @@ -1,6 +1,6 @@
141.4 #
141.5 #
141.6 -# Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
141.7 +# Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
141.8 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
141.9 #
141.10 # This code is free software; you can redistribute it and/or modify it
141.11 @@ -31,8 +31,11 @@
141.12 # Component Font Mappings
141.13
141.14 allfonts.chinese-ms936=SimSun
141.15 +allfonts.chinese-ms936-extb=SimSun-ExtB
141.16 allfonts.chinese-gb18030=SimSun-18030
141.17 +allfonts.chinese-gb18030-extb=SimSun-ExtB
141.18 allfonts.chinese-hkscs=MingLiU_HKSCS
141.19 +allfonts.chinese-ms950-extb=MingLiU-ExtB
141.20 allfonts.devanagari=Mangal
141.21 allfonts.dingbats=Wingdings
141.22 allfonts.lucida=Lucida Sans Regular
141.23 @@ -41,120 +44,140 @@
141.24
141.25 serif.plain.alphabetic=Times New Roman
141.26 serif.plain.chinese-ms950=MingLiU
141.27 +serif.plain.chinese-ms950-extb=MingLiU-ExtB
141.28 serif.plain.hebrew=David
141.29 serif.plain.japanese=MS Mincho
141.30 serif.plain.korean=Batang
141.31
141.32 serif.bold.alphabetic=Times New Roman Bold
141.33 serif.bold.chinese-ms950=PMingLiU
141.34 +serif.bold.chinese-ms950-extb=PMingLiU-ExtB
141.35 serif.bold.hebrew=David Bold
141.36 serif.bold.japanese=MS Mincho
141.37 serif.bold.korean=Batang
141.38
141.39 serif.italic.alphabetic=Times New Roman Italic
141.40 serif.italic.chinese-ms950=PMingLiU
141.41 +serif.italic.chinese-ms950-extb=PMingLiU-ExtB
141.42 serif.italic.hebrew=David
141.43 serif.italic.japanese=MS Mincho
141.44 serif.italic.korean=Batang
141.45
141.46 serif.bolditalic.alphabetic=Times New Roman Bold Italic
141.47 serif.bolditalic.chinese-ms950=PMingLiU
141.48 +serif.bolditalic.chinese-ms950-extb=PMingLiU-ExtB
141.49 serif.bolditalic.hebrew=David Bold
141.50 serif.bolditalic.japanese=MS Mincho
141.51 serif.bolditalic.korean=Batang
141.52
141.53 sansserif.plain.alphabetic=Arial
141.54 sansserif.plain.chinese-ms950=MingLiU
141.55 +sansserif.plain.chinese-ms950-extb=MingLiU-ExtB
141.56 sansserif.plain.hebrew=David
141.57 sansserif.plain.japanese=MS Gothic
141.58 sansserif.plain.korean=Gulim
141.59
141.60 sansserif.bold.alphabetic=Arial Bold
141.61 sansserif.bold.chinese-ms950=PMingLiU
141.62 +sansserif.bold.chinese-ms950-extb=PMingLiU-ExtB
141.63 sansserif.bold.hebrew=David Bold
141.64 sansserif.bold.japanese=MS Gothic
141.65 sansserif.bold.korean=Gulim
141.66
141.67 sansserif.italic.alphabetic=Arial Italic
141.68 sansserif.italic.chinese-ms950=PMingLiU
141.69 +sansserif.italic.chinese-ms950-extb=PMingLiU-ExtB
141.70 sansserif.italic.hebrew=David
141.71 sansserif.italic.japanese=MS Gothic
141.72 sansserif.italic.korean=Gulim
141.73
141.74 sansserif.bolditalic.alphabetic=Arial Bold Italic
141.75 sansserif.bolditalic.chinese-ms950=PMingLiU
141.76 +sansserif.bolditalic.chinese-ms950-extb=PMingLiU-ExtB
141.77 sansserif.bolditalic.hebrew=David Bold
141.78 sansserif.bolditalic.japanese=MS Gothic
141.79 sansserif.bolditalic.korean=Gulim
141.80
141.81 monospaced.plain.alphabetic=Courier New
141.82 monospaced.plain.chinese-ms950=MingLiU
141.83 +monospaced.plain.chinese-ms950-extb=MingLiU-ExtB
141.84 monospaced.plain.hebrew=David
141.85 monospaced.plain.japanese=MS Gothic
141.86 monospaced.plain.korean=GulimChe
141.87
141.88 monospaced.bold.alphabetic=Courier New Bold
141.89 monospaced.bold.chinese-ms950=PMingLiU
141.90 +monospaced.bold.chinese-ms950-extb=PMingLiU-ExtB
141.91 monospaced.bold.hebrew=David Bold
141.92 monospaced.bold.japanese=MS Gothic
141.93 monospaced.bold.korean=GulimChe
141.94
141.95 monospaced.italic.alphabetic=Courier New Italic
141.96 monospaced.italic.chinese-ms950=PMingLiU
141.97 +monospaced.italic.chinese-ms950-extb=PMingLiU-ExtB
141.98 monospaced.italic.hebrew=David
141.99 monospaced.italic.japanese=MS Gothic
141.100 monospaced.italic.korean=GulimChe
141.101
141.102 monospaced.bolditalic.alphabetic=Courier New Bold Italic
141.103 monospaced.bolditalic.chinese-ms950=PMingLiU
141.104 +monospaced.bolditalic.chinese-ms950-extb=PMingLiU-ExtB
141.105 monospaced.bolditalic.hebrew=David Bold
141.106 monospaced.bolditalic.japanese=MS Gothic
141.107 monospaced.bolditalic.korean=GulimChe
141.108
141.109 dialog.plain.alphabetic=Arial
141.110 dialog.plain.chinese-ms950=MingLiU
141.111 +dialog.plain.chinese-ms950-extb=MingLiU-ExtB
141.112 dialog.plain.hebrew=David
141.113 dialog.plain.japanese=MS Gothic
141.114 dialog.plain.korean=Gulim
141.115
141.116 dialog.bold.alphabetic=Arial Bold
141.117 dialog.bold.chinese-ms950=PMingLiU
141.118 +dialog.bold.chinese-ms950-extb=PMingLiU-ExtB
141.119 dialog.bold.hebrew=David Bold
141.120 dialog.bold.japanese=MS Gothic
141.121 dialog.bold.korean=Gulim
141.122
141.123 dialog.italic.alphabetic=Arial Italic
141.124 dialog.italic.chinese-ms950=PMingLiU
141.125 +dialog.italic.chinese-ms950-extb=PMingLiU-ExtB
141.126 dialog.italic.hebrew=David
141.127 dialog.italic.japanese=MS Gothic
141.128 dialog.italic.korean=Gulim
141.129
141.130 dialog.bolditalic.alphabetic=Arial Bold Italic
141.131 dialog.bolditalic.chinese-ms950=PMingLiU
141.132 +dialog.bolditalic.chinese-ms950-extb=PMingLiU-ExtB
141.133 dialog.bolditalic.hebrew=David Bold
141.134 dialog.bolditalic.japanese=MS Gothic
141.135 dialog.bolditalic.korean=Gulim
141.136
141.137 dialoginput.plain.alphabetic=Courier New
141.138 dialoginput.plain.chinese-ms950=MingLiU
141.139 +dialoginput.plain.chinese-ms950-extb=MingLiU-ExtB
141.140 dialoginput.plain.hebrew=David
141.141 dialoginput.plain.japanese=MS Gothic
141.142 dialoginput.plain.korean=Gulim
141.143
141.144 dialoginput.bold.alphabetic=Courier New Bold
141.145 dialoginput.bold.chinese-ms950=PMingLiU
141.146 +dialoginput.bold.chinese-ms950-extb=PMingLiU-ExtB
141.147 dialoginput.bold.hebrew=David Bold
141.148 dialoginput.bold.japanese=MS Gothic
141.149 dialoginput.bold.korean=Gulim
141.150
141.151 dialoginput.italic.alphabetic=Courier New Italic
141.152 dialoginput.italic.chinese-ms950=PMingLiU
141.153 +dialoginput.italic.chinese-ms950-extb=PMingLiU-ExtB
141.154 dialoginput.italic.hebrew=David
141.155 dialoginput.italic.japanese=MS Gothic
141.156 dialoginput.italic.korean=Gulim
141.157
141.158 dialoginput.bolditalic.alphabetic=Courier New Bold Italic
141.159 dialoginput.bolditalic.chinese-ms950=PMingLiU
141.160 +dialoginput.bolditalic.chinese-ms950-extb=PMingLiU-ExtB
141.161 dialoginput.bolditalic.hebrew=David Bold
141.162 dialoginput.bolditalic.japanese=MS Gothic
141.163 dialoginput.bolditalic.korean=Gulim
141.164 @@ -163,31 +186,32 @@
141.165
141.166 sequence.allfonts=alphabetic/default,dingbats,symbol
141.167
141.168 -sequence.serif.GBK=alphabetic,chinese-ms936,dingbats,symbol
141.169 -sequence.sansserif.GBK=alphabetic,chinese-ms936,dingbats,symbol
141.170 -sequence.monospaced.GBK=chinese-ms936,alphabetic,dingbats,symbol
141.171 -sequence.dialog.GBK=alphabetic,chinese-ms936,dingbats,symbol
141.172 -sequence.dialoginput.GBK=alphabetic,chinese-ms936,dingbats,symbol
141.173 +sequence.serif.GBK=alphabetic,chinese-ms936,dingbats,symbol,chinese-ms936-extb
141.174 +sequence.sansserif.GBK=alphabetic,chinese-ms936,dingbats,symbol,chinese-ms936-extb
141.175 +sequence.monospaced.GBK=chinese-ms936,alphabetic,dingbats,symbol,chinese-ms936-extb
141.176 +sequence.dialog.GBK=alphabetic,chinese-ms936,dingbats,symbol,chinese-ms936-extb
141.177 +sequence.dialoginput.GBK=alphabetic,chinese-ms936,dingbats,symbol,chinese-ms936-extb
141.178
141.179 -sequence.serif.GB18030=alphabetic,chinese-gb18030,dingbats,symbol
141.180 -sequence.sansserif.GB18030=alphabetic,chinese-gb18030,dingbats,symbol
141.181 -sequence.monospaced.GB18030=chinese-gb18030,alphabetic,dingbats,symbol
141.182 -sequence.dialog.GB18030=alphabetic,chinese-gb18030,dingbats,symbol
141.183 -sequence.dialoginput.GB18030=alphabetic,chinese-gb18030,dingbats,symbol
141.184 +sequence.serif.GB18030=alphabetic,chinese-gb18030,dingbats,symbol,chinese-gb18030-extb
141.185 +sequence.sansserif.GB18030=alphabetic,chinese-gb18030,dingbats,symbol,chinese-gb18030-extb
141.186 +sequence.monospaced.GB18030=chinese-gb18030,alphabetic,dingbats,symbol,chinese-gb18030-extb
141.187 +sequence.dialog.GB18030=alphabetic,chinese-gb18030,dingbats,symbol,chinese-gb18030-extb
141.188 +sequence.dialoginput.GB18030=alphabetic,chinese-gb18030,dingbats,symbol,chinese-gb18030-extb
141.189
141.190 -sequence.serif.x-windows-950=alphabetic,chinese-ms950,dingbats,symbol
141.191 -sequence.sansserif.x-windows-950=alphabetic,chinese-ms950,dingbats,symbol
141.192 -sequence.monospaced.x-windows-950=chinese-ms950,alphabetic,dingbats,symbol
141.193 -sequence.dialog.x-windows-950=alphabetic,chinese-ms950,dingbats,symbol
141.194 -sequence.dialoginput.x-windows-950=alphabetic,chinese-ms950,dingbats,symbol
141.195 +sequence.serif.x-windows-950=alphabetic,chinese-ms950,dingbats,symbol,chinese-ms950-extb
141.196 +sequence.sansserif.x-windows-950=alphabetic,chinese-ms950,dingbats,symbol,chinese-ms950-extb
141.197 +sequence.monospaced.x-windows-950=chinese-ms950,alphabetic,dingbats,symbol,chinese-ms950-extb
141.198 +sequence.dialog.x-windows-950=alphabetic,chinese-ms950,dingbats,symbol,chinese-ms950-extb
141.199 +sequence.dialoginput.x-windows-950=alphabetic,chinese-ms950,dingbats,symbol,chinese-ms950-extb
141.200
141.201 -sequence.serif.x-MS950-HKSCS=alphabetic,chinese-ms950,chinese-hkscs,dingbats,symbol
141.202 -sequence.sansserif.x-MS950-HKSCS=alphabetic,chinese-ms950,chinese-hkscs,dingbats,symbol
141.203 -sequence.monospaced.x-MS950-HKSCS=chinese-ms950,alphabetic,chinese-hkscs,dingbats,symbol
141.204 -sequence.dialog.x-MS950-HKSCS=alphabetic,chinese-ms950,chinese-hkscs,dingbats,symbol
141.205 -sequence.dialoginput.x-MS950-HKSCS=alphabetic,chinese-ms950,chinese-hkscs,dingbats,symbol
141.206 +sequence.serif.x-MS950-HKSCS=alphabetic,chinese-ms950,chinese-hkscs,dingbats,symbol,chinese-ms950-extb
141.207 +sequence.sansserif.x-MS950-HKSCS=alphabetic,chinese-ms950,chinese-hkscs,dingbats,symbol,chinese-ms950-extb
141.208 +sequence.monospaced.x-MS950-HKSCS=chinese-ms950,alphabetic,chinese-hkscs,dingbats,symbol,chinese-ms950-extb
141.209 +sequence.dialog.x-MS950-HKSCS=alphabetic,chinese-ms950,chinese-hkscs,dingbats,symbol,chinese-ms950-extb
141.210 +sequence.dialoginput.x-MS950-HKSCS=alphabetic,chinese-ms950,chinese-hkscs,dingbats,symbol,chinese-ms950-extb
141.211
141.212 sequence.allfonts.UTF-8.hi=alphabetic/1252,devanagari,dingbats,symbol
141.213 +sequence.allfonts.UTF-8.ja=alphabetic,japanese,devanagari,dingbats,symbol
141.214
141.215 sequence.allfonts.windows-1255=hebrew,alphabetic/1252,dingbats,symbol
141.216
141.217 @@ -207,7 +231,7 @@
141.218
141.219 sequence.fallback=lucida,\
141.220 chinese-ms950,chinese-hkscs,chinese-ms936,chinese-gb18030,\
141.221 - japanese,korean
141.222 + japanese,korean,chinese-ms950-extb,chinese-ms936-extb
141.223
141.224 # Exclusion Ranges
141.225
141.226 @@ -220,6 +244,7 @@
141.227 proportional.MS_Gothic=MS PGothic
141.228 proportional.MS_Mincho=MS PMincho
141.229 proportional.MingLiU=PMingLiU
141.230 +proportional.MingLiU-ExtB=PMingLiU-ExtB
141.231
141.232 # Font File Names
141.233
141.234 @@ -240,9 +265,12 @@
141.235
141.236 filename.SimSun=SIMSUN.TTC
141.237 filename.SimSun-18030=SIMSUN18030.TTC
141.238 +filename.SimSun-ExtB=SIMSUNB.TTF
141.239
141.240 filename.MingLiU=MINGLIU.TTC
141.241 +filename.MingLiU-ExtB=MINGLIUB.TTC
141.242 filename.PMingLiU=MINGLIU.TTC
141.243 +filename.PMingLiU-ExtB=MINGLIUB.TTC
141.244 filename.MingLiU_HKSCS=hkscsm3u.ttf
141.245
141.246 filename.David=DAVID.TTF
142.1 --- a/src/windows/lib/tzmappings Sun Sep 06 23:14:42 2009 -0700
142.2 +++ b/src/windows/lib/tzmappings Tue Sep 15 23:41:40 2009 -0700
142.3 @@ -82,8 +82,8 @@
142.4 GMT Standard Time:0,1::Europe/London:
142.5 Ekaterinburg:10,11::Asia/Yekaterinburg:
142.6 Ekaterinburg Standard Time:10,11::Asia/Yekaterinburg:
142.7 -West Asia:10,11::Asia/Karachi:
142.8 -West Asia Standard Time:10,11::Asia/Karachi:
142.9 +West Asia:10,11:UZ:Asia/Tashkent:
142.10 +West Asia Standard Time:10,11:UZ:Asia/Tashkent:
142.11 Central Asia:12,13::Asia/Dhaka:
142.12 Central Asia Standard Time:12,13::Asia/Dhaka:
142.13 N. Central Asia Standard Time:12,13::Asia/Novosibirsk:
142.14 @@ -146,8 +146,8 @@
142.15 South Africa Standard Time:4,69::Africa/Harare:
142.16 Atlantic:40,41::America/Halifax:
142.17 Atlantic Standard Time:40,41::America/Halifax:
142.18 -SA Eastern:42,43::America/Buenos_Aires:
142.19 -SA Eastern Standard Time:42,43::America/Buenos_Aires:
142.20 +SA Eastern:42,43:GF:America/Cayenne:
142.21 +SA Eastern Standard Time:42,43:GF:America/Cayenne:
142.22 Mid-Atlantic:44,45::Atlantic/South_Georgia:
142.23 Mid-Atlantic Standard Time:44,45::Atlantic/South_Georgia:
142.24 Azores:46,47::Atlantic/Azores:
142.25 @@ -160,21 +160,28 @@
142.26 Tonga Standard Time:78,79::Pacific/Tongatapu:
142.27 Arabian:8,9::Asia/Muscat:
142.28 Arabian Standard Time:8,9::Asia/Muscat:
142.29 -Caucasus:8,9::GMT+0400:
142.30 -Caucasus Standard Time:8,9::GMT+0400:
142.31 +Caucasus:8,9:AM:Asia/Yerevan:
142.32 +Caucasus Standard Time:8,9:AM:Asia/Yerevan:
142.33 GMT Standard Time:88,89::GMT:
142.34 Greenwich:88,89::GMT:
142.35 Greenwich Standard Time:88,89::GMT:
142.36 -Central Brazilian Standard Time:900,900:BR:America/Manaus:
142.37 -Central Standard Time (Mexico):901,901::America/Mexico_City:
142.38 -Georgian Standard Time:902,902:GE:Asia/Tbilisi:
142.39 -Mountain Standard Time (Mexico):903,903:MX:America/Chihuahua:
142.40 -Namibia Standard Time:904,904:NA:Africa/Windhoek:
142.41 -Pacific Standard Time (Mexico):905,905:MX:America/Tijuana:
142.42 -Western Brazilian Standard Time:906,906:BR:America/Rio_Branco:
142.43 -Azerbaijan Standard Time:907,907:AZ:Asia/Baku:
142.44 -Jordan Standard Time:908,908:JO:Asia/Amman:
142.45 -Middle East Standard Time:909,909:LB:Asia/Beirut:
142.46 -Armenian Standard Time:910,910:AM:Asia/Yerevan:
142.47 -Montevideo Standard Time:911,911:UY:America/Montevideo:
142.48 -Venezuela Standard Time:912,912::America/Caracas:
142.49 +Argentina Standard Time:900,900::America/Buenos_Aires:
142.50 +Azerbaijan Standard Time:901,901:AZ:Asia/Baku:
142.51 +Central Brazilian Standard Time:902,902:BR:America/Manaus:
142.52 +Central Standard Time (Mexico):903,903::America/Mexico_City:
142.53 +Georgian Standard Time:904,904:GE:Asia/Tbilisi:
142.54 +Jordan Standard Time:905,905:JO:Asia/Amman:
142.55 +Mauritius Standard Time:906,906:MU:Indian/Mauritius:
142.56 +Middle East Standard Time:907,907:LB:Asia/Beirut:
142.57 +Montevideo Standard Time:908,908:UY:America/Montevideo:
142.58 +Morocco Standard Time:909,909:MA:Africa/Casablanca:
142.59 +Mountain Standard Time (Mexico):910,910:MX:America/Chihuahua:
142.60 +Namibia Standard Time:911,911:NA:Africa/Windhoek:
142.61 +Pacific Standard Time (Mexico):912,912:MX:America/Tijuana:
142.62 +Pakistan Standard Time:913,913::Asia/Karachi:
142.63 +UTC:914,914::UTC:
142.64 +Venezuela Standard Time:915,915::America/Caracas:
142.65 +Kamchatka Standard Time:916,916:RU:Asia/Kamchatka:
142.66 +Paraguay Standard Time:917,917:PY:America/Asuncion:
142.67 +Western Brazilian Standard Time:918,918:BR:America/Rio_Branco:
142.68 +Armenian Standard Time:919,919:AM:Asia/Yerevan:
143.1 --- a/src/windows/native/sun/windows/awt_Dialog.cpp Sun Sep 06 23:14:42 2009 -0700
143.2 +++ b/src/windows/native/sun/windows/awt_Dialog.cpp Tue Sep 15 23:41:40 2009 -0700
143.3 @@ -364,6 +364,7 @@
143.4 if (locationByPlatform) {
143.5 moveToDefaultLocation();
143.6 }
143.7 + EnableTranslucency(TRUE);
143.8 if (IsFocusableWindow() && (IsAutoRequestFocus() || IsFocusedWindowModalBlocker())) {
143.9 ::ShowWindow(GetHWnd(), SW_SHOW);
143.10 } else {
144.1 --- a/src/windows/native/sun/windows/awt_Frame.cpp Sun Sep 06 23:14:42 2009 -0700
144.2 +++ b/src/windows/native/sun/windows/awt_Frame.cpp Tue Sep 15 23:41:40 2009 -0700
144.3 @@ -690,6 +690,8 @@
144.4 if (locationByPlatform) {
144.5 moveToDefaultLocation();
144.6 }
144.7 + EnableTranslucency(TRUE);
144.8 +
144.9 BOOL autoRequestFocus = IsAutoRequestFocus();
144.10
144.11 if (m_iconic) {
145.1 --- a/src/windows/native/sun/windows/awt_Window.cpp Sun Sep 06 23:14:42 2009 -0700
145.2 +++ b/src/windows/native/sun/windows/awt_Window.cpp Tue Sep 15 23:41:40 2009 -0700
145.3 @@ -218,12 +218,7 @@
145.4 if (warningString != NULL) {
145.5 delete [] warningString;
145.6 }
145.7 - ::EnterCriticalSection(&contentBitmapCS);
145.8 - if (hContentBitmap != NULL) {
145.9 - ::DeleteObject(hContentBitmap);
145.10 - hContentBitmap = NULL;
145.11 - }
145.12 - ::LeaveCriticalSection(&contentBitmapCS);
145.13 + DeleteContentBitmap();
145.14 ::DeleteCriticalSection(&contentBitmapCS);
145.15 }
145.16
145.17 @@ -372,6 +367,10 @@
145.18 }
145.19 }
145.20
145.21 + if (wp->flags & SWP_HIDEWINDOW) {
145.22 + EnableTranslucency(FALSE);
145.23 + }
145.24 +
145.25 return mrDoDefault;
145.26 }
145.27
145.28 @@ -1130,6 +1129,8 @@
145.29 moveToDefaultLocation();
145.30 }
145.31
145.32 + EnableTranslucency(TRUE);
145.33 +
145.34 // The following block exists to support Menu/Tooltip animation for
145.35 // Swing programs in a way which avoids introducing any new public api into
145.36 // AWT or Swing.
145.37 @@ -2494,27 +2495,73 @@
145.38 }
145.39 }
145.40
145.41 -void AwtWindow::SetTranslucency(BYTE opacity, BOOL opaque)
145.42 +// Deletes the hContentBitmap if it is non-null
145.43 +void AwtWindow::DeleteContentBitmap()
145.44 {
145.45 - BYTE old_opacity = getOpacity();
145.46 - BOOL old_opaque = isOpaque();
145.47 + ::EnterCriticalSection(&contentBitmapCS);
145.48 + if (hContentBitmap != NULL) {
145.49 + ::DeleteObject(hContentBitmap);
145.50 + hContentBitmap = NULL;
145.51 + }
145.52 + ::LeaveCriticalSection(&contentBitmapCS);
145.53 +}
145.54 +
145.55 +// The effects are enabled only upon showing the window.
145.56 +// See 6780496 for details.
145.57 +void AwtWindow::EnableTranslucency(BOOL enable)
145.58 +{
145.59 + if (enable) {
145.60 + SetTranslucency(getOpacity(), isOpaque(), FALSE, TRUE);
145.61 + } else {
145.62 + SetTranslucency(0xFF, TRUE, FALSE);
145.63 + }
145.64 +}
145.65 +
145.66 +/**
145.67 + * Sets the translucency effects.
145.68 + *
145.69 + * This method is used to:
145.70 + *
145.71 + * 1. Apply the translucency effects upon showing the window
145.72 + * (setValues == FALSE, useDefaultForOldValues == TRUE);
145.73 + * 2. Turn off the effects upon hiding the window
145.74 + * (setValues == FALSE, useDefaultForOldValues == FALSE);
145.75 + * 3. Set the effects per user's request
145.76 + * (setValues == TRUE, useDefaultForOldValues == FALSE);
145.77 + *
145.78 + * In case #3 the effects may or may not be applied immediately depending on
145.79 + * the current visibility status of the window.
145.80 + *
145.81 + * The setValues argument indicates if we need to preserve the passed values
145.82 + * in local fields for further use.
145.83 + * The useDefaultForOldValues argument indicates whether we should consider
145.84 + * the window as if it has not any effects applied at the moment.
145.85 + */
145.86 +void AwtWindow::SetTranslucency(BYTE opacity, BOOL opaque, BOOL setValues,
145.87 + BOOL useDefaultForOldValues)
145.88 +{
145.89 + BYTE old_opacity = useDefaultForOldValues ? 0xFF : getOpacity();
145.90 + BOOL old_opaque = useDefaultForOldValues ? TRUE : isOpaque();
145.91
145.92 if (opacity == old_opacity && opaque == old_opaque) {
145.93 return;
145.94 }
145.95
145.96 - setOpacity(opacity);
145.97 - setOpaque(opaque);
145.98 + if (setValues) {
145.99 + m_opacity = opacity;
145.100 + m_opaque = opaque;
145.101 + }
145.102 +
145.103 + // If we're invisible and are storing the values, return
145.104 + // Otherwise, apply the effects immediately
145.105 + if (!IsVisible() && setValues) {
145.106 + return;
145.107 + }
145.108
145.109 HWND hwnd = GetHWnd();
145.110
145.111 if (opaque != old_opaque) {
145.112 - ::EnterCriticalSection(&contentBitmapCS);
145.113 - if (hContentBitmap != NULL) {
145.114 - ::DeleteObject(hContentBitmap);
145.115 - hContentBitmap = NULL;
145.116 - }
145.117 - ::LeaveCriticalSection(&contentBitmapCS);
145.118 + DeleteContentBitmap();
145.119 }
145.120
145.121 if (opaque && opacity == 0xff) {
145.122 @@ -2634,9 +2681,7 @@
145.123 }
145.124
145.125 ::EnterCriticalSection(&contentBitmapCS);
145.126 - if (hContentBitmap != NULL) {
145.127 - ::DeleteObject(hContentBitmap);
145.128 - }
145.129 + DeleteContentBitmap();
145.130 hContentBitmap = hBitmap;
145.131 contentWidth = width;
145.132 contentHeight = height;
146.1 --- a/src/windows/native/sun/windows/awt_Window.h Sun Sep 06 23:14:42 2009 -0700
146.2 +++ b/src/windows/native/sun/windows/awt_Window.h Tue Sep 15 23:41:40 2009 -0700
146.3 @@ -262,32 +262,29 @@
146.4 // from its hierarchy when shown. Currently applied to instances of
146.5 // javax/swing/Popup$HeavyWeightWindow class.
146.6
146.7 + // SetTranslucency() is the setter for the following two fields
146.8 BYTE m_opacity; // The opacity level. == 0xff by default (when opacity mode is disabled)
146.9 BOOL m_opaque; // Whether the window uses the perpixel translucency (false), or not (true).
146.10
146.11 inline BYTE getOpacity() {
146.12 return m_opacity;
146.13 }
146.14 - inline void setOpacity(BYTE opacity) {
146.15 - m_opacity = opacity;
146.16 - }
146.17
146.18 inline BOOL isOpaque() {
146.19 return m_opaque;
146.20 }
146.21 - inline void setOpaque(BOOL opaque) {
146.22 - m_opaque = opaque;
146.23 - }
146.24
146.25 CRITICAL_SECTION contentBitmapCS;
146.26 HBITMAP hContentBitmap;
146.27 UINT contentWidth;
146.28 UINT contentHeight;
146.29
146.30 - void SetTranslucency(BYTE opacity, BOOL opaque);
146.31 + void SetTranslucency(BYTE opacity, BOOL opaque, BOOL setValues = TRUE,
146.32 + BOOL useDefaultForOldValues = FALSE);
146.33 void UpdateWindow(int width, int height, HBITMAP hBitmap);
146.34 void UpdateWindowImpl(int width, int height, HBITMAP hBitmap);
146.35 void RedrawWindow();
146.36 + void DeleteContentBitmap();
146.37
146.38 static UINT untrustedWindowsCounter;
146.39
146.40 @@ -352,6 +349,8 @@
146.41
146.42 UINT currentWmSizeState;
146.43
146.44 + void EnableTranslucency(BOOL enable);
146.45 +
146.46 private:
146.47 int m_screenNum;
146.48
147.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
147.2 +++ b/test/com/sun/java/swing/plaf/windows/Test6824600.java Tue Sep 15 23:41:40 2009 -0700
147.3 @@ -0,0 +1,70 @@
147.4 +/*
147.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
147.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
147.7 + *
147.8 + * This code is free software; you can redistribute it and/or modify it
147.9 + * under the terms of the GNU General Public License version 2 only, as
147.10 + * published by the Free Software Foundation.
147.11 + *
147.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
147.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
147.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
147.15 + * version 2 for more details (a copy is included in the LICENSE file that
147.16 + * accompanied this code).
147.17 + *
147.18 + * You should have received a copy of the GNU General Public License version
147.19 + * 2 along with this work; if not, write to the Free Software Foundation,
147.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
147.21 + *
147.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
147.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
147.24 + * have any questions.
147.25 + */
147.26 +
147.27 +/* @test
147.28 + @bug 6824600
147.29 + @summary OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
147.30 + @author Pavel Porvatov
147.31 + @run main Test6824600
147.32 +*/
147.33 +
147.34 +import com.sun.java.swing.plaf.windows.DesktopProperty;
147.35 +
147.36 +import java.awt.*;
147.37 +
147.38 +public class Test6824600 {
147.39 + public static void main(String[] args) throws Exception {
147.40 + Toolkit toolkit = Toolkit.getDefaultToolkit();
147.41 +
147.42 + HackedDesktopProperty desktopProperty = new HackedDesktopProperty("Button.background", null);
147.43 +
147.44 + // Register listener in toolkit
147.45 + desktopProperty.getValueFromDesktop();
147.46 +
147.47 + int length = toolkit.getPropertyChangeListeners().length;
147.48 +
147.49 + // Make several invocations
147.50 + desktopProperty.getValueFromDesktop();
147.51 + desktopProperty.getValueFromDesktop();
147.52 +
147.53 + desktopProperty.invalidate();
147.54 +
147.55 + desktopProperty.getValueFromDesktop();
147.56 + desktopProperty.getValueFromDesktop();
147.57 +
147.58 + if (length != toolkit.getPropertyChangeListeners().length) {
147.59 + throw new RuntimeException("New listeners were added into Toolkit");
147.60 + }
147.61 + }
147.62 +
147.63 + public static class HackedDesktopProperty extends DesktopProperty {
147.64 + public HackedDesktopProperty(String key, Object fallback) {
147.65 + super(key, fallback);
147.66 + }
147.67 +
147.68 + // Publish the method
147.69 + public Object getValueFromDesktop() {
147.70 + return super.getValueFromDesktop();
147.71 + }
147.72 + }
147.73 +}
148.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
148.2 +++ b/test/java/util/TimeZone/ListTimeZones.java Tue Sep 15 23:41:40 2009 -0700
148.3 @@ -0,0 +1,45 @@
148.4 +/*
148.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
148.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
148.7 + *
148.8 + * This code is free software; you can redistribute it and/or modify it
148.9 + * under the terms of the GNU General Public License version 2 only, as
148.10 + * published by the Free Software Foundation. Sun designates this
148.11 + * particular file as subject to the "Classpath" exception as provided
148.12 + * by Sun in the LICENSE file that accompanied this code.
148.13 + *
148.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
148.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
148.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
148.17 + * version 2 for more details (a copy is included in the LICENSE file that
148.18 + * accompanied this code).
148.19 + *
148.20 + * You should have received a copy of the GNU General Public License version
148.21 + * 2 along with this work; if not, write to the Free Software Foundation,
148.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
148.23 + *
148.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
148.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
148.26 + * have any questions.
148.27 + */
148.28 +
148.29 +/**
148.30 + * @test
148.31 + * @bug 6851214
148.32 + * @summary Allow 24:00 as a valid end/start DST time stamp
148.33 + * @run main ListTimeZones
148.34 + */
148.35 +
148.36 +import java.util.*;
148.37 +
148.38 +public class ListTimeZones{
148.39 + public static void main(String[] args){
148.40 + Date date = new Date();
148.41 + String TimeZoneIds[] = TimeZone.getAvailableIDs();
148.42 + for(int i = 0; i < TimeZoneIds.length; i++){
148.43 + TimeZone tz = TimeZone.getTimeZone(TimeZoneIds[i]);
148.44 + Calendar calendar = new GregorianCalendar(tz);
148.45 + String calString = calendar.toString();
148.46 + }
148.47 + }
148.48 +}
149.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
149.2 +++ b/test/javax/swing/JFileChooser/6484091/bug6484091.java Tue Sep 15 23:41:40 2009 -0700
149.3 @@ -0,0 +1,61 @@
149.4 +/*
149.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
149.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
149.7 + *
149.8 + * This code is free software; you can redistribute it and/or modify it
149.9 + * under the terms of the GNU General Public License version 2 only, as
149.10 + * published by the Free Software Foundation.
149.11 + *
149.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
149.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
149.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
149.15 + * version 2 for more details (a copy is included in the LICENSE file that
149.16 + * accompanied this code).
149.17 + *
149.18 + * You should have received a copy of the GNU General Public License version
149.19 + * 2 along with this work; if not, write to the Free Software Foundation,
149.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
149.21 + *
149.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
149.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
149.24 + * have any questions.
149.25 + */
149.26 +
149.27 +/* @test
149.28 + * @bug 6484091
149.29 + * @summary FileSystemView leaks directory info
149.30 + * @author Pavel Porvatov
149.31 + @run main bug6484091
149.32 + */
149.33 +
149.34 +import javax.swing.filechooser.FileSystemView;
149.35 +import java.io.File;
149.36 +import java.security.AccessControlException;
149.37 +
149.38 +public class bug6484091 {
149.39 + public static void main(String[] args) {
149.40 + File dir = FileSystemView.getFileSystemView().getDefaultDirectory();
149.41 +
149.42 + printDirContent(dir);
149.43 +
149.44 + System.setSecurityManager(new SecurityManager());
149.45 +
149.46 + // The next test cases use 'dir' obtained without SecurityManager
149.47 +
149.48 + try {
149.49 + printDirContent(dir);
149.50 +
149.51 + throw new RuntimeException("Dir content was derived bypass SecurityManager");
149.52 + } catch (AccessControlException e) {
149.53 + // It's a successful situation
149.54 + }
149.55 + }
149.56 +
149.57 + private static void printDirContent(File dir) {
149.58 + System.out.println("Files in " + dir.getAbsolutePath() + ":");
149.59 +
149.60 + for (File file : dir.listFiles()) {
149.61 + System.out.println(file.getName());
149.62 + }
149.63 + }
149.64 +}
150.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
150.2 +++ b/test/javax/swing/JLayer/6824395/bug6824395.java Tue Sep 15 23:41:40 2009 -0700
150.3 @@ -0,0 +1,80 @@
150.4 +/*
150.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
150.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
150.7 + *
150.8 + * This code is free software; you can redistribute it and/or modify it
150.9 + * under the terms of the GNU General Public License version 2 only, as
150.10 + * published by the Free Software Foundation.
150.11 + *
150.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
150.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
150.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
150.15 + * version 2 for more details (a copy is included in the LICENSE file that
150.16 + * accompanied this code).
150.17 + *
150.18 + * You should have received a copy of the GNU General Public License version
150.19 + * 2 along with this work; if not, write to the Free Software Foundation,
150.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
150.21 + *
150.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
150.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
150.24 + * have any questions.
150.25 + */
150.26 +
150.27 + /*
150.28 + * @test
150.29 + * @summary Checks that JLayer inside JViewport works is correctly laid out
150.30 + * @author Alexander Potochkin
150.31 + * @run main bug6824395
150.32 + */
150.33 +
150.34 +
150.35 +import sun.awt.SunToolkit;
150.36 +
150.37 +import javax.swing.*;
150.38 +import javax.swing.plaf.LayerUI;
150.39 +import java.awt.*;
150.40 +
150.41 +public class bug6824395 {
150.42 +
150.43 + static JScrollPane scrollPane;
150.44 +
150.45 + public static void main(String[] args) throws Exception {
150.46 + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
150.47 + SwingUtilities.invokeAndWait(new Runnable() {
150.48 + public void run() {
150.49 + JFrame frame = new JFrame("testing");
150.50 + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
150.51 +
150.52 + JEditorPane editorPane = new JEditorPane();
150.53 + String str = "hello\n";
150.54 + for(int i = 0; i<5; i++) {
150.55 + str += str;
150.56 + }
150.57 +
150.58 + editorPane.setText(str);
150.59 +
150.60 + JLayer<JEditorPane> editorPaneLayer = new JLayer<JEditorPane>(editorPane);
150.61 + LayerUI<JComponent> layerUI = new LayerUI<JComponent>();
150.62 + editorPaneLayer.setUI(layerUI);
150.63 +
150.64 + scrollPane = new JScrollPane(editorPaneLayer);
150.65 +
150.66 + scrollPane.setPreferredSize(new Dimension(200, 250));
150.67 + frame.add(scrollPane);
150.68 +
150.69 + frame.setSize(200, 200);
150.70 + frame.pack();
150.71 + frame.setVisible(true);
150.72 + }
150.73 + });
150.74 + toolkit.realSync();
150.75 + SwingUtilities.invokeAndWait(new Runnable() {
150.76 + public void run() {
150.77 + if (scrollPane.getViewportBorderBounds().width != scrollPane.getViewport().getView().getWidth()) {
150.78 + throw new RuntimeException("Wrong component's width!");
150.79 + }
150.80 + }
150.81 + });
150.82 + }
150.83 +}
151.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
151.2 +++ b/test/javax/swing/JLayer/6872503/bug6872503.java Tue Sep 15 23:41:40 2009 -0700
151.3 @@ -0,0 +1,135 @@
151.4 +/*
151.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
151.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
151.7 + *
151.8 + * This code is free software; you can redistribute it and/or modify it
151.9 + * under the terms of the GNU General Public License version 2 only, as
151.10 + * published by the Free Software Foundation.
151.11 + *
151.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
151.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
151.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
151.15 + * version 2 for more details (a copy is included in the LICENSE file that
151.16 + * accompanied this code).
151.17 + *
151.18 + * You should have received a copy of the GNU General Public License version
151.19 + * 2 along with this work; if not, write to the Free Software Foundation,
151.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
151.21 + *
151.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
151.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
151.24 + * have any questions.
151.25 + */
151.26 +
151.27 +/* @test
151.28 + * @bug 6872503
151.29 + * @summary Checks that JLayer correctly works with its AWTEventListener
151.30 + * @author Alexander Potochkin
151.31 + */
151.32 +
151.33 +import javax.swing.*;
151.34 +import java.awt.*;
151.35 +import java.awt.event.AWTEventListener;
151.36 +import java.awt.event.AWTEventListenerProxy;
151.37 +
151.38 +public class bug6872503 {
151.39 +
151.40 + static JLayer<Component> l1;
151.41 + static JLayer<Component> l2;
151.42 +
151.43 + private static void createGui() {
151.44 + Toolkit toolkit = Toolkit.getDefaultToolkit();
151.45 + int length = toolkit.getAWTEventListeners().length;
151.46 +
151.47 + l1 = new JLayer<Component>();
151.48 + l1.setLayerEventMask(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.FOCUS_EVENT_MASK);
151.49 +
151.50 + l2 = new JLayer<Component>();
151.51 + l2.setLayerEventMask(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
151.52 +
151.53 + if (isLayerEventControllerAdded()) {
151.54 + throw new RuntimeException("Unexpected AWTEventListener was added");
151.55 + }
151.56 +
151.57 + JFrame frame = new JFrame();
151.58 + frame.setLayout(new FlowLayout());
151.59 + frame.add(l1);
151.60 + frame.add(l2);
151.61 +
151.62 + if (isLayerEventControllerAdded()) {
151.63 + throw new RuntimeException("Unexpected AWTEventListener was added");
151.64 + }
151.65 +
151.66 + frame.pack();
151.67 +
151.68 + if (!isLayerEventControllerAdded()) {
151.69 + throw new RuntimeException("AWTEventListener was not added");
151.70 + }
151.71 +
151.72 + if (!layerEventControllerMaskEquals(l1.getLayerEventMask() | l2.getLayerEventMask())) {
151.73 + throw new RuntimeException("Wrong mask for AWTEventListener");
151.74 + }
151.75 +
151.76 + frame.dispose();
151.77 +
151.78 + if (isLayerEventControllerAdded()) {
151.79 + throw new RuntimeException("Unexpected AWTEventListener was added");
151.80 + }
151.81 + }
151.82 +
151.83 + static boolean isLayerEventControllerAdded() {
151.84 + Toolkit toolkit = Toolkit.getDefaultToolkit();
151.85 + AWTEventListener layerEventController = null;
151.86 + for (AWTEventListener listener : toolkit.getAWTEventListeners()) {
151.87 + if (listener instanceof AWTEventListenerProxy) {
151.88 + listener = ((AWTEventListenerProxy)listener).getListener();
151.89 +
151.90 + }
151.91 + if ("LayerEventController".equals(listener.getClass().getSimpleName())) {
151.92 + if (layerEventController != null) {
151.93 + throw new RuntimeException("Duplicated LayerEventController");
151.94 + }
151.95 + layerEventController = listener;
151.96 + }
151.97 + }
151.98 + boolean ret = layerEventController != null;
151.99 + if (ret) {
151.100 + System.out.println("LayerEventController found");
151.101 + } else {
151.102 + System.out.println("No LayerEventController");
151.103 + }
151.104 + return ret;
151.105 + }
151.106 +
151.107 + static boolean layerEventControllerMaskEquals(long mask) {
151.108 + Toolkit toolkit = Toolkit.getDefaultToolkit();
151.109 + AWTEventListener layerEventController = null;
151.110 + for (AWTEventListener listener : toolkit.getAWTEventListeners(mask)) {
151.111 + if (listener instanceof AWTEventListenerProxy) {
151.112 + listener = ((AWTEventListenerProxy)listener).getListener();
151.113 +
151.114 + }
151.115 + if ("LayerEventController".equals(listener.getClass().getSimpleName())) {
151.116 + if (layerEventController != null) {
151.117 + throw new RuntimeException("Duplicated LayerEventController");
151.118 + }
151.119 + layerEventController = listener;
151.120 + }
151.121 + }
151.122 + boolean ret = layerEventController != null;
151.123 + if (ret) {
151.124 + System.out.println("LayerEventController with the correct mask found");
151.125 + } else {
151.126 + System.out.println("No LayerEventController with the correct mask");
151.127 + }
151.128 + return ret;
151.129 + }
151.130 +
151.131 + public static void main(String[] args) throws Exception {
151.132 + SwingUtilities.invokeAndWait(new Runnable() {
151.133 + public void run() {
151.134 + bug6872503.createGui();
151.135 + }
151.136 + });
151.137 + }
151.138 +}
152.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
152.2 +++ b/test/javax/swing/JLayer/6875153/bug6875153.java Tue Sep 15 23:41:40 2009 -0700
152.3 @@ -0,0 +1,47 @@
152.4 +/*
152.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
152.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
152.7 + *
152.8 + * This code is free software; you can redistribute it and/or modify it
152.9 + * under the terms of the GNU General Public License version 2 only, as
152.10 + * published by the Free Software Foundation.
152.11 + *
152.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
152.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
152.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
152.15 + * version 2 for more details (a copy is included in the LICENSE file that
152.16 + * accompanied this code).
152.17 + *
152.18 + * You should have received a copy of the GNU General Public License version
152.19 + * 2 along with this work; if not, write to the Free Software Foundation,
152.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
152.21 + *
152.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
152.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
152.24 + * have any questions.
152.25 + */
152.26 +
152.27 +/* @test
152.28 + * @bug 6875153
152.29 + * @summary JLayer.isOptimizedDrawingEnabled() throws NPE for null glass pane set
152.30 + * @author Alexander Potochkin
152.31 + */
152.32 +
152.33 +import javax.swing.*;
152.34 +
152.35 +public class bug6875153 {
152.36 +
152.37 + private static void createGui() {
152.38 + JLayer layer = new JLayer();
152.39 + layer.setGlassPane(null);
152.40 + layer.isOptimizedDrawingEnabled();
152.41 + }
152.42 +
152.43 + public static void main(String[] args) throws Exception {
152.44 + SwingUtilities.invokeAndWait(new Runnable() {
152.45 + public void run() {
152.46 + bug6875153.createGui();
152.47 + }
152.48 + });
152.49 + }
152.50 +}
153.1 --- a/test/javax/swing/JLayer/SerializationTest/SerializationTest.java Sun Sep 06 23:14:42 2009 -0700
153.2 +++ b/test/javax/swing/JLayer/SerializationTest/SerializationTest.java Tue Sep 15 23:41:40 2009 -0700
153.3 @@ -1,3 +1,26 @@
153.4 +/*
153.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
153.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
153.7 + *
153.8 + * This code is free software; you can redistribute it and/or modify it
153.9 + * under the terms of the GNU General Public License version 2 only, as
153.10 + * published by the Free Software Foundation.
153.11 + *
153.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
153.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
153.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
153.15 + * version 2 for more details (a copy is included in the LICENSE file that
153.16 + * accompanied this code).
153.17 + *
153.18 + * You should have received a copy of the GNU General Public License version
153.19 + * 2 along with this work; if not, write to the Free Software Foundation,
153.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
153.21 + *
153.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
153.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
153.24 + * have any questions.
153.25 + */
153.26 +
153.27 /*
153.28 * @test
153.29 * @summary Makes sure that JLayer is synchronizable
153.30 @@ -50,4 +73,4 @@
153.31 return "TestLayerUI";
153.32 }
153.33 }
153.34 -}
153.35 \ No newline at end of file
153.36 +}
154.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
154.2 +++ b/test/javax/swing/JSlider/6579827/bug6579827.java Tue Sep 15 23:41:40 2009 -0700
154.3 @@ -0,0 +1,68 @@
154.4 +/*
154.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
154.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
154.7 + *
154.8 + * This code is free software; you can redistribute it and/or modify it
154.9 + * under the terms of the GNU General Public License version 2 only, as
154.10 + * published by the Free Software Foundation.
154.11 + *
154.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
154.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
154.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
154.15 + * version 2 for more details (a copy is included in the LICENSE file that
154.16 + * accompanied this code).
154.17 + *
154.18 + * You should have received a copy of the GNU General Public License version
154.19 + * 2 along with this work; if not, write to the Free Software Foundation,
154.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
154.21 + *
154.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
154.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
154.24 + * have any questions.
154.25 + */
154.26 +
154.27 +/* @test
154.28 + * @bug 6579827
154.29 + * @summary vista : JSlider on JColorchooser is not properly render or can't be seen completely
154.30 + * @author Pavel Porvatov
154.31 + @run main bug6579827
154.32 + */
154.33 +
154.34 +import sun.awt.OSInfo;
154.35 +
154.36 +import javax.swing.*;
154.37 +import java.awt.*;
154.38 +
154.39 +public class bug6579827 {
154.40 + public static void main(String[] args) throws Exception {
154.41 + if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS ||
154.42 + OSInfo.getWindowsVersion() != OSInfo.WINDOWS_VISTA) {
154.43 + System.out.println("This test is only for Windows Vista. Skipped.");
154.44 +
154.45 + return;
154.46 + }
154.47 +
154.48 + SwingUtilities.invokeLater(new Runnable() {
154.49 + public void run() {
154.50 + try {
154.51 + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
154.52 + } catch (Exception e) {
154.53 + e.printStackTrace();
154.54 +
154.55 + throw new RuntimeException(e);
154.56 + }
154.57 +
154.58 + JSlider slider = new JSlider(JSlider.VERTICAL, 0, 100, 0);
154.59 +
154.60 + Dimension prefferdSize = slider.getPreferredSize();
154.61 +
154.62 + slider.setPaintTrack(false);
154.63 + slider.putClientProperty("Slider.paintThumbArrowShape", Boolean.TRUE);
154.64 +
154.65 + if (prefferdSize.equals(slider.getPreferredSize())) {
154.66 + throw new RuntimeException();
154.67 + }
154.68 + }
154.69 + });
154.70 + }
154.71 +}
155.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
155.2 +++ b/test/javax/swing/SwingUtilities/6797139/bug6797139.java Tue Sep 15 23:41:40 2009 -0700
155.3 @@ -0,0 +1,62 @@
155.4 +/*
155.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
155.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
155.7 + *
155.8 + * This code is free software; you can redistribute it and/or modify it
155.9 + * under the terms of the GNU General Public License version 2 only, as
155.10 + * published by the Free Software Foundation.
155.11 + *
155.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
155.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
155.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
155.15 + * version 2 for more details (a copy is included in the LICENSE file that
155.16 + * accompanied this code).
155.17 + *
155.18 + * You should have received a copy of the GNU General Public License version
155.19 + * 2 along with this work; if not, write to the Free Software Foundation,
155.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
155.21 + *
155.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
155.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
155.24 + * have any questions.
155.25 + */
155.26 +
155.27 +/* @test
155.28 + *
155.29 + * @bug 6797139
155.30 + * @author Alexander Potochkin
155.31 + * @summary tests that JButton's text is not incorrectly truncated
155.32 + */
155.33 +import javax.swing.*;
155.34 +import javax.swing.plaf.basic.BasicButtonUI;
155.35 +import java.awt.*;
155.36 +import java.awt.image.BufferedImage;
155.37 +
155.38 +public class bug6797139 {
155.39 +
155.40 + private static void createGui() {
155.41 + JButton b = new JButton("Probably");
155.42 + b.setUI(new BasicButtonUI() {
155.43 + protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
155.44 + super.paintText(g, b, textRect, text);
155.45 + if (text.endsWith("...")) {
155.46 + throw new RuntimeException("Text is truncated!");
155.47 + }
155.48 + }
155.49 + });
155.50 + b.setSize(b.getPreferredSize());
155.51 + BufferedImage image = new BufferedImage(b.getWidth(), b.getHeight(),
155.52 + BufferedImage.TYPE_INT_ARGB);
155.53 + Graphics g = image.getGraphics();
155.54 + b.paint(g);
155.55 + g.dispose();
155.56 + }
155.57 +
155.58 + public static void main(String[] args) throws Exception {
155.59 + SwingUtilities.invokeAndWait(new Runnable() {
155.60 + public void run() {
155.61 + createGui();
155.62 + }
155.63 + });
155.64 + }
155.65 +}