substance-5.3.orig/0000755000175000017500000000000011272630263014205 5ustar drazzibdrazzibsubstance-5.3.orig/build.xml0000644000175000017500000004165111257646660016050 0ustar drazzibdrazzib substance-5.3.orig/lib/0000755000175000017500000000000011257647210014756 5ustar drazzibdrazzibsubstance-5.3.orig/lib/test/0000755000175000017500000000000011254222104015721 5ustar drazzibdrazzibsubstance-5.3.orig/www/0000755000175000017500000000000011254222170015023 5ustar drazzibdrazzibsubstance-5.3.orig/build.properties0000644000175000017500000000027511253701664017431 0ustar drazzibdrazzibjdk.home=C:/Program Files/Java/jdk1.6.0_16 javac.source=1.6 javac.target=1.6 javac.encoding=ISO-8859-1 javac.debug=on javac.generate.no.warnings=off javac.args= javac.max.memory=128msubstance-5.3.orig/src/0000755000175000017500000000000011256731144014776 5ustar drazzibdrazzibsubstance-5.3.orig/src/Quaqua.license0000644000175000017500000007522410634344704017612 0ustar drazzibdrazzibUse of the Quaqua Look and Feel is entirely at your own risk. I will not be liable for any data loss, hardware damage or whatever this program might cause. Permission to use this release of the Quaqua Look and Feel is granted provided you agree with its license terms, that the license fee is paid and the copyright notice and this license notice appear in all copies and in supporting documentation. The license terms applies to the version of the Quaqua Look and Feel, which is stated at the top of this document. Different versions may have different license terms. The license terms of the Quaqua Look and Feel do not apply to third party libraries that are included with the Quaqua Look and Feel. See section License Terms of Third Party Libraries. License Terms Source code, documentation and binaries of the Quaqua Look and Feel (also called "this software") are subject to the GNU Lesser General Public License (LGPL). Alternatively, this software may be used under the terms of the Modified BSD License. Third party software used by the Quaqua Look and Feel come with their own license restrictions. You may not use or disclose this software except in compliance with these license term. Modified BSD License Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. GNU Lesser General Public License Table of Contents * GNU LESSER GENERAL PUBLIC LICENSE o Preamble o TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION o How to Apply These Terms to Your New Libraries GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: * a) The modified work must itself be a software library. * b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. * c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. * d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: * a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) * b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. * c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. * d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. * e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: * a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. * b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. License Terms of Third Party Libraries NanoXML NanoXML is distributed under the zlib/libpng license, which is OSS (Open Source Software) compliant. It is not GPL or LGPL and it will never be part of the GNU project. Copyrighted 2000-2002 Marc De Scheemaecker, All Rights Reserved This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Base64 Copyright Robert Harder. All Rights reserved. This software is in the public domain. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, without any conditions or restrictions. This software is provided "as is" without express or implied warranty. JBrowser Copyright Steve Roy. All Rights reserved. You can do whatever you like with it. As usual with this kind of stuff, if you have success with it, great, if you manage to create a catastrophy with it, such as render your computer useless or crash the entire Internet, too bad, although rather unlikely. Swing-Layout Copyright (C) 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. This program is free software; you can redistribute it and/or modify it under the terms of the Lesser GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Copyright Quaqua Look And Feel 2003-2006 Werner Randelshofer, Staldenmattweg 2, Immensee, CH-6405, Switzerland http://www.randelshofer.ch/ werner.randelshofer@bluewin.ch All Rights Reserved. Contributors * Christopher Atlan * Steve Roy Third Party Libraries * NanoXML 2000-2002 Marc De Scheemaecker All Rights Reserved. * Base64 Robert Harder * Swing-Layout Sun Microsystems https://swing-layout.dev.java.net/ All Rights Reserved. Artwork The artwork used by the Quaqua Look and Feel is copyright Apple Computer Inc. Use of the artwork is only licensed for Apple hardware running an Apple operating system. substance-5.3.orig/src/META-INF/0000755000175000017500000000000011256731144016136 5ustar drazzibdrazzibsubstance-5.3.orig/src/META-INF/substance-plugin.xml0000644000175000017500000000030711215776156022152 0ustar drazzibdrazzib org.jvnet.substance.plugin.BasePlugin org.jvnet.substance.plugin.BaseSkinPlugin substance-5.3.orig/src/META-INF/substance.highlight.properties0000644000175000017500000000016310644541206024207 0ustar drazzibdrazzibjavax.swing.JList javax.swing.JTable javax.swing.JTree javax.swing.JMenuItem javax.swing.table.JTableHeader substance-5.3.orig/src/tools/0000755000175000017500000000000011246106054016131 5ustar drazzibdrazzibsubstance-5.3.orig/src/tools/docrobot/0000755000175000017500000000000011256731164017753 5ustar drazzibdrazzibsubstance-5.3.orig/src/tools/docrobot/RobotDefaultSkin.java0000644000175000017500000001071111250363642024031 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot; import org.jvnet.substance.api.*; import org.jvnet.substance.api.painter.overlay.BottomLineOverlayPainter; import org.jvnet.substance.colorscheme.LightGrayColorScheme; import org.jvnet.substance.colorscheme.MetallicColorScheme; import org.jvnet.substance.painter.border.ClassicBorderPainter; import org.jvnet.substance.painter.decoration.*; import org.jvnet.substance.painter.gradient.ClassicGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; import org.jvnet.substance.watermark.SubstanceWatermark; /** * The default light skin for the docrobot scripts. * * @author Kirill Grouchnikov */ public class RobotDefaultSkin extends SubstanceSkin { /** * Display name for this skin. */ public static String NAME = "Robot Default"; /** * Creates the skin based on the specified color scheme. * * @param colorScheme * The active color scheme. */ public RobotDefaultSkin(SubstanceColorScheme colorScheme) { SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( colorScheme, new MetallicColorScheme(), new LightGrayColorScheme()); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.registerAsDecorationArea(colorScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER); BottomLineOverlayPainter bottomLineOverlayPainter = new BottomLineOverlayPainter( ColorSchemeSingleColorQuery.MID); this.addOverlayPainter(bottomLineOverlayPainter, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new ClassicGradientPainter(); this.borderPainter = new ClassicBorderPainter(); MarbleNoiseDecorationPainter decorationPainter = new MarbleNoiseDecorationPainter(); decorationPainter.setBaseDecorationPainter(new ArcDecorationPainter()); decorationPainter.setTextureAlpha(0.3f); this.decorationPainter = decorationPainter; this.highlightPainter = new ClassicHighlightPainter(); this.borderPainter = new ClassicBorderPainter(); } /** * Creates the skin based on the specified color scheme and watermark. * * @param colorScheme * The active color scheme. * @param watermark * Watermark. */ public RobotDefaultSkin(SubstanceColorScheme colorScheme, SubstanceWatermark watermark) { this(colorScheme); this.watermark = watermark; } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/tools/docrobot/ColorSchemeRobot.java0000644000175000017500000000440411136475576024042 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot; import org.jvnet.substance.api.SubstanceColorScheme; /** * The base class for taking a single screenshot for Substance documentation. * * @author Kirill Grouchnikov */ public abstract class ColorSchemeRobot extends BaseRobot { /** * Creates the new screenshot robot. * * @param colorScheme * The color scheme. * @param screenshotFilename * The screenshot filename. */ public ColorSchemeRobot(SubstanceColorScheme colorScheme, String screenshotFilename) { super(colorScheme.isDark() ? new RobotDefaultDarkSkin(colorScheme) : new RobotDefaultSkin(colorScheme), screenshotFilename); } } substance-5.3.orig/src/tools/docrobot/WatermarkRobot.java0000644000175000017500000000435411136475576023600 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot; import org.jvnet.substance.skin.ModerateSkin; import org.jvnet.substance.watermark.SubstanceWatermark; /** * The base class for taking a single screenshot for Substance documentation. * * @author Kirill Grouchnikov */ public abstract class WatermarkRobot extends BaseRobot { /** * Creates the new screenshot robot. * * @param watermark * Watermark. * @param screenshotFilename * The screenshot filename. */ public WatermarkRobot(SubstanceWatermark watermark, String screenshotFilename) { super(new ModerateSkin().withWatermark(watermark), screenshotFilename); } } substance-5.3.orig/src/tools/docrobot/painters/0000755000175000017500000000000011256731164021600 5ustar drazzibdrazzibsubstance-5.3.orig/src/tools/docrobot/painters/WatermarkOverlaying.java0000644000175000017500000000424011136475576026451 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.painters; import org.jvnet.substance.skin.RavenSkin; import org.jvnet.substance.watermark.SubstancePlanktonWatermark; import tools.docrobot.BaseRobot; /** * Screenshot robot for watermark overlaying. * * @author Kirill Grouchnikov */ public class WatermarkOverlaying extends BaseRobot { /** * Creates the screenshot robot. */ public WatermarkOverlaying() { super(new RavenSkin().withWatermark(new SubstancePlanktonWatermark()), "C:/jprojects/substance/www/images/screenshots/painters/titlepane.png"); } } substance-5.3.orig/src/tools/docrobot/BaseRobot.java0000644000175000017500000001164111245653516022503 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFrame; import org.fest.swing.core.BasicRobot; import org.fest.swing.core.Robot; import org.fest.swing.edt.GuiActionRunner; import org.fest.swing.edt.GuiTask; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.utils.SubstanceImageCreator; import test.check.SampleFrame; /** * The base class for taking a single screenshot for Substance documentation. * * @author Kirill Grouchnikov */ public abstract class BaseRobot { /** * The associated Substance skin. */ protected SubstanceSkin skin; /** * The screenshot filename. */ protected String screenshotFilename; /** * The frame instance. */ protected SampleFrame sf; /** * Creates the new screenshot robot. * * @param skin * The skin. * @param screenshotFilename * The screenshot filename. */ public BaseRobot(SubstanceSkin skin, String screenshotFilename) { this.skin = skin; this.screenshotFilename = screenshotFilename; } /** * Runs the screenshot process. */ public void run() { long start = System.currentTimeMillis(); Robot robot = BasicRobot.robotWithNewAwtHierarchy(); // set skin GuiActionRunner.execute(new GuiTask() { @Override protected void executeInEDT() throws Throwable { SubstanceLookAndFeel.setSkin(skin); JFrame.setDefaultLookAndFeelDecorated(true); } }); robot.waitForIdle(); // create the frame and set the icon image GuiActionRunner.execute(new GuiTask() { @Override protected void executeInEDT() throws Throwable { sf = new SampleFrame(false); sf.setIconImage(SubstanceImageCreator.getColorSchemeImage(null, new ImageIcon(SkinRobot.class.getClassLoader() .getResource( "test/resource/image-x-generic.png")), SubstanceLookAndFeel.getCurrentSkin(sf.getRootPane()) .getMainActiveColorScheme(), 0.0f)); sf.setSize(315, 245); sf.setLocationRelativeTo(null); sf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); sf.setVisible(true); } }); robot.waitForIdle(); // make the screenshot GuiActionRunner.execute(new GuiTask() { @Override protected void executeInEDT() throws Throwable { makeScreenshot(); } }); robot.waitForIdle(); // dispose the frame GuiActionRunner.execute(new GuiTask() { @Override protected void executeInEDT() throws Throwable { sf.dispose(); } }); robot.waitForIdle(); long end = System.currentTimeMillis(); System.out.println(this.getClass().getSimpleName() + " : " + (end - start) + "ms"); } /** * Creates the screenshot and saves it on the disk. */ public void makeScreenshot() { BufferedImage bi = new BufferedImage(sf.getWidth(), sf.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = bi.getGraphics(); sf.paint(g); try { File target = new File(this.screenshotFilename); target.getParentFile().mkdirs(); ImageIO.write(bi, "png", target); } catch (IOException ioe) { ioe.printStackTrace(); } } } substance-5.3.orig/src/tools/docrobot/watermarks/0000755000175000017500000000000011256731164022133 5ustar drazzibdrazzibsubstance-5.3.orig/src/tools/docrobot/watermarks/ImageWatermarkAngelina.java0000644000175000017500000000532111136475576027347 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.watermarks; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.ImageWatermarkKind; import org.jvnet.substance.colorscheme.EbonyColorScheme; import org.jvnet.substance.watermark.SubstanceImageWatermark; import tools.docrobot.ImageWatermarkRobot; import tools.docrobot.RobotDefaultDarkSkin; /** * Screenshot robot for {@link SubstanceImageWatermark}. * * @author Kirill Grouchnikov */ public class ImageWatermarkAngelina extends ImageWatermarkRobot { /** * Creates the screenshot robot. */ public ImageWatermarkAngelina() { super( "C:/jprojects/substance/www/images/screenshots/watermarks/image-angelina.png"); } /* * (non-Javadoc) * * @see docrobot.ImageWatermarkRobot#apply() */ @Override protected void apply() { SubstanceImageWatermark watermark = new SubstanceImageWatermark( "tools/docrobot/watermarks/AngelinaJolie.jpg"); watermark.setKind(ImageWatermarkKind.APP_ANCHOR); SubstanceLookAndFeel.setSkin(new RobotDefaultDarkSkin( new EbonyColorScheme(), watermark)); } } substance-5.3.orig/src/tools/docrobot/watermarks/ImageWatermarkBeyonce.java0000644000175000017500000000531111136475576027214 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.watermarks; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.ImageWatermarkKind; import org.jvnet.substance.colorscheme.SunsetColorScheme; import org.jvnet.substance.watermark.SubstanceImageWatermark; import tools.docrobot.ImageWatermarkRobot; import tools.docrobot.RobotDefaultSkin; /** * Screenshot robot for {@link SubstanceImageWatermark}. * * @author Kirill Grouchnikov */ public class ImageWatermarkBeyonce extends ImageWatermarkRobot { /** * Creates the screenshot robot. */ public ImageWatermarkBeyonce() { super( "C:/jprojects/substance/www/images/screenshots/watermarks/image-beyonce.png"); } /* * (non-Javadoc) * * @see docrobot.ImageWatermarkRobot#apply() */ @Override protected void apply() { SubstanceImageWatermark watermark = new SubstanceImageWatermark( "tools/docrobot/watermarks/BeyonceKnowles.jpg"); watermark.setKind(ImageWatermarkKind.APP_ANCHOR); SubstanceLookAndFeel.setSkin(new RobotDefaultSkin( new SunsetColorScheme(), watermark)); } } substance-5.3.orig/src/tools/docrobot/watermarks/NoisePlanktonWatermark.java0000644000175000017500000000561611136475576027461 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.watermarks; import javax.swing.JFrame; import javax.swing.SwingUtilities; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.*; import org.jvnet.substance.watermark.SubstancePlanktonWatermark; import test.check.SampleFrame; import tools.docrobot.WatermarkRobot; /** * Screenshot robot for {@link SubstancePlanktonWatermark}. * * @author Kirill Grouchnikov */ public class NoisePlanktonWatermark extends WatermarkRobot { /** * Creates the screenshot robot. */ public NoisePlanktonWatermark() { super(new SubstancePlanktonWatermark(), "C:/jprojects/substance/www/images/screenshots/watermarks/noise-plankton.png"); } /** * Main method for testing the plankton noise watermark robot. * * @param args * Ignored. */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new ModerateSkin() .withWatermark(new SubstancePlanktonWatermark())); JFrame.setDefaultLookAndFeelDecorated(true); SampleFrame sf = new SampleFrame(false); sf.setSize(315, 245); sf.setLocationRelativeTo(null); sf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); sf.setVisible(true); } }); } } substance-5.3.orig/src/tools/docrobot/watermarks/CrosshatchWatermark.java0000644000175000017500000000417011136475576026770 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.watermarks; import org.jvnet.substance.watermark.SubstanceCrosshatchWatermark; import tools.docrobot.WatermarkRobot; /** * Screenshot robot for {@link SubstanceCrosshatchWatermark}. * * @author Kirill Grouchnikov */ public class CrosshatchWatermark extends WatermarkRobot { /** * Creates the screenshot robot. */ public CrosshatchWatermark() { super(new SubstanceCrosshatchWatermark(), "C:/jprojects/substance/www/images/screenshots/watermarks/crosshatch.png"); } } substance-5.3.orig/src/tools/docrobot/watermarks/StripesWatermark.java0000644000175000017500000000414311136475576026320 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.watermarks; import org.jvnet.substance.watermark.SubstanceStripeWatermark; import tools.docrobot.WatermarkRobot; /** * Screenshot robot for {@link SubstanceStripeWatermark}. * * @author Kirill Grouchnikov */ public class StripesWatermark extends WatermarkRobot { /** * Creates the screenshot robot. */ public StripesWatermark() { super(new SubstanceStripeWatermark(), "C:/jprojects/substance/www/images/screenshots/watermarks/stripes.png"); } } substance-5.3.orig/src/tools/docrobot/watermarks/ImageWatermarkDominic.java0000644000175000017500000000532311136475576027215 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.watermarks; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.ImageWatermarkKind; import org.jvnet.substance.colorscheme.CharcoalColorScheme; import org.jvnet.substance.watermark.SubstanceImageWatermark; import tools.docrobot.ImageWatermarkRobot; import tools.docrobot.RobotDefaultDarkSkin; /** * Screenshot robot for {@link SubstanceImageWatermark}. * * @author Kirill Grouchnikov */ public class ImageWatermarkDominic extends ImageWatermarkRobot { /** * Creates the screenshot robot. */ public ImageWatermarkDominic() { super( "C:/jprojects/substance/www/images/screenshots/watermarks/image-dominic.png"); } /* * (non-Javadoc) * * @see docrobot.ImageWatermarkRobot#apply() */ @Override protected void apply() { SubstanceImageWatermark watermark = new SubstanceImageWatermark( "tools/docrobot/watermarks/PrisonBreak3.jpg"); watermark.setKind(ImageWatermarkKind.APP_ANCHOR); SubstanceLookAndFeel.setSkin(new RobotDefaultDarkSkin( new CharcoalColorScheme(), watermark)); } } substance-5.3.orig/src/tools/docrobot/watermarks/ImageWatermarkTerry.java0000644000175000017500000000527411136475576026745 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.watermarks; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.ImageWatermarkKind; import org.jvnet.substance.colorscheme.SepiaColorScheme; import org.jvnet.substance.watermark.SubstanceImageWatermark; import tools.docrobot.ImageWatermarkRobot; import tools.docrobot.RobotDefaultSkin; /** * Screenshot robot for {@link SubstanceImageWatermark}. * * @author Kirill Grouchnikov */ public class ImageWatermarkTerry extends ImageWatermarkRobot { /** * Creates the screenshot robot. */ public ImageWatermarkTerry() { super( "C:/jprojects/substance/www/images/screenshots/watermarks/image-terry.png"); } /* * (non-Javadoc) * * @see docrobot.ImageWatermarkRobot#apply() */ @Override protected void apply() { SubstanceImageWatermark watermark = new SubstanceImageWatermark( "tools/docrobot/watermarks/LostLocke.jpg"); watermark.setKind(ImageWatermarkKind.APP_ANCHOR); SubstanceLookAndFeel.setSkin(new RobotDefaultSkin( new SepiaColorScheme(), watermark)); } } substance-5.3.orig/src/tools/docrobot/watermarks/NullWatermark.java0000644000175000017500000000412411136475576025600 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.watermarks; import org.jvnet.substance.watermark.SubstanceNullWatermark; import tools.docrobot.WatermarkRobot; /** * Screenshot robot for {@link SubstanceNullWatermark}. * * @author Kirill Grouchnikov */ public class NullWatermark extends WatermarkRobot { /** * Creates the screenshot robot. */ public NullWatermark() { super(new SubstanceNullWatermark(), "C:/jprojects/substance/www/images/screenshots/watermarks/null.png"); } } substance-5.3.orig/src/tools/docrobot/SkinRobot.java0000644000175000017500000001367411246137226022541 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot; import java.awt.Graphics; import java.awt.Point; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.*; import org.fest.swing.core.BasicRobot; import org.fest.swing.core.Robot; import org.fest.swing.edt.*; import org.fest.swing.timing.Pause; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.utils.SubstanceImageCreator; import test.check.SampleFrame; /** * The base class for taking screenshots of skins for Substance documentation. * * @author Kirill Grouchnikov */ public abstract class SkinRobot { /** * The associated Substance skin. */ protected SubstanceSkin skin; /** * The screenshot filename. */ protected String screenshotFilename; /** * The frame instance. */ protected SampleFrame sf; /** * Creates the new screenshot robot. * * @param skin * Substance skin. * @param screenshotFilename * The screenshot filename. */ public SkinRobot(SubstanceSkin skin, String screenshotFilename) { this.skin = skin; this.screenshotFilename = screenshotFilename; } /** * Runs the screenshot process. */ public void run() { long start = System.currentTimeMillis(); Robot robot = BasicRobot.robotWithNewAwtHierarchy(); // set skin GuiActionRunner.execute(new GuiTask() { @Override protected void executeInEDT() throws Throwable { SubstanceLookAndFeel.setSkin(skin); JFrame.setDefaultLookAndFeelDecorated(true); } }); robot.waitForIdle(); // create the frame and set the icon image GuiActionRunner.execute(new GuiTask() { @Override protected void executeInEDT() throws Throwable { sf = new SampleFrame(false); sf.setIconImage(SubstanceImageCreator.getColorSchemeImage(null, new ImageIcon(SkinRobot.class.getClassLoader() .getResource( "test/resource/image-x-generic.png")), SubstanceLookAndFeel.getCurrentSkin(sf.getRootPane()) .getMainActiveColorScheme(), 0.0f)); sf.setSize(315, 245); sf.setLocationRelativeTo(null); sf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); sf.setVisible(true); } }); robot.waitForIdle(); // get the default button JButton defaultButton = GuiActionRunner .execute(new GuiQuery() { @Override protected JButton executeInEDT() throws Throwable { return sf.getRootPane().getDefaultButton(); } }); // and move the mouse to it robot.moveMouse(defaultButton); robot.waitForIdle(); // wait for a second Pause.pause(1000); // make the first screenshot GuiActionRunner.execute(new GuiTask() { @Override protected void executeInEDT() throws Throwable { makeScreenshot(1); } }); robot.waitForIdle(); // switch to the last tab GuiActionRunner.execute(new GuiTask() { @Override protected void executeInEDT() throws Throwable { sf.switchToLastTab(); } }); robot.waitForIdle(); // move the mouse away from the frame robot.moveMouse(new Point(0, 0)); robot.waitForIdle(); // wait for two seconds Pause.pause(1000); // make the second screenshot GuiActionRunner.execute(new GuiTask() { @Override protected void executeInEDT() throws Throwable { makeScreenshot(2); } }); robot.waitForIdle(); // dispose the frame GuiActionRunner.execute(new GuiTask() { @Override protected void executeInEDT() throws Throwable { sf.dispose(); } }); robot.waitForIdle(); long end = System.currentTimeMillis(); System.out.println(this.getClass().getSimpleName() + " : " + (end - start) + "ms"); } /** * Creates the screenshot and saves it on the disk. * * @param count * Sequence number for the screenshot. */ public void makeScreenshot(int count) { BufferedImage bi = new BufferedImage(sf.getWidth(), sf.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = bi.getGraphics(); sf.paint(g); try { File output = new File(this.screenshotFilename + count + ".png"); output.getParentFile().mkdirs(); ImageIO.write(bi, "png", output); } catch (IOException ioe) { ioe.printStackTrace(); } } } substance-5.3.orig/src/tools/docrobot/RobotMain.java0000644000175000017500000000546611245625762022527 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot; import java.lang.reflect.Method; import javax.swing.JFrame; import javax.swing.UIManager; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.utils.LafConstants.AnimationKind; /** * The main method for taking screenshots for Substance documentation. Expects * one parameter - fully qualified class name of a single screenshot robot which * has a public void run() method. * * @author Kirill Grouchnikov */ public class RobotMain { /** * Runs the specified screenshot robot. * * @param args * Should contain one string - fully qualified class name of a * single screenshot robot which has a * public void run() method. * @throws Exception */ public static void main(String[] args) throws Exception { JFrame.setDefaultLookAndFeelDecorated(true); UIManager.put(LafWidget.ANIMATION_KIND, AnimationKind.NONE); String mainClassName = args[0]; Class robotClass = Class.forName(mainClassName); Object robotInstance = robotClass.newInstance(); Method runMethod = robotClass.getMethod("run", new Class[0]); runMethod.invoke(robotInstance, new Object[0]); } } substance-5.3.orig/src/tools/docrobot/RobotDefaultDarkSkin.java0000644000175000017500000001176511250363530024641 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot; import org.jvnet.substance.api.*; import org.jvnet.substance.api.painter.overlay.BottomLineOverlayPainter; import org.jvnet.substance.colorscheme.BlendBiColorScheme; import org.jvnet.substance.colorscheme.DarkMetallicColorScheme; import org.jvnet.substance.painter.border.ClassicBorderPainter; import org.jvnet.substance.painter.decoration.*; import org.jvnet.substance.painter.gradient.ClassicGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; import org.jvnet.substance.watermark.SubstancePlanktonWatermark; import org.jvnet.substance.watermark.SubstanceWatermark; /** * The default dark skin for the docrobot scripts. * * @author Kirill Grouchnikov */ public class RobotDefaultDarkSkin extends SubstanceSkin { /** * Display name for this skin. */ public static String NAME = "Robot Default Dark"; /** * Creates the skin based on the specified color scheme. * * @param colorScheme * The active color scheme. */ public RobotDefaultDarkSkin(SubstanceColorScheme colorScheme) { SubstanceColorScheme inactiveScheme = new BlendBiColorScheme( colorScheme, new DarkMetallicColorScheme(), 0.6); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( colorScheme, inactiveScheme, inactiveScheme); defaultSchemeBundle.registerColorScheme(inactiveScheme, 0.5f, ComponentState.DISABLED_UNSELECTED, ComponentState.DISABLED_SELECTED); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.registerAsDecorationArea(colorScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER); this.selectedTabFadeStart = 1.0; this.selectedTabFadeEnd = 1.0; BottomLineOverlayPainter bottomLineOverlayPainter = new BottomLineOverlayPainter( ColorSchemeSingleColorQuery.MID); this.addOverlayPainter(bottomLineOverlayPainter, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER); this.watermark = new SubstancePlanktonWatermark(); this.watermarkScheme = new BlendBiColorScheme(colorScheme, new DarkMetallicColorScheme(), 0.5); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new ClassicGradientPainter(); this.borderPainter = new ClassicBorderPainter(); MarbleNoiseDecorationPainter decorationPainter = new MarbleNoiseDecorationPainter(); decorationPainter.setBaseDecorationPainter(new ArcDecorationPainter()); decorationPainter.setTextureAlpha(0.3f); this.decorationPainter = decorationPainter; this.highlightPainter = new ClassicHighlightPainter(); this.borderPainter = new ClassicBorderPainter(); } /** * Creates the skin based on the specified color scheme and watermark. * * @param colorScheme * The active color scheme. * @param watermark * Watermark. */ public RobotDefaultDarkSkin(SubstanceColorScheme colorScheme, SubstanceWatermark watermark) { this(colorScheme); this.watermark = watermark; } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/tools/docrobot/skins/0000755000175000017500000000000011256731164021102 5ustar drazzibdrazzibsubstance-5.3.orig/src/tools/docrobot/skins/DustCoffee.java0000644000175000017500000000403711164754064024002 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.DustCoffeeSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link DustCoffeeSkin}. * * @author Kirill Grouchnikov */ public class DustCoffee extends SkinRobot { /** * Creates the screenshot robot. */ public DustCoffee() { super(new DustCoffeeSkin(), "C:/jprojects/substance/www/images/screenshots/skins/dustcoffee"); } } substance-5.3.orig/src/tools/docrobot/skins/Creme.java0000644000175000017500000000400111136475576023004 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.CremeSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link CremeSkin}. * * @author Kirill Grouchnikov */ public class Creme extends SkinRobot { /** * Creates the screenshot robot. */ public Creme() { super(new CremeSkin(), "C:/jprojects/substance/www/images/screenshots/skins/creme"); } } substance-5.3.orig/src/tools/docrobot/skins/NebulaBrickWall.java0000644000175000017500000000407511136475576024765 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.NebulaBrickWallSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link NebulaBrickWallSkin}. * * @author Kirill Grouchnikov */ public class NebulaBrickWall extends SkinRobot { /** * Creates the screenshot robot. */ public NebulaBrickWall() { super(new NebulaBrickWallSkin(), "C:/jprojects/substance/www/images/screenshots/skins/nebulabrickwall"); } } substance-5.3.orig/src/tools/docrobot/skins/MistAqua.java0000644000175000017500000000402311136475576023501 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.MistAquaSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link MistAquaSkin}. * * @author Kirill Grouchnikov */ public class MistAqua extends SkinRobot { /** * Creates the screenshot robot. */ public MistAqua() { super(new MistAquaSkin(), "C:/jprojects/substance/www/images/screenshots/skins/mistaqua"); } } substance-5.3.orig/src/tools/docrobot/skins/OfficeBlue2007.java0000644000175000017500000000407011136475576024273 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.OfficeBlue2007Skin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link OfficeBlue2007Skin}. * * @author Kirill Grouchnikov */ public class OfficeBlue2007 extends SkinRobot { /** * Creates the screenshot robot. */ public OfficeBlue2007() { super(new OfficeBlue2007Skin(), "C:/jprojects/substance/www/images/screenshots/skins/officeblue2007_"); } } substance-5.3.orig/src/tools/docrobot/skins/CremeCoffee.java0000644000175000017500000000404511136475576024124 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.CremeCoffeeSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link CremeCoffeeSkin}. * * @author Kirill Grouchnikov */ public class CremeCoffee extends SkinRobot { /** * Creates the screenshot robot. */ public CremeCoffee() { super(new CremeCoffeeSkin(), "C:/jprojects/substance/www/images/screenshots/skins/cremecoffee"); } } substance-5.3.orig/src/tools/docrobot/skins/Autumn.java0000644000175000017500000000400711136475576023230 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.AutumnSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link AutumnSkin}. * * @author Kirill Grouchnikov */ public class Autumn extends SkinRobot { /** * Creates the screenshot robot. */ public Autumn() { super(new AutumnSkin(), "C:/jprojects/substance/www/images/screenshots/skins/autumn"); } } substance-5.3.orig/src/tools/docrobot/skins/Magma.java0000644000175000017500000000400111136475576022773 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.MagmaSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link MagmaSkin}. * * @author Kirill Grouchnikov */ public class Magma extends SkinRobot { /** * Creates the screenshot robot. */ public Magma() { super(new MagmaSkin(), "C:/jprojects/substance/www/images/screenshots/skins/magma"); } } substance-5.3.orig/src/tools/docrobot/skins/Moderate.java0000644000175000017500000000402311136475576023515 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.ModerateSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link ModerateSkin}. * * @author Kirill Grouchnikov */ public class Moderate extends SkinRobot { /** * Creates the screenshot robot. */ public Moderate() { super(new ModerateSkin(), "C:/jprojects/substance/www/images/screenshots/skins/moderate"); } } substance-5.3.orig/src/tools/docrobot/skins/Twilight.java0000644000175000017500000000402311174407230023530 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.TwilightSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link TwilightSkin}. * * @author Kirill Grouchnikov */ public class Twilight extends SkinRobot { /** * Creates the screenshot robot. */ public Twilight() { super(new TwilightSkin(), "C:/jprojects/substance/www/images/screenshots/skins/twilight"); } } substance-5.3.orig/src/tools/docrobot/skins/Raven.java0000644000175000017500000000400111136475576023024 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.RavenSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link RavenSkin}. * * @author Kirill Grouchnikov */ public class Raven extends SkinRobot { /** * Creates the screenshot robot. */ public Raven() { super(new RavenSkin(), "C:/jprojects/substance/www/images/screenshots/skins/raven"); } } substance-5.3.orig/src/tools/docrobot/skins/BusinessBlueSteel.java0000644000175000017500000000411111136475576025353 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.BusinessBlueSteelSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link BusinessBlueSteelSkin}. * * @author Kirill Grouchnikov */ public class BusinessBlueSteel extends SkinRobot { /** * Creates the screenshot robot. */ public BusinessBlueSteel() { super(new BusinessBlueSteelSkin(), "C:/jprojects/substance/www/images/screenshots/skins/businessbluesteel"); } } substance-5.3.orig/src/tools/docrobot/skins/GraphiteAqua.java0000644000175000017500000000405711246400150024311 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.api.skin.GraphiteAquaSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link GraphiteAquaSkin}. * * @author Kirill Grouchnikov */ public class GraphiteAqua extends SkinRobot { /** * Creates the screenshot robot. */ public GraphiteAqua() { super(new GraphiteAquaSkin(), "C:/jprojects/substance/www/images/screenshots/skins/graphiteaqua"); } } substance-5.3.orig/src/tools/docrobot/skins/EmeraldDusk.java0000644000175000017500000000404511136475576024161 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.EmeraldDuskSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link EmeraldDuskSkin}. * * @author Kirill Grouchnikov */ public class EmeraldDusk extends SkinRobot { /** * Creates the screenshot robot. */ public EmeraldDusk() { super(new EmeraldDuskSkin(), "C:/jprojects/substance/www/images/screenshots/skins/emeralddusk"); } } substance-5.3.orig/src/tools/docrobot/skins/BusinessBlackSteel.java0000644000175000017500000000411711136475576025506 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link BusinessBlackSteelSkin}. * * @author Kirill Grouchnikov */ public class BusinessBlackSteel extends SkinRobot { /** * Creates the screenshot robot. */ public BusinessBlackSteel() { super(new BusinessBlackSteelSkin(), "C:/jprojects/substance/www/images/screenshots/skins/businessblacksteel"); } } substance-5.3.orig/src/tools/docrobot/skins/RavenGraphiteGlass.java0000644000175000017500000000411711136475576025512 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.RavenGraphiteGlassSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link RavenGraphiteGlassSkin}. * * @author Kirill Grouchnikov */ public class RavenGraphiteGlass extends SkinRobot { /** * Creates the screenshot robot. */ public RavenGraphiteGlass() { super(new RavenGraphiteGlassSkin(), "C:/jprojects/substance/www/images/screenshots/skins/ravengraphiteglass"); } } substance-5.3.orig/src/tools/docrobot/skins/Sahara.java0000644000175000017500000000400711136475576023156 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.SaharaSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link SaharaSkin}. * * @author Kirill Grouchnikov */ public class Sahara extends SkinRobot { /** * Creates the screenshot robot. */ public Sahara() { super(new SaharaSkin(), "C:/jprojects/substance/www/images/screenshots/skins/sahara"); } } substance-5.3.orig/src/tools/docrobot/skins/Nebula.java0000644000175000017500000000400711136475576023165 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.NebulaSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link NebulaSkin}. * * @author Kirill Grouchnikov */ public class Nebula extends SkinRobot { /** * Creates the screenshot robot. */ public Nebula() { super(new NebulaSkin(), "C:/jprojects/substance/www/images/screenshots/skins/nebula"); } } substance-5.3.orig/src/tools/docrobot/skins/Business.java0000644000175000017500000000402211136475576023547 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.BusinessSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link BusinessSkin}. * * @author Kirill Grouchnikov */ public class Business extends SkinRobot { /** * Creates the screenshot robot. */ public Business() { super(new BusinessSkin(), "C:/jprojects/substance/www/images/screenshots/skins/business"); } } substance-5.3.orig/src/tools/docrobot/skins/Dust.java0000644000175000017500000000377311157465606022703 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.DustSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link DustSkin}. * * @author Kirill Grouchnikov */ public class Dust extends SkinRobot { /** * Creates the screenshot robot. */ public Dust() { super(new DustSkin(), "C:/jprojects/substance/www/images/screenshots/skins/dust"); } } substance-5.3.orig/src/tools/docrobot/skins/ChallengerDeep.java0000644000175000017500000000406711136475576024627 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.ChallengerDeepSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link ChallengerDeepSkin}. * * @author Kirill Grouchnikov */ public class ChallengerDeep extends SkinRobot { /** * Creates the screenshot robot. */ public ChallengerDeep() { super(new ChallengerDeepSkin(), "C:/jprojects/substance/www/images/screenshots/skins/challengerdeep"); } } substance-5.3.orig/src/tools/docrobot/skins/RavenGraphite.java0000644000175000017500000000406111136475576024516 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.RavenGraphiteSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link RavenGraphiteSkin}. * * @author Kirill Grouchnikov */ public class RavenGraphite extends SkinRobot { /** * Creates the screenshot robot. */ public RavenGraphite() { super(new RavenGraphiteSkin(), "C:/jprojects/substance/www/images/screenshots/skins/ravengraphite"); } } substance-5.3.orig/src/tools/docrobot/skins/Magellan.java0000644000175000017500000000402711246143656023472 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.api.skin.MagellanSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link MagellanSkin}. * * @author Kirill Grouchnikov */ public class Magellan extends SkinRobot { /** * Creates the screenshot robot. */ public Magellan() { super(new MagellanSkin(), "C:/jprojects/substance/www/images/screenshots/skins/magellan"); } } substance-5.3.orig/src/tools/docrobot/skins/Gemini.java0000644000175000017500000000401311246414522023146 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.api.skin.GeminiSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link GeminiSkin}. * * @author Kirill Grouchnikov */ public class Gemini extends SkinRobot { /** * Creates the screenshot robot. */ public Gemini() { super(new GeminiSkin(), "C:/jprojects/substance/www/images/screenshots/skins/gemini"); } } substance-5.3.orig/src/tools/docrobot/skins/OfficeSilver2007.java0000644000175000017500000000410411136475576024646 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.OfficeSilver2007Skin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link OfficeSilver2007Skin}. * * @author Kirill Grouchnikov */ public class OfficeSilver2007 extends SkinRobot { /** * Creates the screenshot robot. */ public OfficeSilver2007() { super(new OfficeSilver2007Skin(), "C:/jprojects/substance/www/images/screenshots/skins/officesilver2007_"); } } substance-5.3.orig/src/tools/docrobot/skins/MistSilver.java0000644000175000017500000000403711136475576024063 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.skins; import org.jvnet.substance.skin.MistSilverSkin; import tools.docrobot.SkinRobot; /** * Screenshot robot for {@link MistSilverSkin}. * * @author Kirill Grouchnikov */ public class MistSilver extends SkinRobot { /** * Creates the screenshot robot. */ public MistSilver() { super(new MistSilverSkin(), "C:/jprojects/substance/www/images/screenshots/skins/mistsilver"); } } substance-5.3.orig/src/tools/docrobot/ImageWatermarkRobot.java0000644000175000017500000001177611245654772024547 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot; import java.awt.FlowLayout; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.JButton; import javax.swing.JFrame; import org.fest.swing.core.BasicRobot; import org.fest.swing.core.Robot; import org.fest.swing.edt.GuiActionRunner; import org.fest.swing.edt.GuiTask; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * The base class for taking a single screenshot for Substance documentation. * * @author Kirill Grouchnikov */ public abstract class ImageWatermarkRobot { /** * The screenshot filename. */ protected String screenshotFilename; /** * The frame instance. */ protected JFrame sf; /** * Creates the new screenshot robot. * * @param screenshotFilename * The screenshot filename. */ public ImageWatermarkRobot(String screenshotFilename) { this.screenshotFilename = screenshotFilename; } /** * Runs the screenshot process. */ public void run() { long start = System.currentTimeMillis(); Robot robot = BasicRobot.robotWithNewAwtHierarchy(); // set skin GuiActionRunner.execute(new GuiTask() { @Override protected void executeInEDT() throws Throwable { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); JFrame.setDefaultLookAndFeelDecorated(true); } }); robot.waitForIdle(); // create the frame and set the icon image GuiActionRunner.execute(new GuiTask() { @Override protected void executeInEDT() throws Throwable { sf = new JFrame("Sample frame"); apply(); sf.setSize(238, 261); sf.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton defButton = new JButton("default"); JButton disButton = new JButton("disabled"); JButton regButton = new JButton("regular"); disButton.setEnabled(false); sf.add(defButton); sf.add(disButton); sf.add(regButton); sf.getRootPane().setDefaultButton(defButton); BufferedImage iconImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); sf.setIconImage(iconImage); sf.setLocationRelativeTo(null); sf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); sf.setVisible(true); } }); robot.waitForIdle(); // make the screenshot GuiActionRunner.execute(new GuiTask() { @Override protected void executeInEDT() throws Throwable { makeScreenshot(); } }); robot.waitForIdle(); // dispose the frame GuiActionRunner.execute(new GuiTask() { @Override protected void executeInEDT() throws Throwable { sf.dispose(); } }); robot.waitForIdle(); long end = System.currentTimeMillis(); System.out.println(this.getClass().getSimpleName() + " : " + (end - start) + "ms"); } /** * Applies instance-specific Substance settings before taking the * screenshot. */ protected abstract void apply(); /** * Creates the screenshot and saves it on the disk. */ public void makeScreenshot() { BufferedImage bi = new BufferedImage(sf.getWidth(), sf.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = bi.getGraphics(); sf.paint(g); try { ImageIO.write(bi, "png", new File(this.screenshotFilename)); } catch (IOException ioe) { ioe.printStackTrace(); } } } substance-5.3.orig/src/tools/docrobot/schemes/0000755000175000017500000000000011256731164021402 5ustar drazzibdrazzibsubstance-5.3.orig/src/tools/docrobot/schemes/BrownScheme.java0000644000175000017500000000411011136475576024466 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.BrownColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link BrownColorScheme}. * * @author Kirill Grouchnikov */ public class BrownScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public BrownScheme() { super(new BrownColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/brown.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/DerivedInvertedScheme.java0000644000175000017500000000426311136475576026473 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.PurpleColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link SubstanceColorScheme#invert()}. * * @author Kirill Grouchnikov */ public class DerivedInvertedScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public DerivedInvertedScheme() { super(new PurpleColorScheme().invert(), "C:/jprojects/substance/www/images/screenshots/colorschemes/derived-invert.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/SunsetScheme.java0000644000175000017500000000411611136475576024666 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.SunsetColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link SunsetColorScheme}. * * @author Kirill Grouchnikov */ public class SunsetScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public SunsetScheme() { super(new SunsetColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/sunset.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/DerivedTintedScheme.java0000644000175000017500000000426411136475576026143 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.PurpleColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link SubstanceColorScheme#tint(double)}. * * @author Kirill Grouchnikov */ public class DerivedTintedScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public DerivedTintedScheme() { super(new PurpleColorScheme().tint(0.4), "C:/jprojects/substance/www/images/screenshots/colorschemes/derived-tinted.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/LightAquaScheme.java0000644000175000017500000000414111136475576025262 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.LightAquaColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link LightAquaColorScheme}. * * @author Kirill Grouchnikov */ public class LightAquaScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public LightAquaScheme() { super(new LightAquaColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/light-aqua.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/DerivedShiftedBackgroundScheme.java0000644000175000017500000000447011136475576030301 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.PurpleColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link SubstanceColorScheme#shiftBackground(Color, * double)}. * * @author Kirill Grouchnikov */ public class DerivedShiftedBackgroundScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public DerivedShiftedBackgroundScheme() { super( new PurpleColorScheme().shiftBackground( new Color(255, 128, 128), 0.8), "C:/jprojects/substance/www/images/screenshots/colorschemes/derived-shiftedbackground.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/UltramarineScheme.java0000644000175000017500000000415411136475576025672 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.UltramarineColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link UltramarineColorScheme}. * * @author Kirill Grouchnikov */ public class UltramarineScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public UltramarineScheme() { super(new UltramarineColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/ultramarine.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/DesertSandScheme.java0000644000175000017500000000414711136475576025445 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.DesertSandColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link DesertSandColorScheme}. * * @author Kirill Grouchnikov */ public class DesertSandScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public DesertSandScheme() { super(new DesertSandColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/desert-sand.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/CremeScheme.java0000644000175000017500000000411011136475576024432 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.CremeColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link CremeColorScheme}. * * @author Kirill Grouchnikov */ public class CremeScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public CremeScheme() { super(new CremeColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/creme.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/OliveScheme.java0000644000175000017500000000411011136475576024455 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.OliveColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link OliveColorScheme}. * * @author Kirill Grouchnikov */ public class OliveScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public OliveScheme() { super(new OliveColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/olive.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/PurpleScheme.java0000644000175000017500000000411611136475576024654 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.PurpleColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link PurpleColorScheme}. * * @author Kirill Grouchnikov */ public class PurpleScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public PurpleScheme() { super(new PurpleColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/purple.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/DerivedNegatedScheme.java0000644000175000017500000000426111136475576026260 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.PurpleColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link SubstanceColorScheme#negate()}. * * @author Kirill Grouchnikov */ public class DerivedNegatedScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public DerivedNegatedScheme() { super(new PurpleColorScheme().negate(), "C:/jprojects/substance/www/images/screenshots/colorschemes/derived-negate.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/DarkVioletScheme.java0000644000175000017500000000414711136475576025455 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.DarkVioletColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link DarkVioletColorScheme}. * * @author Kirill Grouchnikov */ public class DarkVioletScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public DarkVioletScheme() { super(new DarkVioletColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/dark-violet.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/OrangeScheme.java0000644000175000017500000000411611136475576024620 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.OrangeColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link OrangeColorScheme}. * * @author Kirill Grouchnikov */ public class OrangeScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public OrangeScheme() { super(new OrangeColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/orange.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/CharcoalScheme.java0000644000175000017500000000536711136475576025132 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.colorscheme.CharcoalColorScheme; import test.check.SampleFrame; import tools.docrobot.*; /** * Screenshot robot for the {@link CharcoalColorScheme}. * * @author Kirill Grouchnikov */ public class CharcoalScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public CharcoalScheme() { super(new CharcoalColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/charcoal.png"); } /** * Main method for testing the charcoal scheme robot * * @param args * Ignored. */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new RobotDefaultDarkSkin( new CharcoalColorScheme())); JFrame.setDefaultLookAndFeelDecorated(true); SampleFrame sf = new SampleFrame(false); sf.setSize(315, 245); sf.setLocationRelativeTo(null); sf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); sf.setVisible(true); } }); } } substance-5.3.orig/src/tools/docrobot/schemes/AquaScheme.java0000644000175000017500000000410211136475576024267 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.AquaColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link AquaColorScheme}. * * @author Kirill Grouchnikov */ public class AquaScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public AquaScheme() { super(new AquaColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/aqua.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/SepiaScheme.java0000644000175000017500000000411011136475576024440 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.SepiaColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link SepiaColorScheme}. * * @author Kirill Grouchnikov */ public class SepiaScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public SepiaScheme() { super(new SepiaColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/sepia.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/DerivedHueShiftedScheme.java0000644000175000017500000000431411136475576026740 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.PurpleColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link SubstanceColorScheme#hueShift(double)}. * * @author Kirill Grouchnikov */ public class DerivedHueShiftedScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public DerivedHueShiftedScheme() { super( new PurpleColorScheme().hueShift(0.4), "C:/jprojects/substance/www/images/screenshots/colorschemes/derived-hueshift.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/EbonyScheme.java0000644000175000017500000000411011136475576024453 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.EbonyColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link EbonyColorScheme}. * * @author Kirill Grouchnikov */ public class EbonyScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public EbonyScheme() { super(new EbonyColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/ebony.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/TerracottaScheme.java0000644000175000017500000000414511136475576025517 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESSOR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.TerracottaColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link TerracottaColorScheme}. * * @author Kirill Grouchnikov */ public class TerracottaScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public TerracottaScheme() { super(new TerracottaColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/terracotta.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/RaspberryScheme.java0000644000175000017500000000414011136475576025353 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.RaspberryColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link RaspberryColorScheme}. * * @author Kirill Grouchnikov */ public class RaspberryScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public RaspberryScheme() { super(new RaspberryColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/raspberry.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/LimeGreenScheme.java0000644000175000017500000000414111136475576025252 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.LimeGreenColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link LimeGreenColorScheme}. * * @author Kirill Grouchnikov */ public class LimeGreenScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public LimeGreenScheme() { super(new LimeGreenColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/lime-green.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/DerivedTonedScheme.java0000644000175000017500000000426111136475576025762 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.PurpleColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link SubstanceColorScheme#tone(double)}. * * @author Kirill Grouchnikov */ public class DerivedTonedScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public DerivedTonedScheme() { super(new PurpleColorScheme().tone(0.4), "C:/jprojects/substance/www/images/screenshots/colorschemes/derived-toned.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/DerivedShadedScheme.java0000644000175000017500000000426611136475576026106 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.PurpleColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link SubstanceColorScheme#shade(double)}. * * @author Kirill Grouchnikov */ public class DerivedShadedScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public DerivedShadedScheme() { super(new PurpleColorScheme().shade(0.4), "C:/jprojects/substance/www/images/screenshots/colorschemes/derived-shaded.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/DerivedSaturatedScheme.java0000644000175000017500000000431211136475576026642 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.PurpleColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link SubstanceColorScheme#saturate(double)}. * * @author Kirill Grouchnikov */ public class DerivedSaturatedScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public DerivedSaturatedScheme() { super( new PurpleColorScheme().saturate(0.4), "C:/jprojects/substance/www/images/screenshots/colorschemes/derived-saturate.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/DerivedDesaturatedScheme.java0000644000175000017500000000432111136475576027153 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.PurpleColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link SubstanceColorScheme#saturate(double)}. * * @author Kirill Grouchnikov */ public class DerivedDesaturatedScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public DerivedDesaturatedScheme() { super( new PurpleColorScheme().saturate(-0.4), "C:/jprojects/substance/www/images/screenshots/colorschemes/derived-desaturate.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/BottleGreenScheme.java0000644000175000017500000000415511136475576025622 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.BottleGreenColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link BottleGreenColorScheme}. * * @author Kirill Grouchnikov */ public class BottleGreenScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public BottleGreenScheme() { super(new BottleGreenColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/bottle-green.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/DerivedShiftedScheme.java0000644000175000017500000000445711136475576026306 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.PurpleColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link SubstanceColorScheme#shift(Color, double, * Color, double)}. * * @author Kirill Grouchnikov */ public class DerivedShiftedScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public DerivedShiftedScheme() { super( new PurpleColorScheme().shift(new Color(128, 255, 128), 0.8, new Color(128, 0, 0), 0.7), "C:/jprojects/substance/www/images/screenshots/colorschemes/derived-shifted.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/SteelBlueScheme.java0000644000175000017500000000414111136475576025267 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.SteelBlueColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link SteelBlueColorScheme}. * * @author Kirill Grouchnikov */ public class SteelBlueScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public SteelBlueScheme() { super(new SteelBlueColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/steel-blue.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/JadeForestScheme.java0000644000175000017500000000414711136475576025437 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.JadeForestColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link JadeForestColorScheme}. * * @author Kirill Grouchnikov */ public class JadeForestScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public JadeForestScheme() { super(new JadeForestColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/jade-forest.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/BarbyPinkScheme.java0000644000175000017500000000414111136475576025264 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.BarbyPinkColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link BarbyPinkColorScheme}. * * @author Kirill Grouchnikov */ public class BarbyPinkScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public BarbyPinkScheme() { super(new BarbyPinkColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/barby-pink.png"); } } substance-5.3.orig/src/tools/docrobot/schemes/SunGlareScheme.java0000644000175000017500000000413311136475576025124 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.docrobot.schemes; import org.jvnet.substance.colorscheme.SunGlareColorScheme; import tools.docrobot.ColorSchemeRobot; /** * Screenshot robot for the {@link SunGlareColorScheme}. * * @author Kirill Grouchnikov */ public class SunGlareScheme extends ColorSchemeRobot { /** * Creates the screenshot robot. */ public SunGlareScheme() { super(new SunGlareColorScheme(), "C:/jprojects/substance/www/images/screenshots/colorschemes/sun-glare.png"); } } substance-5.3.orig/src/tools/uidebug/0000755000175000017500000000000011256731164017564 5ustar drazzibdrazzibsubstance-5.3.orig/src/tools/uidebug/META-INF/0000755000175000017500000000000011256731164020724 5ustar drazzibdrazzibsubstance-5.3.orig/src/tools/uidebug/META-INF/lafwidget.properties0000644000175000017500000000017711003535420025000 0ustar drazzibdrazzibtools.uidebug.RootPaneTitlePaneUiDebugger = javax.swing.JRootPane tools.uidebug.ScrollBarUiDebugger = javax.swing.JScrollBar substance-5.3.orig/src/tools/uidebug/ProtanopiaColorScheme.java0000644000175000017500000000427011136475576024703 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.uidebug; import org.jvnet.substance.api.SubstanceColorScheme; /** * Color scheme for protanopia color blindness. * * @author Kirill Grouchnikov * @see ColorBlindColorScheme */ public class ProtanopiaColorScheme extends ColorBlindColorScheme { /** * Creates a new protanopia color blindness color scheme. * * @param origColorScheme * The original color scheme. */ public ProtanopiaColorScheme(SubstanceColorScheme origColorScheme) { super(origColorScheme, BlindnessKind.PROTANOPIA); } } substance-5.3.orig/src/tools/uidebug/ScrollBarUiDebugger.java0000644000175000017500000000625711003536014024252 0ustar drazzibdrazzibpackage tools.uidebug; import java.awt.event.*; import javax.swing.*; import org.jvnet.lafwidget.LafWidgetAdapter; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.ScrollPaneButtonPolicyKind; public class ScrollBarUiDebugger extends LafWidgetAdapter { protected MouseListener substanceDebugUiListener; @Override public boolean requiresCustomLafSupport() { return false; } @Override public void installListeners() { this.substanceDebugUiListener = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { this.process(e); } @Override public void mouseReleased(MouseEvent e) { this.process(e); } protected void process(MouseEvent e) { if (e.isPopupTrigger()) { JPopupMenu popup = new JPopupMenu(); JMenuItem policyNone = new JMenuItem("Empty policy"); policyNone.addActionListener(new PolicyChanger( ScrollPaneButtonPolicyKind.NONE)); popup.add(policyNone); JMenuItem policyOpposite = new JMenuItem("Opposite policy"); policyOpposite.addActionListener(new PolicyChanger( ScrollPaneButtonPolicyKind.OPPOSITE)); popup.add(policyOpposite); JMenuItem policyAdjacent = new JMenuItem("Adjacent policy"); policyAdjacent.addActionListener(new PolicyChanger( ScrollPaneButtonPolicyKind.ADJACENT)); popup.add(policyAdjacent); JMenuItem policyMultiple = new JMenuItem("Multiple policy"); policyMultiple.addActionListener(new PolicyChanger( ScrollPaneButtonPolicyKind.MULTIPLE)); popup.add(policyMultiple); JMenuItem policyMultipleBoth = new JMenuItem( "Multiple both policy"); policyMultipleBoth.addActionListener(new PolicyChanger( ScrollPaneButtonPolicyKind.MULTIPLE_BOTH)); popup.add(policyMultipleBoth); popup.show(jcomp, e.getX(), e.getY()); } } }; this.jcomp.addMouseListener(this.substanceDebugUiListener); } @Override public void uninstallListeners() { if (this.substanceDebugUiListener != null) { this.jcomp.removeMouseListener(this.substanceDebugUiListener); this.substanceDebugUiListener = null; } } /** * Listener on policy change menu items in debug UI mode. * * @author Kirill Grouchnikov */ protected class PolicyChanger implements ActionListener { /** * Policy to set. */ protected ScrollPaneButtonPolicyKind newPolicy; /** * Creates a new policy change listener. * * @param newPolicy * Policy to set. */ public PolicyChanger(ScrollPaneButtonPolicyKind newPolicy) { super(); this.newPolicy = newPolicy; } /* * (non-Javadoc) * * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { ((JScrollPane) jcomp.getParent()).putClientProperty( SubstanceLookAndFeel.SCROLL_PANE_BUTTONS_POLICY, PolicyChanger.this.newPolicy); jcomp.getParent().doLayout(); jcomp.getParent().repaint(); } }); } } } substance-5.3.orig/src/tools/uidebug/DeuteranopiaColorScheme.java0000644000175000017500000000430211136475576025203 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.uidebug; import org.jvnet.substance.api.SubstanceColorScheme; /** * Color scheme for deuteranopia color blindness. * * @author Kirill Grouchnikov * @see ColorBlindColorScheme */ public class DeuteranopiaColorScheme extends ColorBlindColorScheme { /** * Creates a new deuteranopia color blindness color scheme. * * @param origColorScheme * The original color scheme. */ public DeuteranopiaColorScheme(SubstanceColorScheme origColorScheme) { super(origColorScheme, BlindnessKind.DEUTERANOPIA); } } substance-5.3.orig/src/tools/uidebug/ColorBlindColorScheme.java0000644000175000017500000002324311136475576024617 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.uidebug; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.BaseColorScheme; /** * Base class for color schemes simulating color-blind users. * * @author Kirill Grouchnikov */ public class ColorBlindColorScheme extends BaseColorScheme { /** * Matrix for converting RGB to LMS. */ public double[][] _rgbToLms = { { 0.05059983, 0.08585369, 0.00952420 }, { 0.01893033, 0.08925308, 0.01370054 }, { 0.00292202, 0.00975732, 0.07145979 } }; /** * Matrix for converting LMS to RGB. */ public double[][] _lmsToRgb = { { 30.830854, -29.832659, 1.610474 }, { -6.481468, 17.715578, -2.532642 }, { -0.375690, -1.199062, 14.273846 } }; /** * The main ultra-light color. */ private Color mainUltraLightColor; /** * The main extra-light color. */ private Color mainExtraLightColor; /** * The main light color. */ private Color mainLightColor; /** * The main medium color. */ private Color mainMidColor; /** * The main dark color. */ private Color mainDarkColor; /** * The main ultra-dark color. */ private Color mainUltraDarkColor; /** * The foreground color. */ private Color foregroundColor; /** * The original color scheme. */ private SubstanceColorScheme origScheme; /** * Blindness kind. * * @author Kirill Grouchnikov */ public enum BlindnessKind { /** * Protanopia color blindness. */ PROTANOPIA, /** * Deuteranopia color blindness. */ DEUTERANOPIA, /** * Tritanopia color blindness. */ TRITANOPIA } /** * Creates a new color scheme that simulates color-blindness. * * @param origScheme * Original color scheme. * @param kind * Color-blindness kind. */ public ColorBlindColorScheme(SubstanceColorScheme origScheme, BlindnessKind kind) { super(kind.name() + " " + origScheme.getDisplayName(), origScheme .isDark()); this.origScheme = origScheme; this.foregroundColor = getColorBlindColor(origScheme .getForegroundColor(), _rgbToLms, kind, _lmsToRgb); this.mainUltraDarkColor = getColorBlindColor(origScheme .getUltraDarkColor(), _rgbToLms, kind, _lmsToRgb); this.mainDarkColor = getColorBlindColor(origScheme.getDarkColor(), _rgbToLms, kind, _lmsToRgb); this.mainMidColor = getColorBlindColor(origScheme.getMidColor(), _rgbToLms, kind, _lmsToRgb); this.mainLightColor = getColorBlindColor(origScheme.getLightColor(), _rgbToLms, kind, _lmsToRgb); this.mainExtraLightColor = getColorBlindColor(origScheme .getExtraLightColor(), _rgbToLms, kind, _lmsToRgb); this.mainUltraLightColor = getColorBlindColor(origScheme .getUltraLightColor(), _rgbToLms, kind, _lmsToRgb); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return this.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return this.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return this.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return this.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return this.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return this.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return this.mainUltraDarkColor; } /** * Returns the original color scheme. * * @return The original color scheme. */ public SubstanceColorScheme getOrigScheme() { return this.origScheme; } /** * Converts the specified color into color-blind version. * * @param orig * The original color. * @param rgbToLms * RGB to LMS conversion matrix. * @param kind * Color-blindness kind. * @param lmsToRgb * LMS to RGB conversion matrix. * @return Color-blind version of the original color. */ private static Color getColorBlindColor(Color orig, double[][] rgbToLms, BlindnessKind kind, double[][] lmsToRgb) { double r = orig.getRed(); double g = orig.getGreen(); double b = orig.getBlue(); double[] rgbOrig = new double[] { r, g, b }; double[] lms = mult3(rgbToLms, rgbOrig); double tmp = 0.0; double[] anchor = { 0.08008, 0.1579, 0.5897, 0.1284, 0.2237, 0.3636, 0.9856, 0.7325, 0.001079, 0.0914, 0.007009, 0.0 }; double[] rgbAnchor = { rgbToLms[0][0] + rgbToLms[0][1] + rgbToLms[0][2], rgbToLms[1][0] + rgbToLms[1][1] + rgbToLms[1][2], rgbToLms[2][0] + rgbToLms[2][1] + rgbToLms[2][2] }; double a1, a2, b1, b2, c1, c2, inflection; switch (kind) { case PROTANOPIA: a1 = rgbAnchor[1] * anchor[8] - rgbAnchor[2] * anchor[7]; b1 = rgbAnchor[2] * anchor[6] - rgbAnchor[0] * anchor[8]; c1 = rgbAnchor[0] * anchor[7] - rgbAnchor[1] * anchor[6]; a2 = rgbAnchor[1] * anchor[2] - rgbAnchor[2] * anchor[1]; b2 = rgbAnchor[2] * anchor[0] - rgbAnchor[0] * anchor[2]; c2 = rgbAnchor[0] * anchor[1] - rgbAnchor[1] * anchor[0]; inflection = rgbAnchor[2] / rgbAnchor[1]; tmp = lms[2] / lms[1]; if (tmp < inflection) lms[0] = -(b1 * lms[1] + c1 * lms[2]) / a1; else lms[0] = -(b2 * lms[1] + c2 * lms[2]) / a2; break; case DEUTERANOPIA: a1 = rgbAnchor[1] * anchor[8] - rgbAnchor[2] * anchor[7]; b1 = rgbAnchor[2] * anchor[6] - rgbAnchor[0] * anchor[8]; c1 = rgbAnchor[0] * anchor[7] - rgbAnchor[1] * anchor[6]; a2 = rgbAnchor[1] * anchor[2] - rgbAnchor[2] * anchor[1]; b2 = rgbAnchor[2] * anchor[0] - rgbAnchor[0] * anchor[2]; c2 = rgbAnchor[0] * anchor[1] - rgbAnchor[1] * anchor[0]; inflection = rgbAnchor[2] / rgbAnchor[0]; tmp = lms[2] / lms[0]; /* See which side of the inflection line we fall... */ if (tmp < inflection) lms[1] = -(a1 * lms[0] + c1 * lms[2]) / b1; else lms[1] = -(a2 * lms[0] + c2 * lms[2]) / b2; break; case TRITANOPIA: a1 = rgbAnchor[1] * anchor[11] - rgbAnchor[2] * anchor[10]; b1 = rgbAnchor[2] * anchor[9] - rgbAnchor[0] * anchor[11]; c1 = rgbAnchor[0] * anchor[10] - rgbAnchor[1] * anchor[9]; a2 = rgbAnchor[1] * anchor[5] - rgbAnchor[2] * anchor[4]; b2 = rgbAnchor[2] * anchor[3] - rgbAnchor[0] * anchor[5]; c2 = rgbAnchor[0] * anchor[4] - rgbAnchor[1] * anchor[3]; inflection = (rgbAnchor[1] / rgbAnchor[0]); tmp = lms[1] / lms[0]; if (tmp < inflection) lms[2] = -(a1 * lms[0] + b1 * lms[1]) / c1; else lms[2] = -(a2 * lms[0] + b2 * lms[1]) / c2; break; default: break; } double[] rgbCb = mult3(lmsToRgb, lms); double nr = Math.min(255.0, Math.max(0.0, rgbCb[0])); double ng = Math.min(255.0, Math.max(0.0, rgbCb[1])); double nb = Math.min(255.0, Math.max(0.0, rgbCb[2])); return new Color((int) nr, (int) ng, (int) nb); } /** * Multiplies the specified 3x3 matrix by the specified 3x1 vector. * * @param matrix * Matrix. * @param vector * Vector. * @return Vector multiplication. */ private static double[] mult3(double[][] matrix, double[] vector) { double[] res = new double[3]; res[0] = matrix[0][0] * vector[0] + matrix[0][1] * vector[1] + matrix[0][2] * vector[2]; res[1] = matrix[1][0] * vector[0] + matrix[1][1] * vector[1] + matrix[1][2] * vector[2]; res[2] = matrix[2][0] * vector[0] + matrix[2][1] * vector[1] + matrix[2][2] * vector[2]; return res; } } substance-5.3.orig/src/tools/uidebug/TritanopiaColorScheme.java0000644000175000017500000000427011136475576024701 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package tools.uidebug; import org.jvnet.substance.api.SubstanceColorScheme; /** * Color scheme for tritanopia color blindness. * * @author Kirill Grouchnikov * @see ColorBlindColorScheme */ public class TritanopiaColorScheme extends ColorBlindColorScheme { /** * Creates a new tritanopia color blindness color scheme. * * @param origColorScheme * The original color scheme. */ public TritanopiaColorScheme(SubstanceColorScheme origColorScheme) { super(origColorScheme, BlindnessKind.TRITANOPIA); } } substance-5.3.orig/src/tools/uidebug/RootPaneTitlePaneUiDebugger.java0000644000175000017500000003301711161450560025724 0ustar drazzibdrazzibpackage tools.uidebug; import java.awt.*; import java.awt.Dialog.ModalityType; import java.awt.event.*; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.LafWidgetAdapter; import org.jvnet.lafwidget.animation.effects.GhostPaintingUtils; import org.jvnet.lafwidget.utils.LafConstants.AnimationKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.*; import org.jvnet.substance.api.SubstanceConstants.FocusKind; import org.jvnet.substance.utils.LazyResettableHashMap; import org.jvnet.substance.utils.SubstanceCoreUtilities; public class RootPaneTitlePaneUiDebugger extends LafWidgetAdapter { protected MouseListener substanceDebugUiListener; protected JComponent titlePane; @Override public boolean requiresCustomLafSupport() { return false; } @Override public void installUI() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (!(UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel)) return; titlePane = SubstanceLookAndFeel .getTitlePaneComponent(SwingUtilities .getWindowAncestor(jcomp)); if (titlePane != null) { substanceDebugUiListener = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { process(e); } @Override public void mouseReleased(MouseEvent e) { process(e); } protected void process(MouseEvent e) { if (e.isPopupTrigger()) { JPopupMenu popup = new JPopupMenu(); JMenu cbMenu = new JMenu("Color blindness"); JMenuItem protanopiaCurrent = new JMenuItem( "Protanopia current"); protanopiaCurrent .addActionListener(new SkinChanger( new ColorSchemeTransform() { public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return new ProtanopiaColorScheme( scheme); } }, "Protanopia current")); cbMenu.add(protanopiaCurrent); JMenuItem deuteranopiaCurrent = new JMenuItem( "Deuteranopia current"); deuteranopiaCurrent .addActionListener(new SkinChanger( new ColorSchemeTransform() { public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return new DeuteranopiaColorScheme( scheme); } }, "Deuteranopia current")); cbMenu.add(deuteranopiaCurrent); JMenuItem tritanopiaCurrent = new JMenuItem( "Tritanopia current"); tritanopiaCurrent .addActionListener(new SkinChanger( new ColorSchemeTransform() { public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return new TritanopiaColorScheme( scheme); } }, "Tritanopia current")); cbMenu.add(tritanopiaCurrent); cbMenu.addSeparator(); JMenuItem restoreOriginal = new JMenuItem( "Restore original"); if (SubstanceLookAndFeel.getCurrentSkin(null) .getColorScheme(null, ComponentState.DEFAULT) instanceof ColorBlindColorScheme) { restoreOriginal .addActionListener(new SkinChanger( new ColorSchemeTransform() { public SubstanceColorScheme transform( SubstanceColorScheme scheme) { if (scheme instanceof ColorBlindColorScheme) return ((ColorBlindColorScheme) scheme) .getOrigScheme(); return scheme; } }, "Current")); } else { restoreOriginal.setEnabled(false); } cbMenu.add(restoreOriginal); popup.add(cbMenu); JMenu animMenu = new JMenu("Animation rate"); JMenuItem debugNone = new JMenuItem("None"); debugNone .addActionListener(new AnimationChanger( AnimationKind.NONE)); animMenu.add(debugNone); JMenuItem debugAnim = new JMenuItem( "Debug rate (extra slow)"); debugAnim .addActionListener(new AnimationChanger( AnimationKind.DEBUG)); animMenu.add(debugAnim); JMenuItem debugAnimFast = new JMenuItem( "Debug rate (faster)"); debugAnimFast .addActionListener(new AnimationChanger( AnimationKind.DEBUG_FAST)); animMenu.add(debugAnimFast); JMenuItem debugSlow = new JMenuItem("Slow rate"); debugSlow .addActionListener(new AnimationChanger( AnimationKind.SLOW)); animMenu.add(debugSlow); JMenuItem debugRegular = new JMenuItem( "Regular rate"); debugRegular .addActionListener(new AnimationChanger( AnimationKind.REGULAR)); animMenu.add(debugRegular); JMenuItem debugFast = new JMenuItem("Fast rate"); debugFast .addActionListener(new AnimationChanger( AnimationKind.FAST)); animMenu.add(debugFast); popup.add(animMenu); JMenu focusMenu = new JMenu("Focus kind"); for (FocusKind fKind : FocusKind.values()) { JMenuItem focusMenuItem = new JMenuItem( fKind.name().toLowerCase()); focusMenuItem .addActionListener(new FocusKindChanger( fKind)); focusMenu.add(focusMenuItem); } popup.add(focusMenu); JMenuItem dumpHierarchy = new JMenuItem( "Dump hierarchy"); dumpHierarchy .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent e) { dump(jcomp, 0); } }); popup.add(dumpHierarchy); final JCheckBoxMenuItem ltrChange = new JCheckBoxMenuItem( "Is left-to-right"); ltrChange.setSelected(jcomp .getComponentOrientation() .isLeftToRight()); ltrChange .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent e) { SwingUtilities .invokeLater(new Runnable() { public void run() { jcomp .applyComponentOrientation(ltrChange .isSelected() ? ComponentOrientation.LEFT_TO_RIGHT : ComponentOrientation.RIGHT_TO_LEFT); } }); } }); popup.add(ltrChange); final JCheckBoxMenuItem useThemedIcons = new JCheckBoxMenuItem( "Use themed icons"); useThemedIcons .setSelected(SubstanceCoreUtilities .useThemedDefaultIcon()); useThemedIcons .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent e) { SwingUtilities .invokeLater(new Runnable() { public void run() { UIManager .put( SubstanceLookAndFeel.USE_THEMED_DEFAULT_ICONS, useThemedIcons .isSelected() ? Boolean.TRUE : null); jcomp.repaint(); } }); } }); popup.add(useThemedIcons); final JCheckBoxMenuItem ghostDebugMode = new JCheckBoxMenuItem( "Ghost debug mode"); ghostDebugMode .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent e) { SwingUtilities .invokeLater(new Runnable() { public void run() { ghostDebugMode .setEnabled(false); GhostPaintingUtils.MAX_ICON_GHOSTING_ALPHA = 0.8f; GhostPaintingUtils.MIN_ICON_GHOSTING_ALPHA = 0.6f; GhostPaintingUtils.MAX_PRESS_GHOSTING_ALPHA = 0.8f; GhostPaintingUtils.MIN_PRESS_GHOSTING_ALPHA = 0.6f; GhostPaintingUtils.DECAY_FACTOR = 0.7f; } }); } }); popup.add(ghostDebugMode); JMenuItem showCacheStats = new JMenuItem( "Show cache stats"); showCacheStats .addActionListener(new ActionListener() { @Override public void actionPerformed( ActionEvent e) { SwingUtilities .invokeLater(new Runnable() { public void run() { final JTextArea textArea = new JTextArea(); java.util.List stats = LazyResettableHashMap .getStats(); if (stats != null) { for (String stat : stats) { textArea .append(stat + "\n"); } } final JDialog dialog = new JDialog( SwingUtilities .getWindowAncestor(jcomp), ModalityType.APPLICATION_MODAL); dialog .setTitle("Substance cache stats"); dialog .setLayout(new BorderLayout()); dialog .add( new JScrollPane( textArea), BorderLayout.CENTER); JButton dismiss = new JButton( "Dismiss"); dismiss .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent e) { dialog .dispose(); } }); JButton copyToClipboard = new JButton( "Copy to clipboard"); copyToClipboard .addActionListener(new ActionListener() { public void actionPerformed( ActionEvent e) { textArea .selectAll(); TransferHandler .getCopyAction() .actionPerformed( new ActionEvent( textArea, ActionEvent.ACTION_PERFORMED, "Copy")); } }); JPanel controls = new JPanel( new FlowLayout( FlowLayout.RIGHT)); controls .add(copyToClipboard); controls .add(dismiss); dialog .add( controls, BorderLayout.SOUTH); dialog.setSize( 500, 400); dialog .setLocationRelativeTo(SwingUtilities .getRootPane(jcomp)); dialog .setVisible(true); } }); } }); popup.add(showCacheStats); popup.show(titlePane, e.getX(), e.getY()); } } }; titlePane.addMouseListener(substanceDebugUiListener); } } }); } @Override public void uninstallUI() { if (this.substanceDebugUiListener != null) { titlePane.removeMouseListener(this.substanceDebugUiListener); this.substanceDebugUiListener = null; } } protected static class SkinChanger implements ActionListener { protected ColorSchemeTransform transform; protected String name; public SkinChanger(ColorSchemeTransform transform, String name) { super(); this.transform = transform; this.name = name; } public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceSkin newSkin = SubstanceLookAndFeel .getCurrentSkin(null).transform(transform, name); SubstanceLookAndFeel.setSkin(newSkin); } }); } } protected static class AnimationChanger implements ActionListener { protected AnimationKind newAnimationKind; public AnimationChanger(AnimationKind newAnimationKind) { super(); this.newAnimationKind = newAnimationKind; } public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { UIManager.put(LafWidget.ANIMATION_KIND, newAnimationKind); } }); } } protected static class FocusKindChanger implements ActionListener { protected FocusKind newFocusKind; public FocusKindChanger(FocusKind newFocusKind) { super(); this.newFocusKind = newFocusKind; } public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { UIManager .put(SubstanceLookAndFeel.FOCUS_KIND, newFocusKind); } }); } } public static void dump(Component comp, int level) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < level; i++) sb.append(" "); sb.append(comp.toString()); System.out.println(sb); if (comp instanceof Container) { Container cont = (Container) comp; for (int i = 0; i < cont.getComponentCount(); i++) { dump(cont.getComponent(i), level + 1); } } } } substance-5.3.orig/src/tools/jitterbug/0000755000175000017500000000000011256731164020137 5ustar drazzibdrazzibsubstance-5.3.orig/src/tools/jitterbug/JColorSchemeComponent.java0000644000175000017500000001776211244204566025215 0ustar drazzibdrazzibpackage tools.jitterbug; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.event.ChangeListener; import org.jvnet.substance.api.SubstanceColorScheme; import tools.jitterbug.StateChangeEvent.StateChangeType; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; public class JColorSchemeComponent extends JPanel { private JCheckBox isLight; private JLabel name; private JColorComponent ultraLight; private JColorComponent extraLight; private JColorComponent light; private JColorComponent mid; private JColorComponent dark; private JColorComponent ultraDark; private JColorComponent foreground; private ButtonGroup bg; public JColorSchemeComponent() { FormLayout layout = new FormLayout("fill:pref", ""); DefaultFormBuilder formBuilder = new DefaultFormBuilder(layout, this); this.bg = new ButtonGroup(); this.ultraLight = createColorComponent("ultra light"); this.extraLight = createColorComponent("extra light"); this.light = createColorComponent("light"); this.mid = createColorComponent("mid"); this.dark = createColorComponent("dark"); this.ultraDark = createColorComponent("ultra dark"); this.foreground = createColorComponent("foreground"); JPanel header = new JPanel(); FormLayout hLayout = new FormLayout( "fill:pref,2dlu,fill:min(150px;pref):grow,4dlu,right:pref", ""); DefaultFormBuilder headerBuilder = new DefaultFormBuilder(hLayout, header); name = new JLabel(""); name.setFont(name.getFont().deriveFont(Font.BOLD)); isLight = new JCheckBox("light"); isLight.setSelected(true); isLight.setFocusable(false); headerBuilder.append(new JLabel("Display name:")); headerBuilder.append(name); headerBuilder.append(isLight); isLight.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fireStateChanged(StateChangeType.MODIFIED); } }); formBuilder.append(header); formBuilder.append(ultraLight); formBuilder.append(extraLight); formBuilder.append(light); formBuilder.append(mid); formBuilder.append(dark); formBuilder.append(ultraDark); formBuilder.append(foreground); } private JColorComponent createColorComponent(String label) { JColorComponent result = new JColorComponent(label, null); result.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("selectedColor".equals(evt.getPropertyName())) { fireStateChanged(StateChangeType.MODIFIED); } } }); this.bg.add(result.getRadio()); return result; } public void setContent(SubstanceColorScheme scheme) { this.setEnabled(true); ultraLight.setColor(scheme.getUltraLightColor(), false); extraLight.setColor(scheme.getExtraLightColor(), false); light.setColor(scheme.getLightColor(), false); mid.setColor(scheme.getMidColor(), false); dark.setColor(scheme.getDarkColor(), false); ultraDark.setColor(scheme.getUltraDarkColor(), false); foreground.setColor(scheme.getForegroundColor(), false); isLight.setSelected(!scheme.isDark()); name.setText(scheme.getDisplayName()); fireStateChanged(StateChangeType.INITIALIZED); } @Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); this.setEnabledChildren(this, enabled); } private void setEnabledChildren(Component c, boolean enabled) { if (c instanceof Container) { Container cont = (Container) c; for (int i = 0; i < cont.getComponentCount(); i++) { Component child = cont.getComponent(i); child.setEnabled(enabled); setEnabledChildren(child, enabled); } } } public void clearContent() { this.setEnabled(false); ultraLight.setColor(null, false); extraLight.setColor(null, false); light.setColor(null, false); mid.setColor(null, false); dark.setColor(null, false); ultraDark.setColor(null, false); foreground.setColor(null, false); isLight.setSelected(true); name.setText(""); fireStateChanged(StateChangeType.RESET); } public boolean isLight() { return this.isLight.isSelected(); } public String getDisplayName() { return this.name.getText(); } public Color getUltraLightColor() { return ultraLight.getColor(); } public Color getExtraLightColor() { return extraLight.getColor(); } public Color getLightColor() { return light.getColor(); } public Color getMidColor() { return mid.getColor(); } public Color getDarkColor() { return dark.getColor(); } public Color getUltraDarkColor() { return ultraDark.getColor(); } public Color getForegroundColor() { return foreground.getColor(); } public String getEncoded() { StringBuffer sb = new StringBuffer(); sb.append(this.getDisplayName() + " {\n"); sb.append("\tkind=" + (this.isLight() ? "Light" : "Dark") + "\n"); sb.append("\tcolorUltraLight=" + this.ultraLight.getEncodedColor() + "\n"); sb.append("\tcolorExtraLight=" + this.extraLight.getEncodedColor() + "\n"); sb.append("\tcolorLight=" + this.light.getEncodedColor() + "\n"); sb.append("\tcolorMid=" + this.mid.getEncodedColor() + "\n"); sb.append("\tcolorDark=" + this.dark.getEncodedColor() + "\n"); sb .append("\tcolorUltraDark=" + this.ultraDark.getEncodedColor() + "\n"); sb.append("\tcolorForeground=" + this.foreground.getEncodedColor() + "\n"); sb.append("}\n"); return sb.toString(); } /** * Adds the specified change listener to track changes to this ribbon. * * @param l * Change listener to add. * @see #removeChangeListener(ChangeListener) */ public void addStateChangeListener(StateChangeListener l) { this.listenerList.add(StateChangeListener.class, l); } /** * Removes the specified change listener from tracking changes to this * ribbon. * * @param l * Change listener to remove. * @see #addChangeListener(ChangeListener) */ public void removeStateChangeListener(StateChangeListener l) { this.listenerList.remove(StateChangeListener.class, l); } /** * Notifies all registered listener that the state of this component has * changed. */ protected void fireStateChanged( StateChangeEvent.StateChangeType stateChangeType) { // Guaranteed to return a non-null array Object[] listeners = this.listenerList.getListenerList(); // Process the listeners last to first, notifying // those that are interested in this event StateChangeEvent event = new StateChangeEvent(this, stateChangeType); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == StateChangeListener.class) { ((StateChangeListener) listeners[i + 1]).stateChanged(event); } } } public boolean isDefined() { if ((this.name.getText() == null) || (this.name.getText().trim().length() == 0)) return false; if (!this.ultraLight.isDefined()) return false; if (!this.extraLight.isDefined()) return false; if (!this.light.isDefined()) return false; if (!this.mid.isDefined()) return false; if (!this.dark.isDefined()) return false; if (!this.ultraDark.isDefined()) return false; if (!this.foreground.isDefined()) return false; return true; } public JColorComponent getSelectedColorComponent() { if (this.ultraLight.getRadio().isSelected()) return this.ultraLight; if (this.extraLight.getRadio().isSelected()) return this.extraLight; if (this.light.getRadio().isSelected()) return this.light; if (this.mid.getRadio().isSelected()) return this.mid; if (this.dark.getRadio().isSelected()) return this.dark; if (this.ultraDark.getRadio().isSelected()) return this.ultraDark; if (this.foreground.getRadio().isSelected()) return this.foreground; return null; } } substance-5.3.orig/src/tools/jitterbug/substance.java0000644000175000017500000001042511244200622022756 0ustar drazzibdrazzibpackage tools.jitterbug; import java.awt.*; import java.awt.geom.*; /** * This class has been automatically generated using Flamingo SVG transcoder. */ public class substance { /** * Paints the transcoded SVG image on the specified graphics context. You * can install a custom transformation on the graphics context to scale the * image. * * @param g * Graphics context. */ public static void paint(Graphics2D g) { Shape shape = null; Paint paint = null; Stroke stroke = null; float origAlpha = 1.0f; Composite origComposite = ((Graphics2D)g).getComposite(); if (origComposite instanceof AlphaComposite) { AlphaComposite origAlphaComposite = (AlphaComposite)origComposite; if (origAlphaComposite.getRule() == AlphaComposite.SRC_OVER) { origAlpha = origAlphaComposite.getAlpha(); } } AffineTransform defaultTransform_ = g.getTransform(); // g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); AffineTransform defaultTransform__0 = g.getTransform(); g.transform(new AffineTransform(1.3333326578140259f, 0.0f, 0.0f, 1.3333326578140259f, 5.900062114960747E-4f, -0.0f)); // _0 g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); AffineTransform defaultTransform__0_0 = g.getTransform(); g.transform(new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f)); // _0_0 g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); AffineTransform defaultTransform__0_0_0 = g.getTransform(); g.transform(new AffineTransform(-0.752575781317554f, 0.6585056517405703f, -0.6585056517405703f, -0.752575781317554f, 310.2049865722656f, 167.59800720214844f)); // _0_0_0 g.setComposite(AlphaComposite.getInstance(3, 1.0f * origAlpha)); AffineTransform defaultTransform__0_0_0_0 = g.getTransform(); g.transform(new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f)); // _0_0_0_0 paint = new Color(0, 0, 0, 255); stroke = new BasicStroke(20.0f,1,1,3.0f,null,0.0f); shape = new GeneralPath(); ((GeneralPath)shape).moveTo(0.0, 139.41); ((GeneralPath)shape).curveTo(23.64, 156.92, 46.62, 183.6, 74.01, 184.91); ((GeneralPath)shape).curveTo(95.69, 185.94, 120.12, 171.07, 142.34, 167.23); ((GeneralPath)shape).curveTo(158.16, 164.5, 172.85, 167.36, 184.27, 175.05); ((GeneralPath)shape).curveTo(195.56, 182.66, 203.65, 195.0, 201.61, 205.97); ((GeneralPath)shape).curveTo(200.21, 213.5, 194.06, 220.39, 186.75, 222.32); ((GeneralPath)shape).curveTo(176.88, 224.94, 164.91, 218.53, 157.54, 209.84); ((GeneralPath)shape).curveTo(148.63, 199.34, 146.44, 185.49, 147.06, 170.49); ((GeneralPath)shape).curveTo(147.72, 154.46, 151.57, 137.12, 150.12, 118.98); ((GeneralPath)shape).curveTo(148.86, 103.29, 143.64, 86.99, 134.79, 74.2); ((GeneralPath)shape).curveTo(120.67, 53.81, 97.33, 42.33, 75.36, 45.25); ((GeneralPath)shape).curveTo(63.41, 46.84, 51.87, 52.69, 44.12, 61.07); ((GeneralPath)shape).curveTo(31.55, 74.67, 28.96, 94.96, 39.07, 110.9); ((GeneralPath)shape).curveTo(50.18, 128.41, 76.62, 140.68, 95.67, 139.41); g.setPaint(paint); g.setStroke(stroke); g.draw(shape); g.setTransform(defaultTransform__0_0_0_0); g.setTransform(defaultTransform__0_0_0); g.setTransform(defaultTransform__0_0); g.setTransform(defaultTransform__0); g.setTransform(defaultTransform_); } /** * Returns the X of the bounding box of the original SVG image. * * @return The X of the bounding box of the original SVG image. */ public static int getOrigX() { return -5; } /** * Returns the Y of the bounding box of the original SVG image. * * @return The Y of the bounding box of the original SVG image. */ public static int getOrigY() { return -21; } /** * Returns the width of the bounding box of the original SVG image. * * @return The width of the bounding box of the original SVG image. */ public static int getOrigWidth() { return 403; } /** * Returns the height of the bounding box of the original SVG image. * * @return The height of the bounding box of the original SVG image. */ public static int getOrigHeight() { return 400; } } substance-5.3.orig/src/tools/jitterbug/arrow_down.png0000644000175000017500000000057311244207530023023 0ustar drazzibdrazzibPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe< IDAT8˥?KQi H*.EA!XX vc!v{;,ӻ\}Ï7Ibc0u2B^h gw`4+@jɥ s5"H hPǁh"H.EBFݜ& 5EɃZn+;l8r9~c$ h>*k>hLLjƳRwUd:<$hݸIENDB`substance-5.3.orig/src/tools/jitterbug/JColorComponent.java0000644000175000017500000001131311244173030024041 0ustar drazzibdrazzibpackage tools.jitterbug; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.*; import org.jvnet.lafwidget.utils.RenderingUtils; public class JColorComponent extends JComponent { private JRadioButton radio; private Color selectedColor; private String name; private ColorVisualizer visualizer; private class ColorVisualizer extends JComponent { boolean isRollover; public ColorVisualizer() { this.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (!isEnabled()) return; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { radio.setSelected(true); Color selected = JColorChooser.showDialog( ColorVisualizer.this, "Color chooser", selectedColor); if (selected != null) { Color old = selectedColor; selectedColor = selected; JColorComponent.this.firePropertyChange( "selectedColor", old, selectedColor); } } }); } @Override public void mouseEntered(MouseEvent e) { if (!isEnabled()) return; isRollover = true; repaint(); } @Override public void mouseExited(MouseEvent e) { if (!isEnabled()) return; isRollover = false; repaint(); } }); this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); this.setToolTipText("Open color chooser and change the color"); this.isRollover = false; } @Override protected void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g.create(); RenderingUtils.installDesktopHints(g2d, this); g2d.setFont(UIManager.getFont("Label.font")); if (selectedColor != null) { g2d.setColor(selectedColor); g2d.fillRect(2, 2, 100, getHeight() - 4); g2d.setStroke(new BasicStroke(isRollover ? 2.5f : 1.0f)); g2d.setColor(selectedColor.darker()); g2d.drawRect(2, 2, 99, getHeight() - 5); g2d.setColor(Color.black); g2d.drawString(getEncodedColor(), 108, (getHeight() + g2d .getFontMetrics().getHeight()) / 2 - g2d.getFontMetrics().getDescent()); } else { g2d.setColor(isEnabled() ? Color.gray : Color.lightGray); g2d.drawString("click to choose", 5, (getHeight() + g2d .getFontMetrics().getHeight()) / 2 - g2d.getFontMetrics().getDescent()); } g2d.dispose(); } @Override public Dimension getPreferredSize() { return new Dimension(200, 25); } } public JColorComponent(String name, Color color) { this.radio = new JRadioButton(name); this.radio.setFocusable(false); this.selectedColor = color; this.visualizer = new ColorVisualizer(); this.setLayout(new ColorComponentLayout()); this.add(this.radio); this.add(this.visualizer); } private class ColorComponentLayout implements LayoutManager { @Override public void addLayoutComponent(String name, Component comp) { } @Override public void layoutContainer(Container parent) { JColorComponent cc = (JColorComponent) parent; int width = cc.getWidth(); int height = cc.getHeight(); ColorVisualizer cv = cc.visualizer; Dimension cvPref = cv.getPreferredSize(); cv.setBounds(width - cvPref.width, 0, cvPref.width, height); cc.radio.setBounds(0, 0, width - cvPref.width, height); } @Override public Dimension minimumLayoutSize(Container parent) { return preferredLayoutSize(parent); } @Override public Dimension preferredLayoutSize(Container parent) { JColorComponent cc = (JColorComponent) parent; ColorVisualizer cv = cc.visualizer; Dimension cvPref = cv.getPreferredSize(); return new Dimension(100 + cvPref.width, cvPref.height); } @Override public void removeLayoutComponent(Component comp) { } } public String getEncodedColor() { return "#" + encodeColorComponent(selectedColor.getRed()) + encodeColorComponent(selectedColor.getGreen()) + encodeColorComponent(selectedColor.getBlue()); } private static String encodeColorComponent(int colorComp) { String hex = "0123456789ABCDEF"; return "" + hex.charAt(colorComp / 16) + hex.charAt(colorComp % 16); } public JRadioButton getRadio() { return radio; } public void setColor(Color color, boolean firePropertyChange) { Color old = this.selectedColor; this.selectedColor = color; this.repaint(); if (firePropertyChange) { this.firePropertyChange("selectedColor", old, selectedColor); } } public Color getColor() { return this.selectedColor; } public boolean isDefined() { return (this.selectedColor != null); } } substance-5.3.orig/src/tools/jitterbug/JImageComponent.java0000644000175000017500000002074711245456672024041 0ustar drazzibdrazzib/** * */ package tools.jitterbug; import java.awt.*; import java.awt.datatransfer.*; import java.awt.event.*; import java.awt.image.BufferedImage; import java.io.File; import java.net.URL; import javax.imageio.ImageIO; import javax.swing.*; import org.jvnet.lafwidget.utils.RenderingUtils; import org.jvnet.substance.utils.border.SubstanceBorder; public class JImageComponent extends JPanel { private BufferedImage image; private double leftX; private double topY; private double zoom; private boolean isDragging; private Point lastDragPoint; private Color selectedColor; private Color rolloverColor; public JImageComponent() { this.setTransferHandler(new TransferHandler() { @Override public boolean canImport(TransferSupport support) { // can import a list of files if (support .isDataFlavorSupported(DataFlavor.javaFileListFlavor)) return true; // an image if (support.isDataFlavorSupported(DataFlavor.imageFlavor)) return true; for (DataFlavor df : support.getDataFlavors()) { // and a flavor represented by URL if (df.getRepresentationClass() == URL.class) return true; } return false; } @Override public boolean importData(TransferSupport support) { Transferable t = support.getTransferable(); try { if (t.isDataFlavorSupported(DataFlavor.imageFlavor)) { // load the image Image data = (Image) t .getTransferData(DataFlavor.imageFlavor); image = new BufferedImage(data.getWidth(null), data .getHeight(null), BufferedImage.TYPE_INT_ARGB); image.getGraphics().drawImage(data, 0, 0, null); reset(); repaint(); return true; } if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { // load the image from the file java.util.List l = (java.util.List) t .getTransferData(DataFlavor.javaFileListFlavor); if (l.size() == 1) { image = ImageIO.read(l.get(0)); reset(); repaint(); } return true; } for (DataFlavor df : support.getDataFlavors()) { if (df.getRepresentationClass() == URL.class) { // load the image from the URL URL url = (URL) t.getTransferData(df); Image data = ImageIO.read(url); if (data != null) { image = new BufferedImage(data.getWidth(null), data.getHeight(null), BufferedImage.TYPE_INT_ARGB); image.getGraphics().drawImage(data, 0, 0, null); reset(); repaint(); return true; } } } return true; } catch (Throwable thr) { thr.printStackTrace(); return false; } } }); this.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (image == null) return; if (!e.isPopupTrigger()) { lastDragPoint = e.getPoint(); } else { processPopup(e); } } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { processPopup(e); } else { if (image == null) return; if (!isDragging) { int xRel = e.getX(); int yRel = e.getY(); int xAbs = (int) ((xRel / zoom) + leftX); int yAbs = (int) ((yRel / zoom) + topY); if ((xAbs >= 0) && (xAbs < image.getWidth()) && (yAbs >= 0) && (yAbs < image.getHeight())) { selectedColor = new Color(image.getRGB(xAbs, yAbs)); firePropertyChange("selectedColor", null, selectedColor); } } isDragging = false; } } private void processPopup(MouseEvent e) { JPopupMenu editMenu = new JPopupMenu(); editMenu.add(new AbstractAction("paste from clipboard") { @Override public void actionPerformed(ActionEvent e) { try { Clipboard clipboard = Toolkit.getDefaultToolkit() .getSystemClipboard(); DataFlavor[] flavors = clipboard .getAvailableDataFlavors(); if (flavors != null) { for (DataFlavor flavor : flavors) { if (Image.class == flavor .getRepresentationClass()) { Image data = (Image) clipboard .getData(flavor); image = new BufferedImage(data .getWidth(null), data .getHeight(null), BufferedImage.TYPE_INT_ARGB); image.getGraphics().drawImage(data, 0, 0, null); reset(); break; } } } repaint(); } catch (Throwable thr) { } } @Override public boolean isEnabled() { Clipboard clipboard = Toolkit.getDefaultToolkit() .getSystemClipboard(); DataFlavor[] flavors = clipboard .getAvailableDataFlavors(); if (flavors != null) { for (DataFlavor flavor : flavors) { if (Image.class == flavor .getRepresentationClass()) { return true; } } } return false; } }); Point pt = SwingUtilities.convertPoint(e.getComponent(), e .getPoint(), JImageComponent.this); editMenu.show(JImageComponent.this, pt.x, pt.y); } }); this.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent e) { if (image == null) return; isDragging = true; Point currDragPoint = e.getPoint(); double dx = ((currDragPoint.x - lastDragPoint.x) / zoom); double dy = ((currDragPoint.y - lastDragPoint.y) / zoom); leftX -= dx; topY -= dy; lastDragPoint = currDragPoint; repaint(); } @Override public void mouseMoved(MouseEvent e) { if (image == null) return; int xRel = e.getX(); int yRel = e.getY(); int xAbs = (int) ((xRel / zoom) + leftX); int yAbs = (int) ((yRel / zoom) + topY); // System.out.println(xRel + ":" + yRel + "->" + xAbs + ":" // + yAbs); if ((xAbs >= 0) && (xAbs < image.getWidth()) && (yAbs >= 0) && (yAbs < image.getHeight())) { Color old = rolloverColor; rolloverColor = new Color(image.getRGB(xAbs, yAbs)); firePropertyChange("rolloverColor", old, rolloverColor); } } }); this.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { zoom += e.getScrollAmount() * e.getWheelRotation() / 10.0; zoom = Math.max(1.0, zoom); repaint(); } }); Action zoomInAction = new AbstractAction("zoomin") { @Override public void actionPerformed(ActionEvent e) { zoom += 0.1; repaint(); } }; Action zoomOutAction = new AbstractAction("zoomout") { @Override public void actionPerformed(ActionEvent e) { zoom -= 0.1; zoom = Math.max(1.0, zoom); repaint(); } }; // create the key input maps to handle the zooming // with I and O InputMap inputMap = new ComponentInputMap(this); inputMap.put(KeyStroke.getKeyStroke("I"), "zoomin"); inputMap.put(KeyStroke.getKeyStroke("O"), "zoomout"); ActionMap actionMap = new ActionMap(); actionMap.put("zoomin", zoomInAction); actionMap.put("zoomout", zoomOutAction); // and register the maps this.setInputMap(WHEN_IN_FOCUSED_WINDOW, inputMap); this.setActionMap(actionMap); this.setBorder(new SubstanceBorder()); this.zoom = 1.0; } @Override protected void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g.create(); g2d.setColor(Color.white); g2d.fillRect(0, 0, getWidth(), getHeight()); if (this.image != null) { // zoom from the visible top-left pixel g2d.scale(zoom, zoom); g2d.translate(-this.leftX, -this.topY); g2d.drawImage(this.image, 0, 0, null); } else { RenderingUtils.installDesktopHints(g2d, this); g2d.setFont(UIManager.getFont("Label.font")); g2d.setColor(Color.black); int fh = g2d.getFontMetrics().getHeight(); g2d.drawString( "Image panel. Use one of the following to show an image:", 10, 10 + fh); g2d.drawString( "* Right-click to paste an image from the clipboard", 20, 10 + 2 * fh); g2d .drawString( "* Drag and drop an image file from local disk or another app", 20, 10 + 3 * fh); g2d.drawString("* Drag and drop a URL pointing to an image", 20, 10 + 4 * fh); } g2d.dispose(); } private void reset() { leftX = 0; topY = 0; zoom = 1.0; } }substance-5.3.orig/src/tools/jitterbug/exclamation.png0000644000175000017500000000127511124621416023146 0ustar drazzibdrazzibPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<OIDAT8˥Ka SAoc6.PDC Dբ@Zxh1N"CN:vf}󶰾6uvyy1=!4ИvCv$ HS8d*P. M`+Sذnv~cHVr}ފOKW55Bb `l`yj`yk1AjE @EoqS2FE64(l=$6#1![?@Dw$-WfW&D$Fn>SRJuZNWc#di@% b_s Rۆ^t&:?!DmSQeJWeJÈqMT 'DB:RE_as3ȯC2Vz9W[9ŢwU*B4!B|zPJ fVcdEmZVw!Opřzp!MuS>x9f0Uއx8GHv=}uʡGBy=-Ka J8K+${?`vLЉ37ӿѯLjIENDB`substance-5.3.orig/src/tools/jitterbug/JHsvGraph.java0000644000175000017500000001112411126072174022630 0ustar drazzibdrazzibpackage tools.jitterbug; import java.awt.*; import javax.swing.JComponent; import javax.swing.UIManager; import org.jvnet.lafwidget.utils.RenderingUtils; public class JHsvGraph extends JComponent { private static Color COLOR_HUE = new Color(159, 41, 54); private static Color COLOR_SAT = new Color(27, 88, 124); private static Color COLOR_BRI = new Color(241, 135, 23); private Color[] colors; public JHsvGraph() { } public void setColors(Color[] colors) { this.colors = colors; this.repaint(); } @Override protected void paintComponent(Graphics g) { int w = getWidth(); int h = getHeight(); Graphics2D g2d = (Graphics2D) g.create(); RenderingUtils.installDesktopHints(g2d, this); g2d.setColor(Color.black); int xOffset = g2d.getFontMetrics().stringWidth("255") + 5; int yOffset = 2 * g2d.getFontMetrics().getHeight(); g2d.drawLine(xOffset, yOffset / 2, xOffset, h - yOffset); g2d.drawLine(xOffset, h - yOffset, w - 1, h - yOffset); String keys = "0123456789ABCDEF"; for (int i = 0; i < keys.length(); i++) { String key = keys.charAt(i) + "F"; int y = yOffset + (h - 2 * yOffset) - (h - 2 * yOffset) * (i + 1) / 16; g2d.setColor(Color.lightGray); g2d.drawLine(xOffset + 1, y, w - 1, y); g2d.setColor(Color.gray); g2d.drawString(key, xOffset - 5 - g2d.getFontMetrics().stringWidth(key), y + g2d.getFontMetrics().getDescent()); } if (this.colors != null) { float[] hue = new float[this.colors.length]; float[] sat = new float[this.colors.length]; float[] bri = new float[this.colors.length]; int index = 0; for (Color c : this.colors) { float[] hsb = Color.RGBtoHSB(c.getRed(), c.getGreen(), c .getBlue(), null); hue[index] = hsb[0]; sat[index] = hsb[1]; bri[index] = hsb[2]; index++; } g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Hue g2d.setColor(COLOR_HUE); for (int i = 0; i < this.colors.length; i++) { int x = xOffset + 5 + (w - 1 - xOffset - 10) * i / (this.colors.length - 1); int yHue = yOffset + (h - 2 * yOffset) - (int) ((h - 2 * yOffset) * hue[i]); g2d.fillRect(x - 2, yHue - 2, 5, 5); if (i > 0) { int prevHue = yOffset + (h - 2 * yOffset) - (int) ((h - 2 * yOffset) * hue[i - 1]); int xPrev = xOffset + 5 + (w - 1 - xOffset - 10) * (i - 1) / (this.colors.length - 1); g2d.drawLine(xPrev, prevHue, x, yHue); } } // Saturation g2d.setColor(COLOR_SAT); for (int i = 0; i < this.colors.length; i++) { int x = xOffset + 5 + (w - 1 - xOffset - 10) * i / (this.colors.length - 1); int ySat = yOffset + (h - 2 * yOffset) - (int) ((h - 2 * yOffset) * sat[i]); g2d.fillRect(x - 2, ySat - 2, 5, 5); if (i > 0) { int prevSat = yOffset + (h - 2 * yOffset) - (int) ((h - 2 * yOffset) * sat[i - 1]); int xPrev = xOffset + 5 + (w - 1 - xOffset - 10) * (i - 1) / (this.colors.length - 1); g2d.drawLine(xPrev, prevSat, x, ySat); } } // Brightness g2d.setColor(COLOR_BRI); for (int i = 0; i < this.colors.length; i++) { int x = xOffset + 5 + (w - 1 - xOffset - 10) * i / (this.colors.length - 1); int yBri = yOffset + (h - 2 * yOffset) - (int) ((h - 2 * yOffset) * bri[i]); g2d.fillRect(x - 2, yBri - 2, 5, 5); if (i > 0) { int prevBri = yOffset + (h - 2 * yOffset) - (int) ((h - 2 * yOffset) * bri[i - 1]); int xPrev = xOffset + 5 + (w - 1 - xOffset - 10) * (i - 1) / (this.colors.length - 1); g2d.drawLine(xPrev, prevBri, x, yBri); } } g2d.setFont(UIManager.getFont("Label.font").deriveFont(Font.BOLD)); int labelWidth = g2d.getFontMetrics().stringWidth("WWW") + 20; int xLabel = xOffset + (w - xOffset - 3 * labelWidth) / 2; int lh = h - g2d.getFontMetrics().getAscent() / 2 + 2 - yOffset / 2; g2d.setColor(COLOR_HUE); g2d.drawLine(xLabel, lh, xLabel + 15, lh); g2d.fillRect(xLabel + 6, lh - 2, 5, 5); g2d.drawString("Hue", xLabel + 20, h - yOffset / 2); xLabel += labelWidth; g2d.setColor(COLOR_SAT); g2d.drawLine(xLabel, lh, xLabel + 15, lh); g2d.fillRect(xLabel + 6, lh - 2, 5, 5); g2d.drawString("Sat", xLabel + 20, h - yOffset / 2); xLabel += labelWidth; g2d.setColor(COLOR_BRI); g2d.drawLine(xLabel, lh, xLabel + 15, lh); g2d.fillRect(xLabel + 6, lh - 2, 5, 5); g2d.drawString("Bri", xLabel + 20, h - yOffset / 2); xLabel += labelWidth; } g2d.dispose(); } } substance-5.3.orig/src/tools/jitterbug/chart_line_edit.png0000644000175000017500000000131611243370556023763 0ustar drazzibdrazzibPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<`IDAT8c?%,M_| z= 0); renameButton.setEnabled(hasSelection); deleteButton.setEnabled(hasSelection); moveUpButton.setEnabled(hasSelection && (selectedIndex > 0)); moveDownButton.setEnabled(hasSelection && (selectedIndex < (schemes.size() - 1))); } }); JPanel mainControlPanel = new JPanel(new BorderLayout()); mainControlPanel.add(new JScrollPane(this.schemeList), BorderLayout.CENTER); mainControlPanel.add(bottomButtonsPanel, BorderLayout.SOUTH); // Set up a card panel. It has two cards: // * instructional text // * list of color schemes with button controls this.cardPanel = new JPanel(new CardLayout()); JTextArea textArea = new JTextArea( "List of color schemes. Use one of the following:\n * Drag a .colorschemes file here\n * Click the \"New\" button below"); textArea.setBorder(new EmptyBorder(10, 8, 0, 8)); textArea.setEditable(false); textArea.setOpaque(false); textArea.setRows(9); // textArea.setColumns(20); this.cardPanel.add(textArea, INSTRUCTIONAL); this.cardPanel.add(mainControlPanel, LIST); this.setLayout(new BorderLayout()); this.add(this.cardPanel, BorderLayout.CENTER); // constrain the preferred size so that the layout doesn't // change once the control panel is shown this.setPreferredSize(textArea.getPreferredSize()); } public void setColorSchemeList(File file) { if (!this.checkModifiedStateAndSaveIfNecessary()) { return; } try { this.schemesFile = file; if (file != null) { this.schemes = SubstanceSkin.getColorSchemes(file.toURI() .toURL()); } else { this.schemes = new SubstanceSkin.ColorSchemes(); } // switch to the list view CardLayout cl = (CardLayout) (cardPanel.getLayout()); cl.show(cardPanel, LIST); // let the view know that the model has changed schemeListModel.fireContentsChanged(); // update the buttons state if (file == null) { moveUpButton.setEnabled(false); moveDownButton.setEnabled(false); deleteButton.setEnabled(false); renameButton.setEnabled(false); } this.setModified(false); } catch (Exception exc) { exc.printStackTrace(); } } public boolean checkModifiedStateAndSaveIfNecessary() { if (!this.isModified) { return true; } // does the user want to save modifications? String fileName = (this.schemesFile == null) ? "Unsaved" : this.schemesFile.getName(); int userSelection = JOptionPane.showConfirmDialog(SwingUtilities .getWindowAncestor(this), "Do you want to save the changes to '" + fileName + "'?", "Modified contents", JOptionPane.YES_NO_CANCEL_OPTION); if (userSelection == JOptionPane.CANCEL_OPTION) { return false; } if (userSelection == JOptionPane.YES_OPTION) { if (this.schemesFile != null) { // ask to save this.save(); } else { this.saveAs(); } } return true; } private String getFileNameForSaving() { JFileChooser jfc = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter( "Color scheme files", "colorschemes"); jfc.setFileFilter(filter); int returnVal = jfc.showSaveDialog(SwingUtilities .getWindowAncestor(this)); if (returnVal == JFileChooser.APPROVE_OPTION) { String res = jfc.getSelectedFile().getAbsolutePath(); if (!res.endsWith(".colorschemes")) res += ".colorschemes"; return res; } return null; } private String getNewColorSchemeName(String nameToStartWith) { String result = JOptionPane.showInputDialog(SwingUtilities .getWindowAncestor(this), "Type the color scheme name", nameToStartWith); if (result == null) return null; if (result.equals(nameToStartWith)) return result; result = result.trim(); // check characters Pattern pattern = Pattern.compile("[a-zA-Z ]+"); Matcher matcher = pattern.matcher(result); if (!matcher.matches()) { JOptionPane.showMessageDialog(SwingUtilities .getWindowAncestor(this), "Only use letters and spaces", "Name invalid", JOptionPane.ERROR_MESSAGE); return null; } // check for uniqueness SubstanceColorScheme existing = this.schemes.get(result); if (existing != null) { JOptionPane.showMessageDialog(SwingUtilities .getWindowAncestor(this), "Name already exists", "Name clash", JOptionPane.ERROR_MESSAGE); return null; } return result; } public void save() { this.saveAs(this.schemesFile); } public void saveAs() { // ask for a filename for the save String fileName = this.getFileNameForSaving(); if (fileName != null) { File file = new File(fileName); this.saveAs(file); } } private void saveAs(File file) { PrintStream printStream = null; try { printStream = new PrintStream(new FileOutputStream(file)); for (int i = 0; i < this.schemes.size(); i++) { SubstanceColorScheme colorScheme = this.schemes.get(i); String encodedColorScheme = colorScheme.toString(); printStream.println(encodedColorScheme); printStream.println(); } } catch (IOException ioe) { ioe.printStackTrace(); } if (printStream != null) { printStream.close(); } this.schemesFile = file; this.setModified(false); } public void setModified(boolean isModified) { if (this.isModified == isModified) return; boolean old = this.isModified; this.isModified = isModified; this.firePropertyChange("modified", old, isModified); } public File getCurrentFile() { return this.schemesFile; } public void updateColorScheme(SubstanceColorScheme colorScheme) { SubstanceColorScheme existing = this.schemes.get(colorScheme .getDisplayName()); if (existing == null) throw new IllegalArgumentException("Color scheme " + colorScheme.getDisplayName() + " not found"); this.schemes.replace(colorScheme.getDisplayName(), colorScheme); } public boolean isModified() { return isModified; } } substance-5.3.orig/src/tools/jitterbug/StateChangeEvent.java0000644000175000017500000000071511243737012024167 0ustar drazzibdrazzibpackage tools.jitterbug; import java.util.EventObject; public class StateChangeEvent extends EventObject { private StateChangeType stateChangeType; public static enum StateChangeType { INITIALIZED, MODIFIED, RESET } public StateChangeEvent(Object source, StateChangeType stateChangeType) { super(source); this.stateChangeType = stateChangeType; } public StateChangeType getStateChangeType() { return stateChangeType; } } substance-5.3.orig/src/tools/jitterbug/JitterbugEditor.java0000644000175000017500000002610411244362052024104 0ustar drazzibdrazzibpackage tools.jitterbug; import java.awt.*; import java.awt.datatransfer.*; import java.awt.dnd.*; import java.awt.event.*; import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; import java.io.InputStream; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.skin.BusinessSkin; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; import org.jvnet.substance.utils.SubstanceCoreUtilities; import tools.jitterbug.StateChangeEvent.StateChangeType; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; public class JitterbugEditor extends JFrame implements ClipboardOwner { private static final String APP_TITLE = "Jitterbug color scheme editor"; private JColorSchemeList colorSchemeList; private JColorSchemeComponent colorSchemeComp; private JHsvGraph hsvGraph; private class JitterbugLogo implements Icon { substance logo = new substance(); @Override public int getIconHeight() { return 16; } @Override public int getIconWidth() { return 16; } @Override public void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D g2d = (Graphics2D) g.create(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.translate(x, y); double coef1 = (double) getIconWidth() / (double) logo.getOrigWidth(); double coef2 = (double) getIconHeight() / (double) logo.getOrigHeight(); double coef = Math.min(coef1, coef2); g2d.scale(coef, coef); g2d.translate(logo.getOrigX(), logo.getOrigY()); logo.paint(g2d); g2d.dispose(); } } protected class JitterbugDropHandler extends DropTargetAdapter { @Override public void drop(DropTargetDropEvent dtde) { Transferable t = dtde.getTransferable(); if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { try { dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); java.util.List files = (java.util.List) t .getTransferData(DataFlavor.javaFileListFlavor); File f = (File) files.get(0); System.out.println("Reading from " + f.getAbsolutePath()); colorSchemeList.setColorSchemeList(f); colorSchemeComp.clearContent(); dtde.dropComplete(true); JitterbugEditor.this.setTitle(APP_TITLE + " - " + f.getAbsolutePath()); return; } catch (Exception exc) { exc.printStackTrace(); } } // if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) { // try { // dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); // String content = (String) t // .getTransferData(DataFlavor.stringFlavor); // colorSchemeComp.setContent(new ByteArrayInputStream(content // .getBytes())); // dtde.dropComplete(true); // return; // } catch (Exception exc) { // exc.printStackTrace(); // } // } } @Override public void dragEnter(DropTargetDragEvent dtde) { for (DataFlavor df : dtde.getCurrentDataFlavors()) { Class repClass = df.getDefaultRepresentationClass(); boolean canDrop = InputStream.class.isAssignableFrom(repClass); if (canDrop) { dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); return; } } } } public JitterbugEditor() { super(); BufferedImage iconImage = SubstanceCoreUtilities.getBlankImage(16, 16); new JitterbugLogo().paintIcon(this, iconImage.getGraphics(), 0, 0); this.setIconImage(iconImage); FormLayout leftPanelLayout = new FormLayout("fill:pref", "fill:pref, fill:pref, fill:pref:grow, fill:pref"); DefaultFormBuilder leftPanelBuilder = new DefaultFormBuilder( leftPanelLayout); this.colorSchemeList = new JColorSchemeList(); this.colorSchemeList.setDropTarget(new DropTarget(this, new JitterbugDropHandler())); leftPanelBuilder.append(this.colorSchemeList); this.colorSchemeComp = new JColorSchemeComponent(); this.colorSchemeComp.setEnabled(false); this.colorSchemeComp.setDropTarget(new DropTarget(this, new JitterbugDropHandler())); leftPanelBuilder.append(this.colorSchemeComp); this.hsvGraph = new JHsvGraph(); this.hsvGraph.setDropTarget(new DropTarget(this, new JitterbugDropHandler())); leftPanelBuilder.append(this.hsvGraph); JPanel controlsPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING)); final JButton saveButton = new JButton("save"); saveButton.setIcon(new ImageIcon(JitterbugEditor.class.getClassLoader() .getResource("tools/jitterbug/page_save.png"))); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { colorSchemeList.save(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { saveButton.setEnabled(false); } }); } }); saveButton.setEnabled(false); controlsPanel.add(saveButton); JButton saveAsButton = new JButton("save as..."); saveAsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { colorSchemeList.saveAs(); updateMainWindowTitle(colorSchemeList.isModified()); } }); controlsPanel.add(saveAsButton); JButton newButton = new JButton("new"); newButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { colorSchemeList.setColorSchemeList(null); colorSchemeComp.clearContent(); updateMainWindowTitle(colorSchemeList.isModified()); } }); controlsPanel.add(Box.createHorizontalStrut(20)); controlsPanel.add(newButton); leftPanelBuilder.append(controlsPanel); JPanel leftPanel = leftPanelBuilder.getPanel(); // wire drag and drop wireDragAndDrop(leftPanel); // wire color scheme selection in the list to the // color scheme component this.colorSchemeList.addPropertyChangeListener("selectedColorScheme", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { SubstanceColorScheme newSelection = (SubstanceColorScheme) evt .getNewValue(); if (newSelection != null) colorSchemeComp.setContent(newSelection); else colorSchemeComp.clearContent(); } }); // track color modifications of the currently selected // color scheme this.colorSchemeComp.addStateChangeListener(new StateChangeListener() { @Override public void stateChanged(StateChangeEvent event) { if (event.getStateChangeType() == StateChangeType.MODIFIED) { // let the color scheme list know that there was change colorSchemeList.setModified(true); } // update the HSV graph component if (colorSchemeComp.isDefined()) { Color[] colors = new Color[] { colorSchemeComp.getUltraLightColor(), colorSchemeComp.getExtraLightColor(), colorSchemeComp.getLightColor(), colorSchemeComp.getMidColor(), colorSchemeComp.getDarkColor(), colorSchemeComp.getUltraDarkColor() }; hsvGraph.setColors(colors); } else { hsvGraph.setColors(null); } if (event.getStateChangeType() == StateChangeType.MODIFIED) { if (colorSchemeComp.isDefined()) { boolean isLight = colorSchemeComp.isLight(); Color ultraDark = colorSchemeComp.getUltraDarkColor(); Color dark = colorSchemeComp.getDarkColor(); Color mid = colorSchemeComp.getMidColor(); Color light = colorSchemeComp.getLightColor(); Color extraLight = colorSchemeComp.getExtraLightColor(); Color ultraLight = colorSchemeComp.getUltraLightColor(); Color foreground = colorSchemeComp.getForegroundColor(); String name = colorSchemeComp.getDisplayName(); Color[] colors = new Color[] { ultraLight, extraLight, light, mid, dark, ultraDark, foreground }; SubstanceColorScheme scheme = isLight ? SubstanceColorSchemeUtilities .getLightColorScheme(name, colors) : SubstanceColorSchemeUtilities .getDarkColorScheme(name, colors); colorSchemeList.updateColorScheme(scheme); } } } }); // track modification changes on the scheme list and any scheme in it this.colorSchemeList.addPropertyChangeListener("modified", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { boolean isModified = (Boolean) evt.getNewValue(); getRootPane().putClientProperty( SubstanceLookAndFeel.WINDOW_MODIFIED, Boolean.valueOf(isModified)); // update the main frame title updateMainWindowTitle(isModified); File currFile = colorSchemeList.getCurrentFile(); saveButton.setEnabled(currFile != null); } }); this.add(leftPanel, BorderLayout.WEST); JPanel mainPanel = new JPanel(new BorderLayout()); JImageComponent imageComp = new JImageComponent(); imageComp.addPropertyChangeListener("selectedColor", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { Color selectedImageColor = (Color) evt.getNewValue(); JColorComponent selectedColorComp = colorSchemeComp .getSelectedColorComponent(); if (selectedColorComp != null) { selectedColorComp .setColor(selectedImageColor, true); } } }); mainPanel.add(imageComp, BorderLayout.CENTER); this.add(mainPanel, BorderLayout.CENTER); this.setSize(800, 700); this.setExtendedState(JFrame.MAXIMIZED_BOTH); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { // do we need to save the modified scheme list? if (colorSchemeList.checkModifiedStateAndSaveIfNecessary()) { dispose(); } } }); this.updateMainWindowTitle(false); } private void wireDragAndDrop(Component comp) { comp.setDropTarget(new DropTarget(this, new JitterbugDropHandler())); if (comp instanceof Container) { Container cont = (Container) comp; for (int i = 0; i < cont.getComponentCount(); i++) { wireDragAndDrop(cont.getComponent(i)); } } } @Override public void lostOwnership(Clipboard clipboard, Transferable contents) { } private void updateMainWindowTitle(boolean isModified) { File schemesFile = colorSchemeList.getCurrentFile(); String title = APP_TITLE + " - "; if (isModified) { title += "* "; } if (schemesFile != null) { title += schemesFile.getAbsolutePath(); } else { title += "Unsaved"; } setTitle(title); } public static void main(String[] args) { JDialog.setDefaultLookAndFeelDecorated(true); JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessSkin()); new JitterbugEditor().setVisible(true); } }); } } substance-5.3.orig/src/tools/jitterbug/arrow_up.png0000644000175000017500000000056411244207530022500 0ustar drazzibdrazzibPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDAT8˥?/Qϲhg5j%'F,[ LH 3(vw=fcoN{O~9VM4Q7ܿ)v/WQ=&bpSO ^'&^:\˨6eND!& 9꒣_|?\ srx,g*,(F#d[OaAA*P p1O+C$`)*w`A#0$ *?b&NRIENDB`substance-5.3.orig/src/tools/jitterbug/add.png0000644000175000017500000000133511243370570021373 0ustar drazzibdrazzibPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<oIDAT8˥Ka[/Y()%X(olNۖskn.-h;8fEP"jïMGˈ}yພ羹$I.tulu AX:𼂒ZHh1DnZJOJB{Z?`2`S=N$ő=;a &jw qJG#<"N2h8޵`6xցn_+ ~Zto}`x%XЛ͈ hXѿƻ/}BJ_G&|Qr-6Aރ EL⬡\U3:WUh[C6+ 6.f *K͸ܝFq ou4܄?d|XҥMvD` *_[ #A20liR|xq`4w=\uQ m+G|%$5Թ5RO*YGMUO Gqj4ְ(X& s1c˭(LVf RdjQ '-1ATA>U j4,pV"4L$e@.ArBY a~myY])Q8tNLܞt2"I o=CSd)__AF(IENDB`substance-5.3.orig/src/tools/jitterbug/delete.png0000644000175000017500000000131311243370570022101 0ustar drazzibdrazzibPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<]IDAT8˥KSa[nQP2wܦγL[,biaA\Cv_2MlZFjסNMjmkʷ`&.#z<ϓ bVPT3%I{GqRivȅ tz#E6EddJ`DR2<]N ;4Ѿ;m>78ɀQe6LIt殷cq!z |v j/Xi@ %1|hl !|! Y#uUNw]˼ H3u t]E>k%IfoRD:0`~ | (r on3oG0!$V *[W0_-+ dW&2ZfMFVJpiF&B > Rg- ~ CmڴER ឫ p5ްy+21Kawh` #aZ񽞆TZoLѓ`"(?'ˎJvKކ|:G9[aw82 Jw f'ymzsӘTsw__ιIrIENDB`substance-5.3.orig/src/tools/jitterbug/page_save.png0000644000175000017500000000140611243371046022573 0ustar drazzibdrazzibPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<IDATMVe78bDfai*QT@h妍P;]B@hQTP6Rd%XAT(T0sxM(a6/AV]-_cgNʞ| #[/?_8s|qmibGm)%deUץOl]z^té̦m "PmYܻٶ'׵s3@I JD(J.][s} ÷h&L8)me4ZkR6DE'.X?갳a+k>+4;uʚ/~{=ov:_ >rIqԎL*2V#nt+"֜LI)IFءjMFn VnaG5^n(#e?y?Wu\%2dzjnl-[6әF:;=2?9oՑUXU/F/ˮIENDB`substance-5.3.orig/src/tools/jitterbug/StateChangeListener.java0000644000175000017500000000026411243736142024675 0ustar drazzibdrazzibpackage tools.jitterbug; import java.util.EventListener; public interface StateChangeListener extends EventListener { public void stateChanged(StateChangeEvent event); } substance-5.3.orig/src/Substance.license0000644000175000017500000000357011206042120020256 0ustar drazzibdrazzibCopyright (c) 2005-2009, Kirill Grouchnikov and contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Kirill Grouchnikov and contributors nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> The original artwork used in the Quaqua color chooser implementation has been replaced by images from Famfam Silk collection available under Creative Commons Attribution-ShareAlike 2.5 license and images created dynamically by the Substance core code. substance-5.3.orig/src/XUI.license0000644000175000017500000006316110634345122017012 0ustar drazzibdrazzib MOZILLA PUBLIC LICENSE Version 1.1 --------------- 1. Definitions. 1.0.1. "Commercial Use" means distribution or otherwise making the Covered Code available to a third party. 1.1. "Contributor" means each entity that creates or contributes to the creation of Modifications. 1.2. "Contributor Version" means the combination of the Original Code, prior Modifications used by a Contributor, and the Modifications made by that particular Contributor. 1.3. "Covered Code" means the Original Code or Modifications or the combination of the Original Code and Modifications, in each case including portions thereof. 1.4. "Electronic Distribution Mechanism" means a mechanism generally accepted in the software development community for the electronic transfer of data. 1.5. "Executable" means Covered Code in any form other than Source Code. 1.6. "Initial Developer" means the individual or entity identified as the Initial Developer in the Source Code notice required by Exhibit A. 1.7. "Larger Work" means a work which combines Covered Code or portions thereof with code not governed by the terms of this License. 1.8. "License" means this document. 1.8.1. "Licensable" means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein. 1.9. "Modifications" means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a Modification is: A. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications. B. Any new file that contains any part of the Original Code or previous Modifications. 1.10. "Original Code" means Source Code of computer software code which is described in the Source Code notice required by Exhibit A as Original Code, and which, at the time of its release under this License is not already Covered Code governed by this License. 1.10.1. "Patent Claims" means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor. 1.11. "Source Code" means the preferred form of the Covered Code for making modifications to it, including all modules it contains, plus any associated interface definition files, scripts used to control compilation and installation of an Executable, or source code differential comparisons against either the Original Code or another well known, available Covered Code of the Contributor's choice. The Source Code can be in a compressed or archival form, provided the appropriate decompression or de-archiving software is widely available for no charge. 1.12. "You" (or "Your") means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License or a future version of this License issued under Section 6.1. For legal entities, "You" includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, "control" means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 2. Source Code License. 2.1. The Initial Developer Grant. The Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license, subject to third party intellectual property claims: (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer to use, reproduce, modify, display, perform, sublicense and distribute the Original Code (or portions thereof) with or without Modifications, and/or as part of a Larger Work; and (b) under Patents Claims infringed by the making, using or selling of Original Code, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Code (or portions thereof). (c) the licenses granted in this Section 2.1(a) and (b) are effective on the date Initial Developer first distributes Original Code under the terms of this License. (d) Notwithstanding Section 2.1(b) above, no patent license is granted: 1) for code that You delete from the Original Code; 2) separate from the Original Code; or 3) for infringements caused by: i) the modification of the Original Code or ii) the combination of the Original Code with other software or devices. 2.2. Contributor Grant. Subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor, to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof) either on an unmodified basis, with other Modifications, as Covered Code and/or as part of a Larger Work; and (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: 1) Modifications made by that Contributor (or portions thereof); and 2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination). (c) the licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first makes Commercial Use of the Covered Code. (d) Notwithstanding Section 2.2(b) above, no patent license is granted: 1) for any code that Contributor has deleted from the Contributor Version; 2) separate from the Contributor Version; 3) for infringements caused by: i) third party modifications of Contributor Version or ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or 4) under Patent Claims infringed by Covered Code in the absence of Modifications made by that Contributor. 3. Distribution Obligations. 3.1. Application of License. The Modifications which You create or to which You contribute are governed by the terms of this License, including without limitation Section 2.2. The Source Code version of Covered Code may be distributed only under the terms of this License or a future version of this License released under Section 6.1, and You must include a copy of this License with every copy of the Source Code You distribute. You may not offer or impose any terms on any Source Code version that alters or restricts the applicable version of this License or the recipients' rights hereunder. However, You may include an additional document offering the additional rights described in Section 3.5. 3.2. Availability of Source Code. Any Modification which You create or to which You contribute must be made available in Source Code form under the terms of this License either on the same media as an Executable version or via an accepted Electronic Distribution Mechanism to anyone to whom you made an Executable version available; and if made available via Electronic Distribution Mechanism, must remain available for at least twelve (12) months after the date it initially became available, or at least six (6) months after a subsequent version of that particular Modification has been made available to such recipients. You are responsible for ensuring that the Source Code version remains available even if the Electronic Distribution Mechanism is maintained by a third party. 3.3. Description of Modifications. You must cause all Covered Code to which You contribute to contain a file documenting the changes You made to create that Covered Code and the date of any change. You must include a prominent statement that the Modification is derived, directly or indirectly, from Original Code provided by the Initial Developer and including the name of the Initial Developer in (a) the Source Code, and (b) in any notice in an Executable version or related documentation in which You describe the origin or ownership of the Covered Code. 3.4. Intellectual Property Matters (a) Third Party Claims. If Contributor has knowledge that a license under a third party's intellectual property rights is required to exercise the rights granted by such Contributor under Sections 2.1 or 2.2, Contributor must include a text file with the Source Code distribution titled "LEGAL" which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If Contributor obtains such knowledge after the Modification is made available as described in Section 3.2, Contributor shall promptly modify the LEGAL file in all copies Contributor makes available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained. (b) Contributor APIs. If Contributor's Modifications include an application programming interface and Contributor has knowledge of patent licenses which are reasonably necessary to implement that API, Contributor must also include this information in the LEGAL file. (c) Representations. Contributor represents that, except as disclosed pursuant to Section 3.4(a) above, Contributor believes that Contributor's Modifications are Contributor's original creation(s) and/or Contributor has sufficient rights to grant the rights conveyed by this License. 3.5. Required Notices. You must duplicate the notice in Exhibit A in each file of the Source Code. If it is not possible to put such notice in a particular Source Code file due to its structure, then You must include such notice in a location (such as a relevant directory) where a user would be likely to look for such a notice. If You created one or more Modification(s) You may add your name as a Contributor to the notice described in Exhibit A. You must also duplicate this License in any documentation for the Source Code where You describe recipients' rights or ownership rights relating to Covered Code. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer. 3.6. Distribution of Executable Versions. You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You describe recipients' rights relating to the Covered Code. You may distribute the Executable version of Covered Code or ownership rights under a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient's rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or any Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. 3.7. Larger Works. You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code. 4. Inability to Comply Due to Statute or Regulation. If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. 5. Application of this License. This License applies to code to which the Initial Developer has attached the notice in Exhibit A and to related Covered Code. 6. Versions of the License. 6.1. New Versions. Netscape Communications Corporation ("Netscape") may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number. 6.2. Effect of New Versions. Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by Netscape. No one other than Netscape has the right to modify the terms applicable to Covered Code created under this License. 6.3. Derivative Works. If You create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), You must (a) rename Your license so that the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", "MPL", "NPL" or any confusingly similar phrase do not appear in your license (except to note that your license differs from this License) and (b) otherwise make it clear that Your version of the license contains terms which differ from the Mozilla Public License and Netscape Public License. (Filling in the name of the Initial Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.) 7. DISCLAIMER OF WARRANTY. COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. 8. TERMINATION. 8.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. 8.2. If You initiate litigation by asserting a patent infringement claim (excluding declatory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You file such action is referred to as "Participant") alleging that: (a) such Participant's Contributor Version directly or indirectly infringes any patent, then any and all rights granted by such Participant to You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively, unless if within 60 days after receipt of notice You either: (i) agree in writing to pay Participant a mutually agreeable reasonable royalty for Your past and future use of Modifications made by such Participant, or (ii) withdraw Your litigation claim with respect to the Contributor Version against such Participant. If within 60 days of notice, a reasonable royalty and payment arrangement are not mutually agreed upon in writing by the parties or the litigation claim is not withdrawn, the rights granted by Participant to You under Sections 2.1 and/or 2.2 automatically terminate at the expiration of the 60 day notice period specified above. (b) any software, hardware, or device, other than such Participant's Contributor Version, directly or indirectly infringes any patent, then any rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are revoked effective as of the date You first made, used, sold, distributed, or had made, Modifications made by that Participant. 8.3. If You assert a patent infringement claim against Participant alleging that such Participant's Contributor Version directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license. 8.4. In the event of termination under Sections 8.1 or 8.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or any distributor hereunder prior to termination shall survive termination. 9. LIMITATION OF LIABILITY. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. 10. U.S. GOVERNMENT END USERS. The Covered Code is a "commercial item," as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial computer software documentation," as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein. 11. MISCELLANEOUS. This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by California law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in the United States of America, any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California, with venue lying in Santa Clara County, California, with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys' fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. 12. RESPONSIBILITY FOR CLAIMS. As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability. 13. MULTIPLE-LICENSED CODE. Initial Developer may designate portions of the Covered Code as "Multiple-Licensed". "Multiple-Licensed" means that the Initial Developer permits you to utilize portions of the Covered Code under Your choice of the NPL or the alternative licenses, if any, specified by the Initial Developer in the file described in Exhibit A. EXHIBIT A -Mozilla Public License. ``The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is ______________________________________. The Initial Developer of the Original Code is ________________________. Portions created by ______________________ are Copyright (C) ______ _______________________. All Rights Reserved. Contributor(s): ______________________________________. Alternatively, the contents of this file may be used under the terms of the _____ license (the "[___] License"), in which case the provisions of [______] License are applicable instead of those above. If you wish to allow use of your version of this file only under the terms of the [____] License and not to allow others to use your version of this file under the MPL, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the [___] License. If you do not delete the provisions above, a recipient may use your version of this file under either the MPL or the [___] License." [NOTE: The text of this Exhibit A may differ slightly from the text of the notices in the Source Code files of the Original Code. You should use the text of this Exhibit A rather than the text found in the Original Code Source Code for Your Modifications.] substance-5.3.orig/src/org/0000755000175000017500000000000010570313710015556 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/0000755000175000017500000000000010570313710016704 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/0000755000175000017500000000000011256731146020704 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/SubstancePopupMenuUI.java0000644000175000017500000001124711247214770025611 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.event.ContainerEvent; import java.awt.event.ContainerListener; import javax.swing.JComponent; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicPopupMenuUI; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.menu.MenuUtilities; /** * UI for popup menus in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstancePopupMenuUI extends BasicPopupMenuUI { /** * Tracks changes to the popup menu and invalidates precomputed text offset. */ protected ContainerListener substanceContainerListener; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstancePopupMenuUI(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicPopupMenuUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); this.substanceContainerListener = new ContainerListener() { public void componentAdded(ContainerEvent e) { MenuUtilities.cleanPopupLayoutMetrics(popupMenu); } public void componentRemoved(ContainerEvent e) { MenuUtilities.cleanPopupLayoutMetrics(popupMenu); } }; this.popupMenu.addContainerListener(this.substanceContainerListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicPopupMenuUI#uninstallListeners() */ @Override protected void uninstallListeners() { this.popupMenu.removeContainerListener(this.substanceContainerListener); this.substanceContainerListener = null; super.uninstallListeners(); } // // @Override // public void update(Graphics g, JComponent c) { // MenuLayoutMetrics popupMetrics = MenuUtilities.getPopupLayoutMetrics( // (JPopupMenu) c, true); // // int xOffset = 0; // int gap = popupMetrics.maxIconTextGap; // Insets i = c.getInsets(); // Component firstChild = c.getComponent(0); // Insets i1 = (firstChild instanceof JComponent) ? ((JComponent) // firstChild) // .getInsets() // : null; // if (c.getComponentOrientation().isLeftToRight()) { // xOffset = i.left; // if (i1 != null) // xOffset += i1.left; // xOffset += gap / 2; // if (popupMetrics.maxCheckIconWidth > 0) { // xOffset += (popupMetrics.maxCheckIconWidth + gap); // } // if (popupMetrics.maxIconWidth > 0) { // xOffset += (popupMetrics.maxIconWidth + gap); // } // xOffset += gap / 2; // } else { // xOffset = c.getWidth() - i.right; // if (i1 != null) // xOffset -= i1.right; // xOffset -= gap / 2; // if (popupMetrics.maxCheckIconWidth > 0) { // xOffset -= (popupMetrics.maxCheckIconWidth + gap); // } // if (popupMetrics.maxIconWidth > 0) { // xOffset -= (popupMetrics.maxIconWidth + gap); // } // xOffset += gap / 2; // } // // SubstanceMenuBackgroundDelegate.paintBackground(g, c, xOffset); // } } substance-5.3.orig/src/org/jvnet/substance/SubstancePasswordFieldUI.java0000644000175000017500000003323411136475560026432 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.*; import javax.swing.plaf.basic.BasicBorders; import javax.swing.plaf.basic.BasicPasswordFieldUI; import javax.swing.text.*; import org.jvnet.lafwidget.animation.FadeStateListener; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.border.SubstanceBorder; /** * UI for password fields in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstancePasswordFieldUI extends BasicPasswordFieldUI { /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /** * The associated password field. */ protected JPasswordField passwordField; /** * Property change listener. */ protected PropertyChangeListener substancePropertyChangeListener; /** * Custom password view. * * @author Kirill Grouchnikov */ private static class SubstancePasswordView extends FieldView { /** * The associated password field. */ private JPasswordField field; /** * Simple constructor. * * @param field * The associated password field. * @param element * The element */ public SubstancePasswordView(JPasswordField field, Element element) { super(element); this.field = field; } /** * Draws the echo character(s) for a single password field character. * The number of echo characters is defined by * {@link SubstanceLookAndFeel#PASSWORD_ECHO_PER_CHAR} client property. * * @param g * Graphics context * @param x * X coordinate of the first echo character to draw. * @param y * Y coordinate of the first echo character to draw. * @param c * Password field. * @param isSelected * Indicates whether the password field character is * selected. * @return The X location of the next echo character. * @see SubstanceLookAndFeel#PASSWORD_ECHO_PER_CHAR */ protected int drawEchoCharacter(Graphics g, int x, int y, char c, boolean isSelected) { Container container = this.getContainer(); Graphics2D graphics = (Graphics2D) g; graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); JPasswordField field = (JPasswordField) container; int fontSize = SubstanceSizeUtils.getComponentFontSize(this.field); int dotDiameter = SubstanceSizeUtils .getPasswordDotDiameter(fontSize); int dotGap = SubstanceSizeUtils.getPasswordDotGap(fontSize); ComponentState state = // isSelected ? ComponentState.SELECTED (field.isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED); SubstanceColorScheme scheme = SubstanceColorSchemeUtilities .getColorScheme(field, state); Color topColor = isSelected ? scheme.getSelectionForegroundColor() : SubstanceColorUtilities.getForegroundColor(scheme); Color bottomColor = topColor.brighter(); graphics.setPaint(new GradientPaint(x, y - dotDiameter, topColor, x, y, bottomColor)); int echoPerChar = SubstanceCoreUtilities.getEchoPerChar(field); for (int i = 0; i < echoPerChar; i++) { graphics.fillOval(x + dotGap / 2, y - dotDiameter, dotDiameter, dotDiameter); x += (dotDiameter + dotGap); } return x; } /** * Returns the advance of a single password field character. The advance * is the pixel distance between first echo characters of consecutive * password field characters. The * {@link SubstanceLookAndFeel#PASSWORD_ECHO_PER_CHAR} can be used to * specify that more than one echo character is used for each password * field character. * * @return The advance of a single password field character */ protected int getEchoCharAdvance() { int fontSize = SubstanceSizeUtils.getComponentFontSize(this.field); int dotDiameter = SubstanceSizeUtils .getPasswordDotDiameter(fontSize); int dotGap = SubstanceSizeUtils.getPasswordDotGap(fontSize); int echoPerChar = SubstanceCoreUtilities.getEchoPerChar(field); return echoPerChar * (dotDiameter + dotGap); } /* * (non-Javadoc) * * @see javax.swing.text.PlainView#drawSelectedText(java.awt.Graphics, * int, int, int, int) */ @Override protected int drawSelectedText(Graphics g, final int x, final int y, int p0, int p1) throws BadLocationException { Container c = getContainer(); if (c instanceof JPasswordField) { JPasswordField f = (JPasswordField) c; if (!f.echoCharIsSet()) { return super.drawSelectedText(g, x, y, p0, p1); } int n = p1 - p0; char echoChar = f.getEchoChar(); int currPos = x; for (int i = 0; i < n; i++) { currPos = drawEchoCharacter(g, currPos, y, echoChar, true); } return x + n * getEchoCharAdvance(); } return x; } /* * (non-Javadoc) * * @see javax.swing.text.PlainView#drawUnselectedText(java.awt.Graphics, * int, int, int, int) */ @Override protected int drawUnselectedText(Graphics g, final int x, final int y, int p0, int p1) throws BadLocationException { Container c = getContainer(); if (c instanceof JPasswordField) { JPasswordField f = (JPasswordField) c; if (!f.echoCharIsSet()) { return super.drawUnselectedText(g, x, y, p0, p1); } int n = p1 - p0; char echoChar = f.getEchoChar(); int currPos = x; for (int i = 0; i < n; i++) { currPos = drawEchoCharacter(g, currPos, y, echoChar, false); } return x + n * getEchoCharAdvance(); } return x; } /* * (non-Javadoc) * * @see javax.swing.text.View#modelToView(int, java.awt.Shape, * javax.swing.text.Position.Bias) */ @Override public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException { Container c = this.getContainer(); if (c instanceof JPasswordField) { JPasswordField f = (JPasswordField) c; if (!f.echoCharIsSet()) { return super.modelToView(pos, a, b); } Rectangle alloc = this.adjustAllocation(a).getBounds(); int echoPerChar = SubstanceCoreUtilities.getEchoPerChar(f); int fontSize = SubstanceSizeUtils .getComponentFontSize(this.field); int dotWidth = SubstanceSizeUtils .getPasswordDotDiameter(fontSize) + SubstanceSizeUtils.getPasswordDotGap(fontSize); int dx = (pos - this.getStartOffset()) * echoPerChar * dotWidth; alloc.x += dx; alloc.width = 1; return alloc; } return null; } /* * (non-Javadoc) * * @see javax.swing.text.View#viewToModel(float, float, java.awt.Shape, * javax.swing.text.Position.Bias[]) */ @Override public int viewToModel(float fx, float fy, Shape a, Position.Bias[] bias) { bias[0] = Position.Bias.Forward; int n = 0; Container c = this.getContainer(); if (c instanceof JPasswordField) { JPasswordField f = (JPasswordField) c; if (!f.echoCharIsSet()) { return super.viewToModel(fx, fy, a, bias); } a = this.adjustAllocation(a); Rectangle alloc = (a instanceof Rectangle) ? (Rectangle) a : a .getBounds(); int echoPerChar = SubstanceCoreUtilities.getEchoPerChar(f); int fontSize = SubstanceSizeUtils .getComponentFontSize(this.field); int dotWidth = SubstanceSizeUtils .getPasswordDotDiameter(fontSize) + SubstanceSizeUtils.getPasswordDotGap(fontSize); n = ((int) fx - alloc.x) / (echoPerChar * dotWidth); if (n < 0) { n = 0; } else { if (n > (this.getStartOffset() + this.getDocument() .getLength())) { n = this.getDocument().getLength() - this.getStartOffset(); } } } return this.getStartOffset() + n; } /* * (non-Javadoc) * * @see javax.swing.text.View#getPreferredSpan(int) */ @Override public float getPreferredSpan(int axis) { switch (axis) { case View.X_AXIS: Container c = this.getContainer(); if (c instanceof JPasswordField) { JPasswordField f = (JPasswordField) c; if (f.echoCharIsSet()) { int echoPerChar = SubstanceCoreUtilities .getEchoPerChar(f); int fontSize = SubstanceSizeUtils .getComponentFontSize(this.field); int dotWidth = SubstanceSizeUtils .getPasswordDotDiameter(fontSize) + SubstanceSizeUtils .getPasswordDotGap(fontSize); return echoPerChar * dotWidth * this.getDocument().getLength(); } } } return super.getPreferredSpan(axis); } } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstancePasswordFieldUI(comp); } /** * Creates the UI delegate for the specified component (password field). * * @param c * Component. */ public SubstancePasswordFieldUI(JComponent c) { super(); this.passwordField = (JPasswordField) c; } /* * (non-Javadoc) * * @see javax.swing.text.ViewFactory#create(javax.swing.text.Element) */ @Override public View create(Element elem) { return new SubstancePasswordView(this.passwordField, elem); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTextUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); this.substanceFadeStateListener = new FadeStateListener( this.passwordField, null, null); this.substanceFadeStateListener.registerListeners(false); this.substancePropertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("font".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { // remember the caret location - issue 404 int caretPos = passwordField.getCaretPosition(); passwordField.updateUI(); passwordField.setCaretPosition(caretPos); } }); } } }; this.passwordField .addPropertyChangeListener(this.substancePropertyChangeListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTextUI#uninstallListeners() */ @Override protected void uninstallListeners() { this.substanceFadeStateListener.unregisterListeners(); this.substanceFadeStateListener = null; this.passwordField .removePropertyChangeListener(this.substancePropertyChangeListener); this.substancePropertyChangeListener = null; super.uninstallListeners(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTextUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); Border b = this.passwordField.getBorder(); if (b == null || b instanceof UIResource) { Border newB = new BorderUIResource.CompoundBorderUIResource( new SubstanceBorder(SubstanceSizeUtils .getTextBorderInsets(SubstanceSizeUtils .getComponentFontSize(this.passwordField))), new BasicBorders.MarginBorder()); this.passwordField.setBorder(newB); } // support for per-window skins Color foregr = this.passwordField.getForeground(); if ((foregr == null) || (foregr instanceof UIResource)) { this.passwordField.setForeground(SubstanceColorUtilities .getForegroundColor(SubstanceLookAndFeel.getCurrentSkin( this.passwordField).getMainDefaultColorScheme())); } } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTextUI#paintBackground(java.awt.Graphics) */ @Override protected void paintBackground(Graphics g) { SubstanceTextUtilities.paintTextCompBackground(g, this.passwordField); } }substance-5.3.orig/src/org/jvnet/substance/SubstanceColorChooserUI.java0000644000175000017500000000735011246717062026263 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.lang.reflect.Method; import java.security.AccessControlException; import java.util.*; import javax.swing.JComponent; import javax.swing.UIManager; import javax.swing.colorchooser.AbstractColorChooserPanel; import javax.swing.plaf.ComponentUI; import org.jvnet.substance.utils.SubstanceCoreUtilities; import contrib.ch.randelshofer.quaqua.Quaqua14ColorChooserUI; /** * UI for color chooser in Substance look and feel. This UI delegate is * removed in Lite versions of Substance. * * @author Kirill Grouchnikov */ public class SubstanceColorChooserUI extends Quaqua14ColorChooserUI { public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceColorChooserUI(); } @Override protected AbstractColorChooserPanel[] createDefaultChoosers() { String[] defaultChoosers = (String[]) UIManager .get("ColorChooser.defaultChoosers"); List panelList = new LinkedList(); // AbstractColorChooserPanel[] panels = new // AbstractColorChooserPanel[defaultChoosers.length]; for (int i = 0; i < defaultChoosers.length; i++) { try { Method setBundleMethod = Class.forName(defaultChoosers[i]) .getMethod("setLabelBundle", new Class[] { ResourceBundle.class }); setBundleMethod.invoke(null, new Object[] { SubstanceCoreUtilities .getResourceBundle(null) }); } catch (Throwable t) { // ignore - either the method doesn't exist or the invocation // failed. Nothing to do in both cases. } try { AbstractColorChooserPanel panel = (AbstractColorChooserPanel) Class .forName(defaultChoosers[i]).newInstance(); panelList.add(panel); } catch (AccessControlException e) { // ignore - happens on unsigned apps in WebStart environment } catch (Exception e) { e.printStackTrace(); throw new InternalError("Unable to instantiate " + defaultChoosers[i]); } } return panelList.toArray(new AbstractColorChooserPanel[0]); } } substance-5.3.orig/src/org/jvnet/substance/SubstancePopupMenuSeparatorUI.java0000644000175000017500000000734211247214724027472 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import javax.swing.JComponent; import javax.swing.JSeparator; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicPopupMenuSeparatorUI; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.painter.utils.SeparatorPainterUtils; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.SubstanceSizeUtils; import org.jvnet.substance.utils.menu.MenuUtilities; import org.jvnet.substance.utils.menu.SubstanceMenuBackgroundDelegate; /** * UI for popup menu separators in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstancePopupMenuSeparatorUI extends BasicPopupMenuSeparatorUI { public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstancePopupMenuSeparatorUI(); } @Override public void paint(Graphics g, JComponent c) { Graphics2D graphics = (Graphics2D) g.create(); JSeparator sep = (JSeparator) c; int xOffset = MenuUtilities.getTextOffset(sep, sep.getParent()); SubstanceMenuBackgroundDelegate.paintBackground(graphics, c, xOffset); Dimension s = c.getSize(); int startX = 0; int width = s.width; if (c.getComponentOrientation().isLeftToRight()) { startX = xOffset - 2; width = s.width - startX; } else { startX = 0; width = xOffset - 4; } graphics.translate(startX, 0); graphics.setComposite(TransitionLayout.getAlphaComposite(sep)); SeparatorPainterUtils.paintSeparator(sep, graphics, width, s.height, sep.getOrientation(), true, 2); graphics.dispose(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicPopupMenuSeparatorUI#getPreferredSize(javax * .swing.JComponent) */ @Override public Dimension getPreferredSize(JComponent c) { float borderStrokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(c)); int prefSize = (int) (Math.ceil(2.0 * borderStrokeWidth)); return new Dimension(0, prefSize); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceComboBoxUI.java0000644000175000017500000005043311246717506025375 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.beans.PropertyChangeEvent; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.plaf.*; import javax.swing.plaf.basic.BasicComboBoxUI; import javax.swing.plaf.basic.ComboPopup; import org.jvnet.lafwidget.animation.FadeStateListener; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.api.SubstanceConstants.Side; import org.jvnet.substance.api.renderers.SubstanceDefaultComboBoxRenderer; import org.jvnet.substance.painter.utils.HighlightPainterUtils; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.border.SubstanceBorder; import org.jvnet.substance.utils.combo.*; /** * UI for combo boxes in Substance look and feel. * * @author Kirill Grouchnikov * @author Thomas Bierhance http://www.orbital-computer.de/JComboBox/ * @author inostock */ public class SubstanceComboBoxUI extends BasicComboBoxUI { /** * Property change handler on enabled property, * componentOrientation property and on * {@link SubstanceLookAndFeel#COMBO_BOX_POPUP_FLYOUT_ORIENTATION} property. */ protected ComboBoxPropertyChangeHandler substanceChangeHandler; /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /** * Focus listener on the combobox. */ protected FocusListener substanceFocusListener; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); SubstanceComboBoxUI ui = new SubstanceComboBoxUI(); ui.comboBox = (JComboBox) comp; ui.comboBox.setOpaque(false); return ui; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboBoxUI#createArrowButton() */ @Override protected JButton createArrowButton() { SubstanceComboBoxButton result = new SubstanceComboBoxButton( this.comboBox); result.setFont(this.comboBox.getFont()); result.setIcon(getCurrentIcon(result)); // System.out.println("Combo [@" + this.comboBox.hashCode() + "] font " // + this.comboBox.getFont().getSize() + ", button [@" // + result.hashCode() + "] font " + result.getFont().getSize()); return result; } /** * Returns the icon for the specified arrow button. * * @param button * Arrow button. * @return Icon for the specified button. */ private Icon getCurrentIcon(JButton button) { Icon icon = SubstanceCoreUtilities .getArrowIcon(button, SubstanceCoreUtilities .getPopupFlyoutOrientation(this.comboBox)); return icon; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboBoxUI#createRenderer() */ @Override protected ListCellRenderer createRenderer() { return new SubstanceDefaultComboBoxRenderer.SubstanceUIResource( this.comboBox); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboBoxUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); this.substanceChangeHandler = new ComboBoxPropertyChangeHandler(); this.comboBox.addPropertyChangeListener(this.substanceChangeHandler); this.substanceFadeStateListener = new FadeStateListener(this.comboBox, null, null); this.substanceFadeStateListener.registerListeners(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboBoxUI#uninstallListeners() */ @Override protected void uninstallListeners() { this.substanceFadeStateListener.unregisterListeners(); this.substanceFadeStateListener = null; this.comboBox.removePropertyChangeListener(this.substanceChangeHandler); this.substanceChangeHandler = null; super.uninstallListeners(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboBoxUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); Border b = this.comboBox.getBorder(); if (b == null || b instanceof UIResource) { Border newB = new SubstanceBorder(SubstanceSizeUtils .getComboBorderInsets(SubstanceSizeUtils .getComponentFontSize(this.comboBox))); this.comboBox.setBorder(newB); } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboBoxUI#createLayoutManager() */ @Override protected LayoutManager createLayoutManager() { return new SubstanceComboBoxLayoutManager(); } /** * Layout manager for combo box. * * @author Kirill Grouchnikov */ private class SubstanceComboBoxLayoutManager extends BasicComboBoxUI.ComboBoxLayoutManager { /* * (non-Javadoc) * * @see java.awt.LayoutManager#layoutContainer(java.awt.Container) */ @Override public void layoutContainer(Container parent) { JComboBox cb = (JComboBox) parent; int width = cb.getWidth(); int height = cb.getHeight(); Insets insets = SubstanceComboBoxUI.this.getInsets(); int buttonWidth = SubstanceSizeUtils .getScrollBarWidth(SubstanceSizeUtils .getComponentFontSize(comboBox)); // buttonWidth = Math.max(buttonWidth, // arrowButton.getPreferredSize().width); if (SubstanceComboBoxUI.this.arrowButton != null) { if (cb.getComponentOrientation().isLeftToRight()) { SubstanceComboBoxUI.this.arrowButton .setBounds( width - buttonWidth - insets.right, 0, buttonWidth + SubstanceSizeUtils .getComboBorderInsets(SubstanceSizeUtils .getComponentFontSize(comboBox)).right, height); } else { int left = SubstanceSizeUtils .getComboBorderInsets(SubstanceSizeUtils .getComponentFontSize(comboBox)).left; SubstanceComboBoxUI.this.arrowButton.setBounds(insets.left - left, 0, buttonWidth + left, height); } } if (SubstanceComboBoxUI.this.editor != null) { SubstanceComboBoxUI.this.editor .setBounds(SubstanceComboBoxUI.this .rectangleForCurrentValue()); } } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboBoxUI#getDefaultSize() */ @Override protected Dimension getDefaultSize() { Component rend = new SubstanceDefaultComboBoxRenderer(this.comboBox) .getListCellRendererComponent(listBox, " ", -1, false, false); rend.setFont(this.comboBox.getFont()); return rend.getPreferredSize(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicComboBoxUI#getMinimumSize(javax.swing.JComponent * ) */ @Override public Dimension getMinimumSize(JComponent c) { if (!this.isMinimumSizeDirty) { return new Dimension(this.cachedMinimumSize); } // Dimension size = null; // // if (!this.comboBox.isEditable() && this.arrowButton != null // && this.arrowButton instanceof SubstanceComboBoxButton) { // SubstanceComboBoxButton button = (SubstanceComboBoxButton) this.arrowButton; Insets buttonInsets = button.getInsets(); Insets insets = this.comboBox.getInsets(); Dimension size = this.getDisplaySize(); size.width += insets.left + insets.right; size.width += buttonInsets.left + buttonInsets.right; size.width += button.getMinimumSize().getWidth(); size.height += insets.top + insets.bottom; // } else if (this.comboBox.isEditable() && this.arrowButton != null // && this.editor != null) { // size = super.getMinimumSize(c); // } else { // size = super.getMinimumSize(c); // } this.cachedMinimumSize.setSize(size.width, size.height); this.isMinimumSizeDirty = false; return new Dimension(this.cachedMinimumSize); } /** * This property change handler changes combo box arrow icon based on the * enabled status of the combo box. * * @author Kirill Grouchnikov */ public class ComboBoxPropertyChangeHandler extends PropertyChangeHandler { /* * (non-Javadoc) * * @seejavax.swing.plaf.basic.BasicComboBoxUI$PropertyChangeHandler# * propertyChange(java.beans.PropertyChangeEvent) */ @Override public void propertyChange(final PropertyChangeEvent e) { String propertyName = e.getPropertyName(); if (propertyName.equals("componentOrientation")) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (SubstanceComboBoxUI.this.comboBox == null) return; final ComponentOrientation newOrientation = (ComponentOrientation) e .getNewValue(); final ListCellRenderer cellRenderer = SubstanceComboBoxUI.this.comboBox .getRenderer(); final ComboBoxEditor editor = SubstanceComboBoxUI.this.comboBox .getEditor(); if (SubstanceComboBoxUI.this.popup instanceof Component) { final Component cPopup = (Component) SubstanceComboBoxUI.this.popup; cPopup.applyComponentOrientation(newOrientation); cPopup.doLayout(); } if (cellRenderer instanceof Component) { ((Component) cellRenderer) .applyComponentOrientation(newOrientation); } if ((editor != null) && (editor.getEditorComponent() != null)) { (editor.getEditorComponent()) .applyComponentOrientation(newOrientation); } if (SubstanceComboBoxUI.this.comboBox != null) SubstanceComboBoxUI.this.comboBox.repaint(); configureArrowButtonStraightSide(); } }); } if (SubstanceLookAndFeel.COMBO_BOX_POPUP_FLYOUT_ORIENTATION .equals(propertyName)) { ((SubstanceComboBoxButton) arrowButton) .setIcon(SubstanceCoreUtilities .getArrowIcon( arrowButton, SubstanceCoreUtilities .getPopupFlyoutOrientation(SubstanceComboBoxUI.this.comboBox))); } if ("font".equals(propertyName)) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (comboBox != null) comboBox.updateUI(); } }); } if ("background".equals(propertyName)) { if (comboBox.isEditable()) { comboBox.getEditor().getEditorComponent().setBackground( comboBox.getBackground()); popup.getList().setBackground(comboBox.getBackground()); } } // Do not call super - fix for bug 63 } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboBoxUI#createPopup() */ @Override protected ComboPopup createPopup() { final ComboPopup sPopup = new SubstanceComboPopup(this.comboBox); final ComponentOrientation currOrientation = this.comboBox .getComponentOrientation(); SwingUtilities.invokeLater(new Runnable() { public void run() { if (SubstanceComboBoxUI.this.comboBox == null) return; if (sPopup instanceof Component) { final Component cPopup = (Component) sPopup; cPopup.applyComponentOrientation(currOrientation); cPopup.doLayout(); } ListCellRenderer cellRenderer = SubstanceComboBoxUI.this.comboBox .getRenderer(); if (cellRenderer instanceof Component) { ((Component) cellRenderer) .applyComponentOrientation(currOrientation); } ComboBoxEditor editor = SubstanceComboBoxUI.this.comboBox .getEditor(); if ((editor != null) && (editor.getEditorComponent() != null)) { (editor.getEditorComponent()) .applyComponentOrientation(currOrientation); } SubstanceComboBoxUI.this.comboBox.repaint(); } }); return sPopup; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicComboBoxUI#paintCurrentValueBackground(java * .awt.Graphics, java.awt.Rectangle, boolean) */ @Override public void paintCurrentValueBackground(Graphics g, Rectangle bounds, boolean hasFocus) { ListUI listUI = this.popup.getList().getUI(); SubstanceListUI ui = (SubstanceListUI) listUI; ComponentState state = ui.getCellState(-1, null); boolean isEnabled = this.comboBox.isEnabled(); boolean isSelected = hasFocus; if (isSelected && isEnabled) { state = ComponentState.SELECTED; } if (!isEnabled) { state = ComponentState.DISABLED_UNSELECTED; } Graphics2D graphics = (Graphics2D) g.create(); float alpha = SubstanceColorSchemeUtilities.getAlpha(this.comboBox, state) * 0.8f; int componentFontSize = SubstanceSizeUtils .getComponentFontSize(this.comboBox); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(componentFontSize) / 2.0); Shape contour = SubstanceOutlineUtilities.getBaseOutline(this.comboBox .getWidth(), this.comboBox.getHeight(), 0.5f * SubstanceSizeUtils .getClassicButtonCornerRadius(componentFontSize), null, borderDelta); graphics.clip(contour); // Rectangle newBounds = new Rectangle(1, 1, this.comboBox.getWidth() - // 2, // this.comboBox.getHeight() - 2); graphics.setComposite(TransitionLayout.getAlphaComposite(this.comboBox, alpha, g)); HighlightPainterUtils.paintHighlight(graphics, null, this.comboBox, new Rectangle(0, 0, this.comboBox.getWidth(), this.comboBox .getHeight()), 0.0f, null, state, state, 0.0f); graphics.dispose(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicComboBoxUI#paintCurrentValue(java.awt.Graphics * , java.awt.Rectangle, boolean) */ @Override public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) { Graphics2D graphics = (Graphics2D) g.create(); ListCellRenderer renderer = this.comboBox.getRenderer(); Component c; if (hasFocus) { c = renderer.getListCellRendererComponent(this.listBox, this.comboBox.getSelectedItem(), -1, true, hasFocus); } else { c = renderer.getListCellRendererComponent(this.listBox, this.comboBox.getSelectedItem(), -1, false, hasFocus); } c.setFont(this.comboBox.getFont()); // Fix for 4238829: should lay out the JPanel. boolean shouldValidate = false; if (c instanceof JPanel) { shouldValidate = true; } // SubstanceCoreUtilities.workaroundBug6576507(graphics); if (this.comboBox.getComponentOrientation().isLeftToRight()) { this.currentValuePane.paintComponent(graphics, c, this.comboBox, 1, 1, this.arrowButton.getX() - 1, this.comboBox.getHeight() - 2, shouldValidate); } else { int startX = this.arrowButton.getX() + this.arrowButton.getWidth(); this.currentValuePane.paintComponent(graphics, c, this.comboBox, startX, 1, this.comboBox.getWidth() - startX - 1, this.comboBox.getHeight() - 2, shouldValidate); } graphics.dispose(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboBoxUI#paint(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void paint(Graphics g, JComponent c) { super.paint(g, c); this.hasFocus = this.comboBox.hasFocus(); if (!this.comboBox.isEditable() && this.hasFocus) { Rectangle r = this.rectangleForCurrentValue(); r.y += 1; r.height -= 2; r.width -= (this.arrowButton.getWidth() + 10); this.paintFocus(g, r); } } /** * Paints the focus indication. * * @param g * Graphics. * @param bounds * Bounds for text. */ protected void paintFocus(Graphics g, Rectangle bounds) { int fontSize = SubstanceSizeUtils.getComponentFontSize(this.comboBox); int focusRingPadding = SubstanceSizeUtils.getFocusRingPadding(fontSize); SubstanceCoreUtilities.paintFocus(g, this.comboBox, this.comboBox, SubstanceOutlineUtilities.getBaseOutline(this.arrowButton .getX() - 1, this.comboBox.getHeight() - 3 * focusRingPadding / 2, SubstanceSizeUtils .getClassicButtonCornerRadius(fontSize), null, 0), bounds, 0.4f, 3 * focusRingPadding / 2); } /** * Returns the popup of the associated combobox. * * @return The popup of the associated combobox. */ public ComboPopup getPopup() { return this.popup; } // /* // * (non-Javadoc) // * // * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, // * javax.swing.JComponent) // */ // @Override // public void update(Graphics g, JComponent c) { // if (!this.comboBox.isEditable()) { // SubstanceTextUtilities.paintTextCompBackground(g, c); // } else { // SubstanceTextUtilities.paintTextCompBackground(g, c, this.editor // .getBackground(), false); // } // this.paint(g, c); // } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboBoxUI#configureArrowButton() */ @Override public void configureArrowButton() { super.configureArrowButton(); // Mustang decided to make the arrow button focusable on // focusable comboboxes this.arrowButton.setFocusable(false); this.substanceFocusListener = new FocusListener() { public void focusGained(FocusEvent e) { arrowButton.setSelected(true); } public void focusLost(FocusEvent e) { arrowButton.setSelected(false); } }; this.arrowButton.setSelected(this.comboBox.hasFocus()); this.comboBox.addFocusListener(this.substanceFocusListener); this.configureArrowButtonStraightSide(); } /** * Configures the straight side of the arrow button. */ protected void configureArrowButtonStraightSide() { this.arrowButton.putClientProperty( SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, this.comboBox .getComponentOrientation().isLeftToRight() ? Side.LEFT : Side.RIGHT); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboBoxUI#unconfigureArrowButton() */ @Override public void unconfigureArrowButton() { this.comboBox.removeFocusListener(this.substanceFocusListener); this.substanceFocusListener = null; super.unconfigureArrowButton(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboBoxUI#configureEditor() */ @Override protected void configureEditor() { super.configureEditor(); // This for Mustang - setting Substance once again adds a border on // the text field in the combo editor. if (this.editor instanceof JComponent) { Insets ins = SubstanceSizeUtils .getComboTextBorderInsets(SubstanceSizeUtils .getComponentFontSize(this.editor)); ((JComponent) this.editor).setBorder(new EmptyBorder(ins.top, ins.left, ins.bottom, ins.right)); this.editor.setBackground(this.comboBox.getBackground()); // ((JComponent) this.editor).setBorder(new LineBorder(Color.red)); } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboBoxUI#createEditor() */ @Override protected ComboBoxEditor createEditor() { return new SubstanceComboBoxEditor.UIResource(); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceToolTipUI.java0000644000175000017500000001044711136475560025257 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import javax.swing.JComponent; import javax.swing.JToolTip; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicHTML; import javax.swing.plaf.basic.BasicToolTipUI; import javax.swing.text.View; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.SubstanceTextUtilities; /** * UI for tool tips in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceToolTipUI extends BasicToolTipUI { /** * Creates a UI delegate for the specified component. * * @param comp * Component. * @return UI delegate. */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceToolTipUI(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicToolTipUI#paint(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void paint(Graphics g, JComponent c) { Font font = c.getFont(); // FontMetrics metrics = c.getFontMetrics(font); Dimension size = c.getSize(); if (c.isOpaque()) { g.setColor(c.getBackground()); g.fillRect(0, 0, size.width, size.height); } g.setColor(c.getForeground()); g.setFont(font); // fix for bug 4153892 String tipText = ((JToolTip) c).getTipText(); if (tipText == null) { tipText = ""; } Insets insets = c.getInsets(); Rectangle paintTextR = new Rectangle(insets.left + 3, insets.top, size.width - (insets.left + insets.right + 6), size.height - (insets.top + insets.bottom + 2)); View v = (View) c.getClientProperty(BasicHTML.propertyKey); if (v != null) { v.paint(g, paintTextR); } else { SubstanceTextUtilities.paintText(g, c, paintTextR, tipText, -1, font, c.getForeground(), null); } } @Override public Dimension getPreferredSize(JComponent c) { Font font = c.getFont(); Insets insets = c.getInsets(); Dimension prefSize = new Dimension(insets.left + insets.right, insets.top + insets.bottom); String text = ((JToolTip) c).getTipText(); if ((text == null) || text.equals("")) { text = ""; } else { View v = (c != null) ? (View) c.getClientProperty("html") : null; if (v != null) { // fix for 302 - add extra pixels for the HTML view as well prefSize.width += (int) (v.getPreferredSpan(View.X_AXIS) + 6); prefSize.height += (int) (v.getPreferredSpan(View.Y_AXIS) + 2); } else { FontMetrics fm = c.getFontMetrics(font); prefSize.width += fm.stringWidth(text) + 6; prefSize.height += fm.getHeight() + 2; } } return prefSize; } } substance-5.3.orig/src/org/jvnet/substance/SubstanceRootPaneUI.java0000644000175000017500000013235411256673156025422 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.awt.event.*; import java.beans.PropertyChangeEvent; import java.security.*; import javax.swing.*; import javax.swing.event.MouseInputAdapter; import javax.swing.event.MouseInputListener; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicRootPaneUI; import org.jvnet.substance.utils.*; /** * UI for root panes in Substance look and feel. * * @author Kirill Grouchnikov * @author Larry Salibra (fix for defect 198) */ public class SubstanceRootPaneUI extends BasicRootPaneUI { private enum CursorState { EXITED, ENTERED, NIL } /** * The amount of space (in pixels) that the cursor is changed on. */ private static final int CORNER_DRAG_WIDTH = 16; /** * Region from edges that dragging is active from. */ private static final int BORDER_DRAG_THICKNESS = 5; /** * Window the JRootPane is in. */ private Window window; /** * JComponent providing window decorations. This will be null * if not providing window decorations. */ private JComponent titlePane; /** * MouseInputListener that is added to the parent * Window the JRootPane is contained in. */ private MouseInputListener substanceMouseInputListener; /** * Mouse listener on the title pane (dragging). */ private MouseInputListener substanceTitleMouseInputListener; /** * The LayoutManager that is set on the JRootPane. */ private LayoutManager layoutManager; /** * LayoutManager of the JRootPane before we * replaced it. */ private LayoutManager savedOldLayout; /** * JRootPane providing the look and feel for. */ protected JRootPane root; /** * Window listener that stops all Substance thread when the last frame is * disposed. */ protected WindowListener substanceWindowListener; /** * The current window. */ protected Window substanceCurrentWindow; /** * Hierarchy listener to keep track of the associated top-level window. */ protected HierarchyListener substanceHierarchyListener; /** * Component listener to keep track of the primary graphics configuration * (for recomputing the maximized bounds) - fix for defect 213. */ protected ComponentListener substanceWindowComponentListener; /** * The graphics configuration that contains the top-left corner of the * window (fix for defect 213). */ protected GraphicsConfiguration currentRootPaneGC; /** * Cursor used to track the cursor set by the user. This is * initially Cursor.DEFAULT_CURSOR. */ private Cursor lastCursor = Cursor .getPredefinedCursor(Cursor.DEFAULT_CURSOR); /** * Creates a UI for a JRootPane. * * @param comp * the JRootPane the RootPaneUI will be created for * @return the RootPaneUI implementation for the passed in JRootPane */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceRootPaneUI(); } /** * Invokes supers implementation of installUI to install the * necessary state onto the passed in JRootPane to render the * metal look and feel implementation of RootPaneUI. If the * windowDecorationStyle property of the JRootPane * is other than JRootPane.NONE, this will add a custom * Component to render the widgets to JRootPane, * as well as installing a custom Border and * LayoutManager on the JRootPane. * * @param c * the JRootPane to install state onto */ @Override public void installUI(JComponent c) { super.installUI(c); this.root = (JRootPane) c; int style = this.root.getWindowDecorationStyle(); if (style != JRootPane.NONE) { this.installClientDecorations(this.root); } // TitleButtonManager.getManager().register(this.root); } /** * Invokes supers implementation to uninstall any of its state. This will * also reset the LayoutManager of the JRootPane. * If a Component has been added to the JRootPane * to render the window decoration style, this method will remove it. * Similarly, this will revert the Border and LayoutManager of the * JRootPane to what it was before installUI was * invoked. * * @param c * the JRootPane to uninstall state from */ @Override public void uninstallUI(JComponent c) { super.uninstallUI(c); this.uninstallClientDecorations(this.root); this.layoutManager = null; this.substanceMouseInputListener = null; // TitleButtonManager.getManager().unregister(this.root); this.root = null; } /** * Installs the appropriate Border onto the * JRootPane. * * @param root * Root pane. */ public void installBorder(JRootPane root) { int style = root.getWindowDecorationStyle(); if (style == JRootPane.NONE) { LookAndFeel.uninstallBorder(root); } else { LookAndFeel.installBorder(root, "RootPane.border"); } } /** * Removes any border that may have been installed. * * @param root * Root pane. */ private void uninstallBorder(JRootPane root) { LookAndFeel.uninstallBorder(root); } /** * Installs the necessary Listeners on the parent Window, if * there is one. *

* This takes the parent so that cleanup can be done from * removeNotify, at which point the parent hasn't been reset * yet. * * * @param root * Root pane. * @param parent * The parent of the JRootPane */ private void installWindowListeners(JRootPane root, Component parent) { if (parent instanceof Window) { this.window = (Window) parent; } else { this.window = SwingUtilities.getWindowAncestor(parent); } // System.out.println(titlePanes.size() + " entries in map after adding // " // + window.getClass().getName() + ":" + window.hashCode()); // for (Iterator>> it = // titlePanes // .entrySet().iterator(); it.hasNext();) { // Map.Entry> entry = it // .next(); // Window w = entry.getValue().get(); // System.out.println("\t" + w.getClass().getName() // + ":" + w.hashCode()); // } if (this.window != null) { if (this.substanceMouseInputListener == null) { this.substanceMouseInputListener = this .createWindowMouseInputListener(root); } this.window.addMouseListener(this.substanceMouseInputListener); this.window .addMouseMotionListener(this.substanceMouseInputListener); if (this.titlePane != null) { if (this.substanceTitleMouseInputListener == null) { this.substanceTitleMouseInputListener = new TitleMouseInputHandler(); } this.titlePane .addMouseMotionListener(this.substanceTitleMouseInputListener); this.titlePane .addMouseListener(this.substanceTitleMouseInputListener); } this.setMaximized(); } } /** * Uninstalls the necessary Listeners on the Window the * Listeners were last installed on. * * @param root * Root pane. */ private void uninstallWindowListeners(JRootPane root) { if (this.window != null) { this.window.removeMouseListener(this.substanceMouseInputListener); this.window .removeMouseMotionListener(this.substanceMouseInputListener); } if (this.titlePane != null) { this.titlePane .removeMouseListener(this.substanceTitleMouseInputListener); this.titlePane .removeMouseMotionListener(this.substanceTitleMouseInputListener); } } /** * Installs the appropriate LayoutManager on the JRootPane to * render the window decorations. * * @param root * Root pane. */ private void installLayout(JRootPane root) { if (this.layoutManager == null) { this.layoutManager = this.createLayoutManager(); } this.savedOldLayout = root.getLayout(); root.setLayout(this.layoutManager); } @Override protected void installListeners(final JRootPane root) { super.installListeners(root); // System.out.println("Listeners on root " + root.hashCode()); this.substanceHierarchyListener = new HierarchyListener() { public void hierarchyChanged(HierarchyEvent e) { Component parent = root.getParent(); if (parent == null) { // fix for defect 271 - check for null parent // as early as possible return; } // System.out.println("Root pane " + root.hashCode() // + " parent : " + parent.getClass().getName()); if (MemoryAnalyzer.isRunning()) { MemoryAnalyzer.enqueueUsage("Root pane @" + root.hashCode() + "\n" + SubstanceCoreUtilities.getHierarchy(parent)); } if (parent.getClass().getName().startsWith( "org.jdesktop.jdic.tray") || (parent.getClass().getName().compareTo( "javax.swing.Popup$HeavyWeightWindow") == 0)) { // Workaround for bug 240 - using JDIC system tray // menu results in an HierarchyEvent being fired right // after a MouseEvent. Somehow, the // EventQueue.getCurrentEvent() returns the HierarchyEvent // even when the MouseEvent is being processed, resulting // in zeroed modifiers set on the ActionEvent passed // to the action listeners on that menu item. SwingUtilities.invokeLater(new Runnable() { public void run() { root .removeHierarchyListener(substanceHierarchyListener); // System.out.println(root.hashCode() + ":" // + root.getHierarchyListeners().length); substanceHierarchyListener = null; }; }); } Window currWindow = null; if (parent instanceof Window) { currWindow = (Window) parent; } else { currWindow = SwingUtilities.getWindowAncestor(parent); } if (substanceWindowListener != null) { substanceCurrentWindow .removeWindowListener(substanceWindowListener); substanceWindowListener = null; } if (substanceWindowComponentListener != null) { substanceCurrentWindow .removeComponentListener(substanceWindowComponentListener); substanceWindowComponentListener = null; } if (currWindow != null) { // fix for bug 116 - stopping threads when all frames // are not displayable substanceWindowListener = new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { Frame[] frames = Frame.getFrames(); for (Frame frame : frames) { if (frame.isDisplayable()) return; } SubstanceCoreUtilities.stopThreads(); } }); } }; if (!(parent instanceof JInternalFrame)) { currWindow.addWindowListener(substanceWindowListener); } // fix for defect 213 - maximizing frame under multiple // screens shouldn't always use insets of the primary // screen. substanceWindowComponentListener = new ComponentAdapter() { @Override public void componentMoved(ComponentEvent e) { this.processNewPosition(); } @Override public void componentResized(ComponentEvent e) { this.processNewPosition(); } protected void processNewPosition() { SwingUtilities.invokeLater(new Runnable() { public void run() { if (window == null) return; if (!window.isShowing() || !window.isDisplayable()) { currentRootPaneGC = null; return; } GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge .getScreenDevices(); if (gds.length == 1) return; Point midLoc = new Point(window .getLocationOnScreen().x + window.getWidth() / 2, window .getLocationOnScreen().y + window.getHeight() / 2); // System.out.println("Loc : " // + window.getLocationOnScreen() // + ", width : " // + window.getWidth() // + ", mid : " + midLoc); int index = 0; for (GraphicsDevice gd : gds) { GraphicsConfiguration gc = gd .getDefaultConfiguration(); Rectangle bounds = gc.getBounds(); // System.out.println("Bounds : " // + bounds); if (bounds.contains(midLoc)) { if (gc != currentRootPaneGC) { currentRootPaneGC = gc; setMaximized(); // System.out.println("Set"); } break; } index++; } } }); } }; // fix for defect 225 - install the listener only on // JFrames. if (parent instanceof JFrame) { currWindow .addComponentListener(substanceWindowComponentListener); } SubstanceRootPaneUI.this.window = currWindow; } substanceCurrentWindow = currWindow; } }; root.addHierarchyListener(this.substanceHierarchyListener); // System.out.println(root.hashCode() + ":" // + root.getHierarchyListeners().length); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicRootPaneUI#uninstallListeners(javax.swing * .JRootPane) */ @Override protected void uninstallListeners(JRootPane root) { // fix for bug 116 - stopping threads when all frames are // not displayable if (this.window != null) { this.window.removeWindowListener(this.substanceWindowListener); this.substanceWindowListener = null; this.window .removeComponentListener(this.substanceWindowComponentListener); this.substanceWindowComponentListener = null; } root.removeHierarchyListener(this.substanceHierarchyListener); this.substanceHierarchyListener = null; super.uninstallListeners(root); } /** * Uninstalls the previously installed LayoutManager. * * @param root * Root pane. */ private void uninstallLayout(JRootPane root) { if (this.savedOldLayout != null) { root.setLayout(this.savedOldLayout); this.savedOldLayout = null; } } /** * Installs the necessary state onto the JRootPane to render client * decorations. This is ONLY invoked if the JRootPane has a * decoration style other than JRootPane.NONE. * * @param root * Root pane. */ private void installClientDecorations(JRootPane root) { this.installBorder(root); JComponent titlePane = this.createTitlePane(root); this.setTitlePane(root, titlePane); this.installWindowListeners(root, root.getParent()); this.installLayout(root); if (this.window != null) { root.revalidate(); root.repaint(); } } /** * Uninstalls any state that installClientDecorations has * installed. *

* NOTE: This may be called if you haven't installed client decorations yet * (ie before installClientDecorations has been invoked). * * @param root * Root pane. */ private void uninstallClientDecorations(JRootPane root) { this.uninstallBorder(root); this.uninstallWindowListeners(root); this.setTitlePane(root, null); this.uninstallLayout(root); // We have to revalidate/repaint root if the style is JRootPane.NONE // only. When we needs to call revalidate/repaint with other styles // the installClientDecorations is always called after this method // imediatly and it will cause the revalidate/repaint at the proper // time. int style = root.getWindowDecorationStyle(); if (style == JRootPane.NONE) { root.repaint(); root.revalidate(); } // Reset the cursor, as we may have changed it to a resize cursor if (this.window != null) { this.window.setCursor(Cursor .getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } this.window = null; } /** * Returns the JComponent to render the window decoration * style. * * @param root * Root pane. * @return The title pane component. */ protected JComponent createTitlePane(JRootPane root) { return new SubstanceTitlePane(root, this); } /** * Returns a MouseListener that will be added to the * Window containing the JRootPane. * * @param root * Root pane. * @return Window mouse listener. */ private MouseInputListener createWindowMouseInputListener(JRootPane root) { return new MouseInputHandler(); } /** * Returns a LayoutManager that will be set on the * JRootPane. * * @return Layout manager. */ protected LayoutManager createLayoutManager() { return new SubstanceRootLayout(); } /** * Sets the window title pane -- the JComponent used to provide a plaf a way * to override the native operating system's window title pane with one * whose look and feel are controlled by the plaf. The plaf creates and sets * this value; the default is null, implying a native operating system * window title pane. * * @param root * Root pane * @param titlePane * The JComponent to use for the window title pane. */ private void setTitlePane(JRootPane root, JComponent titlePane) { JLayeredPane layeredPane = root.getLayeredPane(); JComponent oldTitlePane = this.getTitlePane(); if (oldTitlePane != null) { // fix for defect 109 - memory leak on skin change if (oldTitlePane instanceof SubstanceTitlePane) ((SubstanceTitlePane) oldTitlePane).uninstall(); // oldTitlePane.setVisible(false); layeredPane.remove(oldTitlePane); } if (titlePane != null) { layeredPane.add(titlePane, JLayeredPane.FRAME_CONTENT_LAYER); titlePane.setVisible(true); } this.titlePane = titlePane; } /** * Sets maximized bounds according to the display screen insets. */ public void setMaximized() { Component tla = this.root.getTopLevelAncestor(); // fix for defect 213 - maximizing frame under multiple // screens shouldn't always use insets of the primary // screen. GraphicsConfiguration gc = (currentRootPaneGC != null) ? currentRootPaneGC : tla.getGraphicsConfiguration(); Rectangle screenBounds = gc.getBounds(); screenBounds.x = 0; screenBounds.y = 0; Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc); Rectangle maxBounds = new Rectangle( (screenBounds.x + screenInsets.left), (screenBounds.y + screenInsets.top), screenBounds.width - ((screenInsets.left + screenInsets.right)), screenBounds.height - ((screenInsets.top + screenInsets.bottom))); if (tla instanceof JFrame) ((JFrame) tla).setMaximizedBounds(maxBounds); if (MemoryAnalyzer.isRunning()) { MemoryAnalyzer.enqueueUsage("Frame set to bounds " + maxBounds); } } /** * Returns the JComponent rendering the title pane. If this * returns null, it implies there is no need to render window decorations. * This method is for internal use only. * * @see #setTitlePane * @return Title pane. */ public JComponent getTitlePane() { return this.titlePane; } /** * Returns the JRootPane we're providing the look and feel for. * * @return The associated root pane. */ protected JRootPane getRootPane() { return this.root; } /* * (non-Javadoc) * * @seejavax.swing.plaf.basic.BasicRootPaneUI#propertyChange(java.beans. * PropertyChangeEvent) */ @Override public void propertyChange(PropertyChangeEvent e) { super.propertyChange(e); String propertyName = e.getPropertyName(); if (propertyName == null) { return; } if (propertyName.equals("windowDecorationStyle")) { JRootPane root = (JRootPane) e.getSource(); int style = root.getWindowDecorationStyle(); this.uninstallClientDecorations(root); if (style != JRootPane.NONE) { this.installClientDecorations(root); } } if (propertyName.equals("ancestor")) { this.uninstallWindowListeners(this.root); if (((JRootPane) e.getSource()).getWindowDecorationStyle() != JRootPane.NONE) { this.installWindowListeners(this.root, this.root.getParent()); } } if (propertyName.equals("background")) { SubstanceLookAndFeel.getTitlePaneComponent(window).setBackground( (Color) e.getNewValue()); } return; } /** * A custom layout manager that is responsible for the layout of * layeredPane, glassPane, menuBar and titlePane, if one has been installed. */ protected class SubstanceRootLayout implements LayoutManager2 { /** * Returns the amount of space the layout would like to have. * * * aram the Container for which this layout manager is being used * * @return a Dimension object containing the layout's preferred size */ public Dimension preferredLayoutSize(Container parent) { Dimension cpd, mbd, tpd; int cpWidth = 0; int cpHeight = 0; int mbWidth = 0; int mbHeight = 0; int tpWidth = 0; int tpHeight = 0; Insets i = parent.getInsets(); JRootPane root = (JRootPane) parent; if (root.getContentPane() != null) { cpd = root.getContentPane().getPreferredSize(); } else { cpd = root.getSize(); } if (cpd != null) { cpWidth = cpd.width; cpHeight = cpd.height; } if (root.getJMenuBar() != null) { mbd = root.getJMenuBar().getPreferredSize(); if (mbd != null) { mbWidth = mbd.width; mbHeight = mbd.height; } } if ((root.getWindowDecorationStyle() != JRootPane.NONE) && (root.getUI() instanceof SubstanceRootPaneUI)) { JComponent titlePane = ((SubstanceRootPaneUI) root.getUI()) .getTitlePane(); if (titlePane != null) { tpd = titlePane.getPreferredSize(); if (tpd != null) { tpWidth = tpd.width; tpHeight = tpd.height; } } } return new Dimension(Math.max(Math.max(cpWidth, mbWidth), tpWidth) + i.left + i.right, cpHeight + mbHeight + tpHeight + i.top + i.bottom); } /** * Returns the minimum amount of space the layout needs. * * * aram the Container for which this layout manager is being used * * @return a Dimension object containing the layout's minimum size */ public Dimension minimumLayoutSize(Container parent) { Dimension cpd, mbd, tpd; int cpWidth = 0; int cpHeight = 0; int mbWidth = 0; int mbHeight = 0; int tpWidth = 0; int tpHeight = 0; Insets i = parent.getInsets(); JRootPane root = (JRootPane) parent; if (root.getContentPane() != null) { cpd = root.getContentPane().getMinimumSize(); } else { cpd = root.getSize(); } if (cpd != null) { cpWidth = cpd.width; cpHeight = cpd.height; } if (root.getJMenuBar() != null) { mbd = root.getJMenuBar().getMinimumSize(); if (mbd != null) { mbWidth = mbd.width; mbHeight = mbd.height; } } if ((root.getWindowDecorationStyle() != JRootPane.NONE) && (root.getUI() instanceof SubstanceRootPaneUI)) { JComponent titlePane = ((SubstanceRootPaneUI) root.getUI()) .getTitlePane(); if (titlePane != null) { tpd = titlePane.getMinimumSize(); if (tpd != null) { tpWidth = tpd.width; tpHeight = tpd.height; } } } return new Dimension(Math.max(Math.max(cpWidth, mbWidth), tpWidth) + i.left + i.right, cpHeight + mbHeight + tpHeight + i.top + i.bottom); } /** * Returns the maximum amount of space the layout can use. * * * aram the Container for which this layout manager is being used * * @return a Dimension object containing the layout's maximum size */ public Dimension maximumLayoutSize(Container target) { Dimension cpd, mbd, tpd; int cpWidth = Integer.MAX_VALUE; int cpHeight = Integer.MAX_VALUE; int mbWidth = Integer.MAX_VALUE; int mbHeight = Integer.MAX_VALUE; int tpWidth = Integer.MAX_VALUE; int tpHeight = Integer.MAX_VALUE; Insets i = target.getInsets(); JRootPane root = (JRootPane) target; if (root.getContentPane() != null) { cpd = root.getContentPane().getMaximumSize(); if (cpd != null) { cpWidth = cpd.width; cpHeight = cpd.height; } } if (root.getJMenuBar() != null) { mbd = root.getJMenuBar().getMaximumSize(); if (mbd != null) { mbWidth = mbd.width; mbHeight = mbd.height; } } if ((root.getWindowDecorationStyle() != JRootPane.NONE) && (root.getUI() instanceof SubstanceRootPaneUI)) { JComponent titlePane = ((SubstanceRootPaneUI) root.getUI()) .getTitlePane(); if (titlePane != null) { tpd = titlePane.getMaximumSize(); if (tpd != null) { tpWidth = tpd.width; tpHeight = tpd.height; } } } int maxHeight = Math.max(Math.max(cpHeight, mbHeight), tpHeight); // Only overflows if 3 real non-MAX_VALUE heights, sum to > // MAX_VALUE // Only will happen if sums to more than 2 billion units. Not // likely. if (maxHeight != Integer.MAX_VALUE) { maxHeight = cpHeight + mbHeight + tpHeight + i.top + i.bottom; } int maxWidth = Math.max(Math.max(cpWidth, mbWidth), tpWidth); // Similar overflow comment as above if (maxWidth != Integer.MAX_VALUE) { maxWidth += i.left + i.right; } return new Dimension(maxWidth, maxHeight); } /** * Instructs the layout manager to perform the layout for the specified * container. * * * aram the Container for which this layout manager is being used */ public void layoutContainer(Container parent) { JRootPane root = (JRootPane) parent; Rectangle b = root.getBounds(); Insets i = root.getInsets(); int nextY = 0; int w = b.width - i.right - i.left; int h = b.height - i.top - i.bottom; if (root.getLayeredPane() != null) { root.getLayeredPane().setBounds(i.left, i.top, w, h); } if (root.getGlassPane() != null) { root.getGlassPane().setBounds(i.left, i.top, w, h); } // Note: This is laying out the children in the layeredPane, // technically, these are not our children. if ((root.getWindowDecorationStyle() != JRootPane.NONE) && (root.getUI() instanceof SubstanceRootPaneUI)) { JComponent titlePane = ((SubstanceRootPaneUI) root.getUI()) .getTitlePane(); if (titlePane != null) { Dimension tpd = titlePane.getPreferredSize(); if (tpd != null) { int tpHeight = tpd.height; titlePane.setBounds(0, 0, w, tpHeight); nextY += tpHeight; } } } if (root.getJMenuBar() != null) { Dimension mbd = root.getJMenuBar().getPreferredSize(); root.getJMenuBar().setBounds(0, nextY, w, mbd.height); nextY += mbd.height; } if (root.getContentPane() != null) { // Dimension cpd = root.getContentPane().getPreferredSize(); root.getContentPane().setBounds(0, nextY, w, h < nextY ? 0 : h - nextY); } } public void addLayoutComponent(String name, Component comp) { } public void removeLayoutComponent(Component comp) { } public void addLayoutComponent(Component comp, Object constraints) { } public float getLayoutAlignmentX(Container target) { return 0.0f; } public float getLayoutAlignmentY(Container target) { return 0.0f; } public void invalidateLayout(Container target) { } } /** * Maps from positions to cursor type. Refer to calculateCorner and * calculatePosition for details of this. */ private static final int[] cursorMapping = new int[] { Cursor.NW_RESIZE_CURSOR, Cursor.NW_RESIZE_CURSOR, Cursor.N_RESIZE_CURSOR, Cursor.NE_RESIZE_CURSOR, Cursor.NE_RESIZE_CURSOR, Cursor.NW_RESIZE_CURSOR, 0, 0, 0, Cursor.NE_RESIZE_CURSOR, Cursor.W_RESIZE_CURSOR, 0, 0, 0, Cursor.E_RESIZE_CURSOR, Cursor.SW_RESIZE_CURSOR, 0, 0, 0, Cursor.SE_RESIZE_CURSOR, Cursor.SW_RESIZE_CURSOR, Cursor.SW_RESIZE_CURSOR, Cursor.S_RESIZE_CURSOR, Cursor.SE_RESIZE_CURSOR, Cursor.SE_RESIZE_CURSOR }; /** * MouseInputHandler is responsible for handling resize/moving of the * Window. It sets the cursor directly on the Window when then mouse moves * over a hot spot. */ private class MouseInputHandler implements MouseInputListener { /** * Set to true if the drag operation is moving the window. */ private boolean isMovingWindow; /** * Used to determine the corner the resize is occuring from. */ private int dragCursor; /** * X location the mouse went down on for a drag operation. */ private int dragOffsetX; /** * Y location the mouse went down on for a drag operation. */ private int dragOffsetY; /** * Width of the window when the drag started. */ private int dragWidth; /** * Height of the window when the drag started. */ private int dragHeight; /** * PrivilegedExceptionAction needed by mouseDragged method to obtain new * location of window on screen during the drag. */ @SuppressWarnings("unchecked") private final PrivilegedExceptionAction getLocationAction = new PrivilegedExceptionAction() { public Object run() throws HeadlessException { return MouseInfo.getPointerInfo().getLocation(); } }; public void mousePressed(MouseEvent ev) { JRootPane rootPane = SubstanceRootPaneUI.this.getRootPane(); if (rootPane.getWindowDecorationStyle() == JRootPane.NONE) { return; } Point dragWindowOffset = ev.getPoint(); Window w = (Window) ev.getSource(); if (w != null) { w.toFront(); } Point convertedDragWindowOffset = SwingUtilities.convertPoint(w, dragWindowOffset, SubstanceRootPaneUI.this.getTitlePane()); Frame f = null; Dialog d = null; if (w instanceof Frame) { f = (Frame) w; } else if (w instanceof Dialog) { d = (Dialog) w; } int frameState = (f != null) ? f.getExtendedState() : 0; if ((SubstanceRootPaneUI.this.getTitlePane() != null) && SubstanceRootPaneUI.this.getTitlePane().contains( convertedDragWindowOffset)) { if ((((f != null) && ((frameState & Frame.MAXIMIZED_BOTH) == 0)) || (d != null)) && (dragWindowOffset.y >= SubstanceRootPaneUI.BORDER_DRAG_THICKNESS) && (dragWindowOffset.x >= SubstanceRootPaneUI.BORDER_DRAG_THICKNESS) && (dragWindowOffset.x < w.getWidth() - SubstanceRootPaneUI.BORDER_DRAG_THICKNESS)) { this.isMovingWindow = true; this.dragOffsetX = dragWindowOffset.x; this.dragOffsetY = dragWindowOffset.y; } } else if (((f != null) && f.isResizable() && ((frameState & Frame.MAXIMIZED_BOTH) == 0)) || ((d != null) && d.isResizable())) { this.dragOffsetX = dragWindowOffset.x; this.dragOffsetY = dragWindowOffset.y; this.dragWidth = w.getWidth(); this.dragHeight = w.getHeight(); this.dragCursor = this.getCursor(this.calculateCorner(w, dragWindowOffset.x, dragWindowOffset.y)); } } public void mouseReleased(MouseEvent ev) { if ((this.dragCursor != 0) && (SubstanceRootPaneUI.this.window != null) && !SubstanceRootPaneUI.this.window.isValid()) { // Some Window systems validate as you resize, others won't, // thus the check for validity before repainting. SubstanceRootPaneUI.this.window.validate(); SubstanceRootPaneUI.this.getRootPane().repaint(); } this.isMovingWindow = false; this.dragCursor = 0; } public void mouseMoved(MouseEvent ev) { JRootPane root = SubstanceRootPaneUI.this.getRootPane(); if (root.getWindowDecorationStyle() == JRootPane.NONE) { return; } Window w = (Window) ev.getSource(); Frame f = null; Dialog d = null; if (w instanceof Frame) { f = (Frame) w; } else if (w instanceof Dialog) { d = (Dialog) w; } // Update the cursor int cursor = this.getCursor(this.calculateCorner(w, ev.getX(), ev .getY())); if ((cursor != 0) && (((f != null) && (f.isResizable() && ((f .getExtendedState() & Frame.MAXIMIZED_BOTH) == 0))) || ((d != null) && d .isResizable()))) { w.setCursor(Cursor.getPredefinedCursor(cursor)); } else { w.setCursor(SubstanceRootPaneUI.this.lastCursor); } } /** * Adjusts the bounds. * * @param bounds * Original bounds. * @param min * Minimum dimension. * @param deltaX * Delta X. * @param deltaY * Delta Y. * @param deltaWidth * Delta width. * @param deltaHeight * Delta height. */ private void adjust(Rectangle bounds, Dimension min, int deltaX, int deltaY, int deltaWidth, int deltaHeight) { bounds.x += deltaX; bounds.y += deltaY; bounds.width += deltaWidth; bounds.height += deltaHeight; if (min != null) { if (bounds.width < min.width) { int correction = min.width - bounds.width; if (deltaX != 0) { bounds.x -= correction; } bounds.width = min.width; } if (bounds.height < min.height) { int correction = min.height - bounds.height; if (deltaY != 0) { bounds.y -= correction; } bounds.height = min.height; } } } @SuppressWarnings("unchecked") public void mouseDragged(MouseEvent ev) { Window w = (Window) ev.getSource(); Point pt = ev.getPoint(); if (this.isMovingWindow) { Point windowPt; try { windowPt = (Point) AccessController .doPrivileged(this.getLocationAction); windowPt.x = windowPt.x - this.dragOffsetX; windowPt.y = windowPt.y - this.dragOffsetY; w.setLocation(windowPt); } catch (PrivilegedActionException e) { } } else if (this.dragCursor != 0) { Rectangle r = w.getBounds(); Rectangle startBounds = new Rectangle(r); Dimension min = w.getMinimumSize(); switch (this.dragCursor) { case Cursor.E_RESIZE_CURSOR: this.adjust(r, min, 0, 0, pt.x + (this.dragWidth - this.dragOffsetX) - r.width, 0); break; case Cursor.S_RESIZE_CURSOR: this.adjust(r, min, 0, 0, 0, pt.y + (this.dragHeight - this.dragOffsetY) - r.height); break; case Cursor.N_RESIZE_CURSOR: this.adjust(r, min, 0, pt.y - this.dragOffsetY, 0, -(pt.y - this.dragOffsetY)); break; case Cursor.W_RESIZE_CURSOR: this.adjust(r, min, pt.x - this.dragOffsetX, 0, -(pt.x - this.dragOffsetX), 0); break; case Cursor.NE_RESIZE_CURSOR: this.adjust(r, min, 0, pt.y - this.dragOffsetY, pt.x + (this.dragWidth - this.dragOffsetX) - r.width, -(pt.y - this.dragOffsetY)); break; case Cursor.SE_RESIZE_CURSOR: this.adjust(r, min, 0, 0, pt.x + (this.dragWidth - this.dragOffsetX) - r.width, pt.y + (this.dragHeight - this.dragOffsetY) - r.height); break; case Cursor.NW_RESIZE_CURSOR: this.adjust(r, min, pt.x - this.dragOffsetX, pt.y - this.dragOffsetY, -(pt.x - this.dragOffsetX), -(pt.y - this.dragOffsetY)); break; case Cursor.SW_RESIZE_CURSOR: this.adjust(r, min, pt.x - this.dragOffsetX, 0, -(pt.x - this.dragOffsetX), pt.y + (this.dragHeight - this.dragOffsetY) - r.height); break; default: break; } if (!r.equals(startBounds)) { w.setBounds(r); // Defer repaint/validate on mouseReleased unless dynamic // layout is active. if (Toolkit.getDefaultToolkit().isDynamicLayoutActive()) { w.validate(); SubstanceRootPaneUI.this.getRootPane().repaint(); } } } } private CursorState cursorState = CursorState.NIL; public void mouseEntered(MouseEvent ev) { Window w = (Window) ev.getSource(); if (cursorState == CursorState.EXITED || cursorState == CursorState.NIL) { // fix for defect 107 SubstanceRootPaneUI.this.lastCursor = w.getCursor(); } cursorState = CursorState.ENTERED; this.mouseMoved(ev); } public void mouseExited(MouseEvent ev) { Window w = (Window) ev.getSource(); w.setCursor(SubstanceRootPaneUI.this.lastCursor); cursorState = CursorState.EXITED; } public void mouseClicked(MouseEvent ev) { Window w = (Window) ev.getSource(); Frame f = null; if (w instanceof Frame) { f = (Frame) w; } else { return; } JComponent windowTitlePane = SubstanceRootPaneUI.this .getTitlePane(); // fix for issue 444 - ignore double clicks when the title pane // is not showing (for example under JRootPane.NONE decoration // style). if (windowTitlePane == null) return; Point convertedPoint = SwingUtilities.convertPoint(w, ev.getPoint(), windowTitlePane); int state = f.getExtendedState(); if ((windowTitlePane != null) && windowTitlePane.contains(convertedPoint)) { if (((ev.getClickCount() % 2) == 0) && ((ev.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) { if (f.isResizable()) { if ((state & Frame.MAXIMIZED_BOTH) != 0) { setMaximized(); f.setExtendedState(state & ~Frame.MAXIMIZED_BOTH); } else { setMaximized(); f.setExtendedState(state | Frame.MAXIMIZED_BOTH); } return; } } } } /** * Returns the corner that contains the point x, * y, or -1 if the position doesn't match a corner. * * @param w * Window. * @param x * X coordinate. * @param y * Y coordinate. * @return Corner that contains the specified point. */ private int calculateCorner(Window w, int x, int y) { Insets insets = w.getInsets(); int xPosition = this.calculatePosition(x - insets.left, w .getWidth() - insets.left - insets.right); int yPosition = this.calculatePosition(y - insets.top, w .getHeight() - insets.top - insets.bottom); if ((xPosition == -1) || (yPosition == -1)) { return -1; } return yPosition * 5 + xPosition; } /** * Returns the Cursor to render for the specified corner. This returns 0 * if the corner doesn't map to a valid Cursor * * @param corner * Corner * @return Cursor to render for the specified corner. */ private int getCursor(int corner) { if (corner == -1) { return 0; } return SubstanceRootPaneUI.cursorMapping[corner]; } /** * Returns an integer indicating the position of spot in * width. The return value will be: 0 if < * BORDER_DRAG_THICKNESS 1 if < CORNER_DRAG_WIDTH 2 if >= * CORNER_DRAG_WIDTH && < width - BORDER_DRAG_THICKNESS 3 if >= width - * CORNER_DRAG_WIDTH 4 if >= width - BORDER_DRAG_THICKNESS 5 otherwise * * @param spot * Spot. * @param width * Width. * @return The position of spot in width. */ private int calculatePosition(int spot, int width) { if (spot < SubstanceRootPaneUI.BORDER_DRAG_THICKNESS) { return 0; } if (spot < SubstanceRootPaneUI.CORNER_DRAG_WIDTH) { return 1; } if (spot >= (width - SubstanceRootPaneUI.BORDER_DRAG_THICKNESS)) { return 4; } if (spot >= (width - SubstanceRootPaneUI.CORNER_DRAG_WIDTH)) { return 3; } return 2; } } /** * Mouse handler on the title pane. * * @author Kirill Grouchnikov */ private class TitleMouseInputHandler extends MouseInputAdapter { /** * Pointer location when the mouse was pressed for a drag relative to * the upper-lefthand corner of the window. */ private Point dragOffset = new Point(0, 0); @Override public void mousePressed(MouseEvent ev) { JRootPane rootPane = SubstanceRootPaneUI.this.getRootPane(); if (rootPane.getWindowDecorationStyle() == JRootPane.NONE) { return; } Point dragWindowOffset = ev.getPoint(); Component source = (Component) ev.getSource(); Point convertedDragWindowOffset = SwingUtilities.convertPoint( source, dragWindowOffset, getTitlePane()); dragWindowOffset = SwingUtilities.convertPoint(source, dragWindowOffset, SubstanceRootPaneUI.this.window); if (getTitlePane() != null && getTitlePane().contains(convertedDragWindowOffset)) { if (SubstanceRootPaneUI.this.window != null) { SubstanceRootPaneUI.this.window.toFront(); dragOffset = dragWindowOffset; } } } @Override public void mouseDragged(MouseEvent ev) { Component source = (Component) ev.getSource(); // Point pt = SwingUtilities.convertPoint(source, ev.getPoint(), // SubstanceRootPaneUI.this.window); // fix for issue 198 Point eventLocationOnScreen = ev.getLocationOnScreen(); if (eventLocationOnScreen == null) { eventLocationOnScreen = new Point(ev.getX() + source.getLocationOnScreen().x, ev.getY() + source.getLocationOnScreen().y); } // Fix for issue 192 - disable dragging maximized frame. if (SubstanceRootPaneUI.this.window instanceof Frame) { Frame f = (Frame) SubstanceRootPaneUI.this.window; int frameState = (f != null) ? f.getExtendedState() : 0; if ((f != null) && ((frameState & Frame.MAXIMIZED_BOTH) == 0)) { SubstanceRootPaneUI.this.window.setLocation( eventLocationOnScreen.x - dragOffset.x, eventLocationOnScreen.y - dragOffset.y); } } else { // fix for issue 193 - allow dragging decorated dialogs. SubstanceRootPaneUI.this.window.setLocation( eventLocationOnScreen.x - dragOffset.x, eventLocationOnScreen.y - dragOffset.y); } } @Override public void mouseClicked(MouseEvent ev) { Frame f = null; if (SubstanceRootPaneUI.this.window instanceof Frame) { f = (Frame) SubstanceRootPaneUI.this.window; } else { return; } Point convertedPoint = SwingUtilities.convertPoint( SubstanceRootPaneUI.this.window, ev.getPoint(), SubstanceRootPaneUI.this.getTitlePane()); int state = f.getExtendedState(); if ((SubstanceRootPaneUI.this.getTitlePane() != null) && SubstanceRootPaneUI.this.getTitlePane().contains( convertedPoint)) { if (((ev.getClickCount() % 2) == 0) && ((ev.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) { if (f.isResizable()) { if ((state & Frame.MAXIMIZED_BOTH) != 0) { setMaximized(); f.setExtendedState(state & ~Frame.MAXIMIZED_BOTH); } else { setMaximized(); f.setExtendedState(state | Frame.MAXIMIZED_BOTH); } return; } } } } } // /** // * Makes the heap status panel appear / disappear permanently on the // * associated title pane and removes the corresponding check box menu // items // * from the system menu. // * // * @param isVisible // * if true, the heap status panel will be // * permanently shown, if false, the heap status // * panel will be permanently hidden. // */ // public void setHeapStatusPanePermanentVisibility(boolean isVisible) { // if (this.titlePane instanceof SubstanceTitlePane) { // ((SubstanceTitlePane) this.titlePane) // .setHeapStatusPanePermanentVisibility(isVisible); // } // } } substance-5.3.orig/src/org/jvnet/substance/SubstanceCheckBoxMenuItemUI.java0000644000175000017500000002040211247214704027001 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicCheckBoxMenuItemUI; import org.jvnet.lafwidget.animation.FadeStateListener; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.icon.CheckBoxMenuItemIcon; import org.jvnet.substance.utils.menu.MenuUtilities; import org.jvnet.substance.utils.menu.SubstanceMenu; import org.jvnet.substance.utils.menu.MenuUtilities.MenuPropertyListener; /** * UI for check box menu items in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI implements SubstanceMenu { /** * Rollover listener. */ protected RolloverMenuItemListener substanceRolloverListener; /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /** * Listens on all changes to the underlying menu item. */ protected MenuPropertyListener substanceMenuPropertyListener; /** * Property change listener. Listens on changes to * {@link AbstractButton#MODEL_CHANGED_PROPERTY} property. */ protected PropertyChangeListener substancePropertyListener; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); JCheckBoxMenuItem item = (JCheckBoxMenuItem) comp; // add rollover listener item.setRolloverEnabled(true); return new SubstanceCheckBoxMenuItemUI(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicMenuItemUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); // Improving performance on big menus. this.substanceMenuPropertyListener = new MenuPropertyListener( this.menuItem); this.substanceMenuPropertyListener.install(); // fix for defect 109 - storing reference to rollover listener this.substanceRolloverListener = new RolloverMenuItemListener( this.menuItem); this.menuItem.addMouseListener(this.substanceRolloverListener); this.substanceFadeStateListener = new FadeStateListener(this.menuItem, this.menuItem.getModel(), SubstanceCoreUtilities .getFadeCallback(this.menuItem, this.menuItem .getModel(), true, false, this.menuItem)); this.substanceFadeStateListener.registerListeners(); this.substancePropertyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (AbstractButton.MODEL_CHANGED_PROPERTY.equals(evt .getPropertyName())) { if (substanceFadeStateListener != null) substanceFadeStateListener.unregisterListeners(); substanceFadeStateListener = new FadeStateListener( menuItem, menuItem.getModel(), SubstanceCoreUtilities.getFadeCallback(menuItem, menuItem.getModel(), true, false, menuItem)); substanceFadeStateListener.registerListeners(); } if ("font".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (menuItem != null) { menuItem.updateUI(); } } }); } } }; this.menuItem.addPropertyChangeListener(this.substancePropertyListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicMenuItemUI#uninstallListeners() */ @Override protected void uninstallListeners() { super.uninstallListeners(); // Improving performance on big menus. this.substanceMenuPropertyListener.uninstall(); this.substanceMenuPropertyListener = null; // fix for defect 109 - unregistering rollover listener this.menuItem.removeMouseListener(this.substanceRolloverListener); this.substanceRolloverListener = null; this.menuItem .removePropertyChangeListener(this.substancePropertyListener); this.substancePropertyListener = null; this.substanceFadeStateListener.unregisterListeners(); this.substanceFadeStateListener = null; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicMenuItemUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); if (this.checkIcon == null || this.checkIcon instanceof UIResource) { this.checkIcon = new CheckBoxMenuItemIcon(this.menuItem, 1 + SubstanceSizeUtils .getMenuCheckMarkSize(SubstanceSizeUtils .getComponentFontSize(this.menuItem))); } this.defaultTextIconGap = SubstanceSizeUtils .getTextIconGap(SubstanceSizeUtils .getComponentFontSize(this.menuItem)); } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getAssociatedMenuItem() */ public JMenuItem getAssociatedMenuItem() { return this.menuItem; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getAcceleratorFont() */ public Font getAcceleratorFont() { return this.acceleratorFont; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getArrowIcon() */ public Icon getArrowIcon() { return this.arrowIcon; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getCheckIcon() */ public Icon getCheckIcon() { return this.checkIcon; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getDefaultTextIconGap() */ public int getDefaultTextIconGap() { return this.defaultTextIconGap; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicMenuItemUI#getPreferredMenuItemSize(javax * .swing.JComponent, javax.swing.Icon, javax.swing.Icon, int) */ @Override protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { Dimension superDim = super.getPreferredMenuItemSize(c, checkIcon, arrowIcon, defaultTextIconGap); return new Dimension(MenuUtilities.getPreferredWidth(menuItem), superDim.height); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicMenuItemUI#paintMenuItem(java.awt.Graphics, * javax.swing.JComponent, javax.swing.Icon, javax.swing.Icon, * java.awt.Color, java.awt.Color, int) */ @Override protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { MenuUtilities.paintMenuItem(g, menuItem, checkIcon, arrowIcon, defaultTextIconGap); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceMenuItemUI.java0000644000175000017500000001615311247214710025377 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicMenuItemUI; import org.jvnet.lafwidget.animation.FadeStateListener; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.SubstanceSizeUtils; import org.jvnet.substance.utils.menu.MenuUtilities; import org.jvnet.substance.utils.menu.SubstanceMenu; import org.jvnet.substance.utils.menu.MenuUtilities.MenuPropertyListener; /** * UI for menu items in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceMenuItemUI extends BasicMenuItemUI implements SubstanceMenu { /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /** * Listens on all changes to the underlying menu item. */ protected MenuPropertyListener substanceMenuPropertyListener; /** * Property change listener. Listens on changes to * {@link AbstractButton#MODEL_CHANGED_PROPERTY} property. */ protected PropertyChangeListener substancePropertyListener; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceMenuItemUI(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicMenuItemUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); // Improving performance on big menus. this.substanceMenuPropertyListener = new MenuPropertyListener( this.menuItem); this.substanceMenuPropertyListener.install(); this.substanceFadeStateListener = new FadeStateListener(this.menuItem, this.menuItem.getModel(), SubstanceCoreUtilities .getFadeCallback(this.menuItem, this.menuItem .getModel(), true, false, this.menuItem)); this.substanceFadeStateListener.registerListeners(); this.substancePropertyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (AbstractButton.MODEL_CHANGED_PROPERTY.equals(evt .getPropertyName())) { if (substanceFadeStateListener != null) substanceFadeStateListener.unregisterListeners(); substanceFadeStateListener = new FadeStateListener( menuItem, menuItem.getModel(), SubstanceCoreUtilities.getFadeCallback(menuItem, menuItem.getModel(), true, false, menuItem)); substanceFadeStateListener.registerListeners(); } } }; this.menuItem.addPropertyChangeListener(this.substancePropertyListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicMenuItemUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); this.defaultTextIconGap = SubstanceSizeUtils .getTextIconGap(SubstanceSizeUtils .getComponentFontSize(this.menuItem)); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicMenuItemUI#uninstallListeners() */ @Override protected void uninstallListeners() { // Improving performance on big menus. this.substanceMenuPropertyListener.uninstall(); this.substanceMenuPropertyListener = null; this.menuItem .removePropertyChangeListener(this.substancePropertyListener); this.substancePropertyListener = null; this.substanceFadeStateListener.unregisterListeners(); this.substanceFadeStateListener = null; super.uninstallListeners(); } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getAssociatedMenuItem() */ public JMenuItem getAssociatedMenuItem() { return this.menuItem; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getAcceleratorFont() */ public Font getAcceleratorFont() { return this.acceleratorFont; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getArrowIcon() */ public Icon getArrowIcon() { return this.arrowIcon; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getCheckIcon() */ public Icon getCheckIcon() { return null; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getDefaultTextIconGap() */ public int getDefaultTextIconGap() { return this.defaultTextIconGap; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicMenuItemUI#getPreferredMenuItemSize(javax * .swing.JComponent, javax.swing.Icon, javax.swing.Icon, int) */ @Override protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { Dimension superDim = super.getPreferredMenuItemSize(c, checkIcon, arrowIcon, defaultTextIconGap); return new Dimension(MenuUtilities.getPreferredWidth(menuItem), superDim.height); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicMenuItemUI#paintMenuItem(java.awt.Graphics, * javax.swing.JComponent, javax.swing.Icon, javax.swing.Icon, * java.awt.Color, java.awt.Color, int) */ @Override protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { MenuUtilities.paintMenuItem(g, menuItem, checkIcon, arrowIcon, defaultTextIconGap); } } substance-5.3.orig/src/org/jvnet/substance/SubstancePanelUI.java0000644000175000017500000000755711253513556024732 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.Color; import java.awt.Graphics; import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.plaf.*; import javax.swing.plaf.basic.BasicPanelUI; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.utils.SubstanceColorUtilities; import org.jvnet.substance.utils.SubstanceCoreUtilities; /** * UI for panels in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstancePanelUI extends BasicPanelUI { /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstancePanelUI(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicPanelUI#installDefaults(javax.swing.JPanel) */ @Override protected void installDefaults(JPanel p) { super.installDefaults(p); // support for per-window skins Color backgr = p.getBackground(); if ((backgr == null) || (backgr instanceof UIResource)) { Color backgroundFillColor = SubstanceColorUtilities .getBackgroundFillColor(p); // fix for issue 436 - logic in getBackground() of // custom panels can result in null value if (backgroundFillColor != null) { p.setBackground(new ColorUIResource(backgroundFillColor)); } } } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void update(Graphics g, JComponent c) { if (!SubstanceLookAndFeel.isCurrentLookAndFeel()) return; if (toPaintBackground(c)) { BackgroundPaintingUtils.update(g, c, false); } super.paint(g, c); } /** * Returns indication whether the panel background should be filled. * * @param c * Component (should be {@link JPanel}). * @return true if the panel background should be filled with * the background color, false otherwise. */ protected boolean toPaintBackground(JComponent c) { return TransitionLayout.isOpaque(c); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceTabbedPaneUI.java0000644000175000017500000026352211254157314025651 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.*; import java.util.List; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicTabbedPaneUI; import javax.swing.text.View; import org.jvnet.lafwidget.LafWidgetUtilities; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.lafwidget.utils.LafConstants; import org.jvnet.substance.api.*; import org.jvnet.substance.api.SubstanceConstants.*; import org.jvnet.substance.api.tabbed.*; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.shaper.ClassicButtonShaper; import org.jvnet.substance.shaper.SubstanceButtonShaper; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.icon.TransitionAwareIcon; import org.jvnet.substance.utils.scroll.SubstanceScrollButton; /** * UI for tabbed panes in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceTabbedPaneUI extends BasicTabbedPaneUI { /** * Current mouse location. */ protected Point substanceMouseLocation; /** * Hash map for storing already computed backgrounds. */ private static LazyResettableHashMap backgroundMap = new LazyResettableHashMap( "SubstanceTabbedPaneUI.background"); /** * Hash map for storing already computed backgrounds. */ private static LazyResettableHashMap closeButtonMap = new LazyResettableHashMap( "SubstanceTabbedPaneUI.closeButton"); /** * Key - tab component. Value - ID of the (looping) fade transition that * animates the tab component when it's marked as modified (with * {@link SubstanceLookAndFeel#WINDOW_MODIFIED} property). */ private Map fadeModifiedIds; /** * Map of previous fade states (for state-aware color scheme transitions). */ private Map prevStateMap; /** * Map of next fade states (for state-aware color scheme transitions). */ private Map nextStateMap; /** * Currently selected index (for selection animations). */ private int currSelectedIndex; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceTabbedPaneUI(); } /** * Mouse handler for rollover effects. */ protected MouseRolloverHandler substanceRolloverHandler; /** * Tracks changes to the tabbed pane contents. Each tab component is tracked * for changes on the {@link SubstanceLookAndFeel#WINDOW_MODIFIED} property. */ protected TabbedContainerListener substanceContainerListener; /** * Listener for animation effects on tab selection. */ protected ChangeListener substanceSelectionListener; /** * Tracks changes to the tabbed pane contents. Each tab component is tracked * for changes on the {@link SubstanceLookAndFeel#WINDOW_MODIFIED} property. * * @author Kirill Grouchnikov */ protected final class TabbedContainerListener extends ContainerAdapter { /** * Property change listeners on the tab components. *

* Fixes defect 135 - memory leaks on tabbed panes. */ private Map> listeners = new HashMap>(); /** * Creates a new container listener. */ public TabbedContainerListener() { } /** * Tracks all existing tab component. */ protected void trackExistingTabs() { // register listeners on all existing tabs for (int i = 0; i < SubstanceTabbedPaneUI.this.tabPane .getTabCount(); i++) { this.trackTab(SubstanceTabbedPaneUI.this.tabPane .getComponentAt(i)); } } /** * Tracks changes in a single tab component. * * @param tabComponent * Tab component. */ protected void trackTab(final Component tabComponent) { if (tabComponent == null) return; PropertyChangeListener tabModifiedListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (SubstanceLookAndFeel.WINDOW_MODIFIED.equals(evt .getPropertyName())) { Object oldValue = evt.getOldValue(); Object newValue = evt.getNewValue(); boolean wasModified = Boolean.TRUE.equals(oldValue); boolean isModified = Boolean.TRUE.equals(newValue); if (wasModified) { if (!isModified) { long fadeInstanceId = SubstanceTabbedPaneUI.this.fadeModifiedIds .get(tabComponent); FadeTracker.getInstance().cancelFadeInstance( fadeInstanceId); } } else { if (isModified) { int tabIndex = SubstanceTabbedPaneUI.this.tabPane .indexOfComponent(tabComponent); if (tabIndex >= 0) { long fadeInstanceId = FadeTracker .getInstance() .trackFadeLooping( ModifiedFadeStep.MARKED_MODIFIED_FADE_KIND, new LafConstants.AnimationKind( new ModifiedFadeStep(), "modified"), SubstanceTabbedPaneUI.this.tabPane, tabIndex, false, SubstanceTabbedPaneUI.this .getCallback(tabIndex), -1, true); SubstanceTabbedPaneUI.this.fadeModifiedIds .put(tabComponent, fadeInstanceId); } } } } } }; tabComponent.addPropertyChangeListener(tabModifiedListener); // fix for defect 135 - memory leaks on tabbed panes List currList = this.listeners .get(tabComponent); if (currList == null) currList = new LinkedList(); currList.add(tabModifiedListener); // System.err.println(this.hashCode() + " adding for " + // tabComponent.hashCode()); this.listeners.put(tabComponent, currList); // Fix for defect 104 - a' modified' component is added to // the tabbed pane. In this case it should be animated from the // beginning. if (tabComponent instanceof JComponent) { if (Boolean.TRUE .equals(((JComponent) tabComponent) .getClientProperty(SubstanceLookAndFeel.WINDOW_MODIFIED))) { // TabPulseTracker.update(SubstanceTabbedPaneUI.this.tabPane // , // tabComponent); int tabIndex = SubstanceTabbedPaneUI.this.tabPane .indexOfComponent(tabComponent); if (tabIndex >= 0) { long fadeInstanceId = FadeTracker .getInstance() .trackFadeLooping( ModifiedFadeStep.MARKED_MODIFIED_FADE_KIND, new LafConstants.AnimationKind( new ModifiedFadeStep(), "modified"), SubstanceTabbedPaneUI.this.tabPane, tabIndex, false, SubstanceTabbedPaneUI.this .getCallback(tabIndex), -1, true); SubstanceTabbedPaneUI.this.fadeModifiedIds.put( tabComponent, fadeInstanceId); } } } } /** * Stops tracking changes to a single tab component. * * @param tabComponent * Tab component. */ protected void stopTrackTab(final Component tabComponent) { if (tabComponent == null) return; List pclList = this.listeners .get(tabComponent); if (pclList != null) { for (PropertyChangeListener pcl : pclList) tabComponent.removePropertyChangeListener(pcl); } this.listeners.put(tabComponent, null); } /** * Stops tracking all tab components. */ protected void stopTrackExistingTabs() { // register listeners on all existing tabs for (int i = 0; i < SubstanceTabbedPaneUI.this.tabPane .getTabCount(); i++) { this.stopTrackTab(SubstanceTabbedPaneUI.this.tabPane .getComponentAt(i)); } } /* * (non-Javadoc) * * @seejava.awt.event.ContainerAdapter#componentAdded(java.awt.event. * ContainerEvent) */ @Override public void componentAdded(final ContainerEvent e) { final Component tabComponent = e.getChild(); if (tabComponent instanceof UIResource) return; this.trackTab(tabComponent); } /* * (non-Javadoc) * * @seejava.awt.event.ContainerAdapter#componentRemoved(java.awt.event. * ContainerEvent) */ @Override public void componentRemoved(ContainerEvent e) { // fix for defect 135 - memory leaks on tabbed panes final Component tabComponent = e.getChild(); if (tabComponent == null) return; // System.err.println(this.hashCode() + " removing for " + // tabComponent.hashCode()); if (tabComponent instanceof UIResource) return; for (PropertyChangeListener pcl : this.listeners.get(tabComponent)) tabComponent.removePropertyChangeListener(pcl); this.listeners.get(tabComponent).clear(); this.listeners.remove(tabComponent); // this.cleanListeners(tabComponent); } } /** * Listener for rollover animation effects. * * @author Kirill Grouchnikov */ protected class MouseRolloverHandler implements MouseListener, MouseMotionListener { /** * Index of the tab that was rolloed over on the previous mouse event. */ int prevRolledOver = -1; /** * Indicates whether the previous mouse event was located in a close * button. */ boolean prevInCloseButton = false; /** * Tab index of the last mouse pressed event that happened in a close * button. */ int tabOfPressedCloseButton = -1; /* * (non-Javadoc) * * @see * java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) */ public void mouseClicked(final MouseEvent e) { final int tabIndex = SubstanceTabbedPaneUI.this.tabForCoordinate( SubstanceTabbedPaneUI.this.tabPane, e.getX(), e.getY()); TabCloseCallback closeCallback = SubstanceCoreUtilities .getTabCloseCallback(e, SubstanceTabbedPaneUI.this.tabPane, tabIndex); if (closeCallback == null) return; final TabCloseKind tabCloseKind = closeCallback.onAreaClick( SubstanceTabbedPaneUI.this.tabPane, tabIndex, e); if (tabCloseKind == TabCloseKind.NONE) return; SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceTabbedPaneUI.this.tryCloseTabs(tabIndex, tabCloseKind); } }); } /* * (non-Javadoc) * * @see * java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent * ) */ public void mouseDragged(MouseEvent e) { this.handleMouseMoveDrag(e); } /* * (non-Javadoc) * * @see * java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent) */ public void mouseEntered(MouseEvent e) { setRolloverTab(tabForCoordinate(tabPane, e.getX(), e.getY())); } /* * (non-Javadoc) * * @see * java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) */ public void mousePressed(MouseEvent e) { if (!tabPane.isEnabled()) { return; } int tabIndex = tabForCoordinate(tabPane, e.getX(), e.getY()); if (tabIndex >= 0 && tabPane.isEnabledAt(tabIndex)) { Rectangle rect = new Rectangle(); rect = getTabBounds(tabIndex, rect); Rectangle close = getCloseButtonRectangleForEvents(tabIndex, rect.x, rect.y, rect.width, rect.height); boolean inCloseButton = close.contains(e.getPoint()); this.tabOfPressedCloseButton = inCloseButton ? tabIndex : -1; if (tabIndex != tabPane.getSelectedIndex()) { // enhancement 307 - don't select tab on pressing its // close button if (inCloseButton) { return; } // Clicking on unselected tab, change selection, do NOT // request focus. // This will trigger the focusIndex to change by way // of stateChanged. tabPane.setSelectedIndex(tabIndex); } else if (tabPane.isRequestFocusEnabled()) { // Clicking on selected tab, try and give the tabbedpane // focus. Repaint will occur in focusGained. tabPane.requestFocus(); } } } /* * (non-Javadoc) * * @see * java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent * ) */ public void mouseMoved(MouseEvent e) { this.handleMouseMoveDrag(e); } /** * Handles the move and drag mouse events. * * @param e * Mouse event to handle. */ private void handleMouseMoveDrag(MouseEvent e) { if (e.getSource() != tabPane) return; setRolloverTab(tabForCoordinate(tabPane, e.getX(), e.getY())); if (!FadeConfigurationManager.getInstance().fadeAllowed( FadeKind.ROLLOVER, tabPane)) return; SubstanceTabbedPaneUI.this.substanceMouseLocation = e.getPoint(); int currRolledOver = SubstanceTabbedPaneUI.this.getRolloverTab(); TabCloseCallback tabCloseCallback = SubstanceCoreUtilities .getTabCloseCallback(e, tabPane, currRolledOver); // System.err.println("Mouse moved " + currRolledOver + ":" + // prevRolledOver); if (currRolledOver == this.prevRolledOver) { if (currRolledOver >= 0) { Rectangle rect = new Rectangle(); rect = getTabBounds(currRolledOver, rect); Rectangle close = getCloseButtonRectangleForEvents( currRolledOver, rect.x, rect.y, rect.width, rect.height); // System.out.println("move " + rect + " " + close + " " // + e.getPoint()); boolean inCloseButton = close.contains(e.getPoint()); if (this.prevInCloseButton == inCloseButton) return; this.prevInCloseButton = inCloseButton; if (tabCloseCallback != null) { if (inCloseButton) { String closeButtonTooltip = tabCloseCallback .getCloseButtonTooltip(tabPane, currRolledOver); tabPane.setToolTipTextAt(currRolledOver, closeButtonTooltip); } else { String areaTooltip = tabCloseCallback .getAreaTooltip(tabPane, currRolledOver); tabPane.setToolTipTextAt(currRolledOver, areaTooltip); } } if ((currRolledOver >= 0) && (currRolledOver < tabPane.getTabCount())) { FadeTrackerCallback currCallback = SubstanceTabbedPaneUI.this .getCallback(currRolledOver); currCallback.fadePerformed(FadeKind.ROLLOVER, 0.0f); } } } else { FadeTracker fadeTracker = FadeTracker.getInstance(); if ((this.prevRolledOver >= 0) && (this.prevRolledOver < tabPane.getTabCount()) && tabPane.isEnabledAt(this.prevRolledOver)) { // System.out.println("Fading out " + prevRolledOver); fadeTracker.trackFadeOut(FadeKind.ROLLOVER, tabPane, this.prevRolledOver, true, new TabRepaintCallback( tabPane, this.prevRolledOver)); } if ((currRolledOver >= 0) && (currRolledOver < tabPane.getTabCount()) && tabPane.isEnabledAt(currRolledOver)) { fadeTracker.trackFadeIn(FadeKind.ROLLOVER, tabPane, currRolledOver, true, new TabRepaintCallback( tabPane, currRolledOver)); } } this.prevRolledOver = currRolledOver; } /* * (non-Javadoc) * * @see * java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent) */ public void mouseExited(MouseEvent e) { setRolloverTab(-1); // fix for bug 69 - non-selected non-rollover tab // may remain with close button after moving mouse quickly // to inner JTabbedPane if ((this.prevRolledOver >= 0) && (this.prevRolledOver < SubstanceTabbedPaneUI.this.tabPane .getTabCount()) && SubstanceTabbedPaneUI.this.tabPane .isEnabledAt(this.prevRolledOver)) { // only the previously rolled-over tab needs to be // repainted (fade-out) instead of repainting the // whole tab as before. FadeTracker fadeTracker = FadeTracker.getInstance(); fadeTracker.trackFadeOut(FadeKind.ROLLOVER, SubstanceTabbedPaneUI.this.tabPane, this.prevRolledOver, true, new TabRepaintCallback( SubstanceTabbedPaneUI.this.tabPane, this.prevRolledOver)); if (SubstanceCoreUtilities.getTabCloseCallback(e, tabPane, this.prevRolledOver) != null) { tabPane.setToolTipTextAt(this.prevRolledOver, null); } } this.prevRolledOver = -1; } /* * (non-Javadoc) * * @see * java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent) */ public void mouseReleased(final MouseEvent e) { // enhancement 307 - moving the tab close to be on mouse release // and not on mouse press. final int tabIndex = SubstanceTabbedPaneUI.this.tabForCoordinate( SubstanceTabbedPaneUI.this.tabPane, e.getX(), e.getY()); // check that the mouse release is on the same tab as // mouse press, and that the tab has close button if (SubstanceCoreUtilities.hasCloseButton( SubstanceTabbedPaneUI.this.tabPane, tabIndex) && (tabIndex == this.tabOfPressedCloseButton)) { SwingUtilities.invokeLater(new Runnable() { public void run() { if ((tabIndex >= 0) && SubstanceTabbedPaneUI.this.tabPane .isEnabledAt(tabIndex)) { Rectangle rect = new Rectangle(); rect = SubstanceTabbedPaneUI.this.getTabBounds( tabIndex, rect); Rectangle close = SubstanceTabbedPaneUI.this .getCloseButtonRectangleForEvents(tabIndex, rect.x, rect.y, rect.width, rect.height); // System.out.println("press " + close + " " // + e.getPoint()); if (close.contains(e.getPoint())) { TabCloseCallback closeCallback = SubstanceCoreUtilities .getTabCloseCallback( e, SubstanceTabbedPaneUI.this.tabPane, tabIndex); TabCloseKind tabCloseKind = (closeCallback == null) ? TabCloseKind.THIS : closeCallback .onCloseButtonClick( SubstanceTabbedPaneUI.this.tabPane, tabIndex, e); SubstanceTabbedPaneUI.this.tryCloseTabs( tabIndex, tabCloseKind); } } } }); this.tabOfPressedCloseButton = -1; } } } /** * Creates the new UI delegate. */ public SubstanceTabbedPaneUI() { super(); this.prevStateMap = new HashMap(); this.nextStateMap = new HashMap(); this.currSelectedIndex = -1; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTabbedPaneUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); // Install listener to repaint the tabbed pane // on mouse move (for rollover effects). this.substanceRolloverHandler = new MouseRolloverHandler(); this.tabPane.addMouseMotionListener(this.substanceRolloverHandler); this.tabPane.addMouseListener(this.substanceRolloverHandler); // Add container listener to wire property change listener // on each tab in the tabbed pane. this.substanceContainerListener = new TabbedContainerListener(); this.substanceContainerListener.trackExistingTabs(); for (int i = 0; i < this.tabPane.getTabCount(); i++) { Component tabComp = this.tabPane.getComponentAt(i); if (SubstanceCoreUtilities.isTabModified(tabComp)) { // TabPulseTracker.update(this.tabPane, tabComp); long fadeInstanceId = FadeTracker.getInstance() .trackFadeLooping( ModifiedFadeStep.MARKED_MODIFIED_FADE_KIND, new LafConstants.AnimationKind( new ModifiedFadeStep(), "modified"), this.tabPane, i, false, this.getCallback(i), -1, true); this.fadeModifiedIds.put(tabComp, fadeInstanceId); } } this.tabPane.addContainerListener(this.substanceContainerListener); this.substanceSelectionListener = new ChangeListener() { public void stateChanged(ChangeEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (SubstanceTabbedPaneUI.this.tabPane == null) return; int selected = SubstanceTabbedPaneUI.this.tabPane .getSelectedIndex(); FadeTracker fadeTracker = FadeTracker.getInstance(); // fix for issue 437 - track the selection change, // fading out the previously selected tab if ((currSelectedIndex >= 0) && (currSelectedIndex < SubstanceTabbedPaneUI.this.tabPane .getTabCount()) && SubstanceTabbedPaneUI.this.tabPane .isEnabledAt(currSelectedIndex)) { fadeTracker.trackFadeOut(FadeKind.SELECTION, SubstanceTabbedPaneUI.this.tabPane, currSelectedIndex, true, new TabRepaintCallback( SubstanceTabbedPaneUI.this.tabPane, currSelectedIndex)); } currSelectedIndex = selected; if ((selected >= 0) && (selected < SubstanceTabbedPaneUI.this.tabPane .getTabCount()) && SubstanceTabbedPaneUI.this.tabPane .isEnabledAt(selected)) { fadeTracker.trackFadeIn(FadeKind.SELECTION, SubstanceTabbedPaneUI.this.tabPane, selected, true, new TabRepaintCallback( SubstanceTabbedPaneUI.this.tabPane, selected)); } } }); } }; this.tabPane.getModel().addChangeListener( this.substanceSelectionListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTabbedPaneUI#uninstallListeners() */ @Override protected void uninstallListeners() { super.uninstallListeners(); if (this.substanceRolloverHandler != null) { this.tabPane .removeMouseMotionListener(this.substanceRolloverHandler); this.tabPane.removeMouseListener(this.substanceRolloverHandler); this.substanceRolloverHandler = null; } if (this.substanceContainerListener != null) { for (Map.Entry> entry : this.substanceContainerListener.listeners .entrySet()) { Component comp = entry.getKey(); // System.out.println(this.containerListener.hashCode() +" // removing all for" + comp.hashCode()); for (PropertyChangeListener pcl : entry.getValue()) { comp.removePropertyChangeListener(pcl); } } this.substanceContainerListener.listeners.clear(); this.tabPane .removeContainerListener(this.substanceContainerListener); this.substanceContainerListener = null; } this.tabPane.getModel().removeChangeListener( this.substanceSelectionListener); this.substanceSelectionListener = null; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTabbedPaneUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); this.fadeModifiedIds = new HashMap(); int selectedIndex = this.tabPane.getSelectedIndex(); if (selectedIndex >= 0) { this.prevStateMap.put(selectedIndex, ComponentState.SELECTED); } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTabbedPaneUI#uninstallDefaults() */ @Override protected void uninstallDefaults() { this.fadeModifiedIds.clear(); super.uninstallDefaults(); } /** * Retrieves tab background. * * @param tabPane * Tabbed pane. * @param width * Tab width. * @param height * Tab height. * @param isSelected * Indication whether the tab is selected. * @param cyclePos * Tab cycle position (for rollover effects). * @param tabPlacement * Tab placement. * @param side * Tab open side. * @param colorScheme * Color scheme for coloring the background. * @param colorScheme2 * Second color scheme for coloring the background. * @param borderScheme * Color scheme for coloring the border. * @param borderScheme2 * Second color scheme for coloring the border. * @param paintOnlyBorder * If true, only the border will be painted. * @return Tab background of specified parameters. */ private static BufferedImage getTabBackground(JTabbedPane tabPane, int width, int height, boolean isSelected, float cyclePos, int tabPlacement, SubstanceColorScheme colorScheme, SubstanceColorScheme colorScheme2, SubstanceColorScheme borderScheme, SubstanceColorScheme borderScheme2, boolean paintOnlyBorder) { SubstanceGradientPainter gradientPainter = SubstanceCoreUtilities .getGradientPainter(tabPane); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(tabPane); SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(tabPane); int borderDelta = (int) Math.ceil(2.0 * SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane))); int borderInsets = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane)) / 2.0); int dy = 2 + borderDelta; Set straightSides = EnumSet.of(Side.BOTTOM); int cornerRadius = height / 3; if (shaper instanceof ClassicButtonShaper) { cornerRadius = (int) SubstanceSizeUtils .getClassicButtonCornerRadius(SubstanceSizeUtils .getComponentFontSize(tabPane)); if ((tabPlacement == TOP) || (tabPlacement == BOTTOM)) width -= 1; else height -= 1; } GeneralPath contour = SubstanceOutlineUtilities.getBaseOutline(width, height + dy, cornerRadius, straightSides, borderInsets); BufferedImage result = SubstanceCoreUtilities.getBlankImage(width, height); Graphics2D resGraphics = result.createGraphics(); if (!paintOnlyBorder) { gradientPainter.paintContourBackground(resGraphics, tabPane, width, height + dy, contour, false, colorScheme, colorScheme2, cyclePos, true, colorScheme != colorScheme2); } int borderThickness = (int) SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane)); GeneralPath contourInner = borderPainter.isPaintingInnerContour() ? SubstanceOutlineUtilities .getBaseOutline(width, height + dy, cornerRadius - borderThickness, straightSides, borderThickness + borderInsets) : null; borderPainter.paintBorder(resGraphics, tabPane, width, height + dy, contour, contourInner, borderScheme, borderScheme2, cyclePos, borderScheme != borderScheme2); resGraphics.dispose(); return result; } /** * Retrieves tab background that will be shown on the screen. Unlike * {@link #getTabBackground(JTabbedPane, int, int, boolean, float, int, SubstanceColorScheme, SubstanceColorScheme, SubstanceColorScheme, SubstanceColorScheme, boolean)} * , the result is rotated as necessary (for {@link SwingConstants#LEFT} and * {@link SwingConstants#RIGHT} placement) and blended for selected tabs. * * @param tabPane * Tabbed pane. * @param tabIndex * Tab index. * @param width * Tab width. * @param height * Tab height. * @param isSelected * Indication whether the tab is selected. * @param cyclePos * Tab cycle position (for rollover effects). * @param tabPlacement * Tab placement. * @param side * Tab open side. * @param colorScheme * Color scheme for coloring the background. * @param colorScheme2 * Second color scheme for coloring the background. * @param borderScheme * Color scheme for coloring the border. * @param borderScheme2 * Second color scheme for coloring the border. * @param paintOnlyBorder * If true, only the border will be painted. * @return Tab background of specified parameters. */ private static BufferedImage getFinalTabBackgroundImage( JTabbedPane tabPane, int tabIndex, int width, int height, boolean isSelected, float cyclePos, int tabPlacement, SubstanceConstants.Side side, SubstanceColorScheme colorScheme, SubstanceColorScheme colorScheme2, SubstanceColorScheme borderScheme, SubstanceColorScheme borderScheme2) { SubstanceGradientPainter gradientPainter = SubstanceCoreUtilities .getGradientPainter(tabPane); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(tabPane); SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(tabPane); Component tabComponent = tabPane.getComponentAt(tabIndex); Color tabColor = (tabComponent != null) ? tabComponent.getBackground() : tabPane.getBackground(); HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height, isSelected, cyclePos, tabPlacement, gradientPainter .getDisplayName(), borderPainter.getDisplayName(), shaper.getDisplayName(), tabPlacement == SwingConstants.BOTTOM, side.name(), colorScheme.getDisplayName(), colorScheme2 .getDisplayName(), borderScheme.getDisplayName(), borderScheme2.getDisplayName(), tabColor); SubstanceSkin skin = SubstanceCoreUtilities.getSkin(tabPane); BufferedImage result = SubstanceTabbedPaneUI.backgroundMap.get(key); if (result == null) { BufferedImage backgroundImage = null; switch (tabPlacement) { case BOTTOM: return SubstanceImageCreator.getRotated( getFinalTabBackgroundImage(tabPane, tabIndex, width, height, isSelected, cyclePos, SwingConstants.TOP, side, colorScheme, colorScheme2, borderScheme, borderScheme2), 2); case TOP: case LEFT: case RIGHT: backgroundImage = SubstanceTabbedPaneUI.getTabBackground( tabPane, width, height, isSelected, cyclePos, SwingConstants.TOP, colorScheme, colorScheme2, borderScheme, borderScheme2, false); if (isSelected) { int fw = backgroundImage.getWidth(); int fh = backgroundImage.getHeight(); BufferedImage fade = SubstanceCoreUtilities.getBlankImage( fw, fh); Graphics2D fadeGraphics = fade.createGraphics(); fadeGraphics.setColor(tabColor); fadeGraphics.fillRect(0, 0, fw, fh); if (skin.getWatermark() != null) skin.getWatermark().drawWatermarkImage(fadeGraphics, tabPane, 0, 0, fw, fh); fadeGraphics.drawImage(SubstanceTabbedPaneUI .getTabBackground(tabPane, width, height, isSelected, cyclePos, tabPlacement, colorScheme, colorScheme2, borderScheme, borderScheme2, true), 0, 0, null); backgroundImage = SubstanceCoreUtilities .blendImagesVertical(backgroundImage, fade, skin .getSelectedTabFadeStart(), skin .getSelectedTabFadeEnd()); } } SubstanceTabbedPaneUI.backgroundMap.put(key, backgroundImage); } return backgroundMap.get(key); } /** * Retrieves the image of the close button. * * @param tabPane * Tabbed pane. * @param width * Close button width. * @param height * Close button height. * @param cyclePos * Tab cycle position (for rollover effects). * @param toPaintBorder * Indication whether the button background (including contour) * needs to be painted. * @param fillScheme * Color scheme for coloring the background. * @param fillScheme2 * Second color scheme for coloring the background. * @param markScheme * Color scheme for painting the close mark. * @param markScheme2 * Second color scheme for painting the close mark. * @return Image of the close button of specified parameters. */ private static BufferedImage getCloseButtonImage(JTabbedPane tabPane, int width, int height, float cyclePos, boolean toPaintBorder, SubstanceColorScheme fillScheme, SubstanceColorScheme fillScheme2, SubstanceColorScheme markScheme, SubstanceColorScheme markScheme2) { SubstanceGradientPainter gradientPainter = SubstanceCoreUtilities .getGradientPainter(tabPane); if (gradientPainter == null) return null; HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height, toPaintBorder, cyclePos, gradientPainter.getDisplayName(), fillScheme.getDisplayName(), fillScheme2.getDisplayName(), markScheme.getDisplayName(), markScheme2.getDisplayName()); BufferedImage result = SubstanceTabbedPaneUI.closeButtonMap.get(key); if (result == null) { result = SubstanceCoreUtilities.getBlankImage(width, height); Graphics2D finalGraphics = (Graphics2D) result.getGraphics(); if (toPaintBorder) { GeneralPath contour = SubstanceOutlineUtilities.getBaseOutline( width, height, 1, null); gradientPainter.paintContourBackground(finalGraphics, tabPane, width, height, contour, false, fillScheme, fillScheme2, cyclePos, true, fillScheme != fillScheme2); // finalGraphics.drawImage(background, 0, 0, null); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(tabPane); finalGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); borderPainter.paintBorder(finalGraphics, tabPane, width, height, contour, null, markScheme, markScheme2, cyclePos, markScheme != markScheme2); } finalGraphics.setStroke(new BasicStroke(SubstanceSizeUtils .getTabCloseButtonStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane)))); int delta = (int) (Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane)))); if (delta % 2 != 0) delta--; int iconSize = width - delta; if (markScheme == markScheme2) { // little optimization cyclePos = 0.0f; } if (cyclePos > 0.0) { Icon closeIcon2 = SubstanceImageCreator.getCloseIcon(iconSize, markScheme2, markScheme2); closeIcon2.paintIcon(tabPane, finalGraphics, delta / 2, delta / 2); } if (cyclePos < 1.0) { Icon closeIcon = SubstanceImageCreator.getCloseIcon(iconSize, markScheme, markScheme); finalGraphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 1.0f - cyclePos)); closeIcon.paintIcon(tabPane, finalGraphics, delta / 2, delta / 2); } SubstanceTabbedPaneUI.closeButtonMap.put(key, result); } return result; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTabbedPaneUI#paintTabBackground(java.awt. * Graphics, int, int, int, int, int, int, boolean) */ @Override protected void paintTabBackground(Graphics g, int tabPlacement, final int tabIndex, final int x, final int y, int w, int h, boolean isSelected) { Graphics2D graphics = (Graphics2D) g.create(); graphics.setComposite(TransitionLayout.getAlphaComposite(this.tabPane, g)); ComponentState prevState = this.getPrevTabState(tabIndex); ComponentState currState = this.getTabState(tabIndex); if (prevState == null) prevState = currState; SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.tabPane, tabIndex, ColorSchemeAssociationKind.TAB, currState); SubstanceColorScheme colorScheme2 = SubstanceColorSchemeUtilities .getColorScheme(this.tabPane, tabIndex, ColorSchemeAssociationKind.TAB, prevState); SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities .getColorScheme(this.tabPane, tabIndex, ColorSchemeAssociationKind.TAB_BORDER, currState); SubstanceColorScheme borderScheme2 = SubstanceColorSchemeUtilities .getColorScheme(this.tabPane, tabIndex, ColorSchemeAssociationKind.TAB_BORDER, prevState); SubstanceColorScheme markScheme = SubstanceColorSchemeUtilities .getColorScheme(this.tabPane, tabIndex, ColorSchemeAssociationKind.MARK, currState); SubstanceColorScheme markScheme2 = SubstanceColorSchemeUtilities .getColorScheme(this.tabPane, tabIndex, ColorSchemeAssociationKind.MARK, prevState); // fix for defect 138 graphics.clip(new Rectangle(x, y, w, h)); boolean isRollover = (this.getRolloverTab() == tabIndex); boolean isEnabled = this.tabPane.isEnabledAt(tabIndex); boolean hasActivePresence = isSelected || (isRollover && isEnabled); float cyclePos = (isRollover && isEnabled) ? 0.5f : 0.0f; // check if have windowModified property Component comp = this.tabPane.getComponentAt(tabIndex); boolean isWindowModified = SubstanceCoreUtilities.isTabModified(comp); boolean toMarkModifiedCloseButton = SubstanceCoreUtilities .toAnimateCloseIconOfModifiedTab(this.tabPane, tabIndex); if (isWindowModified && isEnabled && !toMarkModifiedCloseButton) { colorScheme2 = SubstanceColorSchemeUtilities.YELLOW; colorScheme = SubstanceColorSchemeUtilities.ORANGE; cyclePos = FadeTracker.getInstance().getFade(this.tabPane, tabIndex, ModifiedFadeStep.MARKED_MODIFIED_FADE_KIND); hasActivePresence = true; } // see if need to use fade animation. Important - don't do it // on pulsating tabs. FadeTracker fadeTracker = FadeTracker.getInstance(); if (!isWindowModified) { FadeState fadeState = fadeTracker.getFadeState(this.tabPane, tabIndex, FadeKind.ROLLOVER); if (fadeState != null) { hasActivePresence = true; cyclePos = fadeState.getFadePosition(); if (fadeState.isFadingIn()) { SubstanceColorScheme temp = colorScheme; colorScheme = colorScheme2; colorScheme2 = temp; temp = borderScheme; borderScheme = borderScheme2; borderScheme2 = temp; temp = markScheme; markScheme = markScheme2; markScheme2 = temp; } } } BufferedImage backgroundImage = SubstanceTabbedPaneUI .getFinalTabBackgroundImage(this.tabPane, tabIndex, w, h, isSelected, cyclePos, tabPlacement, SubstanceConstants.Side.BOTTOM, colorScheme, colorScheme2, borderScheme, borderScheme2); float finalAlpha = (backgroundImage == null) ? 0.0f : 1.0f; if (backgroundImage != null) { if (!hasActivePresence) finalAlpha = 0.5f; } ComponentState state = this.getTabState(tabIndex); finalAlpha *= SubstanceColorSchemeUtilities.getAlpha(this.tabPane .getComponentAt(tabIndex), state); graphics.setComposite(TransitionLayout.getAlphaComposite(this.tabPane, finalAlpha, g)); graphics.drawImage(backgroundImage, x, y, null); // Check if requested to paint close buttons. if (SubstanceCoreUtilities.hasCloseButton(this.tabPane, tabIndex) && isEnabled) { float alpha = (isSelected || isRollover) ? 1.0f : 0.0f; if (!isSelected && fadeTracker.isTracked(this.tabPane, tabIndex, FadeKind.ROLLOVER)) { alpha = fadeTracker.getFade(this.tabPane, tabIndex, FadeKind.ROLLOVER); } if (alpha > 0.0) { graphics.setComposite(TransitionLayout.getAlphaComposite( this.tabPane, finalAlpha * alpha, g)); // paint close button Rectangle orig = this.getCloseButtonRectangleForDraw(tabIndex, x, y, w, h); boolean toPaintCloseBorder = false; if (isRollover) { if (this.substanceMouseLocation != null) { Rectangle bounds = new Rectangle(); bounds = this.getTabBounds(tabIndex, bounds); if (toRotateTabsOnPlacement(tabPlacement)) { bounds = new Rectangle(bounds.x, bounds.y, bounds.height, bounds.width); } Rectangle rect = this.getCloseButtonRectangleForEvents( tabIndex, bounds.x, bounds.y, bounds.width, bounds.height); // System.out.println("paint " + bounds + " " + rect +" // " // + mouseLocation); if (rect.contains(this.substanceMouseLocation)) { toPaintCloseBorder = true; } } } if (isWindowModified && isEnabled && toMarkModifiedCloseButton) { colorScheme2 = SubstanceColorSchemeUtilities.YELLOW; colorScheme = SubstanceColorSchemeUtilities.ORANGE; cyclePos = FadeTracker.getInstance().getFade(this.tabPane, tabIndex, ModifiedFadeStep.MARKED_MODIFIED_FADE_KIND); } // System.out.println("Close tab icon \n\t" + // SubstanceCoreUtilities.getSchemeId(colorScheme) + "\n\t" + // SubstanceCoreUtilities.getSchemeId(colorScheme2) + "\n\t" + // cyclePos + ":" + // alpha + "\n\t" + // prevState.name() + "->" + currState.name()); BufferedImage closeButtonImage = SubstanceTabbedPaneUI .getCloseButtonImage(this.tabPane, orig.width, orig.height, cyclePos, toPaintCloseBorder, colorScheme, colorScheme2, markScheme, markScheme2); graphics.drawImage(closeButtonImage, orig.x, orig.y, null); } } graphics.dispose(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTabbedPaneUI#paintFocusIndicator(java.awt * .Graphics, int, java.awt.Rectangle[], int, java.awt.Rectangle, * java.awt.Rectangle, boolean) */ @Override protected void paintFocusIndicator(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect, boolean isSelected) { // empty to remove Basic functionality } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTabbedPaneUI#paintTabBorder(java.awt.Graphics * , int, int, int, int, int, int, boolean) */ @Override protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { // empty to remove Basic functionality } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTabbedPaneUI#createScrollButton(int) */ @Override protected JButton createScrollButton(final int direction) { SubstanceScrollButton ssb = new SubstanceScrollButton(direction); Icon icon = new TransitionAwareIcon(ssb, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { // fix for defect 279 - tab pane might not yet have the // font installed. int fontSize = SubstanceSizeUtils .getComponentFontSize(tabPane); return SubstanceImageCreator.getArrowIcon(fontSize, direction, scheme); } }, "substance.tabbedpane.scroll." + direction); ssb.setIcon(icon); return ssb; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTabbedPaneUI#calculateTabHeight(int, * int, int) */ @Override protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight) { boolean toSwap = toRotateTabsOnPlacement(tabPlacement); if (toSwap) return this.getTabExtraWidth(tabPlacement, tabIndex) + super.calculateTabWidth(tabPlacement, tabIndex, this .getFontMetrics()); return super.calculateTabHeight(tabPlacement, tabIndex, fontHeight); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTabbedPaneUI#calculateTabWidth(int, int, * java.awt.FontMetrics) */ @Override protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) { boolean toSwap = toRotateTabsOnPlacement(tabPlacement); if (toSwap) return super.calculateTabHeight(tabPlacement, tabIndex, metrics .getHeight()); int result = this.getTabExtraWidth(tabPlacement, tabIndex) + super.calculateTabWidth(tabPlacement, tabIndex, metrics); return result; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTabbedPaneUI#calculateMaxTabHeight(int) */ @Override protected int calculateMaxTabHeight(int tabPlacement) { if (toRotateTabsOnPlacement(tabPlacement)) return super.calculateMaxTabHeight(tabPlacement); int result = 0; for (int i = 0; i < this.tabPane.getTabCount(); i++) result = Math.max(result, this.calculateTabHeight(tabPlacement, i, this.getFontMetrics().getHeight())); return result; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTabbedPaneUI#getTabRunOverlay(int) */ @Override protected int getTabRunOverlay(int tabPlacement) { boolean toSwap = this.toRotateTabsOnPlacement(tabPlacement); if (toSwap) return super.getTabRunOverlay(tabPlacement); return 0; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTabbedPaneUI#paintTab(java.awt.Graphics, * int, java.awt.Rectangle[], int, java.awt.Rectangle, java.awt.Rectangle) */ @Override protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect) { boolean toSwap = toRotateTabsOnPlacement(tabPlacement); if (toSwap) { Graphics2D tempG = (Graphics2D) g.create(); Rectangle tabRect = rects[tabIndex]; Rectangle correctRect = new Rectangle(tabRect.x, tabRect.y, tabRect.height, tabRect.width); if (tabPlacement == SwingConstants.LEFT) { // rotate 90 degrees counterclockwise for LEFT orientation tempG.rotate(-Math.PI / 2, tabRect.x, tabRect.y); tempG.translate(-tabRect.height, 0); } else { // rotate 90 degrees clockwise for RIGHT orientation tempG.rotate(Math.PI / 2, tabRect.x, tabRect.y); tempG.translate(0, -tabRect.getWidth()); } tempG.setColor(Color.red); rects[tabIndex] = correctRect; super.paintTab(tempG, tabPlacement, rects, tabIndex, iconRect, textRect); rects[tabIndex] = tabRect; tempG.dispose(); } else { super .paintTab(g, tabPlacement, rects, tabIndex, iconRect, textRect); } } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTabbedPaneUI#paintTabArea(java.awt.Graphics, * int, int) */ @Override protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex) { // Insets insets = tabPane.getInsets(); // // int x = insets.left; // int y = insets.top; int width = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth); if ((tabPlacement == SwingConstants.TOP) || (tabPlacement == SwingConstants.BOTTOM)) width = Math.max(width, tabPane.getWidth()); // - insets.left // - insets.right); int height = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight); if (toRotateTabsOnPlacement(tabPlacement)) height = Math.max(height, tabPane.getHeight()); // - insets.top // - insets.bottom); // restrict the painting to the tab area only Graphics2D g2d = (Graphics2D) g.create(0, 0, width, height); BackgroundPaintingUtils.update(g2d, this.tabPane, true); g2d.dispose(); super.paintTabArea(g, tabPlacement, selectedIndex); } /** * Retrieves the close button rectangle for drawing purposes. * * @param tabIndex * Tab index. * @param x * X coordinate of the tab. * @param y * Y coordinate of the tab. * @param width * The tab width. * @param height * The tab height. * @return The close button rectangle. */ protected Rectangle getCloseButtonRectangleForDraw(int tabIndex, int x, int y, int width, int height) { int dimension = SubstanceCoreUtilities.getCloseButtonSize(this.tabPane, tabIndex); int borderDelta = (int) Math.ceil(3.0 * SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(this.tabPane))); int xs = this.tabPane.getComponentOrientation().isLeftToRight() ? (x + width - dimension - borderDelta) : (x + borderDelta); int ys = y + (height - dimension) / 2 + 1; return new Rectangle(xs, ys, dimension, dimension); } /** * Retrieves the close button rectangle for event handling. * * @param tabIndex * Tab index. * @param x * X coordinate of the tab. * @param y * Y coordinate of the tab. * @param w * The tab width. * @param h * The tab height. * @return The close button rectangle. */ protected Rectangle getCloseButtonRectangleForEvents(int tabIndex, int x, int y, int w, int h) { int tabPlacement = this.tabPane.getTabPlacement(); boolean toSwap = toRotateTabsOnPlacement(tabPlacement); if (!toSwap) { return this.getCloseButtonRectangleForDraw(tabIndex, x, y, w, h); } int dimension = SubstanceCoreUtilities.getCloseButtonSize(this.tabPane, tabIndex); Point2D transCorner = null; Rectangle rectForDraw = this.getCloseButtonRectangleForDraw(tabIndex, x, y, h, w); if (tabPlacement == SwingConstants.LEFT) { AffineTransform trans = new AffineTransform(); trans.rotate(-Math.PI / 2, x, y); trans.translate(-h, 0); Point2D.Double origCorner = new Point2D.Double(rectForDraw .getMaxX(), rectForDraw.getMinY()); transCorner = trans.transform(origCorner, null); } else { // rotate 90 degrees clockwise for RIGHT orientation AffineTransform trans = new AffineTransform(); trans.rotate(Math.PI / 2, x, y); trans.translate(0, -w); Point2D.Double origCorner = new Point2D.Double(rectForDraw .getMinX(), rectForDraw.getMaxY()); transCorner = trans.transform(origCorner, null); } return new Rectangle((int) transCorner.getX(), (int) transCorner.getY(), dimension, dimension); } /** * Implementation of the fade tracker callback that repaints a single tab. * * @author Kirill Grouchnikov */ protected class TabRepaintCallback extends UIThreadFadeTrackerAdapter { /** * The associated tabbed pane. */ protected JTabbedPane tabbedPane; /** * The associated tab index. */ protected int tabIndex; /** * Creates new tab repaint callback. * * @param tabPane * The associated tabbed pane. * @param tabIndex * The associated tab index. */ public TabRepaintCallback(JTabbedPane tabPane, int tabIndex) { this.tabbedPane = tabPane; this.tabIndex = tabIndex; } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.utils.FadeTracker$FadeTrackerCallback#fadePerformed * (org.jvnet.lafwidget.utils.FadeTracker.FadeKind, float) */ @Override public void fadePerformed(FadeKind fadeKind, float fade) { if ((SubstanceTabbedPaneUI.this.tabPane == this.tabbedPane) && (this.tabIndex < this.tabbedPane.getTabCount())) { SubstanceTabbedPaneUI.this.nextStateMap.put(this.tabIndex, SubstanceTabbedPaneUI.this.getTabState(this.tabIndex)); } this.repaintTab(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.animation.FadeTrackerAdapter#fadeEnded(org.jvnet * .lafwidget.animation.FadeKind) */ @Override public void fadeEnded(FadeKind fadeKind) { if ((SubstanceTabbedPaneUI.this.tabPane == this.tabbedPane) && (this.tabIndex < this.tabbedPane.getTabCount())) { SubstanceTabbedPaneUI.this.prevStateMap.put(this.tabIndex, SubstanceTabbedPaneUI.this.getTabState(this.tabIndex)); SubstanceTabbedPaneUI.this.nextStateMap.put(this.tabIndex, SubstanceTabbedPaneUI.this.getTabState(this.tabIndex)); // System.out.println(tabIndex + "->" // + prevStateMap.get(tabIndex).name()); } this.repaintTab(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.animation.FadeTrackerAdapter#fadeReversed(org * .jvnet.lafwidget.animation.FadeKind, boolean, float) */ @Override public void fadeReversed(FadeKind fadeKind, boolean isFadingIn, float fadeCycle10) { if ((SubstanceTabbedPaneUI.this.tabPane == this.tabbedPane) && (this.tabIndex < this.tabbedPane.getTabCount())) { ComponentState nextState = SubstanceTabbedPaneUI.this.nextStateMap .get(this.tabIndex); SubstanceTabbedPaneUI.this.prevStateMap.put(this.tabIndex, nextState); // System.out.println(tabIndex + "->" // + prevStateMap.get(tabIndex).name()); } this.repaintTab(); } /** * Repaints the relevant tab. */ protected void repaintTab() { SwingUtilities.invokeLater(new Runnable() { public void run() { if (SubstanceTabbedPaneUI.this.tabPane == null) { // may happen if the LAF was switched in the meantime return; } SubstanceTabbedPaneUI.this.ensureCurrentLayout(); int tabCount = SubstanceTabbedPaneUI.this.tabPane .getTabCount(); if ((tabCount > 0) && (TabRepaintCallback.this.tabIndex < tabCount) && (TabRepaintCallback.this.tabIndex < SubstanceTabbedPaneUI.this.rects.length)) { // need to retrieve the tab rectangle since the tabs // can be moved while animating (especially when the // current layout is SCROLL_LAYOUT) Rectangle rect = SubstanceTabbedPaneUI.this .getTabBounds( SubstanceTabbedPaneUI.this.tabPane, TabRepaintCallback.this.tabIndex); // System.out.println("Repainting " + tabIndex); SubstanceTabbedPaneUI.this.tabPane.repaint(rect); } } }); } } /** * Ensures the current layout. */ protected void ensureCurrentLayout() { if (!this.tabPane.isValid()) { this.tabPane.validate(); } /* * If tabPane doesn't have a peer yet, the validate() call will silently * fail. We handle that by forcing a layout if tabPane is still invalid. * See bug 4237677. */ if (!this.tabPane.isValid()) { LayoutManager lm = this.tabPane.getLayout(); if (lm instanceof BasicTabbedPaneUI.TabbedPaneLayout) { BasicTabbedPaneUI.TabbedPaneLayout layout = (BasicTabbedPaneUI.TabbedPaneLayout) lm; layout.calculateLayoutInfo(); } else { if (lm instanceof TransitionLayout) { lm = ((TransitionLayout) lm).getDelegate(); if (lm instanceof TabbedPaneLayout) { TabbedPaneLayout layout = (TabbedPaneLayout) lm; layout.calculateLayoutInfo(); } } } } } /** * Returns the repaint callback for the specified tab index. * * @param tabIndex * Tab index. * @return Repaint callback for the specified tab index. */ public FadeTrackerCallback getCallback(int tabIndex) { return new TabRepaintCallback(this.tabPane, tabIndex); } /** * Tries closing tabs based on the specified tab index and tab close kind. * * @param tabIndex * Tab index. * @param tabCloseKind * Tab close kind. */ protected void tryCloseTabs(int tabIndex, TabCloseKind tabCloseKind) { if (tabCloseKind == null) return; if (tabCloseKind == TabCloseKind.NONE) return; if (tabCloseKind == TabCloseKind.ALL_BUT_THIS) { // close all but this Set indexes = new HashSet(); for (int i = 0; i < this.tabPane.getTabCount(); i++) if (i != tabIndex) indexes.add(i); this.tryCloseTabs(indexes); return; } if (tabCloseKind == TabCloseKind.ALL) { // close all Set indexes = new HashSet(); for (int i = 0; i < this.tabPane.getTabCount(); i++) indexes.add(i); this.tryCloseTabs(indexes); return; } this.tryCloseTab(tabIndex); } /** * Tries closing a single tab. * * @param tabIndex * Tab index. */ protected void tryCloseTab(int tabIndex) { Component component = this.tabPane.getComponentAt(tabIndex); Set componentSet = new HashSet(); componentSet.add(component); // check if there's at least one listener // that vetoes the closing boolean isVetoed = false; for (BaseTabCloseListener listener : SubstanceLookAndFeel .getAllTabCloseListeners(this.tabPane)) { if (listener instanceof VetoableTabCloseListener) { VetoableTabCloseListener vetoableListener = (VetoableTabCloseListener) listener; isVetoed = isVetoed || vetoableListener.vetoTabClosing(this.tabPane, component); } if (listener instanceof VetoableMultipleTabCloseListener) { VetoableMultipleTabCloseListener vetoableListener = (VetoableMultipleTabCloseListener) listener; isVetoed = isVetoed || vetoableListener.vetoTabsClosing(this.tabPane, componentSet); } } if (isVetoed) return; for (BaseTabCloseListener listener : SubstanceLookAndFeel .getAllTabCloseListeners(this.tabPane)) { if (listener instanceof TabCloseListener) ((TabCloseListener) listener).tabClosing(this.tabPane, component); if (listener instanceof MultipleTabCloseListener) ((MultipleTabCloseListener) listener).tabsClosing(this.tabPane, componentSet); } this.tabPane.remove(tabIndex); if (this.tabPane.getTabCount() > 0) { this.selectPreviousTab(0); this.selectNextTab(this.tabPane.getSelectedIndex()); } this.tabPane.repaint(); for (BaseTabCloseListener listener : SubstanceLookAndFeel .getAllTabCloseListeners(this.tabPane)) { if (listener instanceof TabCloseListener) ((TabCloseListener) listener) .tabClosed(this.tabPane, component); if (listener instanceof MultipleTabCloseListener) ((MultipleTabCloseListener) listener).tabsClosed(this.tabPane, componentSet); } } /** * Tries closing the specified tabs. * * @param tabIndexes * Tab indexes. */ protected void tryCloseTabs(Set tabIndexes) { Set componentSet = new HashSet(); for (int tabIndex : tabIndexes) { componentSet.add(this.tabPane.getComponentAt(tabIndex)); } // check if there's at least one listener // that vetoes the closing boolean isVetoed = false; for (BaseTabCloseListener listener : SubstanceLookAndFeel .getAllTabCloseListeners(this.tabPane)) { if (listener instanceof VetoableMultipleTabCloseListener) { VetoableMultipleTabCloseListener vetoableListener = (VetoableMultipleTabCloseListener) listener; isVetoed = isVetoed || vetoableListener.vetoTabsClosing(this.tabPane, componentSet); } } if (isVetoed) return; for (BaseTabCloseListener listener : SubstanceLookAndFeel .getAllTabCloseListeners(this.tabPane)) { if (listener instanceof MultipleTabCloseListener) ((MultipleTabCloseListener) listener).tabsClosing(this.tabPane, componentSet); } for (Component toRemove : componentSet) { this.tabPane.remove(toRemove); } if (this.tabPane.getTabCount() > 0) { this.selectPreviousTab(0); this.selectNextTab(this.tabPane.getSelectedIndex()); } this.tabPane.repaint(); for (BaseTabCloseListener listener : SubstanceLookAndFeel .getAllTabCloseListeners(this.tabPane)) { if (listener instanceof MultipleTabCloseListener) ((MultipleTabCloseListener) listener).tabsClosed(this.tabPane, componentSet); } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTabbedPaneUI#getTabLabelShiftX(int, int, * boolean) */ @Override protected int getTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected) { int delta = 0; if (SubstanceCoreUtilities.hasCloseButton(this.tabPane, tabIndex)) { if (this.tabPane.getComponentOrientation().isLeftToRight()) { delta = 5 - SubstanceCoreUtilities.getCloseButtonSize( this.tabPane, tabIndex); } else { delta = SubstanceCoreUtilities.getCloseButtonSize(this.tabPane, tabIndex) - 5; } } return delta + super.getTabLabelShiftX(tabPlacement, tabIndex, isSelected); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTabbedPaneUI#getTabLabelShiftY(int, int, * boolean) */ @Override protected int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected) { int result = 0; if (tabPlacement == SwingConstants.BOTTOM) result = -1; else result = 1; return result; } /** * Returns extra width for the specified tab. * * @param tabPlacement * Tab placement. * @param tabIndex * Tab index. * @return Extra width for the specified tab. */ protected int getTabExtraWidth(int tabPlacement, int tabIndex) { int extraWidth = 0; SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(this.tabPane); if (shaper instanceof ClassicButtonShaper) extraWidth = (int) (2.0 * SubstanceSizeUtils .getClassicButtonCornerRadius(SubstanceSizeUtils .getComponentFontSize(this.tabPane))); else extraWidth = super.calculateTabHeight(tabPlacement, tabIndex, this .getFontMetrics().getHeight()) / 3; if (SubstanceCoreUtilities.hasCloseButton(this.tabPane, tabIndex) && this.tabPane.isEnabledAt(tabIndex)) { extraWidth += (4 + SubstanceCoreUtilities.getCloseButtonSize( this.tabPane, tabIndex)); } // System.out.println(tabPane.getTitleAt(tabIndex) + ":" + extraWidth); return extraWidth; } /** * Returns the index of the tab currently being rolled-over. * * @return Index of the tab currently being rolled-over. */ public int getRolloverTabIndex() { return this.getRolloverTab(); } /** * Sets new value for tab area insets. * * @param insets * Tab area insets. */ public void setTabAreaInsets(Insets insets) { Insets old = this.tabAreaInsets; this.tabAreaInsets = insets; // Fire a property change event so that the tabbed // pane can revalidate itself LafWidgetUtilities.firePropertyChangeEvent(this.tabPane, "tabAreaInsets", old, tabAreaInsets); } /** * Returns tab area insets. * * @return Tab area insets. */ public Insets getTabAreaInsets() { return this.tabAreaInsets; } /** * Returns the tab rectangle for the specified tab. * * @param tabIndex * Index of a tab. * @return The tab rectangle for the specified parameters. */ public Rectangle getTabRectangle(int tabIndex) { return this.rects[tabIndex]; } /** * Returns the memory usage string. * * @return The memory usage string. */ public static String getMemoryUsage() { StringBuffer sb = new StringBuffer(); sb.append("SubstanceTabbedPaneUI: \n"); sb.append("\t" + SubstanceTabbedPaneUI.backgroundMap.size() + " backgrounds"); return sb.toString(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTabbedPaneUI#shouldPadTabRun(int, int) */ @Override protected boolean shouldPadTabRun(int tabPlacement, int run) { // Don't pad last run return this.runCount > 1 && run < this.runCount - 1; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTabbedPaneUI#createLayoutManager() */ @Override protected LayoutManager createLayoutManager() { if (this.tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { return super.createLayoutManager(); } return new TabbedPaneLayout(); } /** * Layout for the tabbed pane. * * @author Kirill Grouchnikov */ public class TabbedPaneLayout extends BasicTabbedPaneUI.TabbedPaneLayout { /** * Creates a new layout. */ public TabbedPaneLayout() { SubstanceTabbedPaneUI.this.super(); } /* * (non-Javadoc) * * @seejavax.swing.plaf.basic.BasicTabbedPaneUI$TabbedPaneLayout# * normalizeTabRuns(int, int, int, int) */ @Override protected void normalizeTabRuns(int tabPlacement, int tabCount, int start, int max) { // Only normalize the runs for top & bottom; normalizing // doesn't look right for Metal's vertical tabs // because the last run isn't padded and it looks odd to have // fat tabs in the first vertical runs, but slimmer ones in the // last (this effect isn't noticeable for horizontal tabs). if (tabPlacement == TOP || tabPlacement == BOTTOM) { super.normalizeTabRuns(tabPlacement, tabCount, start, max); } } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTabbedPaneUI$TabbedPaneLayout#rotateTabRuns * (int, int) */ @Override protected void rotateTabRuns(int tabPlacement, int selectedRun) { // Don't rotate runs! } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTabbedPaneUI$TabbedPaneLayout#padSelectedTab * (int, int) */ @Override protected void padSelectedTab(int tabPlacement, int selectedIndex) { // Don't pad selected tab } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTabbedPaneUI#getContentBorderInsets(int) */ @Override protected Insets getContentBorderInsets(int tabPlacement) { Insets insets = SubstanceSizeUtils .getTabbedPaneContentInsets(SubstanceSizeUtils .getComponentFontSize(this.tabPane)); TabContentPaneBorderKind kind = SubstanceCoreUtilities .getContentBorderKind(this.tabPane); boolean isDouble = (kind == TabContentPaneBorderKind.DOUBLE_FULL) || (kind == TabContentPaneBorderKind.DOUBLE_PLACEMENT); boolean isPlacement = (kind == TabContentPaneBorderKind.SINGLE_PLACEMENT) || (kind == TabContentPaneBorderKind.DOUBLE_PLACEMENT); int delta = isDouble ? (int) (3.0 * SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane))) : 0; if (isPlacement) { switch (tabPlacement) { case TOP: return new Insets(insets.top + delta, 0, 0, 0); case LEFT: return new Insets(0, insets.left + delta, 0, 0); case RIGHT: return new Insets(0, 0, 0, insets.right + delta); case BOTTOM: return new Insets(0, 0, insets.bottom + delta, 0); } } else { switch (tabPlacement) { case TOP: return new Insets(insets.top + delta, insets.left, insets.bottom, insets.right); case LEFT: return new Insets(insets.top, insets.left + delta, insets.bottom, insets.right); case RIGHT: return new Insets(insets.top, insets.left, insets.bottom, insets.right + delta); case BOTTOM: return new Insets(insets.top, insets.left, insets.bottom + delta, insets.right); } } return insets; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTabbedPaneUI#paintContentBorder(java.awt. * Graphics, int, int) */ @Override protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) { SubstanceColorScheme scheme = SubstanceColorSchemeUtilities .getColorScheme(this.tabPane, selectedIndex, ColorSchemeAssociationKind.TAB, ComponentState.DEFAULT); this.highlight = scheme.isDark() ? SubstanceColorUtilities .getAlphaColor(scheme.getUltraDarkColor(), 100) : scheme .getLightColor(); super.paintContentBorder(g, tabPlacement, selectedIndex); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTabbedPaneUI#paintContentBorderBottomEdge * (java.awt.Graphics, int, int, int, int, int, int) */ @Override protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { TabContentPaneBorderKind kind = SubstanceCoreUtilities .getContentBorderKind(this.tabPane); boolean isDouble = (kind == TabContentPaneBorderKind.DOUBLE_FULL) || (kind == TabContentPaneBorderKind.DOUBLE_PLACEMENT); boolean isPlacement = (kind == TabContentPaneBorderKind.SINGLE_PLACEMENT) || (kind == TabContentPaneBorderKind.DOUBLE_PLACEMENT); if (isPlacement) { if (tabPlacement != SwingConstants.BOTTOM) return; } int ribbonDelta = (int) (2.0 * SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane))); Rectangle selRect = selectedIndex < 0 ? null : this.getTabBounds( selectedIndex, this.calcRect); Graphics2D g2d = (Graphics2D) g.create(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); float strokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane)); int joinKind = BasicStroke.JOIN_ROUND; int capKind = BasicStroke.CAP_BUTT; g2d.setStroke(new BasicStroke(strokeWidth, capKind, joinKind)); int offset = (int) (strokeWidth / 2.0); boolean isUnbroken = (tabPlacement != BOTTOM || selectedIndex < 0 || (selRect.y - 1 > h) || (selRect.x < x || selRect.x > x + w)); x += offset; y += offset; w -= 2 * offset; h -= 2 * offset; // Draw unbroken line if tabs are not on BOTTOM, OR // selected tab is not in run adjacent to content, OR // selected tab is not visible (SCROLL_TAB_LAYOUT) SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities .getColorScheme(this.tabPane, selectedIndex, ColorSchemeAssociationKind.TAB_BORDER, ComponentState.SELECTED); Color darkShadowColor = SubstanceColorUtilities.getMidBorderColor( borderScheme, borderScheme, 0.0); if (isUnbroken) { g2d.setColor(this.highlight); g2d.drawLine(x, y + h - 1, x + w - 1, y + h - 1); } else { // Break line to show visual connection to selected tab SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(this.tabPane); int delta = (shaper instanceof ClassicButtonShaper) ? 1 : 0; int borderInsets = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane)) / 2.0); GeneralPath bottomOutline = new GeneralPath(); bottomOutline.moveTo(x, y + h - 1); bottomOutline.lineTo(selRect.x + borderInsets, y + h - 1); int bumpHeight = super.calculateTabHeight(tabPlacement, 0, SubstanceSizeUtils.getComponentFontSize(this.tabPane)) / 2; bottomOutline.lineTo(selRect.x + borderInsets, y + h + bumpHeight); if (selRect.x + selRect.width < x + w - 1) { int selectionEndX = selRect.x + selRect.width - delta - 1 - borderInsets; bottomOutline.lineTo(selectionEndX, y + h - 1 + bumpHeight); bottomOutline.lineTo(selectionEndX, y + h - 1); bottomOutline.lineTo(x + w - 1, y + h - 1); } g2d.setPaint(new GradientPaint(x, y + h - 1, darkShadowColor, x, y + h - 1 + bumpHeight, SubstanceColorUtilities .getAlphaColor(darkShadowColor, 0))); g2d.draw(bottomOutline); } if (isDouble) { if (tabPlacement == BOTTOM) { g2d.setColor(this.highlight); // g2d.drawLine(x+1, y + h - 2 - ribbonDelta, x + w - 2, // y + h - 2 - ribbonDelta); g2d.setColor(darkShadowColor); g2d.drawLine(x, y + h - 1 - ribbonDelta, x + w - 1, y + h - 1 - ribbonDelta); } if (tabPlacement == LEFT) { g2d.setPaint(new GradientPaint(x, y + h - 1, darkShadowColor, x + 4 * ribbonDelta, y + h - 1, this.highlight)); g2d.drawLine(x, y + h - 1, x + 4 * ribbonDelta, y + h - 1); } if (tabPlacement == RIGHT) { g2d.setPaint(new GradientPaint(x + w - 1 - 4 * ribbonDelta, y + h - 1, this.highlight, x + w - 1, y + h - 1, darkShadowColor)); g2d.drawLine(x + w - 1 - 4 * ribbonDelta, y + h - 1, x + w - 1, y + h - 1); } } g2d.dispose(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTabbedPaneUI#paintContentBorderLeftEdge(java * .awt.Graphics, int, int, int, int, int, int) */ @Override protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { TabContentPaneBorderKind kind = SubstanceCoreUtilities .getContentBorderKind(this.tabPane); boolean isDouble = (kind == TabContentPaneBorderKind.DOUBLE_FULL) || (kind == TabContentPaneBorderKind.DOUBLE_PLACEMENT); boolean isPlacement = (kind == TabContentPaneBorderKind.SINGLE_PLACEMENT) || (kind == TabContentPaneBorderKind.DOUBLE_PLACEMENT); if (isPlacement) { if (tabPlacement != SwingConstants.LEFT) return; } int ribbonDelta = (int) (3.0 * SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane))); Rectangle selRect = selectedIndex < 0 ? null : this.getTabBounds( selectedIndex, this.calcRect); Graphics2D g2d = (Graphics2D) g.create(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); float strokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane)); int joinKind = BasicStroke.JOIN_ROUND; int capKind = BasicStroke.CAP_BUTT; g2d.setStroke(new BasicStroke(strokeWidth, capKind, joinKind)); int offset = (int) (strokeWidth / 2.0); boolean isUnbroken = (tabPlacement != LEFT || selectedIndex < 0 || (selRect.x + selRect.width + 1 < x) || (selRect.y < y || selRect.y > y + h)); x += offset; y += offset; // w -= 2 * offset; h -= 2 * offset; // Draw unbroken line if tabs are not on LEFT, OR // selected tab is not in run adjacent to content, OR // selected tab is not visible (SCROLL_TAB_LAYOUT) SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities .getColorScheme(this.tabPane, selectedIndex, ColorSchemeAssociationKind.TAB_BORDER, ComponentState.SELECTED); Color darkShadowColor = SubstanceColorUtilities.getMidBorderColor( borderScheme, borderScheme, 0.0); if (isUnbroken) { g2d.setColor(this.highlight); g2d.drawLine(x, y, x, y + h); } else { // Break line to show visual connection to selected tab SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(this.tabPane); int delta = (shaper instanceof ClassicButtonShaper) ? 1 : 0; int borderInsets = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane)) / 2.0); GeneralPath leftOutline = new GeneralPath(); leftOutline.moveTo(x, y); leftOutline.lineTo(x, selRect.y + borderInsets); int bumpWidth = super.calculateTabHeight(tabPlacement, 0, SubstanceSizeUtils.getComponentFontSize(this.tabPane)) / 2; leftOutline.lineTo(x - bumpWidth, selRect.y + borderInsets); if (selRect.y + selRect.height < y + h) { int selectionEndY = selRect.y + selRect.height - delta - 1 - borderInsets; leftOutline.lineTo(x - bumpWidth, selectionEndY); leftOutline.lineTo(x, selectionEndY); leftOutline.lineTo(x, y + h); } g2d.setPaint(new GradientPaint(x, y, darkShadowColor, x - bumpWidth, y, SubstanceColorUtilities.getAlphaColor( darkShadowColor, 0))); g2d.draw(leftOutline); } if (isDouble) { if (tabPlacement == LEFT) { g2d.setColor(darkShadowColor); g2d.drawLine(x + ribbonDelta, y, x + ribbonDelta, y + h); // g2d.setColor(this.highlight); // g2d.drawLine(x + 1 + ribbonDelta, y + 1, x + 1 + ribbonDelta, // y + // h - 1); } if (tabPlacement == TOP) { g2d.setPaint(new GradientPaint(x, y, darkShadowColor, x, y + 4 * ribbonDelta, this.highlight)); g2d.drawLine(x, y, x, y + 4 * ribbonDelta); } if (tabPlacement == BOTTOM) { g2d.setPaint(new GradientPaint(x, y + h - 1 - 4 * ribbonDelta, this.highlight, x, y + h - 1, darkShadowColor)); g2d.drawLine(x, y + h - 1 - 4 * ribbonDelta, x, y + h - 1); } } g2d.dispose(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTabbedPaneUI#paintContentBorderRightEdge( * java.awt.Graphics, int, int, int, int, int, int) */ @Override protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { TabContentPaneBorderKind kind = SubstanceCoreUtilities .getContentBorderKind(this.tabPane); boolean isDouble = (kind == TabContentPaneBorderKind.DOUBLE_FULL) || (kind == TabContentPaneBorderKind.DOUBLE_PLACEMENT); boolean isPlacement = (kind == TabContentPaneBorderKind.SINGLE_PLACEMENT) || (kind == TabContentPaneBorderKind.DOUBLE_PLACEMENT); if (isPlacement) { if (tabPlacement != SwingConstants.RIGHT) return; } int ribbonDelta = (int) (3.0 * SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane))); Rectangle selRect = selectedIndex < 0 ? null : this.getTabBounds( selectedIndex, this.calcRect); Graphics2D g2d = (Graphics2D) g.create(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); float strokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane)); int joinKind = BasicStroke.JOIN_ROUND; int capKind = BasicStroke.CAP_BUTT; g2d.setStroke(new BasicStroke(strokeWidth, capKind, joinKind)); int offset = (int) (strokeWidth / 2.0); boolean isUnbroken = (tabPlacement != RIGHT || selectedIndex < 0 || (selRect.x - 1 > w) || (selRect.y < y || selRect.y > y + h)); x += offset; y += offset; w -= 2 * offset; h -= 2 * offset; // Draw unbroken line if tabs are not on RIGHT, OR // selected tab is not in run adjacent to content, OR // selected tab is not visible (SCROLL_TAB_LAYOUT) SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities .getColorScheme(this.tabPane, selectedIndex, ColorSchemeAssociationKind.TAB_BORDER, ComponentState.SELECTED); Color darkShadowColor = SubstanceColorUtilities.getMidBorderColor( borderScheme, borderScheme, 0.0); if (isUnbroken) { g2d.setColor(this.highlight); g2d.drawLine(x + w - 1, y, x + w - 1, y + h); } else { // Break line to show visual connection to selected tab SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(this.tabPane); int delta = (shaper instanceof ClassicButtonShaper) ? 1 : 0; int borderInsets = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane)) / 2.0); GeneralPath rightOutline = new GeneralPath(); rightOutline.moveTo(x + w - 1, y); rightOutline.lineTo(x + w - 1, selRect.y + borderInsets); int bumpWidth = super.calculateTabHeight(tabPlacement, 0, SubstanceSizeUtils.getComponentFontSize(this.tabPane)) / 2; rightOutline .lineTo(x + w - 1 + bumpWidth, selRect.y + borderInsets); if (selRect.y + selRect.height < y + h) { int selectionEndY = selRect.y + selRect.height - delta - 1 - borderInsets; rightOutline.lineTo(x + w - 1 + bumpWidth, selectionEndY); rightOutline.lineTo(x + w - 1, selectionEndY); rightOutline.lineTo(x + w - 1, y + h); } g2d.setPaint(new GradientPaint(x + w - 1, y, darkShadowColor, x + w - 1 + bumpWidth, y, SubstanceColorUtilities.getAlphaColor( darkShadowColor, 0))); g2d.draw(rightOutline); } if (isDouble) { if (tabPlacement == RIGHT) { g2d.setColor(this.highlight); // g2d.drawLine(x + w - 2 - ribbonDelta, y + 1, x + w - 2 - // ribbonDelta, y + h - 1); g2d.setColor(darkShadowColor); g2d.drawLine(x + w - 1 - ribbonDelta, y, x + w - 1 - ribbonDelta, y + h); } if (tabPlacement == TOP) { g2d.setPaint(new GradientPaint(x + w - 1, y, darkShadowColor, x + w - 1, y + 4 * ribbonDelta, this.highlight)); g2d.drawLine(x + w - 1, y, x + w - 1, y + 4 * ribbonDelta); } if (tabPlacement == BOTTOM) { g2d.setPaint(new GradientPaint(x + w - 1, y + h - 1 - 4 * ribbonDelta, this.highlight, x + w - 1, y + h - 1, darkShadowColor)); g2d.drawLine(x + w - 1, y + h - 1 - 4 * ribbonDelta, x + w - 1, y + h - 1); } } g2d.dispose(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTabbedPaneUI#paintContentBorderTopEdge(java * .awt.Graphics, int, int, int, int, int, int) */ @Override protected void paintContentBorderTopEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) { TabContentPaneBorderKind kind = SubstanceCoreUtilities .getContentBorderKind(this.tabPane); boolean isDouble = (kind == TabContentPaneBorderKind.DOUBLE_FULL) || (kind == TabContentPaneBorderKind.DOUBLE_PLACEMENT); boolean isPlacement = (kind == TabContentPaneBorderKind.SINGLE_PLACEMENT) || (kind == TabContentPaneBorderKind.DOUBLE_PLACEMENT); if (isPlacement) { if (tabPlacement != SwingConstants.TOP) return; } int ribbonDelta = (int) (3.0 * SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane))); Rectangle selRect = selectedIndex < 0 ? null : this.getTabBounds( selectedIndex, this.calcRect); Graphics2D g2d = (Graphics2D) g.create(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); float strokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane)); int joinKind = BasicStroke.JOIN_ROUND; int capKind = BasicStroke.CAP_BUTT; g2d.setStroke(new BasicStroke(strokeWidth, capKind, joinKind)); int offset = (int) (strokeWidth / 2.0); boolean isUnbroken = (tabPlacement != TOP || selectedIndex < 0 || (selRect.y + selRect.height + 1 < y) || (selRect.x < x || selRect.x > x + w)); x += offset; y += offset; w -= 2 * offset; // h -= 2 * offset; // Draw unbroken line if tabs are not on TOP, OR // selected tab is not in run adjacent to content, OR // selected tab is not visible (SCROLL_TAB_LAYOUT) SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities .getColorScheme(this.tabPane, selectedIndex, ColorSchemeAssociationKind.TAB_BORDER, ComponentState.SELECTED); Color darkShadowColor = SubstanceColorUtilities.getMidBorderColor( borderScheme, borderScheme, 0.0); if (isUnbroken) { g2d.setColor(this.highlight); g2d.drawLine(x, y, x + w - 1, y); } else { // Break line to show visual connection to selected tab SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(this.tabPane); int delta = (shaper instanceof ClassicButtonShaper) ? 1 : 0; int borderInsets = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(tabPane)) / 2.0); GeneralPath topOutline = new GeneralPath(); topOutline.moveTo(x, y); topOutline.lineTo(selRect.x + borderInsets, y); int bumpHeight = super.calculateTabHeight(tabPlacement, 0, SubstanceSizeUtils.getComponentFontSize(this.tabPane)) / 2; topOutline.lineTo(selRect.x + borderInsets, y - bumpHeight); if (selRect.x + selRect.width < x + w - 1) { int selectionEndX = selRect.x + selRect.width - delta - 1 - borderInsets; topOutline.lineTo(selectionEndX, y - bumpHeight); topOutline.lineTo(selectionEndX, y); topOutline.lineTo(x + w - 1, y); } g2d.setPaint(new GradientPaint(x, y, darkShadowColor, x, y - bumpHeight, SubstanceColorUtilities.getAlphaColor( darkShadowColor, 0))); g2d.draw(topOutline); } if (isDouble) { if (tabPlacement == TOP) { g2d.setColor(darkShadowColor); g2d.drawLine(x, y + ribbonDelta, x + w - 1, y + ribbonDelta); g2d.setColor(this.highlight); // g2d.drawLine(x, y + 1 + ribbonDelta, x + w - 1, y + 1 + // ribbonDelta); } if (tabPlacement == LEFT) { g2d.setPaint(new GradientPaint(x, y, darkShadowColor, x + 4 * ribbonDelta, y, this.highlight)); g2d.drawLine(x, y, x + 4 * ribbonDelta, y); } if (tabPlacement == RIGHT) { g2d.setPaint(new GradientPaint(x + w - 1 - 4 * ribbonDelta, y, this.highlight, x + w - 1, y, darkShadowColor)); g2d.drawLine(x + w - 1 - 4 * ribbonDelta, y, x + w - 1, y); } } g2d.dispose(); } @Override public Rectangle getTabBounds(JTabbedPane pane, int i) { this.ensureCurrentLayout(); Rectangle tabRect = new Rectangle(); return this.getTabBounds(i, tabRect); } /** * Returns the previous state for the specified tab. * * @param tabIndex * Tab index. * @return The previous state for the specified tab. */ protected ComponentState getPrevTabState(int tabIndex) { if (this.prevStateMap.containsKey(tabIndex)) return this.prevStateMap.get(tabIndex); // if (getTabState(tabIndex) == ComponentState.SELECTED) // return ComponentState.SELECTED; return ComponentState.DEFAULT; } /** * Returns the current state for the specified tab. * * @param tabIndex * Tab index. * @return The current state for the specified tab. */ protected ComponentState getTabState(int tabIndex) { boolean isEnabled = this.tabPane.isEnabledAt(tabIndex); boolean isRollover = this.getRolloverTabIndex() == tabIndex; boolean isSelected = this.tabPane.getSelectedIndex() == tabIndex; return ComponentState.getState(isEnabled, isRollover, isSelected); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTabbedPaneUI#paintText(java.awt.Graphics, * int, java.awt.Font, java.awt.FontMetrics, int, java.lang.String, * java.awt.Rectangle, boolean) */ @Override protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected) { g.setFont(font); View v = this.getTextViewForTab(tabIndex); if (v != null) { // html v.paint(g, textRect); } else { // plain text int mnemIndex = this.tabPane.getDisplayedMnemonicIndexAt(tabIndex); ComponentState state = this.getTabState(tabIndex); ComponentState prevState = this.getPrevTabState(tabIndex); if (prevState == null) prevState = state; Color fg = SubstanceColorUtilities.getForegroundColor(this.tabPane, tabIndex, state, prevState); Graphics2D graphics = (Graphics2D) g.create(); if (!state.isKindActive(FadeKind.ENABLE)) { Color bgFillColor = SubstanceColorUtilities .getBackgroundFillColor(this.tabPane); fg = SubstanceColorUtilities.getInterpolatedColor(fg, bgFillColor, SubstanceColorSchemeUtilities.getAlpha( this.tabPane.getComponentAt(tabIndex), state)); } if (state.isKindActive(FadeKind.SELECTION)) { Component comp = this.tabPane.getComponentAt(tabIndex); if (comp != null) fg = SubstanceColorUtilities.getForegroundColor(comp, state, prevState); } graphics.clip(getTabRectangle(tabIndex)); SubstanceTextUtilities.paintText(graphics, this.tabPane, textRect, title, mnemIndex, graphics.getFont(), fg, null); graphics.dispose(); } } @Override protected void paintIcon(Graphics g, int tabPlacement, int tabIndex, Icon icon, Rectangle iconRect, boolean isSelected) { if (icon == null) return; if (SubstanceCoreUtilities.useThemedDefaultIcon()) { ComponentState currState = this.getTabState(tabIndex); FadeTracker fadeTracker = FadeTracker.getInstance(); FadeState fadeState = fadeTracker.getFadeState(this.tabPane, tabIndex, FadeKind.ROLLOVER); if (fadeState == null) { if (currState.isKindActive(FadeKind.ROLLOVER) || currState.isKindActive(FadeKind.SELECTION) || !currState.isKindActive(FadeKind.ENABLE)) { // use the original (full color or disabled) icon super.paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected); return; } } Icon themed = SubstanceCoreUtilities.getThemedIcon(this.tabPane, tabIndex, icon); if (fadeState == null) { super.paintIcon(g, tabPlacement, tabIndex, themed, iconRect, isSelected); } else { Graphics2D g2d = (Graphics2D) g.create(); super.paintIcon(g2d, tabPlacement, tabIndex, icon, iconRect, isSelected); g2d.setComposite(TransitionLayout.getAlphaComposite( this.tabPane, 1.0f - fadeState.getFadePosition(), g2d)); super.paintIcon(g2d, tabPlacement, tabIndex, themed, iconRect, isSelected); g2d.dispose(); } } else { super.paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected); } } @Override protected MouseListener createMouseListener() { return null; } /** * Extension point to allow horizontal orientation of left / right placed * tabs. * * @param tabPlacement * Tab placement. * @return Indication whether the tabs in the specified placement should be * rotated. */ protected boolean toRotateTabsOnPlacement(int tabPlacement) { return (tabPlacement == SwingConstants.LEFT) || (tabPlacement == SwingConstants.RIGHT); } }substance-5.3.orig/src/org/jvnet/substance/SubstanceProgressBarUI.java0000644000175000017500000006433011163113456026107 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicProgressBarUI; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.animation.FadeTracker; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; import org.jvnet.substance.utils.*; /** * UI for progress bars in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceProgressBarUI extends BasicProgressBarUI { /** * Hash for computed stripe images. */ private static LazyResettableHashMap stripeMap = new LazyResettableHashMap( "SubstanceProgressBarUI.stripeMap"); /** * Hash for computed background images. */ private static LazyResettableHashMap backgroundMap = new LazyResettableHashMap( "SubstanceProgressBarUI.backgroundMap"); /** * The current state of the indeterminate animation's cycle. 0, the initial * value, means paint the first frame. When the progress bar is * indeterminate and showing, the default animation thread updates this * variable by invoking incrementAnimationIndex() every repaintInterval * milliseconds. */ private float animationIndex; /** * Value change listener on the associated progress bar. */ protected ChangeListener substanceValueChangeListener; /** * Property change listener. Tracks changes to the font * property. */ protected PropertyChangeListener substancePropertyChangeListener; /** * Inner margin. */ protected int margin; /** * The speed factor for the indeterminate progress bars. */ protected float speed; /** * Fade kind for the progress bar value change. */ public static final FadeKind PROGRESS_BAR_VALUE_CHANGED = new FadeKind( "substancelaf.progressBarValueChanged"); /** * Property name for storing the from value on progress bar * value animation. Is for internal use only. */ private static final String PROGRESS_BAR_FROM = "substancelaf.internal.from"; /** * Property name for storing the to value on progress bar value * animation. Is for internal use only. */ private static final String PROGRESS_BAR_TO = "substancelaf.internal.to"; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceProgressBarUI(); } @Override protected void installDefaults() { super.installDefaults(); progressBar.putClientProperty(PROGRESS_BAR_TO, progressBar.getValue()); LookAndFeel.installProperty(progressBar, "opaque", Boolean.FALSE); this.speed = (20.0f * UIManager.getInt("ProgressBar.repaintInterval")) / UIManager.getInt("ProgressBar.cycleTime"); float borderThickness = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(this.progressBar)); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(this.progressBar); this.margin = borderPainter.isPaintingInnerContour() ? (int) Math .ceil(2.0 * borderThickness) : (int) Math .ceil(1.5 * borderThickness); } @Override protected void installListeners() { super.installListeners(); final BoundedRangeModel model = progressBar.getModel(); if (model instanceof DefaultBoundedRangeModel) { substanceValueChangeListener = new ChangeListener() { public void stateChanged(ChangeEvent e) { SubstanceCoreUtilities .testComponentStateChangeThreadingViolation(progressBar); int oldValue = (Integer) progressBar .getClientProperty(PROGRESS_BAR_TO); int currValue = model.getValue(); int span = model.getMaximum() - model.getMinimum(); // Insets b = getInsets(); // area for border int barRectWidth = progressBar.getWidth() - 2 * margin; int barRectHeight = progressBar.getHeight() - 2 * margin; int totalPixels = (progressBar.getOrientation() == JProgressBar.HORIZONTAL) ? barRectWidth : barRectHeight; // fix for defect 223 (min and max on the model are the // same). int pixelDelta = (span <= 0) ? 0 : (currValue - oldValue) * totalPixels / span; FadeTracker fadeTracker = FadeTracker.getInstance(); if (!fadeTracker.isTracked(progressBar, PROGRESS_BAR_VALUE_CHANGED)) { progressBar.putClientProperty(PROGRESS_BAR_FROM, progressBar.getClientProperty(PROGRESS_BAR_TO)); } progressBar.putClientProperty(PROGRESS_BAR_TO, progressBar .getValue()); // do not animate progress bars used in cell renderers // since in this case it will most probably be the // same progress bar used to display different // values for different cells. boolean isInCellRenderer = (SwingUtilities .getAncestorOfClass(CellRendererPane.class, progressBar) != null); if (!isInCellRenderer && Math.abs(pixelDelta) > 5) { FadeTracker.getInstance().trackFadeIn( PROGRESS_BAR_VALUE_CHANGED, progressBar, false, null); } } }; ((DefaultBoundedRangeModel) model) .addChangeListener(substanceValueChangeListener); } this.substancePropertyChangeListener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("font".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (progressBar != null) progressBar.updateUI(); } }); } } }; this.progressBar .addPropertyChangeListener(this.substancePropertyChangeListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicProgressBarUI#uninstallListeners() */ @Override protected void uninstallListeners() { BoundedRangeModel model = progressBar.getModel(); if (model instanceof DefaultBoundedRangeModel) { ((DefaultBoundedRangeModel) model) .removeChangeListener(substanceValueChangeListener); } this.progressBar .removePropertyChangeListener(this.substancePropertyChangeListener); this.substancePropertyChangeListener = null; super.uninstallListeners(); } /** * Retrieves stripe image. * * @param baseSize * Stripe base in pixels. * @param isRotated * if true, the resulting stripe image will be * rotated. * @param colorScheme * Color scheme to paint the stripe image. * @return Stripe image. */ private static BufferedImage getStripe(int baseSize, boolean isRotated, SubstanceColorScheme colorScheme) { HashMapKey key = SubstanceCoreUtilities.getHashKey(baseSize, isRotated, colorScheme.getDisplayName()); BufferedImage result = SubstanceProgressBarUI.stripeMap.get(key); if (result == null) { result = SubstanceImageCreator.getStripe(baseSize, colorScheme .getUltraLightColor()); if (isRotated) { result = SubstanceImageCreator.getRotated(result, 1); } SubstanceProgressBarUI.stripeMap.put(key, result); } return result; } /** * Returns the background of a determinate progress bar. * * @param bar * Progress bar. * @param width * Progress bar width. * @param height * Progress bar height. * @param scheme * Color scheme for the background. * @param gp * Gradient painter. * @param orientation * Progress bar orientation (vertical / horizontal). * @param componentOrientation * Progress bar LTR / RTL orientation. * @return Background image. */ private static BufferedImage getDeterminateBackground(JProgressBar bar, int width, int height, SubstanceColorScheme scheme, SubstanceGradientPainter gp, int orientation, ComponentOrientation componentOrientation) { HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height, scheme.getDisplayName(), gp.getDisplayName(), orientation, componentOrientation); BufferedImage result = SubstanceProgressBarUI.backgroundMap.get(key); if (result == null) { result = SubstanceCoreUtilities.getBlankImage(width, height); Graphics2D g2d = result.createGraphics(); Shape contour = SubstanceOutlineUtilities.getBaseOutline(width, height, 0, null); gp.paintContourBackground(g2d, bar, width, height, contour, false, scheme, scheme, 0, true, false); g2d.dispose(); if (orientation == SwingConstants.VERTICAL) { if (componentOrientation.isLeftToRight()) result = SubstanceImageCreator.getRotated(result, 3); else result = SubstanceImageCreator.getRotated(result, 1); } SubstanceProgressBarUI.backgroundMap.put(key, result); } return result; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicProgressBarUI#paintDeterminate(java.awt.Graphics * , javax.swing.JComponent) */ @Override public void paintDeterminate(Graphics g, JComponent c) { if (!(g instanceof Graphics2D)) { return; } // final Insets insets = this.getInsets(); // insets.top /= 2; // insets.left /= 2; // insets.bottom /= 2; // insets.right /= 2; int barRectWidth = progressBar.getWidth() - 2 * margin; int barRectHeight = progressBar.getHeight() - 2 * margin; // amount of progress to draw int amountFull = getAmountFull(new Insets(margin, margin, margin, margin), barRectWidth, barRectHeight); Graphics2D g2d = (Graphics2D) g.create(); // install state-aware alpha channel (support for skins // that use translucency on disabled states). float stateAlpha = SubstanceColorSchemeUtilities.getAlpha(progressBar, progressBar.isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED); g2d.setComposite(TransitionLayout.getAlphaComposite(progressBar, stateAlpha, g)); SubstanceColorScheme scheme = SubstanceColorSchemeUtilities .getColorScheme(progressBar, progressBar.isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED); SubstanceGradientPainter gp = SubstanceCoreUtilities .getGradientPainter(progressBar); if (progressBar.getOrientation() == SwingConstants.HORIZONTAL) { BufferedImage back = getDeterminateBackground(progressBar, barRectWidth + 1, barRectHeight + 1, scheme, gp, progressBar.getOrientation(), this.progressBar .getComponentOrientation()); g2d.drawImage(back, margin, margin, null); } else { BufferedImage back = getDeterminateBackground(progressBar, barRectHeight + 1, barRectWidth + 1, scheme, gp, progressBar.getOrientation(), this.progressBar .getComponentOrientation()); g2d.drawImage(back, margin, margin, null); } if (amountFull > 0) { // float borderStrokeWidth = SubstanceSizeUtils // .getBorderStrokeWidth(SubstanceSizeUtils // .getComponentFontSize(progressBar)); // SubstanceBorderPainter borderPainter = SubstanceCoreUtilities // .getBorderPainter(null); int borderDelta = 0; // (borderPainter instanceof InnerDelegateBorderPainter) ? (int) // (Math // .ceil(2.0 * borderStrokeWidth)) / 2 // : (int) (Math.ceil(borderStrokeWidth / 2.0));// : 0; // if (borderDelta == 0) SubstanceColorScheme fillColorScheme = SubstanceColorSchemeUtilities .getColorScheme(progressBar, progressBar.isEnabled() ? ComponentState.SELECTED : ComponentState.DISABLED_UNSELECTED); if (progressBar.getOrientation() == SwingConstants.HORIZONTAL) { int barWidth = amountFull - 2 * borderDelta; int barHeight = barRectHeight - 2 * borderDelta; if ((barWidth > 0) && (barHeight > 0)) { if (progressBar.getComponentOrientation().isLeftToRight()) { SubstanceImageCreator.paintRectangularBackground( progressBar, g, margin + borderDelta, margin + borderDelta, barWidth, barHeight, fillColorScheme, 0.6f, false); // g.setColor(Color.red); // g.fillRect(insets.left + borderDelta, // insets.top + borderDelta, barWidth, barHeight); } else { // fix for RTL determinate horizontal progress // bar in 2.3 SubstanceImageCreator.paintRectangularBackground( progressBar, g, margin + barRectWidth - amountFull - 2 * borderDelta, margin + borderDelta, barWidth, barHeight, fillColorScheme, 0.6f, false); } } } else { // VERTICAL int barWidth = amountFull - 2 * borderDelta; int barHeight = barRectWidth - 2 * borderDelta; if ((amountFull > 0) && (barHeight > 0)) { // fix for issue 95. Vertical bar is growing from // the bottom SubstanceImageCreator.paintRectangularBackground( progressBar, g, margin + borderDelta, margin + barRectHeight - barWidth - borderDelta, barHeight, barWidth, fillColorScheme, 0.6f, true); } } } // Deal with possible text painting if (progressBar.isStringPainted()) { g2d.setComposite(TransitionLayout.getAlphaComposite(progressBar, 1.0f, g)); this.paintString(g2d, margin, margin, barRectWidth, barRectHeight, amountFull, new Insets(margin, margin, margin, margin)); } g2d.dispose(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicProgressBarUI#getSelectionBackground() */ @Override protected Color getSelectionBackground() { SubstanceColorScheme scheme = SubstanceColorSchemeUtilities .getColorScheme(progressBar, progressBar.isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED); return SubstanceColorUtilities.getForegroundColor(scheme); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicProgressBarUI#getSelectionForeground() */ @Override protected Color getSelectionForeground() { SubstanceColorScheme scheme = SubstanceColorSchemeUtilities .getColorScheme(progressBar, progressBar.isEnabled() ? ComponentState.SELECTED : ComponentState.DISABLED_UNSELECTED); return SubstanceColorUtilities.getForegroundColor(scheme); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicProgressBarUI#paintIndeterminate(java.awt * .Graphics, javax.swing.JComponent) */ @Override public void paintIndeterminate(Graphics g, JComponent c) { if (!(g instanceof Graphics2D)) { return; } // final Insets b = this.getInsets(); // area for border final int barRectWidth = progressBar.getWidth() - 2 * margin; final int barRectHeight = progressBar.getHeight() - 2 * margin; final int valComplete = (int) animationIndex; Graphics2D g2d = (Graphics2D) g.create(); // install state-aware alpha channel (support for skins // that use translucency on disabled states). float stateAlpha = SubstanceColorSchemeUtilities.getAlpha(progressBar, progressBar.isEnabled() ? ComponentState.SELECTED : ComponentState.DISABLED_UNSELECTED); g2d.setComposite(TransitionLayout.getAlphaComposite(progressBar, stateAlpha, g)); SubstanceColorScheme scheme = SubstanceColorSchemeUtilities .getColorScheme(progressBar, progressBar.isEnabled() ? ComponentState.SELECTED : ComponentState.DISABLED_UNSELECTED); if (progressBar.getOrientation() == SwingConstants.HORIZONTAL) { SubstanceImageCreator.paintRectangularStripedBackground( progressBar, g2d, margin, margin, barRectWidth, barRectHeight, scheme, SubstanceProgressBarUI.getStripe( barRectHeight, false, scheme), valComplete, 0.6f, false); } else { // fix for issue 95. Vertical progress bar grows from the // bottom. SubstanceImageCreator.paintRectangularStripedBackground( progressBar, g2d, margin, margin, barRectWidth, barRectHeight, scheme, SubstanceProgressBarUI.getStripe( barRectWidth, true, scheme), 2 * barRectWidth - valComplete, 0.6f, true); } // Deal with possible text painting if (progressBar.isStringPainted()) { g2d.setComposite(TransitionLayout.getAlphaComposite(progressBar, 1.0f, g)); this.paintString(g2d, margin, margin, barRectWidth, barRectHeight, barRectWidth, new Insets(margin, margin, margin, margin)); } g2d.dispose(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicProgressBarUI#getBox(java.awt.Rectangle) */ @Override protected Rectangle getBox(Rectangle r) { // Insets b = this.getInsets(); // area for border int barRectWidth = progressBar.getWidth() - 2 * margin; int barRectHeight = progressBar.getHeight() - 2 * margin; return new Rectangle(margin, margin, barRectWidth, barRectHeight); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicProgressBarUI#incrementAnimationIndex() */ @Override protected void incrementAnimationIndex() { float newValue = animationIndex + this.speed; // Insets b = this.getInsets(); // area for border int barRectHeight = progressBar.getHeight() - 2 * margin; int barRectWidth = progressBar.getWidth() - 2 * margin; int threshold = 0; if (progressBar.getOrientation() == SwingConstants.HORIZONTAL) { threshold = 2 * barRectHeight + 1; } else { threshold = 2 * barRectWidth + 1; } animationIndex = newValue % threshold; progressBar.repaint(); } /** * Returns the memory usage string. * * @return The memory usage string. */ public static String getMemoryUsage() { StringBuffer sb = new StringBuffer(); sb.append("SubstanceProgressBarUI: \n"); sb.append("\t" + SubstanceProgressBarUI.stripeMap.size() + " stripes"); return sb.toString(); } @Override protected int getAmountFull(Insets b, int width, int height) { int amountFull = 0; BoundedRangeModel model = progressBar.getModel(); long span = model.getMaximum() - model.getMinimum(); double currentValue = model.getValue(); FadeTracker fadeTracker = FadeTracker.getInstance(); if (fadeTracker.isTracked(progressBar, PROGRESS_BAR_VALUE_CHANGED)) { double fade = fadeTracker.getFade(progressBar, PROGRESS_BAR_VALUE_CHANGED); int from = (Integer) progressBar .getClientProperty(PROGRESS_BAR_FROM); int to = (Integer) progressBar.getClientProperty(PROGRESS_BAR_TO); currentValue = from + (fade * (to - from)); } double percentComplete = (currentValue - model.getMinimum()) / span; if ((model.getMaximum() - model.getMinimum()) != 0) { if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { amountFull = (int) Math.round(width * percentComplete); } else { amountFull = (int) Math.round(height * percentComplete); } } return amountFull; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicProgressBarUI#getPreferredInnerHorizontal() */ @Override protected Dimension getPreferredInnerHorizontal() { int size = SubstanceSizeUtils.getComponentFontSize(this.progressBar); size += 2 * SubstanceSizeUtils.getAdjustedSize(size, 1, 4, 1, false); return new Dimension(146 + SubstanceSizeUtils.getAdjustedSize(size, 0, 1, 10, false), size); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicProgressBarUI#getPreferredInnerVertical() */ @Override protected Dimension getPreferredInnerVertical() { int size = SubstanceSizeUtils.getComponentFontSize(this.progressBar); size += 2 * SubstanceSizeUtils.getAdjustedSize(size, 1, 4, 1, false); return new Dimension(size, 146 + SubstanceSizeUtils.getAdjustedSize( size, 0, 1, 10, false)); } @Override protected void paintString(Graphics g, int x, int y, int width, int height, int amountFull, Insets b) { if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { if (progressBar.getComponentOrientation().isLeftToRight()) { if (progressBar.isIndeterminate()) { boxRect = getBox(boxRect); paintString(g, x, y, width, height, boxRect.x, boxRect.width, b); } else { paintString(g, x, y, width, height, x, amountFull, b); } } else { paintString(g, x, y, width, height, x + width - amountFull, amountFull, b); } } else { if (progressBar.isIndeterminate()) { boxRect = getBox(boxRect); paintString(g, x, y, width, height, boxRect.y, boxRect.height, b); } else { paintString(g, x, y, width, height, y + height - amountFull, amountFull, b); } } } /** * Paints the progress string. * * @param g * Graphics used for drawing. * @param x * x location of bounding box * @param y * y location of bounding box * @param width * width of bounding box * @param height * height of bounding box * @param fillStart * start location, in x or y depending on orientation, of the * filled portion of the progress bar. * @param amountFull * size of the fill region, either width or height depending upon * orientation. * @param b * Insets of the progress bar. */ private void paintString(Graphics g, int x, int y, int width, int height, int fillStart, int amountFull, Insets b) { String progressString = progressBar.getString(); Rectangle renderRectangle = getStringRectangle(progressString, x, y, width, height); if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { SubstanceTextUtilities.paintText(g, this.progressBar, renderRectangle, progressString, -1, progressBar.getFont(), getSelectionBackground(), new Rectangle(amountFull, y, progressBar.getWidth() - amountFull, height)); SubstanceTextUtilities.paintText(g, this.progressBar, renderRectangle, progressString, -1, progressBar.getFont(), getSelectionForeground(), new Rectangle(fillStart, y, amountFull, height)); } else { // VERTICAL SubstanceTextUtilities.paintVerticalText(g, this.progressBar, renderRectangle, progressString, -1, progressBar.getFont(), getSelectionBackground(), new Rectangle(x, y, width, progressBar.getHeight() - amountFull), progressBar .getComponentOrientation().isLeftToRight()); SubstanceTextUtilities.paintVerticalText(g, this.progressBar, renderRectangle, progressString, -1, progressBar.getFont(), getSelectionForeground(), new Rectangle(x, fillStart, width, amountFull), progressBar .getComponentOrientation().isLeftToRight()); } } /** * Returns the rectangle for the progress bar string. * * @param progressString * Progress bar string. * @param x * x location of bounding box * @param y * y location of bounding box * @param width * width of bounding box * @param height * height of bounding box * @return The rectangle for the progress bar string. */ protected Rectangle getStringRectangle(String progressString, int x, int y, int width, int height) { FontMetrics fontSizer = progressBar.getFontMetrics(progressBar .getFont()); int stringWidth = fontSizer.stringWidth(progressString); if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { return new Rectangle(x + Math.round(width / 2 - stringWidth / 2), y + (height - fontSizer.getHeight()) / 2, stringWidth, fontSizer.getHeight()); } else { return new Rectangle(x + (width - fontSizer.getHeight()) / 2, y + Math.round(height / 2 - stringWidth / 2), fontSizer .getHeight(), stringWidth); // return new Rectangle(x - height / 2 - fontSizer.getHeight(), y, // fontSizer.getHeight(), stringWidth); } } // // private Insets getInsets() { // float borderThickness = SubstanceSizeUtils // .getBorderStrokeWidth(SubstanceSizeUtils // .getComponentFontSize(this.progressBar)); // SubstanceBorderPainter borderPainter = SubstanceCoreUtilities // .getBorderPainter(this.progressBar); // int insets = 0; // if (borderPainter instanceof InnerDelegateBorderPainter) { // insets = (int) Math.ceil(2.0 * borderThickness); // } else { // insets = (int) Math.ceil(1.5 * borderThickness); // } // // return new Insets(insets, insets, insets, insets); // } } substance-5.3.orig/src/org/jvnet/substance/SubstanceTextAreaUI.java0000644000175000017500000001311011167404306025362 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.Color; import java.awt.Graphics; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.plaf.*; import javax.swing.plaf.basic.BasicBorders; import javax.swing.plaf.basic.BasicTextAreaUI; import org.jvnet.lafwidget.animation.FadeStateListener; import org.jvnet.substance.utils.*; /** * UI for text areas in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceTextAreaUI extends BasicTextAreaUI { /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /** * The associated text area. */ protected JTextArea textArea; /** * Property change listener. */ protected PropertyChangeListener substancePropertyChangeListener; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceTextAreaUI(comp); } /** * Simple constructor. * * @param c * Component (text area). */ public SubstanceTextAreaUI(JComponent c) { super(); this.textArea = (JTextArea) c; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTextUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); this.substanceFadeStateListener = new FadeStateListener(this.textArea, null, null); this.substanceFadeStateListener.registerListeners(false); this.substancePropertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("font".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { // remember the caret location - issue 404 int caretPos = textArea.getCaretPosition(); textArea.updateUI(); textArea.setCaretPosition(caretPos); } }); } if ("componentOrientation".equals(evt.getPropertyName())) { // fix by Davide Raccagni (A03) getComponent().setText(getComponent().getText()); } } }; this.textArea .addPropertyChangeListener(this.substancePropertyChangeListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTextUI#uninstallListeners() */ @Override protected void uninstallListeners() { this.substanceFadeStateListener.unregisterListeners(); this.substanceFadeStateListener = null; this.textArea .removePropertyChangeListener(this.substancePropertyChangeListener); this.substancePropertyChangeListener = null; super.uninstallListeners(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTextAreaUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); Border b = this.textArea.getBorder(); if (b == null || b instanceof UIResource) { Border newB = new BorderUIResource.CompoundBorderUIResource( new EmptyBorder(SubstanceSizeUtils .getTextBorderInsets(SubstanceSizeUtils .getComponentFontSize(this.textArea))), new BasicBorders.MarginBorder()); this.textArea.setBorder(newB); } // support for per-window skins Color foregr = this.textArea.getForeground(); if ((foregr == null) || (foregr instanceof UIResource)) { this.textArea.setForeground(SubstanceColorUtilities .getForegroundColor(SubstanceLookAndFeel.getCurrentSkin( this.textArea).getMainDefaultColorScheme())); } } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTextUI#paintBackground(java.awt.Graphics) */ @Override protected void paintBackground(Graphics g) { SubstanceTextUtilities.paintTextCompBackground(g, this.textArea); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceFileChooserUI.java0000644000175000017500000001221511162645516026061 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.io.File; import java.util.HashMap; import java.util.Map; import javax.swing.*; import javax.swing.filechooser.FileView; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicFileChooserUI; import javax.swing.plaf.metal.MetalFileChooserUI; import org.jvnet.substance.utils.SubstanceCoreUtilities; /** * UI for file chooser in Substance look and feel. The * {@link BasicFileChooserUI} can't be used on its own (creates an empty * dialog). * * @author Kirill Grouchnikov */ public class SubstanceFileChooserUI extends MetalFileChooserUI { /** * Custom file view - for system icons on the files. */ private final SubstanceFileView fileView = new SubstanceFileView(); /** * Custom file view implementation that returns system-specific file icons. * * @author Kirill Grouchnikov */ private class SubstanceFileView extends BasicFileView { /** * Cache for the file icons. */ private final Map pathIconCache = new HashMap(); /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicFileChooserUI$BasicFileView#getCachedIcon * (java.io.File) */ @Override public Icon getCachedIcon(File f) { return pathIconCache.get(f.getPath()); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicFileChooserUI$BasicFileView#getIcon(java * .io.File) */ @Override public Icon getIcon(File f) { Icon icon = getCachedIcon(f); if (icon != null) return icon; icon = getDefaultIcon(f); // System.out.println("System : " + f.getAbsolutePath() + " --> " // + icon); if (icon == null) { icon = super.getIcon(f); if (icon == null) { icon = new ImageIcon(SubstanceCoreUtilities.getBlankImage( 8, 8)); } // System.out.println("Super : " + f.getAbsolutePath() + " --> " // + icon); } cacheIcon(f, icon); return icon; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicFileChooserUI$BasicFileView#cacheIcon * (java.io.File, javax.swing.Icon) */ @Override public void cacheIcon(File f, Icon icon) { pathIconCache.put(f.getPath(), icon); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicFileChooserUI$BasicFileView#clearIconCache * () */ @Override public void clearIconCache() { pathIconCache.clear(); } /** * Returns the default file icon. * * @param f * File. * @return File icon. */ public Icon getDefaultIcon(File f) { JFileChooser fileChooser = getFileChooser(); Icon icon = fileChooser.getFileSystemView().getSystemIcon(f); if (SubstanceCoreUtilities.useThemedDefaultIcon()) { icon = SubstanceCoreUtilities.getThemedIcon(fileChooser, icon); } return icon; } } public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceFileChooserUI((JFileChooser) comp); } /** * Creates the UI delegate for the specified file chooser. * * @param filechooser * File chooser. */ public SubstanceFileChooserUI(JFileChooser filechooser) { super(filechooser); } /* * (non-Javadoc) * * @seejavax.swing.plaf.basic.BasicFileChooserUI#getFileView(javax.swing. * JFileChooser) */ @Override public FileView getFileView(JFileChooser fc) { return fileView; } } substance-5.3.orig/src/org/jvnet/substance/SubstanceScrollPaneUI.java0000644000175000017500000005711211253511750025717 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.HashSet; import java.util.Set; import javax.swing.*; import javax.swing.border.Border; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.*; import javax.swing.plaf.basic.BasicScrollPaneUI; import javax.swing.table.JTableHeader; import org.jvnet.lafwidget.LafWidgetUtilities; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.layout.TransitionBorder; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.lafwidget.utils.LafConstants; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.SubstanceSizeUtils; import org.jvnet.substance.utils.scroll.SubstanceScrollPaneBorder; /** * UI for scroll panes in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceScrollPaneUI extends BasicScrollPaneUI { /** * Property change listener on * {@link SubstanceLookAndFeel#SCROLL_PANE_BUTTONS_POLICY}, * {@link SubstanceLookAndFeel#WATERMARK_TO_BLEED} and * layoutManager properties. */ protected PropertyChangeListener substancePropertyChangeListener; /** * Listener on the vertical scroll bar. Installed for the smart tree scroll * (see {@link SubstanceLookAndFeel#TREE_SMART_SCROLL_ANIMATION_KIND}. */ protected ChangeListener substanceVerticalScrollbarChangeListener; /** * Fade ID of the current horizontal scroll under smart tree scroll mode. */ protected long horScrollId; /** * Creates new UI delegate. * * @param comp * Component. * @return UI delegate for the component. */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceScrollPaneUI(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicScrollPaneUI#installDefaults(javax.swing. * JScrollPane) */ @Override protected void installDefaults(final JScrollPane scrollpane) { super.installDefaults(scrollpane); if (SubstanceCoreUtilities.toDrawWatermark(scrollpane)) { scrollpane.setOpaque(false); scrollpane.getViewport().setOpaque(false); } scrollpane.setLayout(new AdjustedLayout((ScrollPaneLayout) scrollpane .getLayout())); SwingUtilities.invokeLater(new Runnable() { public void run() { // System.out.println("Installing"); installTableHeaderCornerFiller(scrollpane); } }); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicScrollPaneUI#uninstallDefaults(javax.swing * .JScrollPane) */ @Override protected void uninstallDefaults(JScrollPane c) { Component upperRight = c.getCorner(JScrollPane.UPPER_RIGHT_CORNER); if (upperRight instanceof UIResource) { c.setCorner(JScrollPane.UPPER_RIGHT_CORNER, null); } Component upperLeft = c.getCorner(JScrollPane.UPPER_LEFT_CORNER); if (upperLeft instanceof UIResource) { c.setCorner(JScrollPane.UPPER_LEFT_CORNER, null); } LayoutManager lm = scrollpane.getLayout(); if (lm instanceof AdjustedLayout) { c.setLayout(((AdjustedLayout) lm).delegate); } super.uninstallDefaults(c); } // /* // * (non-Javadoc) // * // * @see // javax.swing.plaf.basic.BasicScrollPaneUI#uninstallDefaults(javax.swing. // JScrollPane) // */ // @Override // protected void uninstallDefaults(JScrollPane c) { // super.uninstallDefaults(c); // ScrollPaneSelector.uninstallScrollPaneSelector(scrollpane); // } // /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicScrollPaneUI#installListeners(javax.swing * .JScrollPane) */ @Override protected void installListeners(final JScrollPane c) { super.installListeners(c); this.substancePropertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (SubstanceLookAndFeel.SCROLL_PANE_BUTTONS_POLICY.equals(evt .getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { c.getHorizontalScrollBar().doLayout(); c.getVerticalScrollBar().doLayout(); } }); } if (SubstanceLookAndFeel.WATERMARK_VISIBLE.equals(evt .getPropertyName())) { boolean toBleed = SubstanceCoreUtilities.toDrawWatermark(c); c.setOpaque(!toBleed); c.getViewport().setOpaque(!toBleed); Component view = c.getViewport().getView(); if (view instanceof JComponent) ((JComponent) view).setOpaque(!toBleed); } if ("layoutManager".equals(evt.getPropertyName())) { if (((Boolean) evt.getNewValue()).booleanValue()) { ScrollPaneLayout currLayout = (ScrollPaneLayout) c .getLayout(); if (!(currLayout instanceof AdjustedLayout)) { c.setLayout(new AdjustedLayout((ScrollPaneLayout) c .getLayout())); } } // else { // ScrollPaneLayout currLayout = (ScrollPaneLayout) c // .getLayout(); // if (currLayout instanceof AdjustedLayout) { // c.setLayout(((AdjustedLayout) currLayout).delegate); // } // } } if ("background".equals(evt.getPropertyName())) { // propagate application-specific background color to the // scroll bars. Color newBackgr = (Color) evt.getNewValue(); if (!(newBackgr instanceof UIResource)) { JScrollBar vertical = scrollpane.getVerticalScrollBar(); if (vertical != null) { if (vertical.getBackground() instanceof UIResource) { vertical.setBackground(newBackgr); } } JScrollBar horizontal = scrollpane .getHorizontalScrollBar(); if (horizontal != null) { if (horizontal.getBackground() instanceof UIResource) { horizontal.setBackground(newBackgr); } } } } if ("columnHeader".equals(evt.getPropertyName()) || "componentOrientation".equals(evt.getPropertyName()) || "ancestor".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { // need to switch the corner filler based on the // current scroll pane state. if (scrollpane != null) { installTableHeaderCornerFiller(scrollpane); } } }); } } }; c.addPropertyChangeListener(this.substancePropertyChangeListener); this.substanceVerticalScrollbarChangeListener = new ChangeListener() { public void stateChanged(ChangeEvent e) { // check if it's a tree inside if (c.getViewport().getView() instanceof JTree) { JTree tree = (JTree) c.getViewport().getView(); // check if the smart scroll is enabled if (FadeConfigurationManager .getInstance() .fadeAllowed( SubstanceLookAndFeel.TREE_SMART_SCROLL_ANIMATION_KIND, tree)) { SubstanceTreeUI treeUI = (SubstanceTreeUI) tree.getUI(); final Rectangle viewportRect = c.getViewport() .getViewRect(); int pivotX = treeUI.getPivotRendererX(viewportRect); int currPivotX = viewportRect.x;// + viewportRect.width // / 2; int delta = pivotX - currPivotX; int finalX = viewportRect.x + delta; if (finalX < 0) { delta -= finalX; } final int finalDelta = delta; if (Math.abs(finalDelta) > viewportRect.width / 6) { // System.err.println("Median : " + medianX); FadeTrackerCallback callback = new UIThreadFadeTrackerAdapter() { @Override public void fadeEnded(FadeKind fadeKind) { // nothing to do here - the scroll has been // either cancelled or just ended } @Override public void fadePerformed(FadeKind fadeKind, float fadeCycle) { if (fadeCycle >= 0.5) { int nudge = (int) (finalDelta * (fadeCycle - 0.5)); c .getViewport() .setViewPosition( new Point( viewportRect.x + nudge, viewportRect.y)); } // System.out.println(fadeCycle10); } }; if (horScrollId >= 0) { // cancel previous horizontal scroll FadeTracker.getInstance().cancelFadeInstance( horScrollId); } final FadeStep delegate = LafWidgetUtilities .getAnimationKind(tree).getStep(); horScrollId = FadeTracker .getInstance() .trackFadeIn( SubstanceLookAndFeel.TREE_SMART_SCROLL_ANIMATION_KIND, tree, null, false, callback, new LafConstants.AnimationKind( new FadeStep() { public float getNextStep( FadeKind fadeKind, float currFadePosition, boolean isFadeIn, boolean isLooping) { if (currFadePosition < 0.5) return delegate .getNextStep( fadeKind, currFadePosition, isFadeIn, isLooping) / 3.0f; else return delegate .getNextStep( fadeKind, currFadePosition, isFadeIn, isLooping) / 1.5f; } }, "substancelaf.treeSmartScrollFadeStep")); // } // System.err.println("Starting " + horScrollId); } } } } }; c.getVerticalScrollBar().getModel().addChangeListener( this.substanceVerticalScrollbarChangeListener); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicScrollPaneUI#uninstallListeners(javax.swing * .JComponent) */ @Override protected void uninstallListeners(JComponent c) { c.removePropertyChangeListener(this.substancePropertyChangeListener); this.substancePropertyChangeListener = null; JScrollPane jsp = (JScrollPane) c; jsp.getVerticalScrollBar().getModel().removeChangeListener( this.substanceVerticalScrollbarChangeListener); this.substanceVerticalScrollbarChangeListener = null; super.uninstallListeners(c); } /** * Layout manager to adjust the bounds of scrollbars and the viewport when * the default ({@link SubstanceScrollPaneBorder}) border is set on the * relevant {@link JScrollPane}. * * @author Kirill Grouchnikov */ protected static class AdjustedLayout extends ScrollPaneLayout implements UIResource { /** * The delegate layout. */ protected ScrollPaneLayout delegate; /** * Creates a new layout for adjusting the bounds of scrollbars and the * viewport. * * @param delegate * The original (delegate) layout. */ public AdjustedLayout(ScrollPaneLayout delegate) { this.delegate = delegate; } @Override public void addLayoutComponent(String s, Component c) { delegate.addLayoutComponent(s, c); } @Override public boolean equals(Object obj) { return delegate.equals(obj); } @Override public JViewport getColumnHeader() { return delegate.getColumnHeader(); } @Override public Component getCorner(String key) { return delegate.getCorner(key); } @Override public JScrollBar getHorizontalScrollBar() { return delegate.getHorizontalScrollBar(); } @Override public int getHorizontalScrollBarPolicy() { return delegate.getHorizontalScrollBarPolicy(); } @Override public JViewport getRowHeader() { return delegate.getRowHeader(); } @Override public JScrollBar getVerticalScrollBar() { return delegate.getVerticalScrollBar(); } @Override public int getVerticalScrollBarPolicy() { return delegate.getVerticalScrollBarPolicy(); } @Override public JViewport getViewport() { return delegate.getViewport(); } @Override @SuppressWarnings("deprecation") public Rectangle getViewportBorderBounds(JScrollPane scrollpane) { return delegate.getViewportBorderBounds(scrollpane); } @Override public int hashCode() { return delegate.hashCode(); } @Override public Dimension minimumLayoutSize(Container parent) { return delegate.minimumLayoutSize(parent); } @Override public Dimension preferredLayoutSize(Container parent) { return delegate.preferredLayoutSize(parent); } @Override public void removeLayoutComponent(Component c) { delegate.removeLayoutComponent(c); } @Override public void setHorizontalScrollBarPolicy(int x) { delegate.setHorizontalScrollBarPolicy(x); } @Override public void setVerticalScrollBarPolicy(int x) { delegate.setVerticalScrollBarPolicy(x); } @Override public void syncWithScrollPane(JScrollPane sp) { delegate.syncWithScrollPane(sp); } @Override public String toString() { return delegate.toString(); } // ScrollPaneLayout.UIResource { /* * (non-Javadoc) * * @see javax.swing.ScrollPaneLayout#layoutContainer(java.awt.Container) */ @Override public void layoutContainer(Container parent) { delegate.layoutContainer(parent); JScrollPane scrollPane = (JScrollPane) parent; Border border = scrollPane.getBorder(); boolean toAdjust = (border instanceof SubstanceScrollPaneBorder); if (border instanceof TransitionBorder) { toAdjust = (((TransitionBorder) border).getDelegate() instanceof SubstanceScrollPaneBorder); } if (toAdjust) { JScrollBar vertical = scrollPane.getVerticalScrollBar(); JScrollBar horizontal = scrollPane.getHorizontalScrollBar(); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(scrollPane)) / 2.0); int borderWidth = (int) SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(scrollPane)); int dx = 0, dy = 0, dw = 0, dh = 0; if (scrollPane.getComponentOrientation().isLeftToRight()) { if ((vertical != null) && vertical.isVisible()) { Rectangle vBounds = vertical.getBounds(); dw += (1 + borderDelta); vertical.setBounds(vBounds.x + 1 + borderDelta, vBounds.y + 1 - 2 * borderWidth, vBounds.width, vBounds.height + 2 * borderWidth); } if ((horizontal != null) && horizontal.isVisible()) { dh += (1 + borderDelta); Rectangle hBounds = horizontal.getBounds(); horizontal.setBounds(hBounds.x + 1 - 2 * borderWidth, hBounds.y + 1, hBounds.width + 2 * borderWidth, hBounds.height); } if (delegate.getCorner(ScrollPaneLayout.LOWER_RIGHT_CORNER) != null) { Rectangle lrBounds = delegate.getCorner( ScrollPaneLayout.LOWER_RIGHT_CORNER) .getBounds(); delegate.getCorner(ScrollPaneLayout.LOWER_RIGHT_CORNER) .setBounds(lrBounds.x + 1 + borderDelta, lrBounds.y + 1 + borderDelta, lrBounds.width, lrBounds.height); } if (delegate.getCorner(ScrollPaneLayout.UPPER_RIGHT_CORNER) != null) { Rectangle urBounds = delegate.getCorner( ScrollPaneLayout.UPPER_RIGHT_CORNER) .getBounds(); delegate.getCorner(ScrollPaneLayout.UPPER_RIGHT_CORNER) .setBounds(urBounds.x + 1 + borderDelta, urBounds.y + borderDelta, urBounds.width - 1, urBounds.height); } } else { if ((vertical != null) && vertical.isVisible()) { dx -= (1 + borderDelta); dw += (1 + borderDelta); Rectangle vBounds = vertical.getBounds(); vertical.setBounds(vBounds.x - 1 - borderDelta, vBounds.y - 1 - borderDelta, vBounds.width, vBounds.height + 2 * borderWidth); } if ((horizontal != null) && horizontal.isVisible()) { dh += (1 + borderDelta); Rectangle hBounds = horizontal.getBounds(); horizontal.setBounds(hBounds.x - 1 - borderDelta, hBounds.y + 1 + borderDelta, hBounds.width + 2 * borderWidth, hBounds.height); } if (delegate.getCorner(ScrollPaneLayout.LOWER_LEFT_CORNER) != null) { Rectangle llBounds = delegate.getCorner( ScrollPaneLayout.LOWER_LEFT_CORNER).getBounds(); delegate.getCorner(ScrollPaneLayout.LOWER_LEFT_CORNER) .setBounds(llBounds.x - 1 - borderDelta, llBounds.y - 1 - borderDelta, llBounds.width, llBounds.height); } if (delegate.getCorner(ScrollPaneLayout.UPPER_LEFT_CORNER) != null) { Rectangle ulBounds = delegate.getCorner( ScrollPaneLayout.UPPER_LEFT_CORNER).getBounds(); delegate.getCorner(ScrollPaneLayout.UPPER_LEFT_CORNER) .setBounds(ulBounds.x - borderDelta, ulBounds.y - borderDelta, ulBounds.width - 1, ulBounds.height); } } if (delegate.getViewport() != null) { Rectangle vpBounds = delegate.getViewport().getBounds(); delegate.getViewport().setBounds( new Rectangle(vpBounds.x + dx, vpBounds.y + dy, vpBounds.width + dw, vpBounds.height + dh)); } if (delegate.getColumnHeader() != null) { Rectangle columnHeaderBounds = delegate.getColumnHeader() .getBounds(); delegate.getColumnHeader().setBounds( new Rectangle(columnHeaderBounds.x + dx, columnHeaderBounds.y + dy, columnHeaderBounds.width + dw, columnHeaderBounds.height)); } } } } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void update(Graphics g, JComponent c) { BackgroundPaintingUtils.updateIfOpaque(g, c); JScrollPane jsp = (JScrollPane) c; // if (SubstanceCoreUtilities.hasOverlayProperty(jsp)) { // JViewport viewport = jsp.getViewport(); // int dx = -viewport.getX() + viewport.getViewRect().x; // int dy = viewport.getY() - viewport.getViewRect().y; // Graphics2D graphics = (Graphics2D) g.create(); // // Area clip = new Area(); // if ((jsp.getVerticalScrollBar() != null) // && jsp.getVerticalScrollBar().isVisible()) // clip.add(new Area(jsp.getVerticalScrollBar().getBounds())); // if ((jsp.getHorizontalScrollBar() != null) // && jsp.getHorizontalScrollBar().isVisible()) // clip.add(new Area(jsp.getHorizontalScrollBar().getBounds())); // graphics.setClip(clip); // // graphics.translate(-dx, dy); // JComponent view = (JComponent) viewport.getView(); // // fix for defect 201 - set non-double buffer for the viewport // // recursively. Takes care of desktop pane wrapped in scroll pane. // Map dbSnapshot = new HashMap(); // SubstanceCoreUtilities.makeNonDoubleBuffered(view, dbSnapshot); // view.paint(graphics); // // restore the double buffer. // SubstanceCoreUtilities.restoreDoubleBuffered(view, dbSnapshot); // graphics.translate(dx, -dy); // graphics.dispose(); // } LayoutManager lm = jsp.getLayout(); ScrollPaneLayout scrollLm = null; if (lm instanceof ScrollPaneLayout) { scrollLm = (ScrollPaneLayout) lm; } else { if (lm instanceof TransitionLayout) { LayoutManager origLm = ((TransitionLayout) lm).getDelegate(); if (origLm instanceof ScrollPaneLayout) { scrollLm = (ScrollPaneLayout) origLm; } } } if (scrollLm != null) { Set corners = new HashSet(); if (scrollLm.getCorner(ScrollPaneLayout.LOWER_LEFT_CORNER) != null) { corners.add(scrollLm .getCorner(ScrollPaneLayout.LOWER_LEFT_CORNER)); } if (scrollLm.getCorner(ScrollPaneLayout.LOWER_RIGHT_CORNER) != null) { corners.add(scrollLm .getCorner(ScrollPaneLayout.LOWER_RIGHT_CORNER)); } if (scrollLm.getCorner(ScrollPaneLayout.UPPER_LEFT_CORNER) != null) { corners.add(scrollLm .getCorner(ScrollPaneLayout.UPPER_LEFT_CORNER)); } if (scrollLm.getCorner(ScrollPaneLayout.UPPER_RIGHT_CORNER) != null) { corners.add(scrollLm .getCorner(ScrollPaneLayout.UPPER_RIGHT_CORNER)); } if (TransitionLayout.isOpaque(c)) { for (Component corner : corners) { BackgroundPaintingUtils.fillAndWatermark(g, c, c .getBackground(), corner.getBounds()); } } } super.paint(g, c); } /** * Installs a corner filler that matches the table header. This is done to * provide a continuous appearance for tables with table headers placed in * scroll panes. * * @param scrollpane * Scroll pane. */ protected static void installTableHeaderCornerFiller(JScrollPane scrollpane) { // install custom scroll pane corner filler // for continuous painting of table headers JViewport columnHeader = scrollpane.getColumnHeader(); // System.out.println("Column header " + columnHeader); if (columnHeader == null) return; Component columnHeaderComp = columnHeader.getView(); // System.out.println("Column header comp " + columnHeaderComp); if (!(columnHeaderComp instanceof JTableHeader)) return; JTableHeader tableHeader = (JTableHeader) columnHeaderComp; TableHeaderUI tableHeaderUI = tableHeader.getUI(); if (!(tableHeaderUI instanceof SubstanceTableHeaderUI)) return; SubstanceTableHeaderUI ui = (SubstanceTableHeaderUI) tableHeaderUI; JComponent scrollPaneCornerFiller = ui.getScrollPaneCornerFiller(); String cornerKey = scrollpane.getComponentOrientation().isLeftToRight() ? JScrollPane.UPPER_RIGHT_CORNER : JScrollPane.UPPER_LEFT_CORNER; Component cornerComp = scrollpane.getCorner(cornerKey); // Corner component can be replaced when the current one is null or // UIResource boolean canReplace = (cornerComp == null) || (cornerComp instanceof UIResource); // System.out.println(canReplace + ":" + cornerComp); if (canReplace) { scrollpane.setCorner(cornerKey, scrollPaneCornerFiller); } } } substance-5.3.orig/src/org/jvnet/substance/SubstanceTextPaneUI.java0000644000175000017500000001247011167404262025406 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.Color; import java.awt.Graphics; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.plaf.*; import javax.swing.plaf.basic.BasicBorders; import javax.swing.plaf.basic.BasicTextPaneUI; import org.jvnet.lafwidget.animation.FadeStateListener; import org.jvnet.substance.utils.*; /** * UI for text panes in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceTextPaneUI extends BasicTextPaneUI { /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /** * The associated text pane. */ protected JTextPane textPane; /** * Property change listener. */ protected PropertyChangeListener substancePropertyChangeListener; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceTextPaneUI(comp); } /** * Simple constructor. * * @param c * Component (text pane). */ public SubstanceTextPaneUI(JComponent c) { super(); this.textPane = (JTextPane) c; } @Override protected void installListeners() { super.installListeners(); this.substanceFadeStateListener = new FadeStateListener(this.textPane, null, null); this.substanceFadeStateListener.registerListeners(false); this.substancePropertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("font".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { // remember the caret location - issue 404 int caretPos = textPane.getCaretPosition(); textPane.updateUI(); textPane.setCaretPosition(caretPos); } }); } } }; this.textPane .addPropertyChangeListener(this.substancePropertyChangeListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTextUI#uninstallListeners() */ @Override protected void uninstallListeners() { this.substanceFadeStateListener.unregisterListeners(); this.substanceFadeStateListener = null; this.textPane .removePropertyChangeListener(this.substancePropertyChangeListener); this.substancePropertyChangeListener = null; super.uninstallListeners(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTextUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); Border b = this.textPane.getBorder(); if (b == null || b instanceof UIResource) { Border newB = new BorderUIResource.CompoundBorderUIResource( new EmptyBorder(SubstanceSizeUtils .getTextBorderInsets(SubstanceSizeUtils .getComponentFontSize(this.textPane))), new BasicBorders.MarginBorder()); this.textPane.setBorder(newB); } // support for per-window skins Color foregr = this.textPane.getForeground(); if ((foregr == null) || (foregr instanceof UIResource)) { this.textPane.setForeground(SubstanceColorUtilities .getForegroundColor(SubstanceLookAndFeel.getCurrentSkin( this.textPane).getMainDefaultColorScheme())); } } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTextUI#paintBackground(java.awt.Graphics) */ @Override protected void paintBackground(Graphics g) { SubstanceTextUtilities.paintTextCompBackground(g, this.textPane); } } substance-5.3.orig/src/org/jvnet/substance/resources/0000755000175000017500000000000011256731150022711 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/resources/Labels_cs.properties0000644000175000017500000000127011064711672026722 0ustar drazzibdrazzib# Czech translation by Milan Misak SystemMenu.close=Zav\u0159\u00EDt SystemMenu.iconify=Minimalizovat SystemMenu.restore=Obnovit SystemMenu.maximize=Maximalizovat SystemMenu.skins=Substance skiny SystemMenu.showHeapStatus=Uka\u017E heap stav Tooltip.contentsNotSaved=obsah nen\u00ED ulo\u017Een Tooltip.heapStatusPanel=Heap stav. Klikni pro spu\u0161t\u011Bn\u00ED garbage collectoru Xoetrope.hue=Zabarven\u00FD Xoetrope.brightness=Sv\u011Btlost Xoetrope.saturation=Nasycen\u00FD Xoetrope.warm=TEPL\u00C9 Xoetrope.cold=CHLADN\u00C9 Xoetrope.decimalRGB=Des\u00FDtkov\u00E9 RGB Xoetrope.webSafeColors=Pou\u017E\u00FD barvy bezpe\u010Dn\u00E9 pro web substance-5.3.orig/src/org/jvnet/substance/resources/Labels_hu.properties0000644000175000017500000000105011064712032026714 0ustar drazzibdrazzibSystemMenu.showHeapStatus=Halom \u00e1llapot\u00e1nak megjelen\u00edt\u00e9se Tooltip.contentsNotSaved=A tartalom nincs mentve. Tooltip.heapStatusPanel=A halommem\u00f3ria \u00e1llapota. Kattintson ide a szem\u00e9tgy\u00fbjt\u00f5 futtat\u00e1s\u00e1hoz. Xoetrope.hue=\u00c1rnyalat Xoetrope.brightness=F\u00e9nyer\u00f5 Xoetrope.saturation=Tel\u00edtetts\u00e9g Xoetrope.warm=MELEG Xoetrope.cold=HIDEG Xoetrope.decimalRGB=Decim\u00e1lis RGB Xoetrope.webSafeColors=Weben megjelen\u00edthet\u00f5 sz\u00ednek haszn\u00e1lata substance-5.3.orig/src/org/jvnet/substance/resources/Labels_nl.properties0000644000175000017500000000120211203744320026710 0ustar drazzibdrazzib# Dutch translation by Ilana Paktor and Joachim van den Berg SystemMenu.close=Sluit SystemMenu.iconify=Minimaliseer SystemMenu.restore=Herstel SystemMenu.maximize=Maximaliseer SystemMenu.skins=Substance skins SystemMenu.showHeapStatus=Toon heap status Tooltip.contentsNotSaved=contents zijn niet bewaard Tooltip.heapStatusPanel=Heap status. Klik om de Garbage Collector te activeren Xoetrope.hue=Kleurschakering Xoetrope.brightness=Helderheid Xoetrope.saturation=Verzadiging Xoetrope.warm=WARM Xoetrope.cold=KOUD Xoetrope.decimalRGB=Decimale RGB Xoetrope.webSafeColors=Gebruik Web-Veilige kleurensubstance-5.3.orig/src/org/jvnet/substance/resources/Labels_zh_CN.properties0000644000175000017500000000127111064712206027311 0ustar drazzibdrazzib# Chinese translation by Pprun and Qil Wong SystemMenu.close=\u5173\u95ed SystemMenu.iconify=\u6700\u5c0f\u5316 SystemMenu.restore=\u6062\u590d SystemMenu.maximize=\u6700\u5927\u5316 SystemMenu.showHeapStatus=\u663e\u793a\u5783\u573e\uff08GC\uff09\u5806\u72b6\u6001 Tooltip.contentsNotSaved=\u5185\u5bb9\u672a\u4fdd\u5b58 Tooltip.heapStatusPanel=\u5355\u51fb\u8fd0\u884c\u5783\u573e\u6536\u96c6 Xoetrope.hue=\u8272\u8c03 Xoetrope.brightness=\u4eae\u5ea6 Xoetrope.saturation=\u9971\u548c\u5ea6 Xoetrope.warm=\u6696\u8272\u8c03 Xoetrope.cold=\u51b7\u8272\u8c03 Xoetrope.decimalRGB=\u5341\u8fdb\u5236RGB Xoetrope.webSafeColors=\u4ec5\u4f7f\u7528WEB\u8272 substance-5.3.orig/src/org/jvnet/substance/resources/Labels_sv.properties0000644000175000017500000000110311256673526026750 0ustar drazzibdrazzibSystemMenu.close=St\u00e4ng SystemMenu.iconify=Minimera SystemMenu.restore=\u00c5terst\u00e4ll SystemMenu.maximize=Maximera SystemMenu.showHeapStatus=Visa heap-status Tooltip.contentsNotSaved=inneh\u00e5llet har inte sparats Tooltip.heapStatusPanel=Heap-status. Klicka h\u00e4r f\u00f6r att k\u00f6ra skr\u00e4pinsamlaren Xoetrope.hue=Nyans Xoetrope.brightness=Ljusstyrka Xoetrope.saturation=M\u00e4ttnad Xoetrope.warm=VARM Xoetrope.cold=KALL Xoetrope.decimalRGB=RGB-decimaler Xoetrope.webSafeColors=Anv\u00e4nd webbs\u00e4kra f\u00e4rger substance-5.3.orig/src/org/jvnet/substance/resources/Labels.properties0000644000175000017500000000107311064674332026237 0ustar drazzibdrazzib# Default labels by Kirill Grouchnikov SystemMenu.close=Close SystemMenu.iconify=Iconify SystemMenu.restore=Restore SystemMenu.maximize=Maximize SystemMenu.skins=Substance skins SystemMenu.showHeapStatus=Show heap status Tooltip.contentsNotSaved=contents not saved Tooltip.heapStatusPanel=Heap status. Click to run garbage collector Xoetrope.hue=Hue Xoetrope.brightness=Brightness Xoetrope.saturation=Saturation Xoetrope.warm=WARM Xoetrope.cold=COLD Xoetrope.decimalRGB=Decimal RGB Xoetrope.webSafeColors=Use web safe colors substance-5.3.orig/src/org/jvnet/substance/resources/Labels_ja.properties0000644000175000017500000000132011064712302026672 0ustar drazzibdrazzibSystemMenu.showHeapStatus=\u30d2\u30fc\u30d7 \u30b9\u30c6\u30fc\u30bf\u30b9\u3092\u8868\u793a Tooltip.contentsNotSaved=\u30b3\u30f3\u30c6\u30f3\u30c4\u304c\u4fdd\u5b58\u3055\u308c\u3066\u3044\u307e\u305b\u3093 Tooltip.heapStatusPanel=\u30d2\u30fc\u30d7 \u30b9\u30c6\u30fc\u30bf\u30b9\u3002\u30ac\u30fc\u30d9\u30b8 \u30b3\u30ec\u30af\u30bf\u3092\u5b9f\u884c\u3059\u308b\u306b\u306f\u3001\u30af\u30ea\u30c3\u30af\u3057\u307e\u3059 Xoetrope.hue=\u8272\u5408\u3044 Xoetrope.brightness=\u8f1d\u5ea6 Xoetrope.saturation=\u5f69\u5ea6 Xoetrope.warm=\u6696 Xoetrope.cold=\u51b7 Xoetrope.decimalRGB=10 \u9032\u6570 RGB Xoetrope.webSafeColors=Web \u30bb\u30fc\u30d5 \u30ab\u30e9\u30fc\u3092\u4f7f\u7528 substance-5.3.orig/src/org/jvnet/substance/resources/Labels_pt_BR.properties0000644000175000017500000000123511064712126027317 0ustar drazzibdrazzib# Portuguese (Brazil) translation by Claudio de Oliveira Miranda SystemMenu.close=Fechar SystemMenu.iconify=Minimizar SystemMenu.restore=Restaurar SystemMenu.maximize=Maximizar SystemMenu.skins=Apar\u00eancia do Substance SystemMenu.showHeapStatus=Mostrar status do heap Tooltip.contentsNotSaved=Conte\u00fado n\u00e3o gravado Tooltip.heapStatusPanel=Status do heap. Clique para acionar o garbage collector Xoetrope.hue=Tonalidade Xoetrope.brightness=Brilho Xoetrope.saturation=Satura\u00e7\u00e3o Xoetrope.warm=QUENTE Xoetrope.cold=FRIO Xoetrope.decimalRGB=RGB Decimal Xoetrope.webSafeColors=Usar cores seguras da web substance-5.3.orig/src/org/jvnet/substance/resources/Labels_ru.properties0000644000175000017500000000271111064712154026740 0ustar drazzibdrazzib# Russian translation by Kirill Grouchnikov SystemMenu.close=\u0417\u0430\u043A\u0440\u044B\u0442\u044C SystemMenu.iconify=\u0421\u0432\u0435\u0440\u043d\u0443\u0442\u044c SystemMenu.restore=\u0412\u0435\u0440\u043d\u0443\u0442\u044c SystemMenu.maximize=\u0423\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c SystemMenu.skins=\u041E\u0431\u043E\u043B\u043E\u0447\u043A\u0438 Substance SystemMenu.showHeapStatus=\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0441\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u0435 \u043A\u0443\u0447\u0438 Tooltip.contentsNotSaved=\u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u0435 \u043D\u0435 \u0441\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u043E Tooltip.heapStatusPanel=\u0421\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u0435 \u043A\u0443\u0447\u0438. \u041A\u043B\u0438\u043A \u043C\u044B\u0448\u0438 \u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442 \u0441\u0431\u043E\u0440\u0449\u0438\u043A \u043C\u0443\u0441\u043E\u0440\u0430. Xoetrope.hue=\u041E\u0442\u0442\u0435\u043D\u043E\u043A Xoetrope.brightness=\u042F\u0440\u043A\u043E\u0441\u0442\u044C Xoetrope.saturation=\u0421\u0430\u0442\u0443\u0440\u0430\u0446\u0438\u044F Xoetrope.warm=\u0422\u0415\u041F\u041B\u041E Xoetrope.cold=\u0425\u041E\u041B\u041E\u0414 Xoetrope.decimalRGB=\u0414\u0435\u0441\u044F\u0442\u0438\u0447\u043D\u043E\u0435 Xoetrope.webSafeColors=\u0411\u0440\u0430\u0442\u044C web-\u0446\u0432\u0435\u0442\u0430 substance-5.3.orig/src/org/jvnet/substance/resources/Labels_vi.properties0000644000175000017500000000156111065071754026737 0ustar drazzibdrazzib#Vietnamese translation by Thang Nguyen SystemMenu.close = \u0110\u00F3ng SystemMenu.iconify = T\u1ED1i thi\u1EC3u SystemMenu.maximize = T\u1ED1i \u0111a SystemMenu.restore = Ph\u1EE5c h\u1ED3i SystemMenu.showHeapStatus = Hi\u1EC3n th\u1ECB thanh tr\u1EA1ng th\u00E1i SystemMenu.skins = B\u1ED9 m\u00E0u Tooltip.contentsNotSaved = N\u1ED9i dung ch\u01B0a \u0111\u01B0\u1EE3c l\u01B0u Tooltip.heapStatusPanel = Thanh tr\u1EA1ng th\u00E1i. Nh\u1EA5p chu\u1ED9t \u0111\u1EC3 d\u1ECDn d\u1EB9p b\u1ED9 nh\u1EDB Xoetrope.brightness = \u0110\u1ED9 s\u00E1ng Xoetrope.cold = L\u1EA0NH Xoetrope.decimalRGB = RGB th\u1EADp ph\u00E2n Xoetrope.hue = M\u00E0u s\u1EAFc Xoetrope.saturation = \u0110\u1ED9 s\u1EABm Xoetrope.warm = N\u00D3NG Xoetrope.webSafeColors = S\u1EED d\u1EE5ng m\u00E0u web substance-5.3.orig/src/org/jvnet/substance/resources/Labels_it.properties0000644000175000017500000000126311064712042026723 0ustar drazzibdrazzib# Italian translation by Sandro Martini SystemMenu.close=Chiudi SystemMenu.iconify=Iconizza SystemMenu.restore=Ripristina SystemMenu.maximize=Massimizza SystemMenu.skins=Skin di Substance SystemMenu.showHeapStatus=Visualizza stato memoria SystemMenu.titlePainters=Disegna Titoli di Substance Tooltip.contentsNotSaved=contenuto non salvato Tooltip.heapStatusPanel=Stato memoria. Clicca per eseguire il Garbage Collector Xoetrope.hue=Tonalit\u00e0 Xoetrope.brightness=Luminosit\u00e0 Xoetrope.saturation=Saturazione Xoetrope.warm=CALDO Xoetrope.cold=FREDDO Xoetrope.decimalRGB=RGB Decimale Xoetrope.webSafeColors=Usa colori sicuri per il web substance-5.3.orig/src/org/jvnet/substance/resources/Labels_fi.properties0000644000175000017500000000072111064712002026677 0ustar drazzibdrazzibSystemMenu.showHeapStatus=N\u00e4yt\u00e4 keon tila Tooltip.contentsNotSaved=sis\u00e4lt\u00f6\u00e4 ei tallennettu Tooltip.heapStatusPanel=Keon tila. Suorita muistin siivous napsauttamalla Xoetrope.hue=S\u00e4vy Xoetrope.brightness=Kirkkaus Xoetrope.saturation=Kyll\u00e4isyys Xoetrope.warm=L\u00c4MMIN Xoetrope.cold=KYLM\u00c4 Xoetrope.decimalRGB=Desimaali-RGB Xoetrope.webSafeColors=K\u00e4yt\u00e4 selainturvallisia v\u00e4rej\u00e4 substance-5.3.orig/src/org/jvnet/substance/resources/Labels_fr_CA.properties0000644000175000017500000000072211064712012027255 0ustar drazzibdrazzibSystemMenu.showHeapStatus=Afficher l\'\u00e9tat d\'entassement Tooltip.contentsNotSaved=contenu non enregistr\u00e9 Tooltip.heapStatusPanel=\u00c9tat d\'entassement. Cliquez pour ex\u00e9cuter le nettoyeur Xoetrope.hue=Teinte Xoetrope.brightness=Luminosit\u00e9 Xoetrope.saturation=Saturation Xoetrope.warm=CHAUD Xoetrope.cold=FROID Xoetrope.decimalRGB=RVB d\u00e9cimal Xoetrope.webSafeColors=Utiliser des couleurs s\u00fbres pour le Web substance-5.3.orig/src/org/jvnet/substance/resources/Labels_bg.properties0000644000175000017500000000362111064711660026704 0ustar drazzibdrazzib# Bulgarian translation by Zar Petkov SystemMenu.close=\u0417\u0430\u0442\u0432\u0430\u0440\u044f\u043d\u0435 SystemMenu.iconify=\u041f\u043e\u0441\u0442\u0430\u0432\u044f\u043d\u0435 \u043d\u0430 \u0438\u043a\u043e\u043d\u0438 SystemMenu.restore=\u0412\u044a\u0437\u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0432\u0430\u043d\u0435 SystemMenu.maximize=\u041c\u0430\u043a\u0441\u0438\u043c\u0438\u0437\u0438\u0440\u0430\u043d\u0435 SystemMenu.skins=\u0421\u0442\u0438\u043b\u043e\u0432\u0435 \u043d\u0430 Substance SystemMenu.showHeapStatus=\u0421\u0442\u0430\u0442\u0443\u0441 \u043D\u0430 \u0434\u0438\u043D\u0430\u043C\u0438\u0447\u043D\u0430\u0442\u0430 \u043F\u0430\u043C\u0435\u0442 Tooltip.contentsNotSaved=\u0421\u044A\u0434\u044A\u0440\u0436\u0430\u043D\u0438\u0435\u0442\u043E \u043D\u0435 \u0435 \u0437\u0430\u043F\u0430\u0437\u0435\u043D\u043E \u0432\u044A\u0440\u0445\u0443 \u0434\u0438\u0441\u043A\u0430 Tooltip.heapStatusPanel=\u0421\u0442\u0430\u0442\u0443\u0441 \u043D\u0430 \u0434\u0438\u043D\u0430\u043C\u0438\u0447\u043D\u0430\u0442\u0430 \u043F\u0430\u043C\u0435\u0442. \u041A\u043B\u0438\u043A\u043D\u0438 \u0437\u0430 \u0434\u0430 \u0441\u0442\u0430\u0440\u0442\u0438\u0440\u0430\u0448 garbage collector Xoetrope.hue=\u0422\u043E\u043D Xoetrope.brightness=\u041E\u0441\u0432\u0435\u0442\u0435\u043D\u043E\u0441\u0442 Xoetrope.saturation=\u041D\u0430\u0441\u0438\u0442\u0435\u043D\u043E\u0441\u0442 Xoetrope.warm=\u0421\u0422\u0423\u0414\u0415\u041D\u041E Xoetrope.cold=\u0422\u041E\u041F\u041B\u041E Xoetrope.decimalRGB=\u0414\u0435\u0441\u0435\u0442\u0438\u0447\u043D\u043E RGB Xoetrope.webSafeColors=\u0418\u0437\u043F\u043E\u043B\u0437\u0432\u0430\u0439 \u0446\u0432\u0435\u0442\u043E\u0432\u0435 \u043F\u043E\u0434\u0445\u043E\u0434\u044F\u0449\u0438 \u0437\u0430 \u0438\u043D\u0442\u0435\u0440\u043D\u0435\u0442 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430. substance-5.3.orig/src/org/jvnet/substance/resources/Labels_es_MX.properties0000644000175000017500000000064611064712372027334 0ustar drazzibdrazzibSystemMenu.showHeapStatus=Mostrar estado de pila Tooltip.contentsNotSaved=contenidos no guardados Tooltip.heapStatusPanel=Estado de pila. Haga clic para ejecutar el basurero Xoetrope.hue=Tono Xoetrope.brightness=Brillo Xoetrope.saturation=Saturaci\u00f3n Xoetrope.warm=C\u00c1LIDO Xoetrope.cold=FR\u00cdO Xoetrope.decimalRGB=RGB decimal Xoetrope.webSafeColors=Use colores seguros para la Web substance-5.3.orig/src/org/jvnet/substance/resources/Labels_pl.properties0000644000175000017500000000131111064712116026716 0ustar drazzibdrazzib# Polish translation by Maciej Zwirski SystemMenu.close=Zamknij SystemMenu.iconify=Minimalizuj SystemMenu.restore=Przywr\u00F3\u0107 SystemMenu.maximize=Maksymalizuj SystemMenu.skins=Sk\u00F3rki Substance SystemMenu.showHeapStatus=Poka\u017C stan stosu Tooltip.contentsNotSaved=zawarto\u015B\u0107 nie zosta\u0142a zapisana Tooltip.heapStatusPanel=Stan stosu. Kliknij, aby uruchomi\u0107 od\u015Bmiecanie pami\u0119ci Xoetrope.hue=Odcie\u0144 Xoetrope.brightness=Jasno\u015B\u0107 Xoetrope.saturation=Nasycenie Xoetrope.warm=CIEP\u0141E Xoetrope.cold=ZIMNE Xoetrope.decimalRGB=Dziesi\u0119tne RGB Xoetrope.webSafeColors=U\u017Cyj kolor\u00F3w przyjaznych dla sieci substance-5.3.orig/src/org/jvnet/substance/resources/Labels_fr.properties0000644000175000017500000000116111064712024026713 0ustar drazzibdrazzib# French translation by Alois Cochard SystemMenu.close=Fermer SystemMenu.iconify=R\u00E9duire SystemMenu.restore=Restaurer SystemMenu.maximize=Agrandir SystemMenu.skins=Substance skins SystemMenu.showHeapStatus=Voir le statut de la pile Tooltip.contentsNotSaved=contenu non sauv\u00E9 Tooltip.heapStatusPanel=Statut de la pile. Cliquez pour lancer 'garbage collector' Xoetrope.hue=Ton Xoetrope.brightness=Luminosit\u00E9 Xoetrope.saturation=Saturation Xoetrope.warm=CHAUD Xoetrope.cold=FROID Xoetrope.decimalRGB=RGB D\u00E9cimal Xoetrope.webSafeColors=Couleurs compatible web substance-5.3.orig/src/org/jvnet/substance/resources/Labels_iw.properties0000644000175000017500000000205111064712054026725 0ustar drazzibdrazzib# Hebrew translation by Kirill Grouchnikov SystemMenu.close=\u05E1\u05D2\u05D5\u05E8 SystemMenu.iconify=\u05DE\u05D6\u05E2\u05E8 SystemMenu.restore=\u05E9\u05D7\u05D6\u05E8 SystemMenu.maximize=\u05D4\u05D2\u05D3\u05DC SystemMenu.skins=\u05E7\u05E8\u05D5\u05DE\u05D9\u05DD \u05D1:Substance SystemMenu.showHeapStatus=\u05D4\u05E8\u05D0\u05D4 \u05DE\u05E6\u05D1 \u05D4\u05E2\u05E8\u05D9\u05DE\u05D4 Tooltip.contentsNotSaved=\u05EA\u05DB\u05D5\u05DC\u05D4 \u05DC\u05D0 \u05E0\u05E9\u05DE\u05E8\u05D4 Tooltip.heapStatusPanel=\u05DE\u05E6\u05D1 \u05D4\u05E2\u05E8\u05D9\u05DE\u05D4. \u05DC\u05D7\u05E5 \u05DC\u05D4\u05E8\u05E6\u05EA \u05D0\u05D5\u05E1\u05E3 \u05D0\u05E9\u05E4\u05D4 Xoetrope.hue=\u05D2\u05D5\u05D5\u05DF Xoetrope.brightness=\u05D1\u05D4\u05D9\u05E8\u05D5\u05EA Xoetrope.saturation=\u05D4\u05E8\u05D5\u05D5\u05D9\u05D4 Xoetrope.warm=\u05D7\u05D5\u05DD Xoetrope.cold=\u05E7\u05D5\u05E8 Xoetrope.decimalRGB=\u05E2\u05E9\u05E8\u05D5\u05E0\u05D9 Xoetrope.webSafeColors=\u05E7\u05D7 \u05E6\u05D1\u05E2\u05D9 web substance-5.3.orig/src/org/jvnet/substance/resources/Labels_ar.properties0000644000175000017500000000257411064711646026730 0ustar drazzibdrazzib# Arabic translation by QamarAlZaman Habeek SystemMenu.close=\u0625\u063A\uFEFB\u0642 SystemMenu.iconify=\u062A\u0635\u063A\u064A\u0631 SystemMenu.restore=\u0627\u0633\u062A\u0631\u062C\u0627\u0639 SystemMenu.maximize=\u062A\u0643\u0628\u064A\u0631 SystemMenu.skins=\u0623\u064F\u0647\u064F\u0628 \u0627\u0644\u0633\u0628\u0633\u062A\u0646\u0633 SystemMenu.showHeapStatus=\u0625\u0638\u0647\u0627\u0631 \u0648\u0636\u0639 \u0627\u0644\u0631\u0643\u0627\u0645 Tooltip.contentsNotSaved=\u0627\u0644\u0645\u062d\u062a\u0648\u0649 \u063a\u064a\u0631 \u0645\u062d\u0641\u0648\u0638 Tooltip.heapStatusPanel=\u0648\u0636\u0639 \u0627\u0644\u0631\u0643\u0627\u0645. \u0627\u0646\u0642\u0631 \u0644\u062a\u0646\u0641\u064a\u0630 \u062c\u0627\u0645\u0639 \u0627\u0644\u0646\u0641\u0627\u064a\u0627\u062a Xoetrope.hue=\u0635\u0650\u0628\u0652\u063a Xoetrope.brightness=\u0627\u0644\u0623\u0644\u0645\u0639\u064a\u0629 Xoetrope.saturation=\u062a\u0634\u0628\u0639 Xoetrope.warm=\u062f\u0627\u0641\u0626 Xoetrope.cold=\u0628\u0627\u0631\u062f Xoetrope.decimalRGB=\u0627\u0644\u0631\u0645\u0632 \u0627\u0644\u0639\u062f\u062f\u064a \u0644\u0644\u0623\u0644\u0648\u0627\u0646 Xoetrope.webSafeColors=\u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0627\u0644\u0623\u0644\u0648\u0627\u0646 \u0627\u0644\u0645\u0644\u0627\u0626\u0645\u0629 \u0644\u0644\u0634\u0628\u0643\u0629 substance-5.3.orig/src/org/jvnet/substance/resources/Labels_pt.properties0000644000175000017500000000065611064712134026741 0ustar drazzibdrazzibSystemMenu.showHeapStatus=Mostrar status da pilha Tooltip.contentsNotSaved=conte\u00fado n\u00e3o gravado Tooltip.heapStatusPanel=Status da pilha. Clique para executar a coleta de lixo Xoetrope.hue=Matiz Xoetrope.brightness=Brilho Xoetrope.saturation=Satura\u00e7\u00e3o Xoetrope.warm=QUENTE Xoetrope.cold=FRIO Xoetrope.decimalRGB=RGB decimal Xoetrope.webSafeColors=Usar cores de seguran\u00e7a da Web substance-5.3.orig/src/org/jvnet/substance/resources/Labels_el.properties0000644000175000017500000000257711064712470026725 0ustar drazzibdrazzibSystemMenu.showHeapStatus=\u0395\u03bc\u03c6\u03ac\u03bd\u03b9\u03c3\u03b7 \u03ba\u03b1\u03c4\u03ac\u03c3\u03c4\u03b1\u03c3\u03b7\u03c2 \u03c3\u03c4\u03bf\u03af\u03b2\u03b1\u03c2 Tooltip.contentsNotSaved=\u03c4\u03b1 \u03c0\u03b5\u03c1\u03b9\u03b5\u03c7\u03cc\u03bc\u03b5\u03bd\u03b1 \u03b4\u03b5\u03bd \u03b1\u03c0\u03bf\u03b8\u03b7\u03ba\u03b5\u03cd\u03c4\u03b7\u03ba\u03b1\u03bd Tooltip.heapStatusPanel=\u039a\u03b1\u03c4\u03ac\u03c3\u03c4\u03b1\u03c3\u03b7 \u03c3\u03c4\u03bf\u03af\u03b2\u03b1\u03c2. \u039a\u03ac\u03bd\u03c4\u03b5 \u03ba\u03bb\u03b9\u03ba \u03b3\u03b9\u03b1 \u03bd\u03b1 \u03b5\u03ba\u03c4\u03b5\u03bb\u03b5\u03c3\u03c4\u03b5\u03af \u03bf \u03c3\u03c5\u03bb\u03bb\u03ad\u03ba\u03c4\u03b7\u03c2 \u03b1\u03c0\u03bf\u03c1\u03c1\u03b9\u03bc\u03ac\u03c4\u03c9\u03bd Xoetrope.hue=\u0391\u03c0\u03cc\u03c7\u03c1\u03c9\u03c3\u03b7 Xoetrope.brightness=\u03a6\u03c9\u03c4\u03b5\u03b9\u03bd\u03cc\u03c4\u03b7\u03c4\u03b1 Xoetrope.saturation=\u039a\u03bf\u03c1\u03b5\u03c3\u03bc\u03cc\u03c2 Xoetrope.warm=\u0398\u0395\u03a1\u039c\u039f Xoetrope.cold=\u03a8\u03a5\u03a7\u03a1\u039f Xoetrope.decimalRGB=\u0394\u03b5\u03ba\u03b1\u03b4\u03b9\u03ba\u03cc RGB Xoetrope.webSafeColors=\u03a7\u03c1\u03ae\u03c3\u03b7 \u03b1\u03c3\u03c6\u03b1\u03bb\u03ce\u03bd \u03b3\u03b9\u03b1 \u03c4\u03bf \u03b4\u03af\u03ba\u03c4\u03c5\u03bf \u03c7\u03c1\u03c9\u03bc\u03ac\u03c4\u03c9\u03bd substance-5.3.orig/src/org/jvnet/substance/resources/Labels_th.properties0000644000175000017500000000213011064712164026721 0ustar drazzibdrazzibSystemMenu.showHeapStatus=\u0e41\u0e2a\u0e14\u0e07\u0e2a\u0e16\u0e32\u0e19\u0e30\u0e42\u0e14\u0e22\u0e23\u0e27\u0e21 Tooltip.contentsNotSaved=\u0e22\u0e31\u0e07\u0e44\u0e21\u0e48\u0e44\u0e14\u0e49\u0e1a\u0e31\u0e19\u0e17\u0e36\u0e01\u0e2d\u0e07\u0e04\u0e4c\u0e1b\u0e23\u0e30\u0e01\u0e2d\u0e1a Tooltip.heapStatusPanel=\u0e2a\u0e16\u0e32\u0e19\u0e30\u0e42\u0e14\u0e22\u0e23\u0e27\u0e21 \u0e04\u0e25\u0e34\u0e01\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e40\u0e23\u0e35\u0e22\u0e01\u0e43\u0e0a\u0e49\u0e15\u0e31\u0e27\u0e23\u0e27\u0e1a\u0e23\u0e27\u0e21\u0e02\u0e22\u0e30 Xoetrope.hue=\u0e2a\u0e35\u0e2a\u0e31\u0e19 Xoetrope.brightness=\u0e04\u0e27\u0e32\u0e21\u0e2a\u0e27\u0e48\u0e32\u0e07 Xoetrope.saturation=\u0e04\u0e27\u0e32\u0e21\u0e40\u0e02\u0e49\u0e21 Xoetrope.warm=\u0e2d\u0e1a\u0e2d\u0e38\u0e48\u0e19 Xoetrope.cold=\u0e40\u0e22\u0e47\u0e19\u0e0a\u0e32 Xoetrope.decimalRGB=RGB \u0e40\u0e1b\u0e47\u0e19\u0e17\u0e28\u0e19\u0e34\u0e22\u0e21 Xoetrope.webSafeColors=\u0e43\u0e0a\u0e49\u0e2a\u0e35\u0e17\u0e35\u0e48\u0e1b\u0e25\u0e2d\u0e14\u0e20\u0e31\u0e22\u0e1a\u0e19\u0e40\u0e27\u0e47\u0e1a substance-5.3.orig/src/org/jvnet/substance/resources/Labels_de.properties0000644000175000017500000000122311064711714026700 0ustar drazzibdrazzib# German translation by Andreas Golchert SystemMenu.close=Schlie\u00DFen SystemMenu.iconify=Ikonifizieren SystemMenu.restore=Wiederherstellen SystemMenu.maximize=Maximieren SystemMenu.skins=Substance skins SystemMenu.showHeapStatus=Heap Status anzeigen Tooltip.contentsNotSaved=Inhalte wurden nicht gespeichert Tooltip.heapStatusPanel=Heap Status. Hier klicken, um den Garbage Collector zu starten Xoetrope.hue=Farbton Xoetrope.brightness=Helligkeit Xoetrope.saturation=S\u00E4ttigung Xoetrope.warm=WARM Xoetrope.cold=KALT Xoetrope.decimalRGB=Dezimal RGB Xoetrope.webSafeColors=Nur Webfarben anzeigen substance-5.3.orig/src/org/jvnet/substance/resources/Labels_ro.properties0000644000175000017500000000101511064712140026721 0ustar drazzibdrazzib# Romanian translation by Sergiu Nicolae Nacu and Ran Locar SystemMenu.showHeapStatus=Vizionare stare memorie heap Tooltip.contentsNotSaved=con\u0163inutul nu a fost salvat Tooltip.heapStatusPanel=Stare memorie heap. Apasa\u0163i pentru a porni garbage colector - ul Xoetrope.hue=Nuan\u0163\u0103 Xoetrope.brightness=Luminozitate Xoetrope.saturation=Satura\u0163ie Xoetrope.warm=CALD Xoetrope.cold=RECE Xoetrope.decimalRGB=RGB decimal Xoetrope.webSafeColors=Folose\u015Fte culori compatibile websubstance-5.3.orig/src/org/jvnet/substance/resources/Labels_tr.properties0000644000175000017500000000135011064712176026741 0ustar drazzibdrazzib# Turkish translation by Magnus de Pourbaix and Oncu Altuntas SystemMenu.close=Kapat SystemMenu.iconify=Simge Durumuna K\u00FC\u00E7\u00FClt SystemMenu.restore=\u00D6nceki boyut SystemMenu.maximize=Ekran\u0131 Kapla SystemMenu.showHeapStatus=K\u00fcme durumunu g\u00f6ster Tooltip.contentsNotSaved=i\u00e7erik kaydedilmedi Tooltip.heapStatusPanel=K\u00fcme durumu. \u00c7\u00f6p toplay\u0131c\u0131y\u0131 \u00e7al\u0131\u015ft\u0131rmak i\u00e7in t\u0131klay\u0131n Xoetrope.hue=Renk tonu Xoetrope.brightness=Parlakl\u0131k Xoetrope.saturation=Doygunluk Xoetrope.warm=ILIK Xoetrope.cold=SO\u011eUK Xoetrope.decimalRGB=Ondal\u0131k RGB Xoetrope.webSafeColors=Web i\u00e7in g\u00fcvenli renkler kullan substance-5.3.orig/src/org/jvnet/substance/resources/Labels_zh_TW.properties0000644000175000017500000000104311064712216027341 0ustar drazzibdrazzibSystemMenu.showHeapStatus=\u986f\u793a\u5806\u7a4d\u72c0\u614b Tooltip.contentsNotSaved=\u5167\u5bb9\u672a\u5132\u5b58 Tooltip.heapStatusPanel=\u5c0d\u6a5f\u72c0\u614b\u3002\u9ede\u9078\u672c\u7d10\u57f7\u884c\u5ee2\u6599\u6536\u96c6\u5668\u3002 Xoetrope.hue=\u8272\u8abf Xoetrope.brightness=\u4eae\u5ea6 Xoetrope.saturation=\u98fd\u548c\u5ea6 Xoetrope.warm=\u6eab\u6696 Xoetrope.cold=\u5bd2\u51b7 Xoetrope.decimalRGB=RGB \u503c Xoetrope.webSafeColors=\u4f7f\u7528\u9069\u65bc\u7db2\u969b\u7db2\u8def\u7684\u984f\u8272 substance-5.3.orig/src/org/jvnet/substance/resources/Labels_da.properties0000644000175000017500000000114111064711702026670 0ustar drazzibdrazzib# Danish translation by Carsten O. Madsen SystemMenu.close=Luk SystemMenu.iconify=Ikoniser SystemMenu.restore=Genskab SystemMenu.maximize=Maksimer SystemMenu.skins=Substance skins SystemMenu.showHeapStatus=Vis heap status Tooltip.contentsNotSaved=indhold er ikke gemt Tooltip.heapStatusPanel=Heap status. Klick for at k\u00F8re garbage collectoren Xoetrope.hue=Farvetone Xoetrope.brightness=Lysintensitet Xoetrope.saturation=Farvem\u00E6tning Xoetrope.warm=VARM Xoetrope.cold=KOLD Xoetrope.decimalRGB=Decimal RGB Xoetrope.webSafeColors=Brug www sikre farver substance-5.3.orig/src/org/jvnet/substance/resources/Labels_en_GB.properties0000644000175000017500000000113611064712520027261 0ustar drazzibdrazzib# British labels by Robert Gibson SystemMenu.showHeapStatus=Show heap status Tooltip.contentsNotSaved=contents not saved Tooltip.heapStatusPanel=Heap status. Click to run garbage collector Tooltip.menuSearchButton=Select to view menu search panel Tooltip.menuSearchField=Enter search string and press 'Enter' button to search Tooltip.menuSearchTooltip=Click to locate menu Xoetrope.hue=Hue Xoetrope.brightness=Brightness Xoetrope.saturation=Saturation Xoetrope.warm=WARM Xoetrope.cold=COLD Xoetrope.decimalRGB=Decimal RGB Xoetrope.webSafeColors=Use web safe colours substance-5.3.orig/src/org/jvnet/substance/resources/Labels_no.properties0000644000175000017500000000115011064712104026715 0ustar drazzibdrazzib# Norwegian translation by Nils-Morten Nilssen SystemMenu.close=Lukk SystemMenu.iconify=Ikoniser SystemMenu.restore=Gjenopprett SystemMenu.maximize=Maksimer SystemMenu.skins=Substance drakter SystemMenu.showHeapStatus=Vis heap status Tooltip.contentsNotSaved=innholdet er ikke lagret Tooltip.heapStatusPanel=Heap status. Klikk for \u00E5 kj\u00F8re garbage collector Xoetrope.hue=Fargetone Xoetrope.brightness=Lysstyrke Xoetrope.saturation=Metningsgrad Xoetrope.warm=VARM Xoetrope.cold=KALD Xoetrope.decimalRGB=Desimal RGB Xoetrope.webSafeColors=Bruk websikre farger substance-5.3.orig/src/org/jvnet/substance/resources/Labels_zh_HK.properties0000644000175000017500000000101211064712212027301 0ustar drazzibdrazzibSystemMenu.showHeapStatus=\u986f\u793a\u5806\u7a4d\u72c0\u614b Tooltip.contentsNotSaved=\u5167\u5bb9\u672a\u5132\u5b58 Tooltip.heapStatusPanel=\u5806\u7a4d\u72c0\u614b\uff0c\u9ede\u64ca\u4f86\u57f7\u884c\u5783\u573e\u56de\u6536 Xoetrope.hue=\u8272\u5f69 Xoetrope.brightness=\u5149\u6697 Xoetrope.saturation=\u98fd\u548c\u5ea6 Xoetrope.warm=\u6696\u8272 Xoetrope.cold=\u51b7\u8272 Xoetrope.decimalRGB=\u5341\u9032\u4f4d\u5236RGB Xoetrope.webSafeColors=\u4f7f\u7528\u7db2\u9801\u5b89\u5168\u8272 substance-5.3.orig/src/org/jvnet/substance/resources/Labels_es.properties0000644000175000017500000000116711064711762026731 0ustar drazzibdrazzib# Danish translation by David lvarez Len SystemMenu.close=Cerrar SystemMenu.iconify=Minimizar SystemMenu.restore=Restaurar SystemMenu.maximize=Maximizar SystemMenu.skins=Fondos Substance SystemMenu.showHeapStatus=Mostrar estado de pila Tooltip.contentsNotSaved=Contenidos sin guardar Tooltip.heapStatusPanel=Estado de pila. Pulse para pasar el recolector de basura. Xoetrope.hue=Tonalidad Xoetrope.brightness=Brillo Xoetrope.saturation=Saturaci\u00F3n Xoetrope.warm=c\u00C1LIDO Xoetrope.cold=F\u00CDRO Xoetrope.decimalRGB=RGB Decimal Xoetrope.webSafeColors=Use colores web seguros substance-5.3.orig/src/org/jvnet/substance/SubstanceTableUI.java0000644000175000017500000026714311256346144024721 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.awt.event.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.plaf.*; import javax.swing.plaf.basic.BasicTableUI; import javax.swing.table.*; import org.jvnet.lafwidget.LafWidgetUtilities; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.api.*; import org.jvnet.substance.api.SubstanceConstants.Side; import org.jvnet.substance.api.renderers.SubstanceDefaultTableCellRenderer; import org.jvnet.substance.api.renderers.SubstanceDefaultTableHeaderCellRenderer; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.painter.utils.HighlightPainterUtils; import org.jvnet.substance.utils.*; /** * UI for tables in Substance look and feel. Unfortunately, the entire * painting stack has been copied from {@link BasicTableUI} since the methods * are private. The animation effects are implemented in the * {@link #paintCell(Graphics, Rectangle, int, int)}. * * @author Kirill Grouchnikov */ public class SubstanceTableUI extends BasicTableUI { /** * Holds the list of currently selected row-column indexes. */ protected Map selectedIndices; /** * Holds the currently rolled-over row-column index, or null if * none such. */ protected TableId rolledOverId; /** * Row index of the focused cell. */ protected int focusedRow; /** * Column index of the focused cell. */ protected int focusedColumn; /** * Holds the currently rolled-over column index, or -1 if none * such. This is used for the table header animations. */ protected int rolledOverColumn; /** * Map of default renderers. */ protected Map, TableCellRenderer> defaultRenderers; /** * Listener that listens to changes on table properties. */ protected PropertyChangeListener substancePropertyChangeListener; /** * Listener for fade animations on list selections. */ protected TableStateListener substanceFadeSelectionListener; /** * Listener for fade animations on table rollovers. */ protected RolloverFadeListener substanceFadeRolloverListener; /** * Map of previous fade states (for state-aware color scheme transitions). */ private Map prevStateMap; /** * Map of next fade states (for state-aware color scheme transitions). */ private Map nextStateMap; /** * Cell renderer insets. Is computed in {@link #installDefaults()} and * reused in * {@link SubstanceDefaultTableCellRenderer#getTableCellRendererComponent(JTable, Object, boolean, boolean, int, int)} * and * {@link SubstanceDefaultTableHeaderCellRenderer#getTableCellRendererComponent(JTable, Object, boolean, boolean, int, int)} * for performance optimizations. */ private Insets cellRendererInsets; // public static final String IGNORE_COLORS = // "substancelaf.internal.table.ignoreColors"; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceTableUI(); } /** * Creates a UI delegate for table. */ public SubstanceTableUI() { super(); this.selectedIndices = new HashMap(); this.prevStateMap = new HashMap(); this.nextStateMap = new HashMap(); this.rolledOverColumn = -1; this.focusedRow = -1; this.focusedColumn = -1; this.rowId = new TableRowId(-1); this.colId = new TableColumnId(-1); this.cellId = new TableCellId(-1, -1); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTableUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); if (SubstanceCoreUtilities.toDrawWatermark(this.table)) this.table.setOpaque(false); // fix for defect 117 - need to restore default table cell // renderers when Substance is unset this.defaultRenderers = new HashMap, TableCellRenderer>(); Class[] defClasses = new Class[] { Object.class, Icon.class, ImageIcon.class, Number.class, Float.class, Double.class, Date.class, Boolean.class }; for (Class clazz : defClasses) { this.defaultRenderers.put(clazz, this.table .getDefaultRenderer(clazz)); } // Override default renderers - note fix for issue 194 // that doesn't override user-specific renderers (those that don't come // from JTable class). this.installRendererIfNecessary(Object.class, new SubstanceDefaultTableCellRenderer()); // this.table.setDefaultRenderer(Object.class, // new SubstanceDefaultTableCellRenderer()); this.installRendererIfNecessary(Icon.class, new SubstanceDefaultTableCellRenderer.IconRenderer()); // this.table.setDefaultRenderer(Icon.class, // new SubstanceDefaultTableCellRenderer.IconRenderer()); this.installRendererIfNecessary(ImageIcon.class, new SubstanceDefaultTableCellRenderer.IconRenderer()); // this.table.setDefaultRenderer(ImageIcon.class, // new SubstanceDefaultTableCellRenderer.IconRenderer()); this.installRendererIfNecessary(Number.class, new SubstanceDefaultTableCellRenderer.NumberRenderer()); // this.table.setDefaultRenderer(Number.class, // new SubstanceDefaultTableCellRenderer.NumberRenderer()); this.installRendererIfNecessary(Float.class, new SubstanceDefaultTableCellRenderer.DoubleRenderer()); // this.table.setDefaultRenderer(Float.class, // new SubstanceDefaultTableCellRenderer.DoubleRenderer()); this.installRendererIfNecessary(Double.class, new SubstanceDefaultTableCellRenderer.DoubleRenderer()); // this.table.setDefaultRenderer(Double.class, // new SubstanceDefaultTableCellRenderer.DoubleRenderer()); this.installRendererIfNecessary(Date.class, new SubstanceDefaultTableCellRenderer.DateRenderer()); // this.table.setDefaultRenderer(Date.class, // new SubstanceDefaultTableCellRenderer.DateRenderer()); // fix for bug 56 - making default renderer for Boolean a check box. this.installRendererIfNecessary(Boolean.class, new SubstanceDefaultTableCellRenderer.BooleanRenderer()); // this.table.setDefaultRenderer(Boolean.class, // new SubstanceDefaultTableCellRenderer.BooleanRenderer()); // Map selected = new HashMap(); int rows = this.table.getRowCount(); int cols = this.table.getColumnCount(); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { if (this.table.isCellSelected(i, j)) { TableCellId cellId = new TableCellId(i, j); this.selectedIndices.put(cellId, this.table .getValueAt(i, j)); this.prevStateMap.put(cellId, ComponentState.SELECTED); } } } // This is a little tricky, and hopefully will not // interfere with existing applications. The row height in tables // is computed differently from trees and lists. While lists // trees respect the current renderers and their insets, the // JTable uses hard-code value of 16 pixels as the default // row height. This, obviously, doesn't sit well with the support // for custom fonts and high-DPI monitors. // // The current solution first checks whether all the renderers // come from Substance. If not, it does nothing. If they do, it // creates a dummy label, computes its preferred height and apply // insets. There's no need to go over each cell and compute its // preferred height - since at this moment the cell renderers // *are* Substance labels. boolean areAllRenderersFromSubstance = true; TableColumnModel columnModel = table.getColumnModel(); for (int i = 0; i < columnModel.getColumnCount(); i++) { TableColumn column = columnModel.getColumn(i); TableCellRenderer renderer = column.getCellRenderer(); if (renderer == null) { renderer = table.getDefaultRenderer(table.getColumnClass(i)); } if ((renderer instanceof SubstanceDefaultTableCellRenderer) || (renderer instanceof SubstanceDefaultTableCellRenderer.BooleanRenderer)) continue; areAllRenderersFromSubstance = false; break; } if (areAllRenderersFromSubstance) { Insets rendererInsets = SubstanceSizeUtils .getTableCellRendererInsets(SubstanceSizeUtils .getComponentFontSize(table)); JLabel dummy = new JLabel("dummy"); dummy.setFont(table.getFont()); int rowHeight = dummy.getPreferredSize().height + rendererInsets.bottom + rendererInsets.top; table.setRowHeight(rowHeight); } this.table.putClientProperty(SubstanceCoreUtilities.USE_HIGHLIGHT, Boolean.TRUE); // instead of computing the cell renderer insets on // every cell rendering, compute it once and expose to the // SubstanceDefaultTableCellRenderer this.cellRendererInsets = SubstanceSizeUtils .getTableCellRendererInsets(SubstanceSizeUtils .getComponentFontSize(table)); } /** * Installs Substance-specific renderers for column classes that don't have * application-specific renderers installed by the user code. * * @param clazz * Column class. * @param renderer * Default renderer for the specified column class. */ protected void installRendererIfNecessary(Class clazz, TableCellRenderer renderer) { TableCellRenderer currRenderer = this.table.getDefaultRenderer(clazz); if (currRenderer != null) { boolean isCore = (currRenderer instanceof DefaultTableCellRenderer.UIResource) || (currRenderer.getClass().getName() .startsWith("javax.swing.JTable")); if (!isCore) return; } // System.out.println(clazz.getSimpleName() + " : overriding " // + currRenderer.getClass().getName() + "[" // + currRenderer.hashCode() + "] with " // + renderer.getClass().getName() + "[" + renderer.hashCode() // + "]"); this.table.setDefaultRenderer(clazz, renderer); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTableUI#uninstallDefaults() */ @Override protected void uninstallDefaults() { // fix for defect 117 - need to restore default table cell // renderers when Substance is unset for (Map.Entry, TableCellRenderer> entry : this.defaultRenderers .entrySet()) { // this.table.setDefaultRenderer(entry.getKey(), entry.getValue()); // fix for issue 194 - restore only those renderers that were // overriden by Substance. this.uninstallRendererIfNecessary(entry.getKey(), entry.getValue()); } this.selectedIndices.clear(); // this.table.putClientProperty(SubstanceTableUI.SELECTED_INDICES, // null); super.uninstallDefaults(); } /** * Uninstalls default Substance renderers that were installed in * {@link #installRendererIfNecessary(Class, TableCellRenderer)}. * * @param clazz * Column class. * @param renderer * Renderer to restore. */ protected void uninstallRendererIfNecessary(Class clazz, TableCellRenderer renderer) { TableCellRenderer currRenderer = this.table.getDefaultRenderer(clazz); if (currRenderer != null) { boolean isSubstanceRenderer = isSubstanceDefaultRenderer(currRenderer); if (!isSubstanceRenderer) return; } if (renderer instanceof Component) SwingUtilities.updateComponentTreeUI((Component) renderer); this.table.setDefaultRenderer(clazz, renderer); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTableUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); this.substancePropertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (SubstanceLookAndFeel.WATERMARK_VISIBLE.equals(evt .getPropertyName())) { SubstanceTableUI.this.table .setOpaque(!SubstanceCoreUtilities .toDrawWatermark(SubstanceTableUI.this.table)); } if ("columnSelectionAllowed".equals(evt.getPropertyName()) || "rowSelectionAllowed".equals(evt.getPropertyName())) { SubstanceTableUI.this.syncSelection(); } if ("model".equals(evt.getPropertyName())) { TableModel old = (TableModel) evt.getOldValue(); if (old != null) { old .removeTableModelListener(substanceFadeSelectionListener); } // fix for defect 291 - track changes to the table. table.getModel().addTableModelListener( substanceFadeSelectionListener); selectedIndices.clear(); prevStateMap.clear(); nextStateMap.clear(); SubstanceTableUI.this.syncSelection(); } if ("columnModel".equals(evt.getPropertyName())) { TableColumnModel old = (TableColumnModel) evt.getOldValue(); if (old != null) { old.getSelectionModel().removeListSelectionListener( substanceFadeSelectionListener); } table.getColumnModel().getSelectionModel() .addListSelectionListener( substanceFadeSelectionListener); selectedIndices.clear(); prevStateMap.clear(); nextStateMap.clear(); SubstanceTableUI.this.syncSelection(); JTableHeader tableHeader = table.getTableHeader(); // fix for issue 408 - table header may be null. if (tableHeader != null) { // fix for issue 309 - syncing animations on tables // and table headers. SubstanceTableHeaderUI headerUI = (SubstanceTableHeaderUI) tableHeader .getUI(); headerUI.processColumnModelChangeEvent( (TableColumnModel) evt.getOldValue(), (TableColumnModel) evt.getNewValue()); } } // fix for defect 243 - not tracking changes to selection // model results in incorrect selection painting on JXTreeTable // component from SwingX. if ("selectionModel".equals(evt.getPropertyName())) { ListSelectionModel old = (ListSelectionModel) evt .getOldValue(); if (old != null) { old .removeListSelectionListener(substanceFadeSelectionListener); } table.getSelectionModel().addListSelectionListener( substanceFadeSelectionListener); selectedIndices.clear(); prevStateMap.clear(); nextStateMap.clear(); SubstanceTableUI.this.syncSelection(); } if ("font".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { // fix for bug 341 if (table == null) return; table.updateUI(); } }); } if ("background".equals(evt.getPropertyName())) { // propagate application-specific background color to the // header. Color newBackgr = (Color) evt.getNewValue(); JTableHeader header = table.getTableHeader(); if (header != null) { Color headerBackground = header.getBackground(); if (SubstanceCoreUtilities .canReplaceChildBackgroundColor(headerBackground)) { if (!(newBackgr instanceof UIResource)) { // Issue 450 - wrap the color in // SubstanceColorResource to // mark that it can be replaced. header .setBackground(new SubstanceColorResource( newBackgr)); } else { header.setBackground(newBackgr); } } } } // fix for issue 361 - track enabled status of the table // and propagate to the table header if ("enabled".equals(evt.getPropertyName())) { JTableHeader header = table.getTableHeader(); if (header != null) { header.setEnabled(table.isEnabled()); } } } }; this.table .addPropertyChangeListener(this.substancePropertyChangeListener); // Add listener for the selection animation this.substanceFadeSelectionListener = new TableStateListener(); this.table.getSelectionModel().addListSelectionListener( this.substanceFadeSelectionListener); TableColumnModel columnModel = this.table.getColumnModel(); columnModel.getSelectionModel().addListSelectionListener( this.substanceFadeSelectionListener); this.table.getModel().addTableModelListener( this.substanceFadeSelectionListener); // Add listener for the fade animation this.substanceFadeRolloverListener = new RolloverFadeListener(); this.table.addMouseMotionListener(this.substanceFadeRolloverListener); this.table.addMouseListener(this.substanceFadeRolloverListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTableUI#uninstallListeners() */ @Override protected void uninstallListeners() { this.table .removePropertyChangeListener(this.substancePropertyChangeListener); this.substancePropertyChangeListener = null; this.table.getSelectionModel().removeListSelectionListener( this.substanceFadeSelectionListener); this.table.getColumnModel().getSelectionModel() .removeListSelectionListener( this.substanceFadeSelectionListener); this.table.getModel().removeTableModelListener( this.substanceFadeSelectionListener); this.substanceFadeSelectionListener = null; // Remove listener for the fade animation this.table .removeMouseMotionListener(this.substanceFadeRolloverListener); this.table.removeMouseListener(this.substanceFadeRolloverListener); this.substanceFadeRolloverListener = null; super.uninstallListeners(); } /** * Paint a representation of the table instance that was set in * installUI(). */ @Override public void paint(Graphics g, JComponent c) { Rectangle clip = g.getClipBounds(); Rectangle bounds = this.table.getBounds(); // account for the fact that the graphics has already been translated // into the table's bounds bounds.x = bounds.y = 0; if (this.table.getRowCount() <= 0 || this.table.getColumnCount() <= 0 || // this check prevents us from painting the entire table // when the clip doesn't intersect our bounds at all !bounds.intersects(clip)) { return; } Point upperLeft = clip.getLocation(); Point lowerRight = new Point(clip.x + clip.width - 1, clip.y + clip.height - 1); int rMin = this.table.rowAtPoint(upperLeft); int rMax = this.table.rowAtPoint(lowerRight); // This should never happen (as long as our bounds intersect the clip, // which is why we bail above if that is the case). if (rMin == -1) { rMin = 0; } // If the table does not have enough rows to fill the view we'll get -1. // (We could also get -1 if our bounds don't intersect the clip, // which is why we bail above if that is the case). // Replace this with the index of the last row. if (rMax == -1) { rMax = this.table.getRowCount() - 1; } boolean ltr = this.table.getComponentOrientation().isLeftToRight(); int cMin = this.table.columnAtPoint(ltr ? upperLeft : lowerRight); int cMax = this.table.columnAtPoint(ltr ? lowerRight : upperLeft); // This should never happen. if (cMin == -1) { cMin = 0; } // If the table does not have enough columns to fill the view we'll get // -1. // Replace this with the index of the last column. if (cMax == -1) { cMax = this.table.getColumnCount() - 1; } // Paint the cells. this.paintCells(g, rMin, rMax, cMin, cMax); // Paint the grid. this.paintGrid(g, rMin, rMax, cMin, cMax); // Paint the drop lines this.paintDropLines(g); } /** * Paints the grid lines within aRect, using the grid color set with * setGridColor. Paints vertical lines if * getShowVerticalLines() returns true and paints horizontal * lines if getShowHorizontalLines() returns true. */ private void paintGrid(Graphics g, int rMin, int rMax, int cMin, int cMax) { Graphics2D g2d = (Graphics2D) g.create(); ComponentState currState = this.table.isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED; float alpha = SubstanceColorSchemeUtilities.getAlpha(this.table, currState); g2d.setComposite(TransitionLayout.getAlphaComposite(this.table, alpha, g)); Color gridColor = this.table.getGridColor(); if (gridColor instanceof UIResource) { SubstanceColorScheme scheme = SubstanceColorSchemeUtilities .getColorScheme(this.table, ColorSchemeAssociationKind.BORDER, this.table .isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED); gridColor = scheme.getLineColor(); } g2d.setColor(gridColor); Rectangle minCell = this.table.getCellRect(rMin, cMin, true); Rectangle maxCell = this.table.getCellRect(rMax, cMax, true); Rectangle damagedArea = minCell.union(maxCell); float strokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(this.table)); g2d.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); if (this.table.getShowHorizontalLines()) { int tableWidth = damagedArea.x + damagedArea.width; int y = damagedArea.y; for (int row = rMin; row <= rMax; row++) { y += this.table.getRowHeight(row); g2d.drawLine(damagedArea.x, y - 1, tableWidth - 1, y - 1); } } if (this.table.getShowVerticalLines()) { TableColumnModel cm = this.table.getColumnModel(); int tableHeight = damagedArea.y + damagedArea.height; int x; if (this.table.getComponentOrientation().isLeftToRight()) { x = damagedArea.x; for (int column = cMin; column <= cMax; column++) { int w = cm.getColumn(column).getWidth(); x += w; if (column != (cm.getColumnCount() - 1)) { g2d.drawLine(x - 1, 0, x - 1, tableHeight - 1); } } } else { x = damagedArea.x + damagedArea.width; // fix for defect 196 - proper grid painting on RTL tables for (int column = cMin; column <= cMax; column++) { g2d.drawLine(x - 1, 0, x - 1, tableHeight - 1); int w = cm.getColumn(column).getWidth(); x -= w; } // x -= cm.getColumn(cMax).getWidth(); g2d.drawLine(x, 0, x, tableHeight - 1); } } g2d.dispose(); } private int viewIndexForColumn(TableColumn aColumn) { TableColumnModel cm = this.table.getColumnModel(); for (int column = 0; column < cm.getColumnCount(); column++) { if (cm.getColumn(column) == aColumn) { return column; } } return -1; } private void paintCells(Graphics g, int rMin, int rMax, int cMin, int cMax) { JTableHeader header = this.table.getTableHeader(); TableColumn draggedColumn = (header == null) ? null : header .getDraggedColumn(); TableColumnModel cm = this.table.getColumnModel(); int columnMargin = cm.getColumnMargin(); int rowMargin = this.table.getRowMargin(); Rectangle cellRect; Rectangle highlightCellRect; TableColumn aColumn; int columnWidth; if (this.table.getComponentOrientation().isLeftToRight()) { for (int row = rMin; row <= rMax; row++) { cellRect = this.table.getCellRect(row, cMin, false); highlightCellRect = new Rectangle(cellRect); // if (!this.table.getShowHorizontalLines()) { // cellRect.y -= this.table.getRowMargin() / 2; // cellRect.height += this.table.getRowMargin(); // } highlightCellRect.y -= rowMargin / 2; highlightCellRect.height += rowMargin; for (int column = cMin; column <= cMax; column++) { aColumn = cm.getColumn(column); columnWidth = aColumn.getWidth(); cellRect.width = columnWidth - columnMargin; highlightCellRect.x = cellRect.x - columnMargin / 2; highlightCellRect.width = columnWidth; if (aColumn != draggedColumn) { this.paintCell(g, cellRect, highlightCellRect, row, column); } cellRect.x += columnWidth; } } } else { for (int row = rMin; row <= rMax; row++) { cellRect = this.table.getCellRect(row, cMin, false); highlightCellRect = new Rectangle(cellRect); highlightCellRect.y -= rowMargin / 2; highlightCellRect.height += rowMargin; aColumn = cm.getColumn(cMin); if (aColumn != draggedColumn) { columnWidth = aColumn.getWidth(); cellRect.width = columnWidth - columnMargin; highlightCellRect.x = cellRect.x - columnMargin / 2; highlightCellRect.width = columnWidth; this.paintCell(g, cellRect, highlightCellRect, row, cMin); } for (int column = cMin + 1; column <= cMax; column++) { aColumn = cm.getColumn(column); columnWidth = aColumn.getWidth(); cellRect.width = columnWidth - columnMargin; cellRect.x -= columnWidth; highlightCellRect.x = cellRect.x - columnMargin / 2; highlightCellRect.width = columnWidth; if (aColumn != draggedColumn) { this.paintCell(g, cellRect, highlightCellRect, row, column); } } } } // Paint the dragged column if we are dragging. if (draggedColumn != null) { Graphics2D g2d = (Graphics2D) g.create(); // enhancement 331 - translucent dragged column g2d.setComposite(TransitionLayout.getAlphaComposite(this.table, 0.65f, g)); this.paintDraggedArea(g2d, rMin, rMax, draggedColumn, header .getDraggedDistance()); g2d.dispose(); } // Remove any renderers that may be left in the rendererPane. this.rendererPane.removeAll(); } private void paintDraggedArea(Graphics g, int rMin, int rMax, TableColumn draggedColumn, int distance) { int draggedColumnIndex = this.viewIndexForColumn(draggedColumn); Rectangle minCell = this.table.getCellRect(rMin, draggedColumnIndex, true); Rectangle maxCell = this.table.getCellRect(rMax, draggedColumnIndex, true); Rectangle vacatedColumnRect = minCell.union(maxCell); // Paint a gray well in place of the moving column. g.setColor(this.table.getParent().getBackground()); g.fillRect(vacatedColumnRect.x, vacatedColumnRect.y, vacatedColumnRect.width, vacatedColumnRect.height); // Move to the where the cell has been dragged. vacatedColumnRect.x += distance; // Fill the background. g.setColor(this.table.getBackground()); g.fillRect(vacatedColumnRect.x, vacatedColumnRect.y, vacatedColumnRect.width, vacatedColumnRect.height); // Paint the vertical grid lines if necessary. if (this.table.getShowVerticalLines()) { g.setColor(this.table.getGridColor()); int x1 = vacatedColumnRect.x; int y1 = vacatedColumnRect.y; int x2 = x1 + vacatedColumnRect.width - 1; int y2 = y1 + vacatedColumnRect.height - 1; // Left g.drawLine(x1 - 1, y1, x1 - 1, y2); // Right g.drawLine(x2, y1, x2, y2); } for (int row = rMin; row <= rMax; row++) { // Render the cell value Rectangle r = this.table .getCellRect(row, draggedColumnIndex, false); r.x += distance; this.paintCell(g, r, r, row, draggedColumnIndex); // Paint the (lower) horizontal grid line if necessary. if (this.table.getShowHorizontalLines()) { g.setColor(this.table.getGridColor()); Rectangle rcr = this.table.getCellRect(row, draggedColumnIndex, true); rcr.x += distance; int x1 = rcr.x; int y1 = rcr.y; int x2 = x1 + rcr.width - 1; int y2 = y1 + rcr.height - 1; g.drawLine(x1, y2, x2, y2); } } } protected void paintCell(Graphics g, Rectangle cellRect, Rectangle highlightCellRect, int row, int column) { // boolean isFromSubstance = (rendererComponent instanceof // SubstanceDefaultTableCellRenderer) // || (rendererComponent instanceof // SubstanceDefaultTableCellRenderer.BooleanRenderer); Graphics2D g2d = (Graphics2D) g.create(); // fix for issue 183 - passing the original Graphics context // to compute the alpha composite. If the table is in a JXPanel // (component from SwingX) and it has custom alpha value set, // then the original graphics context will have a SRC_OVER // alpha composite applied to it. g2d.setComposite(TransitionLayout.getAlphaComposite(this.table, g)); TableCellId cellId = new TableCellId(row, column); ComponentState prevState = this.getPrevCellState(cellId); ComponentState currState = this.getCellState(cellId); // System.out.println(cellId + ":" + prevState.name() + "->" // + currState.name()); // float alphaForPrevBackground = 0.0f; // optimize for tables that don't initiate rollover // or selection animations FadeState state = updateInfo.hasRolloverAnimations || updateInfo.hasSelectionAnimations ? SubstanceFadeUtilities .getFadeState(this.table, cellId, FadeKind.SELECTION, FadeKind.ROLLOVER) : null; boolean hasHighlights = (prevState != ComponentState.DEFAULT) || (currState != ComponentState.DEFAULT) || (state != null); Set highlightOpenSides = null; float highlightBorderAlpha = 0.0f; float totalHighlightAlpha = 0.0f; SubstanceColorScheme prevHighlightScheme = null; SubstanceColorScheme currHighlightScheme = null; SubstanceColorScheme prevBorderScheme = null; SubstanceColorScheme currBorderScheme = null; float fadeHighlightCoef = 0.0f; if (hasHighlights) { prevHighlightScheme = this.updateInfo .getHighlightColorScheme(prevState); currHighlightScheme = this.updateInfo .getHighlightColorScheme(currState); prevBorderScheme = this.updateInfo .getHighlightBorderColorScheme(prevState); currBorderScheme = this.updateInfo .getHighlightBorderColorScheme(currState); // Compute the alpha values for the animation. float startHighlightAlpha = this.updateInfo .getHighlightAlpha(prevState); float endHighlightAlpha = this.updateInfo .getHighlightAlpha(currState); totalHighlightAlpha = endHighlightAlpha; // System.out.println("-------- (" + System.currentTimeMillis() % // 10000 // + ") " + row + ":" + column + " [" + cellRect + "] --------"); if (state != null) { // System.out.println("State not null on " + row + ":" + column // + // ":" // + state.fadeKind + ":" + state.getFadePosition()); // System.out.println("States : " + prevState + "->" + // currState); fadeHighlightCoef = state.getFadePosition(); // compute the total alpha of the overlays. if (state.isFadingIn()) { totalHighlightAlpha = startHighlightAlpha + (endHighlightAlpha - startHighlightAlpha) * fadeHighlightCoef; } else { totalHighlightAlpha = startHighlightAlpha + (endHighlightAlpha - startHighlightAlpha) * (1.0f - fadeHighlightCoef); } if (state.isFadingIn()) fadeHighlightCoef = 1.0f - fadeHighlightCoef; // System.out.println("prev alpha " + alphaForPrevBackground // + ", curr alpha " + alphaForCurrBackground); // System.out.println("from " + prevTheme.getDisplayName() +" // to" // + currTheme.getDisplayName()); } // System.out.println("[" + row + ":" + column + "] from " // + prevTheme.getDisplayName() + "[at " + alphaForPrevBackground // + "] to " + currTheme.getDisplayName() + "[at " // + alphaForCurrBackground + "]"); if (!updateInfo.hasSelectionAnimations && (prevState.isKindActive(FadeKind.SELECTION) || currState .isKindActive(FadeKind.SELECTION))) { // no animations on selected cells in big tables - bug 209 fadeHighlightCoef = 0.0f; } // compute the highlight visuals, but only if there are // highlights on this cell (optimization) highlightOpenSides = EnumSet.noneOf(Side.class); // show highlight border only when the table grid is not shown highlightBorderAlpha = (table.getShowHorizontalLines() || table .getShowVerticalLines()) ? 0.0f : 0.8f; if (!table.getColumnSelectionAllowed() && table.getRowSelectionAllowed()) { // if row selection is on and column selection is off, we // will // show the highlight for the entire row // all cells have open left side highlightOpenSides.add(SubstanceConstants.Side.LEFT); // all cells have open right side highlightOpenSides.add(SubstanceConstants.Side.RIGHT); } if (table.getColumnSelectionAllowed() && !table.getRowSelectionAllowed()) { // if row selection is off and column selection is on, we // will // show the highlight for the entire column // if (table.getTableHeader().isVisible() || (row > 0)) { // the top side is open for all rows except the // first, or when the table header is visible highlightOpenSides.add(SubstanceConstants.Side.TOP); // } // if (row < (this.table.getRowCount() - 1)) { // all cells but the last have open bottom side highlightOpenSides.add(SubstanceConstants.Side.BOTTOM); // } } if (row > 1) { ComponentState upperNeighbourState = this .getCellState(new TableCellId(row - 1, column)); if (currState == upperNeighbourState) { // the cell above it is in the same state highlightOpenSides.add(SubstanceConstants.Side.TOP); } } if (column > 1) { ComponentState leftNeighbourState = this .getCellState(new TableCellId(row, column - 1)); if (currState == leftNeighbourState) { // the cell to the left is in the same state highlightOpenSides.add(SubstanceConstants.Side.LEFT); } } // if ((row == 0) && table.getTableHeader().isVisible()) { // // special case for a selected cell in first row when the // // table header is visible - open top side // highlightOpenSides.add(SubstanceConstants.Side.TOP); // } if (row == 0) { highlightOpenSides.add(SubstanceConstants.Side.TOP); } if (row == (table.getRowCount() - 1)) { highlightOpenSides.add(SubstanceConstants.Side.BOTTOM); } if (column == 0) { highlightOpenSides.add(SubstanceConstants.Side.LEFT); } if (column == (table.getColumnCount() - 1)) { highlightOpenSides.add(SubstanceConstants.Side.RIGHT); } } boolean isRollover = ((this.rolledOverId != null) && this.rolledOverId .equals(cellId)); if (this.table.isEditing() && this.table.getEditingRow() == row && this.table.getEditingColumn() == column) { Component component = this.table.getEditorComponent(); // if (component instanceof JComponent) { // ((JComponent) component).putClientProperty( // SubstanceCoreUtilities.USE_HIGHLIGHT, Boolean.TRUE); // } if (totalHighlightAlpha > 0.0f) { g2d.setComposite(TransitionLayout.getAlphaComposite(this.table, totalHighlightAlpha, g)); HighlightPainterUtils.paintHighlight(g2d, this.rendererPane, component, highlightCellRect, highlightBorderAlpha, highlightOpenSides, currHighlightScheme, prevHighlightScheme, currBorderScheme, prevBorderScheme, fadeHighlightCoef); g2d.setComposite(TransitionLayout.getAlphaComposite(this.table, g)); } if (component instanceof JComponent) { // Play with opacity to make our own gradient background // on selected elements to show. // // Compute the selection status to prevent flicker - JTable // registers a listener on selection changes and repaints // the relevant cell before our listener (in TableUI) gets // the chance to start the fade sequence. The result is that // the first frame uses full opacity, and the next frame // starts the fade sequence. So, we use the UI delegate to // compute the selection status. boolean newOpaque = !(this.selectedIndices.containsKey(cellId) || isRollover || (state != null)); if (this.updateInfo.toDrawWatermark) // SubstanceCoreUtilities.toDrawWatermark(this.table)) newOpaque = false; this.updateInfo.opacity.clear(); // System.out.println("Pre-painting at index " + row + " [" // + // value // + "] " + (rendererComponent.isOpaque() ? "opaque" : // "transparent") // + " with bg " + rendererComponent.getBackground()); if (!newOpaque) SubstanceCoreUtilities.makeNonOpaque(component, this.updateInfo.opacity); // System.out.println("Painting " // + (newOpaque ? "opaque" : "transparent") // + " with bg " + component.getBackground()); component.setBounds(cellRect); component.validate(); // System.out.println("Painting at index " + row + " [" + // value // + "] " + (newOpaque ? "opaque" : "transparent") // + " with bg " + rendererComponent.getBackground()); if (!newOpaque) SubstanceCoreUtilities.restoreOpaque(component, this.updateInfo.opacity); // System.out.println("Post-painting at index " + row + " [" // + // value // + "] " + (rendererComponent.isOpaque() ? "opaque" : // "transparent") // + " with bg " + rendererComponent.getBackground()); } else { component.setBounds(cellRect); component.validate(); } } else { // if (rendererComponent instanceof JComponent) { // ((JComponent) rendererComponent).putClientProperty( // SubstanceCoreUtilities.USE_HIGHLIGHT, Boolean.TRUE); // } TableCellRenderer renderer = this.table .getCellRenderer(row, column); boolean isSubstanceRenderer = isSubstanceDefaultRenderer(renderer); Component rendererComponent = this.table.prepareRenderer(renderer, row, column); boolean isWatermarkBleed = this.updateInfo.toDrawWatermark; if (rendererComponent != null) { if (!isWatermarkBleed) { Color background = rendererComponent.getBackground(); // optimization - only render background if it's different // from the table background if ((background != null) && (!table.getBackground().equals(background) || this.updateInfo.isInDecorationArea)) { // fill with the renderer background color g2d.setColor(background); g2d.fillRect(highlightCellRect.x, highlightCellRect.y, highlightCellRect.width, highlightCellRect.height); } } else { BackgroundPaintingUtils.fillAndWatermark(g2d, this.table, rendererComponent.getBackground(), highlightCellRect); } } if (isSubstanceRenderer && (totalHighlightAlpha > 0.0f)) { g2d.setComposite(TransitionLayout.getAlphaComposite(this.table, totalHighlightAlpha, g)); float extra = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(this.table .getTableHeader())); float extraWidth = highlightOpenSides .contains(SubstanceConstants.Side.LEFT) ? 0.0f : extra; float extraHeight = highlightOpenSides .contains(SubstanceConstants.Side.TOP) ? 0.0f : extra; // if ((column > 0) && isFocusedCell(row, column - 1)) // extraWidth = 0.0f; // if ((row > 0) && isFocusedCell(row - 1, column)) // extraHeight = 0.0f; // System.out // .println(row + ":" + column + ":" // + rendererComponent.getBackground() + ":" // + totalAlpha + ":" // + currTheme.getDisplayName() + ":" // + prevTheme.getDisplayName() + ":" // + fadeCoef); HighlightPainterUtils.paintHighlight(g2d, this.rendererPane, rendererComponent, new Rectangle(highlightCellRect.x - (int) extraWidth, highlightCellRect.y - (int) extraHeight, highlightCellRect.width + (int) extraWidth, highlightCellRect.height + (int) extraHeight), highlightBorderAlpha, highlightOpenSides, currHighlightScheme, prevHighlightScheme, currBorderScheme, prevBorderScheme, fadeHighlightCoef); g2d.setComposite(TransitionLayout.getAlphaComposite(this.table, g)); } if (rendererComponent instanceof JComponent) { // Play with opacity to make our own gradient background // on selected elements to show. JComponent jRenderer = (JComponent) rendererComponent; // Compute the selection status to prevent flicker - JTable // registers a listener on selection changes and repaints // the relevant cell before our listener (in TableUI) gets // the chance to start the fade sequence. The result is that // the first frame uses full opacity, and the next frame // starts the fade sequence. So, we use the UI delegate to // compute the selection status. boolean isSelected = updateInfo.hasSelectionAnimations ? this.selectedIndices .containsKey(cellId) : this.table.isCellSelected(row, column); boolean newOpaque = !(isSelected || isRollover || (state != null)); if (this.updateInfo.toDrawWatermark) newOpaque = false; Map opacity = new HashMap(); // System.out.println("Pre-painting at index " + row + " [" // + // value // + "] " + (rendererComponent.isOpaque() ? "opaque" : // "transparent") // + " with bg " + rendererComponent.getBackground()); if (!newOpaque) SubstanceCoreUtilities.makeNonOpaque(jRenderer, opacity); // System.out.println("Painting " // + rendererComponent.getClass().getSimpleName() // + " at " + row + ":" + column + " " // + (newOpaque ? "opaque" : "transparent") // + " with bg " + rendererComponent.getBackground()); // System.out.println(row + ":" + column + ":" + cellRect); // SubstanceDecorationUtilities.setDecorationType(jRenderer, // this.updateInfo.decorationAreaType); this.rendererPane.paintComponent(g2d, rendererComponent, this.table, cellRect.x, cellRect.y, cellRect.width, cellRect.height, true); // System.out.println("Painting at index " + row + " [" + // value // + "] " + (newOpaque ? "opaque" : "transparent") // + " with bg " + rendererComponent.getBackground()); if (!newOpaque) SubstanceCoreUtilities.restoreOpaque(jRenderer, opacity); // System.out.println("Post-painting at index " + row + " [" // + // value // + "] " + (rendererComponent.isOpaque() ? "opaque" : // "transparent") // + " with bg " + rendererComponent.getBackground()); } else { this.rendererPane.paintComponent(g2d, rendererComponent, this.table, cellRect.x, cellRect.y, cellRect.width, cellRect.height, true); } } // System.out // .println( // "------------------------------------------------------------------------------" // ); g2d.dispose(); } private void paintDropLines(Graphics g) { JTable.DropLocation loc = table.getDropLocation(); if (loc == null) { return; } Color color = UIManager.getColor("Table.dropLineColor"); Color shortColor = UIManager.getColor("Table.dropLineShortColor"); if (color == null && shortColor == null) { return; } Rectangle rect; rect = getHDropLineRect(loc); if (rect != null) { int x = rect.x; int w = rect.width; if (color != null) { extendRect(rect, true); g.setColor(color); g.fillRect(rect.x, rect.y, rect.width, rect.height); } if (!loc.isInsertColumn() && shortColor != null) { g.setColor(shortColor); g.fillRect(x, rect.y, w, rect.height); } } rect = getVDropLineRect(loc); if (rect != null) { int y = rect.y; int h = rect.height; if (color != null) { extendRect(rect, false); g.setColor(color); g.fillRect(rect.x, rect.y, rect.width, rect.height); } if (!loc.isInsertRow() && shortColor != null) { g.setColor(shortColor); g.fillRect(rect.x, y, rect.width, h); } } } private Rectangle getHDropLineRect(JTable.DropLocation loc) { if (!loc.isInsertRow()) { return null; } int row = loc.getRow(); int col = loc.getColumn(); if (col >= table.getColumnCount()) { col--; } Rectangle rect = table.getCellRect(row, col, true); if (row >= table.getRowCount()) { row--; Rectangle prevRect = table.getCellRect(row, col, true); rect.y = prevRect.y + prevRect.height; } if (rect.y == 0) { rect.y = -1; } else { rect.y -= 2; } rect.height = 3; return rect; } private Rectangle getVDropLineRect(JTable.DropLocation loc) { if (!loc.isInsertColumn()) { return null; } boolean ltr = table.getComponentOrientation().isLeftToRight(); int col = loc.getColumn(); Rectangle rect = table.getCellRect(loc.getRow(), col, true); if (col >= table.getColumnCount()) { col--; rect = table.getCellRect(loc.getRow(), col, true); if (ltr) { rect.x = rect.x + rect.width; } } else if (!ltr) { rect.x = rect.x + rect.width; } if (rect.x == 0) { rect.x = -1; } else { rect.x -= 2; } rect.width = 3; return rect; } private Rectangle extendRect(Rectangle rect, boolean horizontal) { if (rect == null) { return rect; } if (horizontal) { rect.x = 0; rect.width = table.getWidth(); } else { rect.y = 0; if (table.getRowCount() != 0) { Rectangle lastRect = table.getCellRect(table.getRowCount() - 1, 0, true); rect.height = lastRect.y + lastRect.height; } else { rect.height = table.getHeight(); } } return rect; } /** * Repaints a single cell during the fade animation cycle. * * @author Kirill Grouchnikov */ protected class CellRepaintCallback extends UIThreadFadeTrackerAdapter { /** * Associated table. */ protected JTable table; /** * Associated (animated) row index. */ protected int rowIndex; /** * Associated (animated) column index. */ protected int columnIndex; /** * Creates a new animation repaint callback. * * @param table * Associated table. * @param rowIndex * Associated (animated) row index. * @param columnIndex * Associated (animated) column index. */ public CellRepaintCallback(JTable table, int rowIndex, int columnIndex) { super(); this.table = table; this.rowIndex = rowIndex; this.columnIndex = columnIndex; } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.utils.FadeTracker$FadeTrackerCallback#fadeEnded * (org.jvnet.lafwidget.utils.FadeTracker.FadeKind) */ @Override public void fadeEnded(FadeKind fadeKind) { if ((SubstanceTableUI.this.table == this.table) && (this.rowIndex < this.table.getRowCount()) && (this.columnIndex < this.table.getColumnCount())) { TableCellId cellIndex = new TableCellId(this.rowIndex, this.columnIndex); ComponentState currState = SubstanceTableUI.this .getCellState(cellIndex); // boolean isLarge = (table.getRowCount() * // table.getColumnCount() > 1000); if (currState == ComponentState.DEFAULT) { // || (isLarge && currState.isSelected())) SubstanceTableUI.this.prevStateMap.remove(cellIndex); SubstanceTableUI.this.nextStateMap.remove(cellIndex); } else { SubstanceTableUI.this.prevStateMap .put(cellIndex, currState); SubstanceTableUI.this.nextStateMap .put(cellIndex, currState); } // System.out.println(rowIndex + ":" + columnIndex + "->" // + prevStateMap.get(cellIndex).name()); } // System.out.println("Cell - Fade ended on " + rowIndex + ":" // + columnIndex); this.repaintCell(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.utils.FadeTracker$FadeTrackerCallback#fadePerformed * (org.jvnet.lafwidget.utils.FadeTracker.FadeKind, float) */ @Override public void fadePerformed(FadeKind fadeKind, float fade) { // System.out.println("Cell - " + fadeKind + " on " + rowIndex + ":" // + columnIndex + ":" + fade); if ((SubstanceTableUI.this.table == this.table) && (this.rowIndex < this.table.getRowCount()) && (this.columnIndex < this.table.getColumnCount())) { TableCellId cellIndex = new TableCellId(this.rowIndex, this.columnIndex); SubstanceTableUI.this.nextStateMap.put(cellIndex, SubstanceTableUI.this.getCellState(cellIndex)); } this.repaintCell(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.animation.FadeTrackerAdapter#fadeReversed(org * .jvnet.lafwidget.animation.FadeKind, boolean, float) */ @Override public void fadeReversed(FadeKind fadeKind, boolean isFadingIn, float fadeCycle10) { if ((SubstanceTableUI.this.table == this.table) && (this.rowIndex < this.table.getRowCount()) && (this.columnIndex < this.table.getColumnCount())) { TableCellId cellIndex = new TableCellId(this.rowIndex, this.columnIndex); ComponentState nextState = SubstanceTableUI.this.nextStateMap .get(cellIndex); if (nextState == null) { SubstanceTableUI.this.prevStateMap.remove(cellIndex); } else { SubstanceTableUI.this.prevStateMap .put(cellIndex, nextState); } // System.out.println(tabIndex + "->" // + prevStateMap.get(tabIndex).name()); } this.repaintCell(); } /** * Repaints the associated cell. */ private void repaintCell() { SwingUtilities.invokeLater(new Runnable() { public void run() { if (SubstanceTableUI.this.table == null) { // may happen if the LAF was switched in the meantime return; } int rowCount = CellRepaintCallback.this.table.getRowCount(); int colCount = CellRepaintCallback.this.table .getColumnCount(); if ((rowCount > 0) && (CellRepaintCallback.this.rowIndex < rowCount) && (colCount > 0) && (CellRepaintCallback.this.columnIndex < colCount)) { // need to retrieve the cell rectangle since the cells // can be moved while animating Rectangle rect = CellRepaintCallback.this.table .getCellRect(CellRepaintCallback.this.rowIndex, CellRepaintCallback.this.columnIndex, true); if (!table.getShowHorizontalLines() && !table.getShowVerticalLines()) { float extra = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(table .getTableHeader())); rect.x -= (int) extra; rect.width += 2 * (int) extra; rect.y -= (int) extra; rect.height += 2 * (int) extra; } // System.out.println("Cell Repainting " + rowIndex + // ":" // + columnIndex + ":" + rect); CellRepaintCallback.this.table.repaint(rect); } } }); } } /** * Repaints a single row during the fade animation cycle. * * @author Kirill Grouchnikov */ protected class RowRepaintCallback extends UIThreadFadeTrackerAdapter { /** * Associated table. */ protected JTable table; /** * Associated (animated) row index. */ protected int rowIndex; /** * Creates a new animation repaint callback. * * @param table * Associated table. * @param rowIndex * Associated (animated) row index. */ public RowRepaintCallback(JTable table, int rowIndex) { super(); this.table = table; this.rowIndex = rowIndex; } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.utils.FadeTracker$FadeTrackerCallback#fadeEnded * (org.jvnet.lafwidget.utils.FadeTracker.FadeKind) */ @Override public void fadeEnded(FadeKind fadeKind) { if ((SubstanceTableUI.this.table == this.table) && (this.rowIndex < this.table.getRowCount())) { for (int columnIndex = 0; columnIndex < this.table .getColumnCount(); columnIndex++) { TableCellId cellIndex = new TableCellId(this.rowIndex, columnIndex); ComponentState currState = SubstanceTableUI.this .getCellState(cellIndex); // boolean isLarge = (table.getRowCount() // * table.getColumnCount() > 1000); if (currState == ComponentState.DEFAULT) { // || (isLarge && currState.isSelected())) SubstanceTableUI.this.prevStateMap.remove(cellIndex); SubstanceTableUI.this.nextStateMap.remove(cellIndex); } else { SubstanceTableUI.this.prevStateMap.put(cellIndex, currState); SubstanceTableUI.this.nextStateMap.put(cellIndex, currState); } } // System.out.println(tabIndex + "->" // + prevStateMap.get(tabIndex).name()); } // System.out.println("Fade ended on " + rowIndex); this.repaintRow(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.utils.FadeTracker$FadeTrackerCallback#fadePerformed * (org.jvnet.lafwidget.utils.FadeTracker.FadeKind, float) */ @Override public void fadePerformed(FadeKind fadeKind, float fade) { // System.out.println("Fade on " + rowIndex + ":" + fade); if ((SubstanceTableUI.this.table == this.table) && (this.rowIndex < this.table.getRowCount())) { for (int columnIndex = 0; columnIndex < this.table .getColumnCount(); columnIndex++) { TableCellId cellIndex = new TableCellId(this.rowIndex, columnIndex); SubstanceTableUI.this.nextStateMap.put(cellIndex, SubstanceTableUI.this.getCellState(cellIndex)); } } this.repaintRow(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.animation.FadeTrackerAdapter#fadeReversed(org * .jvnet.lafwidget.animation.FadeKind, boolean, float) */ @Override public void fadeReversed(FadeKind fadeKind, boolean isFadingIn, float fadeCycle10) { if ((SubstanceTableUI.this.table == this.table) && (this.rowIndex < this.table.getRowCount())) { for (int columnIndex = 0; columnIndex < this.table .getColumnCount(); columnIndex++) { TableCellId cellIndex = new TableCellId(this.rowIndex, columnIndex); ComponentState nextState = SubstanceTableUI.this.nextStateMap .get(cellIndex); if (nextState == null) { SubstanceTableUI.this.prevStateMap.remove(cellIndex); } else { SubstanceTableUI.this.prevStateMap.put(cellIndex, nextState); } // System.out.println(tabIndex + "->" // + prevStateMap.get(tabIndex).name()); } } this.repaintRow(); } /** * Repaints the associated row. */ private void repaintRow() { SwingUtilities.invokeLater(new Runnable() { public void run() { if (SubstanceTableUI.this.table == null) { // may happen if the LAF was switched in the meantime return; } int rowCount = RowRepaintCallback.this.table.getRowCount(); if ((rowCount > 0) && (RowRepaintCallback.this.rowIndex < rowCount)) { // need to retrieve the cell rectangle since the cells // can be moved while animating Rectangle rect = RowRepaintCallback.this.table .getCellRect(RowRepaintCallback.this.rowIndex, 0, true); for (int i = 1; i < RowRepaintCallback.this.table .getColumnCount(); i++) { rect = rect.union(RowRepaintCallback.this.table .getCellRect( RowRepaintCallback.this.rowIndex, i, true)); } if (!table.getShowHorizontalLines() && !table.getShowVerticalLines()) { float extra = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(table .getTableHeader())); rect.y -= (int) extra; rect.height += 2 * (int) extra; } // System.out.println("Repainting row " + rowIndex // + " at " + rect); RowRepaintCallback.this.table.repaint(rect); } } }); } } /** * Repaints a single column during the fade animation cycle. * * @author Kirill Grouchnikov */ protected class ColumnRepaintCallback extends UIThreadFadeTrackerAdapter { /** * Associated table. */ protected JTable table; /** * Associated (animated) column index. */ protected int columnIndex; /** * Creates a new animation repaint callback. * * @param table * Associated table. * @param columnIndex * Associated (animated) column index. */ public ColumnRepaintCallback(JTable table, int columnIndex) { super(); this.table = table; this.columnIndex = columnIndex; } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.utils.FadeTracker$FadeTrackerCallback#fadeEnded * (org.jvnet.lafwidget.utils.FadeTracker.FadeKind) */ @Override public void fadeEnded(FadeKind fadeKind) { if ((SubstanceTableUI.this.table == this.table) && (this.columnIndex < this.table.getColumnCount())) { for (int rowIndex = 0; rowIndex < this.table.getRowCount(); rowIndex++) { TableCellId cellIndex = new TableCellId(rowIndex, this.columnIndex); ComponentState currState = SubstanceTableUI.this .getCellState(cellIndex); // boolean isLarge = (table.getRowCount() // * table.getColumnCount() > 1000); if (currState == ComponentState.DEFAULT) { // || (isLarge && currState.isSelected())) SubstanceTableUI.this.prevStateMap.remove(cellIndex); SubstanceTableUI.this.nextStateMap.remove(cellIndex); } else { SubstanceTableUI.this.prevStateMap.put(cellIndex, currState); SubstanceTableUI.this.nextStateMap.put(cellIndex, currState); } } // System.out.println(tabIndex + "->" // + prevStateMap.get(tabIndex).name()); } this.repaintColumn(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.animation.FadeTrackerAdapter#fadeReversed(org * .jvnet.lafwidget.animation.FadeKind, boolean, float) */ @Override public void fadeReversed(FadeKind fadeKind, boolean isFadingIn, float fadeCycle10) { if ((SubstanceTableUI.this.table == this.table) && (this.columnIndex < this.table.getColumnCount())) { for (int rowIndex = 0; rowIndex < this.table.getRowCount(); rowIndex++) { TableCellId cellIndex = new TableCellId(rowIndex, this.columnIndex); ComponentState nextState = SubstanceTableUI.this.nextStateMap .get(cellIndex); if (nextState == null) { SubstanceTableUI.this.prevStateMap.remove(cellIndex); } else { SubstanceTableUI.this.prevStateMap.put(cellIndex, nextState); } // System.out.println(tabIndex + "->" // + prevStateMap.get(tabIndex).name()); } } this.repaintColumn(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.utils.FadeTracker$FadeTrackerCallback#fadePerformed * (org.jvnet.lafwidget.utils.FadeTracker.FadeKind, float) */ @Override public void fadePerformed(FadeKind fadeKind, float fade) { if ((SubstanceTableUI.this.table == this.table) && (this.columnIndex < this.table.getColumnCount())) { for (int rowIndex = 0; rowIndex < this.table.getRowCount(); rowIndex++) { TableCellId cellIndex = new TableCellId(rowIndex, this.columnIndex); SubstanceTableUI.this.nextStateMap.put(cellIndex, SubstanceTableUI.this.getCellState(cellIndex)); } } this.repaintColumn(); } /** * Repaints the associated row. */ private void repaintColumn() { SwingUtilities.invokeLater(new Runnable() { public void run() { if (SubstanceTableUI.this.table == null) { // may happen if the LAF was switched in the meantime return; } int columnCount = ColumnRepaintCallback.this.table .getColumnCount(); if ((columnCount > 0) && (ColumnRepaintCallback.this.columnIndex < columnCount)) { // need to retrieve the cell rectangle since the cells // can be moved while animating Rectangle rect = ColumnRepaintCallback.this.table .getCellRect(0, ColumnRepaintCallback.this.columnIndex, true); for (int i = 1; i < ColumnRepaintCallback.this.table .getRowCount(); i++) { rect = rect .union(ColumnRepaintCallback.this.table .getCellRect( i, ColumnRepaintCallback.this.columnIndex, true)); } if (!table.getShowHorizontalLines() && !table.getShowVerticalLines()) { float extra = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(table .getTableHeader())); rect.x -= (int) extra; rect.width += 2 * (int) extra; } ColumnRepaintCallback.this.table.repaint(rect); } } }); } } public static interface TableId extends Comparable { public TableId cloneId(); } /** * ID of a single table cell. * * @author Kirill Grouchnikov */ @SuppressWarnings("unchecked") public static class TableCellId implements TableId { /** * Cell row. */ protected int row; /** * Cell column. */ protected int column; /** * Indicates whether the comparison ({@link #equals(Object)}) should * return false when it is passed either * {@link TableColumnId} or {@link TableRowId}. */ protected boolean isExactComparison; /** * Creates a new cell ID. * * @param row * Cell row. * @param column * Cell column. */ public TableCellId(int row, int column) { this.row = row; this.column = column; } /** * Sets the comparison flag. * * @param isExactComparison * If true, the ({@link #equals(Object)}) will * return false when it is passed either * {@link TableColumnId} or {@link TableRowId}. */ public void setExactComparison(boolean isExactComparison) { this.isExactComparison = isExactComparison; } /* * (non-Javadoc) * * @see java.lang.Comparable#compareTo(java.lang.Object) */ public int compareTo(Object o) { if (o instanceof TableCellId) { TableCellId otherId = (TableCellId) o; if ((this.row == otherId.row) && (this.column == otherId.column)) return 0; return 1; } if (!this.isExactComparison) { if (o instanceof TableRowId) { TableRowId otherId = (TableRowId) o; if (this.row == otherId.row) return 0; return 1; } if (o instanceof TableColumnId) { TableColumnId otherId = (TableColumnId) o; if (this.column == otherId.column) return 0; return 1; } } return -1; } /* * (non-Javadoc) * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { return this.compareTo(obj) == 0; } /* * (non-Javadoc) * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { return (this.row ^ (this.row >>> 32)) & (this.column ^ (this.column >>> 32)); } /* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { return this.row + ":" + this.column; } @Override public TableId cloneId() { return new TableCellId(row, column); } } /** * ID of a single table column. * * @author Kirill Grouchnikov */ @SuppressWarnings("unchecked") protected static class TableColumnId implements TableId { /** * Column. */ protected int column; /** * Creates a new column ID. * * @param column * Column. */ public TableColumnId(int column) { this.column = column; } /* * (non-Javadoc) * * @see java.lang.Comparable#compareTo(java.lang.Object) */ public int compareTo(Object o) { if (o instanceof TableCellId) { TableCellId otherId = (TableCellId) o; if (this.column == otherId.column) return 0; return 1; } if (o instanceof TableColumnId) { TableColumnId otherId = (TableColumnId) o; if (this.column == otherId.column) return 0; return 1; } return -1; } /* * (non-Javadoc) * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { return this.compareTo(obj) == 0; } /* * (non-Javadoc) * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { return (this.column ^ (this.column >>> 32)); } @Override public TableId cloneId() { return new TableColumnId(this.column); } } /** * ID of a single table row. * * @author Kirill Grouchnikov */ @SuppressWarnings("unchecked") protected static class TableRowId implements TableId { /** * Row. */ protected int row; /** * Creates a new row ID. * * @param row * Row. */ public TableRowId(int row) { this.row = row; } /* * (non-Javadoc) * * @see java.lang.Comparable#compareTo(java.lang.Object) */ public int compareTo(Object o) { if (o instanceof TableCellId) { TableCellId otherId = (TableCellId) o; if (this.row == otherId.row) return 0; return 1; } if (o instanceof TableRowId) { TableRowId otherId = (TableRowId) o; if (this.row == otherId.row) return 0; return 1; } return -1; } /* * (non-Javadoc) * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { return this.compareTo(obj) == 0; } /* * (non-Javadoc) * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { return (this.row ^ (this.row >>> 32)); } @Override public TableId cloneId() { return new TableRowId(this.row); } } /** * State listener for tracking the selection changes. * * @author Kirill Grouchnikov */ protected class TableStateListener implements ListSelectionListener, TableModelListener { /* * (non-Javadoc) * * @see * javax.swing.event.ListSelectionListener#valueChanged(javax.swing. * event.ListSelectionEvent) */ @SuppressWarnings("unchecked") public void valueChanged(final ListSelectionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { syncSelection(); } }); } /* * (non-Javadoc) * * @see * javax.swing.event.TableModelListener#tableChanged(javax.swing.event * .TableModelEvent) */ public void tableChanged(final TableModelEvent e) { // fix for defect 291 - tracking changes to the table. SwingUtilities.invokeLater(new Runnable() { public void run() { // fix for defect 350 - font might have been // switched in the middle of update if (table == null) return; // fix for defect 328 - do not clear the // internal selection and focus tracking // when the event is table update. if (e.getType() != TableModelEvent.UPDATE) { selectedIndices.clear(); prevStateMap.clear(); nextStateMap.clear(); focusedColumn = -1; focusedRow = -1; } syncSelection(); table.repaint(); } }); } } /** * Listener for fade animations on table rollovers. * * @author Kirill Grouchnikov */ private class RolloverFadeListener implements MouseListener, MouseMotionListener { public void mouseClicked(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void mouseExited(MouseEvent e) { // if (SubstanceCoreUtilities.toBleedWatermark(list)) // return; if (!SubstanceTableUI.this.table.isEnabled()) return; // synchronized (SubstanceTableUI.this.table) { this.fadeOut(); this.fadeOutTableHeader(); // System.out.println("Nulling RO index"); SubstanceTableUI.this.rolledOverId = null; SubstanceTableUI.this.rolledOverColumn = -1; // } } public void mouseMoved(MouseEvent e) { // if (SubstanceCoreUtilities.toBleedWatermark(list)) // return; if (!SubstanceTableUI.this.table.isEnabled()) return; this.handleMove(e); this.handleMoveForHeader(e); } public void mouseDragged(MouseEvent e) { // if (SubstanceCoreUtilities.toBleedWatermark(list)) // return; if (!SubstanceTableUI.this.table.isEnabled()) return; this.handleMove(e); this.handleMoveForHeader(e); } /** * Handles various mouse move events and initiates the fade animation if * necessary. * * @param e * Mouse event. */ private void handleMove(MouseEvent e) { // synchronized (SubstanceTableUI.this.table) { int row = SubstanceTableUI.this.table.rowAtPoint(e.getPoint()); int column = SubstanceTableUI.this.table .columnAtPoint(e.getPoint()); if ((row < 0) || (row >= SubstanceTableUI.this.table.getRowCount()) || (column < 0) || (column >= SubstanceTableUI.this.table.getColumnCount())) { this.fadeOut(); // System.out.println("Nulling RO index"); // table.putClientProperty(ROLLED_OVER_INDEX, null); SubstanceTableUI.this.rolledOverId = null; } else { // check if this is the same index // need to clone ID since it can go to the fade tracker // and be set as the rollover id TableId newId = SubstanceTableUI.this.getId(row, column) .cloneId(); // Comparable currId = (Comparable) table // .getClientProperty(ROLLED_OVER_INDEX); if ((SubstanceTableUI.this.rolledOverId != null) && newId.equals(SubstanceTableUI.this.rolledOverId)) return; this.fadeOut(); FadeTrackerCallback callback = SubstanceTableUI.this .getCallback(row, column); if (SubstanceTableUI.this._hasRolloverAnimations()) { FadeTracker.getInstance() .trackFadeIn(FadeKind.ROLLOVER, SubstanceTableUI.this.table, newId, false, callback); } else { callback.fadeEnded(FadeKind.ROLLOVER); } // System.out.println("Setting RO index to " + roIndex); if (FadeConfigurationManager.getInstance().fadeAllowed( FadeKind.ROLLOVER, SubstanceTableUI.this.table)) { SubstanceTableUI.this.rolledOverId = newId; // table.putClientProperty(ROLLED_OVER_INDEX, newId); } } // } } /** * Handles various mouse move events and initiates the fade animation if * necessary. * * @param e * Mouse event. */ private void handleMoveForHeader(MouseEvent e) { if (!SubstanceTableUI.this.table.getColumnSelectionAllowed()) return; JTableHeader header = SubstanceTableUI.this.table.getTableHeader(); if ((header == null) || (!header.isVisible())) return; TableHeaderUI ui = header.getUI(); if (!(ui instanceof SubstanceTableHeaderUI)) return; SubstanceTableHeaderUI sthui = (SubstanceTableHeaderUI) ui; // synchronized (SubstanceTableUI.this.table) { int row = SubstanceTableUI.this.table.rowAtPoint(e.getPoint()); int column = SubstanceTableUI.this.table .columnAtPoint(e.getPoint()); if ((row < 0) || (row >= SubstanceTableUI.this.table.getRowCount()) || (column < 0) || (column >= SubstanceTableUI.this.table.getColumnCount())) { this.fadeOutTableHeader(); // System.out.println("Nulling RO column index"); SubstanceTableUI.this.rolledOverColumn = -1; } else { // check if this is the same column if (SubstanceTableUI.this.rolledOverColumn == column) return; this.fadeOutTableHeader(); FadeTracker.getInstance().trackFadeIn(FadeKind.ROLLOVER, header, column, false, sthui.getCallback(column)); // System.out.println("Setting RO column index to " + // column); if (FadeConfigurationManager.getInstance().fadeAllowed( FadeKind.ROLLOVER, SubstanceTableUI.this.table)) { SubstanceTableUI.this.rolledOverColumn = column; } } // } } /** * Initiates the fade out effect. */ private void fadeOut() { if (SubstanceTableUI.this.rolledOverId != null) { FadeTrackerCallback callback = SubstanceTableUI.this .getCallback(SubstanceTableUI.this.rolledOverId); if (SubstanceTableUI.this._hasRolloverAnimations()) { FadeTracker.getInstance() .trackFadeOut(FadeKind.ROLLOVER, SubstanceTableUI.this.table, SubstanceTableUI.this.rolledOverId, false, callback); } else { callback.fadeEnded(FadeKind.ROLLOVER); } } } /** * Initiates the fade out effect. */ private void fadeOutTableHeader() { if (SubstanceTableUI.this.rolledOverColumn >= 0) { JTableHeader header = SubstanceTableUI.this.table .getTableHeader(); if ((header == null) || (!header.isVisible())) return; SubstanceTableHeaderUI ui = (SubstanceTableHeaderUI) header .getUI(); FadeTracker.getInstance().trackFadeOut(FadeKind.ROLLOVER, header, SubstanceTableUI.this.rolledOverColumn, false, ui.getCallback(SubstanceTableUI.this.rolledOverColumn)); } } } /** * Returns fade callback for a cell at the specified row and column. * * @param row * Row index. * @param column * Column index. * @return Fade callback for the specified cell. */ private FadeTrackerCallback getCallback(int row, int column) { boolean hasRowSelection = this.table.getRowSelectionAllowed(); boolean hasColumnSelection = this.table.getColumnSelectionAllowed(); if (hasRowSelection && !hasColumnSelection) return new RowRepaintCallback(this.table, row); if (!hasRowSelection && hasColumnSelection) return new ColumnRepaintCallback(this.table, column); return new CellRepaintCallback(this.table, row, column); } /** * Returns fade callback for a cell, row or column specified by the * parameter, which should be one of {@link TableRowId}, * {@link TableColumnId} or {@link TableCellId}. * * @param comparable * One of {@link TableRowId}, {@link TableColumnId} or * {@link TableCellId}. * @return Fade callback. */ private FadeTrackerCallback getCallback(Comparable comparable) { if (comparable instanceof TableRowId) return new RowRepaintCallback(this.table, ((TableRowId) comparable).row); if (comparable instanceof TableColumnId) return new ColumnRepaintCallback(this.table, ((TableColumnId) comparable).column); return new CellRepaintCallback(this.table, ((TableCellId) comparable).row, ((TableCellId) comparable).column); } /** * Returns a comparable ID for the specified location. The result will be * one of {@link TableRowId}, {@link TableColumnId} or {@link TableCellId}, * based on the row and column selection modes of the table. * * @param row * Row index. * @param column * Column index. * @return Comparable ID for the specified location. */ public TableId getId(int row, int column) { boolean hasRowSelection = this.table.getRowSelectionAllowed(); boolean hasColumnSelection = this.table.getColumnSelectionAllowed(); // reuse the ID objects for optimizations - called a lot during // painting and animations if (hasRowSelection && !hasColumnSelection) { rowId.row = row; return rowId; } if (!hasRowSelection && hasColumnSelection) { colId.column = column; return colId; } cellId.column = column; cellId.row = row; return cellId; } TableRowId rowId; TableColumnId colId; TableCellId cellId; /** * Synchronizes the current selection state. * * @param e * Selection event. */ // @SuppressWarnings("unchecked") protected void syncSelection(/* ListSelectionEvent e */) { if (this.table == null) { // fix for defect 270 - if the UI delegate is updated // by another selection listener, ignore this return; } int rows = this.table.getRowCount(); int cols = this.table.getColumnCount(); int rowLeadIndex = this.table.getSelectionModel() .getLeadSelectionIndex(); int colLeadIndex = this.table.getColumnModel().getSelectionModel() .getLeadSelectionIndex(); boolean isFocusOwner = this.table.isFocusOwner(); // fix for defect 209 - selection very slow on large tables with // column selection set to true and row selection set to false. // Solution - no selection animations on tables with more than 1000 // cells. if (!this._hasSelectionAnimations()) { this.prevStateMap.clear(); table.repaint(); // fix for issue 414 - track focus on tables // without selection animations if (isFocusOwner) { this.focusedRow = rowLeadIndex; this.focusedColumn = colLeadIndex; } return; } Set initiatedFadeSequences = new HashSet(); boolean fadeCanceled = false; FadeTracker fadeTrackerInstance = FadeTracker.getInstance(); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { if (this.table.isCellSelected(i, j)) { TableCellId cellId = new TableCellId(i, j); // check if was selected before if (!this.selectedIndices.containsKey(cellId)) { // start fading in // System.err.println("Fade in on " + i + ":" + j); if (!fadeCanceled) { long fadeId = fadeTrackerInstance.trackFadeIn( FadeKind.SELECTION, this.table, cellId, false, new CellRepaintCallback(this.table, i, j)); initiatedFadeSequences.add(fadeId); if (initiatedFadeSequences.size() > 15) { SubstanceFadeUtilities .cancelFades(initiatedFadeSequences); initiatedFadeSequences.clear(); fadeCanceled = true; } } else { new CellRepaintCallback(this.table, i, j) .fadeEnded(FadeKind.SELECTION); } this.selectedIndices.put(cellId, this.table.getValueAt( i, j)); // prevStateMap.put(cellId, ComponentState.SELECTED); } } else { TableCellId cellId = new TableCellId(i, j); // check if was selected before and still points // to the same element if (this.selectedIndices.containsKey(cellId)) { // corner case when the model returns null Object oldValue = this.selectedIndices.get(cellId); Object currValue = this.table.getValueAt(i, j); boolean isSame = false; if (oldValue == null) { isSame = (currValue == null); } else { // if (oldValue instanceof Comparable) { // try { // isSame = (((Comparable) oldValue) // .compareTo(currValue) == 0); // } catch (Throwable t) { // isSame = oldValue.toString().equals( // currValue.toString()); // } // } else { isSame = oldValue.equals(currValue); // } } // if (!isSame) { // System.err.println(i + ":" + j + ":" + oldValue // + ":" + currValue); // } if (isSame) { // start fading out // System.err.println("Fade out on " + i + ":" + j); if (!fadeCanceled) { long fadeId = fadeTrackerInstance.trackFadeOut( FadeKind.SELECTION, this.table, cellId, false, new CellRepaintCallback( this.table, i, j)); initiatedFadeSequences.add(fadeId); // System.err.println("Has " // + initiatedFadeSequences.size() // + " sqs [" + fadeId + "]"); if (initiatedFadeSequences.size() > 15) { // System.err.println("Cancelling fades"); SubstanceFadeUtilities .cancelFades(initiatedFadeSequences); initiatedFadeSequences.clear(); fadeCanceled = true; } } else { new CellRepaintCallback(this.table, i, j) .fadeEnded(FadeKind.SELECTION); } } this.selectedIndices.remove(cellId); } // ComponentState state = getCellState(cellId); // if (state == ComponentState.DEFAULT) { // prevStateMap.remove(cellId); // } else { // prevStateMap.put(cellId, getCellState(cellId)); // System.out.println(cellId.row + ":" + cellId.column // + "->" + state.name()); // } } // handle focus animations boolean cellHasFocus = isFocusOwner && (i == rowLeadIndex) && (j == colLeadIndex); if (cellHasFocus) { // check is it's a different cell if ((this.focusedRow != i) || (this.focusedColumn != j)) { if ((this.focusedRow >= 0) && (this.focusedColumn >= 0)) { // fade out the previous focus holder TableCellId prevFocusedId = new TableCellId( this.focusedRow, this.focusedColumn); // set indication to make exact comparison (since // focus can be only on one cell). prevFocusedId.setExactComparison(true); FadeTrackerCallback callback = this .getCallback(prevFocusedId); // System.out.println("Fading out " + // prevFocusedId); FadeTracker.getInstance().trackFadeOut( FadeKind.FOCUS, this.table, prevFocusedId, false, callback); } FadeTrackerCallback callback = this.getCallback(i, j); // fade in the current cell (new focus holder) // System.out.println("Fading in " + cellId); TableCellId currId = new TableCellId(i, j); // set indication to make exact comparison (since // focus can be only on one cell). currId.setExactComparison(true); FadeTracker.getInstance().trackFadeIn(FadeKind.FOCUS, this.table, currId, false, callback); // System.out.println("Setting focus index to " + i + // ":" // + j); if (FadeConfigurationManager.getInstance().fadeAllowed( FadeKind.FOCUS, this.table)) { // and store it for future checks this.focusedRow = i; this.focusedColumn = j; } } } else { // check if previously it held focus if ((this.focusedRow == i) && (this.focusedColumn == j)) { // fade it out TableCellId prevFocusedId = new TableCellId( this.focusedRow, this.focusedColumn); // set indication to make exact comparison (since // focus can be only on one cell). prevFocusedId.setExactComparison(true); FadeTrackerCallback callback = SubstanceTableUI.this .getCallback(prevFocusedId); // System.out.println("Fading out " + prevFocusedId); FadeTracker.getInstance().trackFadeOut(FadeKind.FOCUS, SubstanceTableUI.this.table, prevFocusedId, false, callback); this.focusedRow = -1; this.focusedColumn = -1; } } } } // System.err.println("Has " + currSelected.size() + " selected cells"); // for (TableCellId cellId : currSelected.keySet()) { // System.err.println("\t" + cellId.row + ":" + cellId.column); // } } /** * Returns the previous state for the specified cell. * * @param cellIndex * Cell index. * @return The previous state for the specified cell. */ public ComponentState getPrevCellState(TableCellId cellIndex) { if (this.prevStateMap.containsKey(cellIndex)) return this.prevStateMap.get(cellIndex); return this.getCellState(cellIndex); } /** * Returns the current state for the specified cell. * * @param cellIndex * Cell index. * @return The current state for the specified cell. */ public ComponentState getCellState(TableCellId cellIndex) { int row = cellIndex.row; int column = cellIndex.column; Comparable cellId = this.getId(row, column); boolean isEnabled = this.table.isEnabled(); boolean isRollover = cellId.equals(this.rolledOverId); boolean isSelected = false; boolean hasSelectionAnimations = (this.updateInfo != null) ? this.updateInfo.hasSelectionAnimations : this._hasSelectionAnimations(); if (hasSelectionAnimations && FadeConfigurationManager.getInstance().fadeAllowed( FadeKind.SELECTION, table)) isSelected = this.selectedIndices.containsKey(cellId); else { isSelected = this.table.isCellSelected(row, column); } return ComponentState.getState(isEnabled, isRollover, isSelected); } /** * Checks whether the table has animations. * * @return true if the table has animations, false * otherwise. */ protected boolean _hasAnimations() { // fix for defects 164 and 209 - selection // and deletion are very slow on large tables. int rowCount = this.table.getRowCount(); int colCount = this.table.getColumnCount(); if (rowCount * colCount >= 500) return false; if (this.table.getColumnSelectionAllowed() && !this.table.getRowSelectionAllowed()) { if (!this.table.getShowHorizontalLines() && !this.table.getShowVerticalLines()) return rowCount <= 8; return rowCount <= 25; } if (!this.table.getColumnSelectionAllowed() && this.table.getRowSelectionAllowed()) { if (!this.table.getShowHorizontalLines() && !this.table.getShowVerticalLines()) return colCount <= 8; return colCount <= 25; } return true; } /** * Checks whether the table has selection animations. * * @return true if the table has selection animations, * false otherwise. */ protected boolean _hasSelectionAnimations() { return this._hasAnimations() && !LafWidgetUtilities.hasNoFades(this.table, FadeKind.SELECTION); } /** * Checks whether the table has rollover animations. * * @return true if the table has rollover animations, * false otherwise. */ protected boolean _hasRolloverAnimations() { return this._hasAnimations() && !LafWidgetUtilities .hasNoFades(this.table, FadeKind.ROLLOVER); } /** * Returns the index of the rollover column. * * @return The index of the rollover column. */ public int getRolloverColumnIndex() { return this.rolledOverColumn; } /** * Returns indication whether the specified cell has focus. * * @param row * Cell row index. * @param column * Cell column index. * @return true If the focus is on the specified cell, * false otherwise. */ public boolean isFocusedCell(int row, int column) { return (this.focusedRow == row) && (this.focusedColumn == column); } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void update(Graphics g, JComponent c) { BackgroundPaintingUtils.updateIfOpaque(g, c); Graphics2D g2d = (Graphics2D) g.create(); SubstanceStripingUtils.setup(c); this.updateInfo = new UpdateOptimizationInfo(); this.paint(g2d, c); SubstanceStripingUtils.tearDown(c); g2d.dispose(); this.updateInfo = null; } /** * Returns the cell renderer insets of this table. Is for internal use only. * * @return The cell renderer insets of this table. */ public Insets getCellRendererInsets() { return this.cellRendererInsets; } public SubstanceColorScheme getDefaultColorScheme() { if (this.updateInfo != null) return this.updateInfo.defaultScheme; return null; } public SubstanceColorScheme getHighlightColorScheme(ComponentState state) { if (this.updateInfo != null) return updateInfo.getHighlightColorScheme(state); return null; } public boolean hasSelectionAnimations() { if (this.updateInfo != null) return this.updateInfo.hasSelectionAnimations; return this._hasSelectionAnimations(); } public boolean hasRolloverAnimations() { if (this.updateInfo != null) return this.updateInfo.hasRolloverAnimations; return this._hasRolloverAnimations(); } private UpdateOptimizationInfo updateInfo; private class UpdateOptimizationInfo { public boolean toDrawWatermark; private Map highlightSchemeMap; private Map borderSchemeMap; private Map highlightAlphaMap; public SubstanceColorScheme defaultScheme; public boolean hasSelectionAnimations; public boolean hasRolloverAnimations; public Map opacity; public DecorationAreaType decorationAreaType; public boolean isInDecorationArea; public UpdateOptimizationInfo() { this.toDrawWatermark = SubstanceCoreUtilities .toDrawWatermark(table); this.defaultScheme = SubstanceColorSchemeUtilities.getColorScheme( table, ComponentState.DEFAULT); this.highlightAlphaMap = new EnumMap( ComponentState.class); this.highlightSchemeMap = new EnumMap( ComponentState.class); this.borderSchemeMap = new EnumMap( ComponentState.class); this.hasSelectionAnimations = _hasSelectionAnimations(); this.opacity = new HashMap(); this.decorationAreaType = SubstanceLookAndFeel .getDecorationType(table); SubstanceSkin skin = SubstanceCoreUtilities.getSkin(table); this.isInDecorationArea = (this.decorationAreaType != null) && skin .isRegisteredAsDecorationArea(this.decorationAreaType) && TransitionLayout.isOpaque(table); } public SubstanceColorScheme getHighlightColorScheme(ComponentState state) { if (!this.highlightSchemeMap.containsKey(state)) { this.highlightSchemeMap.put(state, SubstanceColorSchemeUtilities.getColorScheme(table, ColorSchemeAssociationKind.HIGHLIGHT, state)); } return this.highlightSchemeMap.get(state); } public SubstanceColorScheme getHighlightBorderColorScheme( ComponentState state) { if (!this.borderSchemeMap.containsKey(state)) { this.borderSchemeMap.put(state, SubstanceColorSchemeUtilities .getColorScheme(table, ColorSchemeAssociationKind.HIGHLIGHT_BORDER, state)); } return this.borderSchemeMap.get(state); } public float getHighlightAlpha(ComponentState state) { if (!this.highlightAlphaMap.containsKey(state)) { this.highlightAlphaMap.put(state, SubstanceColorSchemeUtilities .getHighlightAlpha(table, state)); } return this.highlightAlphaMap.get(state); } } private boolean isSubstanceDefaultRenderer(TableCellRenderer renderer) { return (renderer instanceof SubstanceDefaultTableCellRenderer) || (renderer instanceof SubstanceDefaultTableCellRenderer.BooleanRenderer); } } substance-5.3.orig/src/org/jvnet/substance/shaper/0000755000175000017500000000000011256731150022161 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/shaper/ClassicButtonShaper.java0000644000175000017500000002205411246717120026747 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.shaper; import java.awt.*; import java.awt.geom.GeneralPath; import java.util.Set; import javax.swing.*; import javax.swing.border.Border; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.border.SubstanceBorder; import org.jvnet.substance.utils.border.SubstanceButtonBorder; /** * Button shaper that returns rectangular buttons with slightly rounded corners * (ala Windows XP). This class is part of officially supported API. * * @author Kirill Grouchnikov */ public class ClassicButtonShaper extends BaseButtonShaper implements RectangularButtonShaper { /** * Cache of already computed contours. */ private final static LazyResettableHashMap contours = new LazyResettableHashMap( "ClassicButtonShaper"); /** * Reusable instance of this shaper. */ public static final ClassicButtonShaper INSTANCE = new ClassicButtonShaper(); /* * (non-Javadoc) * * @see org.jvnet.substance.button.SubstanceButtonShaper#getDisplayName() */ public String getDisplayName() { return "Classic"; } /* * (non-Javadoc) * * @see * org.jvnet.substance.shaper.SubstanceButtonShaper#getButtonOutline(javax * .swing.AbstractButton, java.awt.Insets, int, int, boolean) */ @Override public GeneralPath getButtonOutline(AbstractButton button, Insets insets, int width, int height, boolean isInner) { Set straightSides = SubstanceCoreUtilities .getSides(button, SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY); float radius = this.getCornerRadius(button, insets); if (isInner) { radius -= (int) SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(button)); } HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height, straightSides, radius, insets); GeneralPath result = contours.get(key); if (result != null) { return result; } result = SubstanceOutlineUtilities.getBaseOutline(width, height, radius, straightSides, insets); contours.put(key, result); return result; } /* * (non-Javadoc) * * @see * org.jvnet.substance.button.SubstanceButtonShaper#getButtonBorder(javax * .swing.AbstractButton) */ public Border getButtonBorder(final AbstractButton button) { return new SubstanceButtonBorder(ClassicButtonShaper.class) { public Insets getBorderInsets(Component c) { int fontSize = SubstanceSizeUtils.getComponentFontSize(button); int extraPadding = SubstanceSizeUtils.getExtraPadding(fontSize); int focusPadding = SubstanceSizeUtils .getFocusRingPadding(fontSize); int lrPadding = SubstanceCoreUtilities.hasText(button) ? SubstanceSizeUtils .getTextButtonLRPadding(fontSize) : 0; Set openSides = SubstanceCoreUtilities .getSides(button, SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY); int left = lrPadding + extraPadding + focusPadding + (openSides.contains(SubstanceConstants.Side.LEFT) ? 1 : 2); int right = lrPadding + extraPadding + focusPadding + (openSides.contains(SubstanceConstants.Side.RIGHT) ? 1 : 2); int top = extraPadding + (openSides.contains(SubstanceConstants.Side.TOP) ? 1 : 2); int bottom = extraPadding + (openSides.contains(SubstanceConstants.Side.BOTTOM) ? 1 : 2); return new Insets(top, left, bottom, right); } }; } /* * (non-Javadoc) * * @see * org.jvnet.substance.button.SubstanceButtonShaper#getPreferredSize(javax * .swing.AbstractButton, java.awt.Dimension) */ public Dimension getPreferredSize(AbstractButton button, Dimension uiPreferredSize) { Dimension result; boolean toTweakWidth = false; boolean toTweakHeight = false; Icon icon = button.getIcon(); boolean hasIcon = SubstanceCoreUtilities.hasIcon(button); boolean hasText = SubstanceCoreUtilities.hasText(button); Insets margin = button.getMargin(); result = uiPreferredSize; boolean hasNoMinSizeProperty = SubstanceCoreUtilities .hasNoMinSizeProperty(button); if ((!hasNoMinSizeProperty) && hasText) { int baseWidth = uiPreferredSize.width; baseWidth = Math.max(baseWidth, SubstanceSizeUtils .getMinButtonWidth(SubstanceSizeUtils .getComponentFontSize(button))); result = new Dimension(baseWidth, uiPreferredSize.height); int baseHeight = result.height; baseHeight = Math.max(baseHeight, SubstanceSizeUtils .getMinButtonHeight(SubstanceSizeUtils .getComponentFontSize(button))); result = new Dimension(result.width, baseHeight); } else { if (hasNoMinSizeProperty) { if (margin != null) { result = new Dimension(result.width + margin.left + margin.right, result.height + margin.top + margin.bottom); } } } int fontSize = SubstanceSizeUtils.getComponentFontSize(button); int extraPadding = SubstanceSizeUtils.getExtraPadding(fontSize); int focusPadding = SubstanceSizeUtils.getFocusRingPadding(fontSize); int iconPaddingWidth = 6 + 2 * extraPadding + 2 * focusPadding; int iconPaddingHeight = 6 + 2 * extraPadding; if (margin != null) { iconPaddingWidth = Math.max(iconPaddingWidth, margin.left + margin.right); iconPaddingHeight = Math.max(iconPaddingHeight, margin.top + margin.bottom); } if (hasIcon) { // check the icon height int iconHeight = icon.getIconHeight(); if (iconHeight > (result.getHeight() - iconPaddingHeight)) { result = new Dimension(result.width, iconHeight); toTweakHeight = true; } int iconWidth = icon.getIconWidth(); if (iconWidth > (result.getWidth() - iconPaddingWidth)) { result = new Dimension(iconWidth, result.height); toTweakWidth = true; } } // else { // if (hasText) { // result = new Dimension(result.width + 2 * extraPadding, // result.height); // } // } if (SubstanceCoreUtilities.isScrollBarButton(button)) { toTweakWidth = false; toTweakHeight = false; } if (toTweakWidth) { result = new Dimension(result.width + iconPaddingWidth, result.height); } if (toTweakHeight) { result = new Dimension(result.width, result.height + iconPaddingHeight); } return result; } /* * (non-Javadoc) * * @see org.jvnet.substance.button.SubstanceButtonShaper#isProportionate() */ public boolean isProportionate() { return true; } /* * (non-Javadoc) * * @see * org.jvnet.substance.shaper.RectangularButtonShaper#getCornerRadius(javax * .swing.JComponent, java.awt.Insets) */ @Override public float getCornerRadius(AbstractButton button, Insets insets) { float radius = SubstanceSizeUtils .getClassicButtonCornerRadius(SubstanceSizeUtils .getComponentFontSize(button)); if (button.getClass().isAnnotationPresent(SubstanceArrowButton.class)) { Border parentBorder = ((JComponent) button.getParent()).getBorder(); if (parentBorder instanceof SubstanceBorder) { radius *= ((SubstanceBorder) parentBorder) .getRadiusScaleFactor(); } } if (SubstanceCoreUtilities.isToolBarButton(button)) { radius = SubstanceCoreUtilities.getToolbarButtonCornerRadius( button, insets); } return radius; } } substance-5.3.orig/src/org/jvnet/substance/shaper/BaseButtonShaper.java0000644000175000017500000000575211172042310026234 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.shaper; import java.awt.Insets; import java.awt.Shape; import javax.swing.AbstractButton; /** * Base button shaper. This class is for internal use only. * * @author Kirill Grouchnikov */ public abstract class BaseButtonShaper implements SubstanceButtonShaper { /* * (non-Javadoc) * * @see * org.jvnet.substance.shaper.SubstanceButtonShaper#getButtonOutline(javax * .swing.JComponent, java.awt.Insets) */ @Override public final Shape getButtonOutline(AbstractButton button, Insets insets) { return this.getButtonOutline(button, insets, button.getWidth(), button .getHeight(), false); } /* * (non-Javadoc) * * @see * org.jvnet.substance.shaper.SubstanceButtonShaper#getButtonOutline(javax * .swing.JComponent) */ @Override public final Shape getButtonOutline(AbstractButton button) { return this.getButtonOutline(button, null, button.getWidth(), button .getHeight(), false); } /* * (non-Javadoc) * * @see * org.jvnet.substance.shaper.SubstanceButtonShaper#getButtonOutline(javax * .swing.AbstractButton, java.awt.Insets, int, int) */ @Override public final Shape getButtonOutline(AbstractButton button, Insets insets, int width, int height) { return this.getButtonOutline(button, null, width, height, false); } } substance-5.3.orig/src/org/jvnet/substance/shaper/RectangularButtonShaper.java0000644000175000017500000000424411136475562027647 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.shaper; import java.awt.Insets; import javax.swing.AbstractButton; /** * Interface for rectangular-based button shapers. * * @author Kirill Grouchnikov */ public interface RectangularButtonShaper { /** * Returns the corner radius of the specified button. * * @param button * Button. * @param insets * Button insets. * @return Corner radius of the specified button. */ public float getCornerRadius(AbstractButton button, Insets insets); } substance-5.3.orig/src/org/jvnet/substance/shaper/SubstanceButtonShaper.java0000644000175000017500000001233111174265264027321 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.shaper; import java.awt.*; import javax.swing.AbstractButton; import javax.swing.border.Border; import org.jvnet.substance.api.trait.SubstanceTrait; /** * Button shaper interface for Substance look and feel. This class is * part of officially supported API. * * @author Kirill Grouchnikov */ public interface SubstanceButtonShaper extends SubstanceTrait { /* * (non-Javadoc) * * @see org.jvnet.substance.utils.SubstanceTrait#getDisplayName() */ public String getDisplayName(); /** * Returns the outline path for the specified control. * * @param button * A button. * @return The outline path for the specified control. * @deprecated Will be removed in version 6.0. Use * {@link #getButtonOutline(AbstractButton, Insets, int, int, boolean)} * instead. */ @Deprecated public Shape getButtonOutline(AbstractButton button); /** * Returns the outline path for the specified button. * * @param button * A button. * @param insets * Button insets. * @param width * Button width. * @param height * Button height. * @return The outline path for the specified button. * @deprecated Will be removed in version 6.0. Use * {@link #getButtonOutline(AbstractButton, Insets, int, int, boolean)} * instead. */ @Deprecated public Shape getButtonOutline(AbstractButton button, Insets insets, int width, int height); /** * Returns the outline path for the specified button. * * @param button * A button. * @param insets * Button insets. * @param width * Button width. * @param height * Button height. * @param isInner * Indication whether the returned outline is used for the inner * contour. * @return The outline path for the specified button. */ public Shape getButtonOutline(AbstractButton button, Insets insets, int width, int height, boolean isInner); /** * Returns the outline path for the specified button. * * @param button * A button. * @param insets * Button insets. * @return The outline path for the specified button. * @deprecated Will be removed in version 6.0. Use * {@link #getButtonOutline(AbstractButton, Insets, int, int, boolean)} * instead. */ @Deprecated public Shape getButtonOutline(AbstractButton button, Insets insets); /** * Returns the border for the specified button. * * @param button * A button. * @return The border for the specified button. */ public Border getButtonBorder(AbstractButton button); /** * Returns the preferred size for the specified button. * * @param button * A button. * @param uiPreferredSize * Preferred size of the button under the regular conditions * (plain rectangular button). * @return The preferred size for the specified button. */ public Dimension getPreferredSize(AbstractButton button, Dimension uiPreferredSize); /** * Returns the boolean indication whether the shaper should maintain button * proportions on the resize. This may be relevant for vector-based shapers * (such as animals / other objects). * * @return true if this shaper should maintain * button proportions on the resize, false otherwise. * */ public boolean isProportionate(); } substance-5.3.orig/src/org/jvnet/substance/shaper/StandardButtonShaper.java0000644000175000017500000002265311246717134027140 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.shaper; import java.awt.*; import java.awt.geom.GeneralPath; import java.util.Set; import javax.swing.*; import javax.swing.border.Border; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.border.SubstanceBorder; import org.jvnet.substance.utils.border.SubstanceButtonBorder; /** * Button shaper that returns buttons with completely rounded corners (ala Mac * 10.4). This class is part of officially supported API. * * @author Kirill Grouchnikov */ public class StandardButtonShaper extends BaseButtonShaper implements RectangularButtonShaper { /** * Cache of already computed contours. */ private final static LazyResettableHashMap contours = new LazyResettableHashMap( "StandardButtonShaper"); /* * (non-Javadoc) * * @see org.jvnet.substance.button.SubstanceButtonShaper#getDisplayName() */ public String getDisplayName() { return "Standard"; } /* * (non-Javadoc) * * @see * org.jvnet.substance.shaper.SubstanceButtonShaper#getButtonOutline(javax * .swing.AbstractButton, java.awt.Insets, int, int, boolean) */ @Override public GeneralPath getButtonOutline(AbstractButton button, Insets insets, int width, int height, boolean isInner) { Set straightSides = SubstanceCoreUtilities .getSides(button, SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY); float radius = this.getCornerRadius(button, insets); if (isInner) { radius -= (int) SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(button)); } HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height, straightSides, radius, insets); GeneralPath result = contours.get(key); if (result != null) { return result; } result = SubstanceOutlineUtilities.getBaseOutline(width, height, radius, straightSides, insets); contours.put(key, result); return result; } /* * (non-Javadoc) * * @see * org.jvnet.substance.button.SubstanceButtonShaper#getButtonBorder(javax * .swing.AbstractButton) */ public Border getButtonBorder(AbstractButton button) { return new SubstanceButtonBorder(StandardButtonShaper.class) { public Insets getBorderInsets(Component c) { int componentFontSize = SubstanceSizeUtils .getComponentFontSize(c); int extraPadding = SubstanceSizeUtils .getExtraPadding(componentFontSize); if (c instanceof AbstractButton) { AbstractButton button = (AbstractButton) c; if (SubstanceCoreUtilities.hasText(button)) { int dh = SubstanceSizeUtils .getMinButtonHeight(SubstanceSizeUtils .getComponentFontSize(button)); int lrPadding = SubstanceSizeUtils .getTextButtonLRPadding(componentFontSize); return new Insets(lrPadding + extraPadding, extraPadding + dh / 2, lrPadding + extraPadding, extraPadding + dh / 2); } } return new Insets(extraPadding, extraPadding, extraPadding, extraPadding); } }; } /* * (non-Javadoc) * * @see * org.jvnet.substance.button.SubstanceButtonShaper#getPreferredSize(javax * .swing.AbstractButton, java.awt.Dimension) */ public Dimension getPreferredSize(AbstractButton button, Dimension uiPreferredSize) { Dimension result; boolean toTweakWidth = false; boolean toTweakHeight = false; Icon icon = button.getIcon(); boolean hasIcon = SubstanceCoreUtilities.hasIcon(button); boolean hasText = SubstanceCoreUtilities.hasText(button); Insets margin = button.getMargin(); result = uiPreferredSize; boolean hasNoMinSizeProperty = SubstanceCoreUtilities .hasNoMinSizeProperty(button); if ((!hasNoMinSizeProperty) && hasText) { int baseWidth = uiPreferredSize.width; baseWidth = Math.max(baseWidth, SubstanceSizeUtils .getMinButtonWidth(SubstanceSizeUtils .getComponentFontSize(button))); // if (baseWidth < DEFAULT_WIDTH) { // baseWidth = DEFAULT_WIDTH; // } result = new Dimension(baseWidth, uiPreferredSize.height); int baseHeight = result.height; baseHeight = Math.max(baseHeight, SubstanceSizeUtils .getMinButtonHeight(SubstanceSizeUtils .getComponentFontSize(button))); result = new Dimension(result.width, baseHeight); } else { if (hasNoMinSizeProperty) { if (margin != null) { result = new Dimension(result.width + margin.left + margin.right, result.height + margin.top + margin.bottom); } } } int extraPadding = SubstanceSizeUtils .getExtraPadding(SubstanceSizeUtils .getComponentFontSize(button)); int iconPaddingWidth = 6 + 2 * extraPadding; int iconPaddingHeight = 6 + 2 * extraPadding; if (margin != null) { iconPaddingWidth = Math.max(iconPaddingWidth, margin.left + margin.right); iconPaddingHeight = Math.max(iconPaddingHeight, margin.top + margin.bottom); } if (hasIcon) { // check the icon height int iconHeight = icon.getIconHeight(); if (iconHeight > (result.getHeight() - iconPaddingHeight)) { result = new Dimension(result.width, iconHeight); toTweakHeight = true; } int iconWidth = icon.getIconWidth(); if (iconWidth > (result.getWidth() - iconPaddingWidth)) { result = new Dimension(iconWidth, result.height); toTweakWidth = true; } } if (SubstanceCoreUtilities.isScrollBarButton(button)) { toTweakWidth = false; toTweakHeight = false; } if (toTweakWidth) { result = new Dimension(result.width + iconPaddingWidth, result.height); } if (toTweakHeight) { result = new Dimension(result.width, result.height + iconPaddingHeight); } if (result.height % 2 != 0) result.height++; return result; } /** * Returns indication whether the specified button should be drawn with * completely round corners. * * @param button * A button. * @return true if the specified button should be drawn with * completely round corners, false otherwise. */ public static boolean isRoundButton(AbstractButton button) { return (!SubstanceCoreUtilities.isComboBoxButton(button)) && (!SubstanceCoreUtilities.isScrollButton(button)) && SubstanceCoreUtilities.hasText(button); } /* * (non-Javadoc) * * @see org.jvnet.substance.button.SubstanceButtonShaper#isProportionate() */ public boolean isProportionate() { return true; } /* * (non-Javadoc) * * @see * org.jvnet.substance.shaper.RectangularButtonShaper#getCornerRadius(javax * .swing.JComponent, java.awt.Insets) */ @Override public float getCornerRadius(AbstractButton button, Insets insets) { int width = button.getWidth(); int height = button.getHeight(); boolean isRoundCorners = isRoundButton(button); float radius = SubstanceSizeUtils .getClassicButtonCornerRadius(SubstanceSizeUtils .getComponentFontSize(button)); if (button.getClass().isAnnotationPresent(SubstanceArrowButton.class)) { Border parentBorder = ((JComponent) button.getParent()).getBorder(); if (parentBorder instanceof SubstanceBorder) { radius *= ((SubstanceBorder) parentBorder) .getRadiusScaleFactor(); } } if (insets != null) { width -= (insets.left + insets.right); height -= (insets.top + insets.bottom); } if (isRoundCorners) { if (width > height) { radius = (height) / 2.0f; } else { radius = (width) / 2.0f; } } if (SubstanceCoreUtilities.isToolBarButton(button)) { radius = SubstanceCoreUtilities.getToolbarButtonCornerRadius( button, insets); } return radius; } } substance-5.3.orig/src/org/jvnet/substance/SubstanceSplitPaneUI.java0000644000175000017500000000732511136475560025565 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.JComponent; import javax.swing.JSplitPane; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicSplitPaneDivider; import javax.swing.plaf.basic.BasicSplitPaneUI; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.SubstanceSplitPaneDivider; /** * UI for split panes in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceSplitPaneUI extends BasicSplitPaneUI { /** * Property change listener that listens on changes to * {@link JSplitPane#ORIENTATION_PROPERTY} property. */ protected PropertyChangeListener substancePropertyListener; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceSplitPaneUI(); } @Override protected void installListeners() { super.installListeners(); this.substancePropertyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (JSplitPane.ORIENTATION_PROPERTY.equals(evt .getPropertyName())) { SubstanceSplitPaneDivider substanceDivider = (SubstanceSplitPaneDivider) SubstanceSplitPaneUI.this.divider; substanceDivider.updateOneTouchButtons((Integer) evt .getNewValue()); } }; }; this.splitPane .addPropertyChangeListener(this.substancePropertyListener); } @Override protected void uninstallListeners() { this.splitPane .removePropertyChangeListener(this.substancePropertyListener); this.substancePropertyListener = null; super.uninstallListeners(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSplitPaneUI#createDefaultDivider() */ @Override public BasicSplitPaneDivider createDefaultDivider() { return new SubstanceSplitPaneDivider(this); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceTableHeaderUI.java0000644000175000017500000007537611245202226026025 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.*; import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.plaf.*; import javax.swing.plaf.basic.BasicTableHeaderUI; import javax.swing.table.*; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.api.*; import org.jvnet.substance.api.renderers.SubstanceDefaultTableHeaderCellRenderer; import org.jvnet.substance.painter.utils.HighlightPainterUtils; import org.jvnet.substance.utils.*; /** * UI for table headers in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceTableHeaderUI extends BasicTableHeaderUI { /** * Repaints the header on column selection. */ protected TableHeaderListener substanceHeaderListener; /** * The default renderer. */ protected TableCellRenderer defaultHeaderRenderer; /** * Holds the list of currently selected indices. */ protected Map selectedIndices; /** * Listener for fade animations on list selections. */ protected ListSelectionListener substanceFadeSelectionListener; /** * Map of previous fade states (for state-aware color scheme transitions). */ private Map prevStateMap; /** * Map of next fade states (for state-aware color scheme transitions). */ private Map nextStateMap; /** * Property change listener. */ protected PropertyChangeListener substancePropertyChangeListener; /** * Listener for table header. * * @author Kirill Grouchnikov */ private static class TableHeaderListener implements ListSelectionListener { /** * The associated table header UI. */ private SubstanceTableHeaderUI ui; /** * Simple constructor. * * @param ui * The associated table header UI */ public TableHeaderListener(SubstanceTableHeaderUI ui) { this.ui = ui; } /* * (non-Javadoc) * * @see * javax.swing.event.ListSelectionListener#valueChanged(javax.swing. * event.ListSelectionEvent) */ public void valueChanged(ListSelectionEvent e) { if (ui.header == null) return; if (ui.header.isValid()) ui.header.repaint(); } } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceTableHeaderUI(); } /** * Creates a new UI delegate. */ public SubstanceTableHeaderUI() { prevStateMap = new HashMap(); nextStateMap = new HashMap(); selectedIndices = new HashMap(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTableHeaderUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); TableColumnModel columnModel = header.getColumnModel(); if (columnModel != null) { ListSelectionModel lsm = columnModel.getSelectionModel(); if (lsm != null) { // fix for defect 109 - memory leak on skin switch substanceHeaderListener = new TableHeaderListener(this); lsm.addListSelectionListener(substanceHeaderListener); } } // Add listener for the selection animation this.substanceFadeSelectionListener = new ListSelectionListener() { protected void cancelFades(Set initiatedFadeSequences) { FadeTracker fadeTrackerInstance = FadeTracker.getInstance(); for (long fadeId : initiatedFadeSequences) { fadeTrackerInstance.cancelFadeInstance(fadeId); } } public void valueChanged(ListSelectionEvent e) { if (header == null) return; // fix for issue 367 - check that there is an associated // table and that it has a substance UI delegate JTable table = header.getTable(); if (table == null) return; TableUI ui = table.getUI(); if (!(ui instanceof SubstanceTableUI)) return; // optimization on large tables and large selections // and syncing the fade presence with the table // (issue 309) SubstanceTableUI tableUI = (SubstanceTableUI) ui; // System.out.println("Sel anim: " // + tableUI.hasSelectionAnimations()); if (!tableUI._hasSelectionAnimations()) return; Set initiatedFadeSequences = new HashSet(); boolean fadeCanceled = false; // if (SubstanceCoreUtilities.toBleedWatermark(list)) // return; FadeTracker fadeTrackerInstance = FadeTracker.getInstance(); TableColumnModel columnModel = header.getColumnModel(); int size = columnModel.getColumnCount(); ListSelectionModel lsm = columnModel.getSelectionModel(); for (int i = e.getFirstIndex(); i <= e.getLastIndex(); i++) { if (i >= size) continue; if (lsm.isSelectedIndex(i)) { // check if was selected before if (!selectedIndices.containsKey(i)) { // start fading in // System.out.println("Fade in on index " + i); if (!fadeCanceled) { long fadeId = fadeTrackerInstance.trackFadeIn( FadeKind.SELECTION, header, i, false, new ColumnHeaderRepaintCallback(header, i)); initiatedFadeSequences.add(fadeId); if (initiatedFadeSequences.size() > 25) { cancelFades(initiatedFadeSequences); initiatedFadeSequences.clear(); fadeCanceled = true; } } selectedIndices.put(i, columnModel.getColumn(i)); } } else { // check if was selected before and still points to the // same element if (selectedIndices.containsKey(i)) { if (selectedIndices.get(i) == columnModel .getColumn(i)) { // start fading out // System.out.println("Fade out on index " + i); if (!fadeCanceled) { long fadeId = fadeTrackerInstance .trackFadeOut( FadeKind.SELECTION, header, i, false, new ColumnHeaderRepaintCallback( header, i)); initiatedFadeSequences.add(fadeId); if (initiatedFadeSequences.size() > 25) { cancelFades(initiatedFadeSequences); initiatedFadeSequences.clear(); fadeCanceled = true; } } } selectedIndices.remove(i); } } } } }; if (columnModel != null) { ListSelectionModel lsm = columnModel.getSelectionModel(); if (lsm != null) { lsm.addListSelectionListener(substanceFadeSelectionListener); } } this.substancePropertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("table".equals(evt.getPropertyName())) { // track changes to the table and re-register the // column model listener to the new table. TableColumnModel oldModel = (evt.getOldValue() instanceof JTable) ? ((JTable) evt .getOldValue()).getColumnModel() : null; TableColumnModel newModel = (evt.getNewValue() instanceof JTable) ? ((JTable) evt .getNewValue()).getColumnModel() : null; processColumnModelChangeEvent(oldModel, newModel); } } }; this.header .addPropertyChangeListener(this.substancePropertyChangeListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTableHeaderUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); defaultHeaderRenderer = header.getDefaultRenderer(); if (defaultHeaderRenderer instanceof UIResource) { header .setDefaultRenderer(new SubstanceDefaultTableHeaderCellRenderer()); } for (int i = 0; i < header.getColumnModel().getColumnCount(); i++) { if (header.getColumnModel().getSelectionModel().isSelectedIndex(i)) { selectedIndices.put(i, header.getColumnModel().getColumn(i)); prevStateMap.put(i, ComponentState.SELECTED); } } this.header.putClientProperty(SubstanceCoreUtilities.USE_HIGHLIGHT, Boolean.TRUE); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTableHeaderUI#uninstallListeners() */ @Override protected void uninstallListeners() { // fix for defect 109 - memory leak on skin switch TableColumnModel columnModel = header.getColumnModel(); if (columnModel != null) { ListSelectionModel lsm = columnModel.getSelectionModel(); if (lsm != null) { lsm.removeListSelectionListener(substanceHeaderListener); substanceHeaderListener = null; } } this.header .removePropertyChangeListener(this.substancePropertyChangeListener); this.substancePropertyChangeListener = null; super.uninstallListeners(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTableHeaderUI#uninstallDefaults() */ @Override protected void uninstallDefaults() { super.uninstallDefaults(); selectedIndices.clear(); if (header.getDefaultRenderer() instanceof SubstanceDefaultTableHeaderCellRenderer) { header.setDefaultRenderer(defaultHeaderRenderer); if (defaultHeaderRenderer instanceof Component) SwingUtilities .updateComponentTreeUI((Component) defaultHeaderRenderer); } } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#paint(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void paint(Graphics g, JComponent c) { if (header.getColumnModel().getColumnCount() <= 0) { return; } boolean ltr = header.getComponentOrientation().isLeftToRight(); Rectangle clip = g.getClipBounds(); Point left = clip.getLocation(); Point right = new Point(clip.x + clip.width - 1, clip.y); TableColumnModel cm = header.getColumnModel(); int[] selectedColumns = cm.getSelectedColumns(); Set selected = new HashSet(); for (int sel : selectedColumns) selected.add(sel); int cMin = header.columnAtPoint(ltr ? left : right); int cMax = header.columnAtPoint(ltr ? right : left); // This should never happen. if (cMin == -1) { cMin = 0; } // If the table does not have enough columns to fill the view we'll get // -1. // Replace this with the index of the last column. if (cMax == -1) { cMax = cm.getColumnCount() - 1; } TableColumn draggedColumn = header.getDraggedColumn(); int columnWidth; Rectangle cellRect = header.getHeaderRect(ltr ? cMin : cMax); TableColumn aColumn; if (ltr) { for (int column = cMin; column <= cMax; column++) { aColumn = cm.getColumn(column); columnWidth = aColumn.getWidth(); cellRect.width = columnWidth; if (aColumn != draggedColumn) { this.paintCell(g, cellRect, column, selected .contains(column)); } cellRect.x += columnWidth; } } else { for (int column = cMax; column >= cMin; column--) { aColumn = cm.getColumn(column); columnWidth = aColumn.getWidth(); cellRect.width = columnWidth; if (aColumn != draggedColumn) { this.paintCell(g, cellRect, column, selected .contains(column)); } cellRect.x += columnWidth; } } this.paintGrid(g, c); // Paint the dragged column if we are dragging. if (draggedColumn != null) { int draggedColumnIndex = viewIndexForColumn(draggedColumn); Rectangle draggedCellRect = header .getHeaderRect(draggedColumnIndex); // Draw a gray well in place of the moving column. g.setColor(header.getParent().getBackground()); g.fillRect(draggedCellRect.x, draggedCellRect.y, draggedCellRect.width, draggedCellRect.height); draggedCellRect.x += header.getDraggedDistance(); // Fill the background. g.setColor(header.getBackground()); g.fillRect(draggedCellRect.x, draggedCellRect.y, draggedCellRect.width, draggedCellRect.height); this.paintCell(g, draggedCellRect, draggedColumnIndex, selected .contains(draggedColumnIndex)); } // Remove all components in the rendererPane. rendererPane.removeAll(); } /** * Retrieves renderer for the specified column header. * * @param columnIndex * Column index. * @return Renderer for the specified column header. */ private Component getHeaderRenderer(int columnIndex) { TableColumn aColumn = header.getColumnModel().getColumn(columnIndex); TableCellRenderer renderer = aColumn.getHeaderRenderer(); if (renderer == null) { renderer = header.getDefaultRenderer(); } return renderer.getTableCellRendererComponent(header.getTable(), aColumn.getHeaderValue(), false, false, -1, columnIndex); } /** * * * @param g * @param c */ protected void paintGrid(Graphics g, JComponent c) { boolean ltr = header.getComponentOrientation().isLeftToRight(); Graphics2D g2d = (Graphics2D) g.create(); Rectangle clip = g.getClipBounds(); Point left = clip.getLocation(); // tweak the points for issue 378 - making sure that the // grid lines are repainted correctly on scroll. int lineWeight = (int) Math.ceil(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(c))); left = new Point(left.x - 2 * lineWeight, left.y); Point right = new Point(clip.x + clip.width + 2 * lineWeight, clip.y); TableColumnModel cm = header.getColumnModel(); int cMin = header.columnAtPoint(ltr ? left : right); int cMax = header.columnAtPoint(ltr ? right : left); // This should never happen. if (cMin == -1) { cMin = 0; } Rectangle cellRect0 = header.getHeaderRect(cMin); // int top = cellRect0.y; int bottom = cellRect0.y + cellRect0.height; Color gridColor = getGridColor(this.header); float strokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(this.header)); g2d.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setColor(gridColor); g2d.setComposite(TransitionLayout.getAlphaComposite(this.header, 0.7f, g)); // g2d.setColor(Color.red); g2d.drawLine((int) left.getX(), (int) (bottom - strokeWidth / 2), (int) right.getX(), (int) (bottom - strokeWidth / 2)); // g2d.setColor(gridColor); // g2d.drawLine((int) left.getX(), top + (int) (strokeWidth / 2), // (int) right.getX(), top + (int) (strokeWidth / 2)); // If the table does not have enough columns to fill the view we'll // get // -1. // Replace this with the index of the last column. if (cMax == -1) { cMax = cm.getColumnCount() - 1; } TableColumn draggedColumn = header.getDraggedColumn(); int columnWidth; Rectangle cellRect = header.getHeaderRect(ltr ? cMin : cMax); TableColumn aColumn; if (ltr) { for (int column = cMin; column <= cMax; column++) { aColumn = cm.getColumn(column); columnWidth = aColumn.getWidth(); cellRect.width = columnWidth; if (aColumn != draggedColumn) { g2d.drawLine(cellRect.x - 1, cellRect.y, cellRect.x - 1, bottom); // if (column == cMax) { // g2d.drawLine(cellRect.x + cellRect.width - 1, // cellRect.y, cellRect.x + cellRect.width - 1, // bottom); // } } cellRect.x += columnWidth; } } else { for (int column = cMax; column >= cMin; column--) { aColumn = cm.getColumn(column); columnWidth = aColumn.getWidth(); cellRect.width = columnWidth; if (aColumn != draggedColumn) { g2d.drawLine(cellRect.x - 1, cellRect.y, cellRect.x - 1, bottom); // if (column == cMin) { // g2d.drawLine(cellRect.x + cellRect.width - 1, // cellRect.y, cellRect.x + cellRect.width - 1, // bottom); // } } cellRect.x += columnWidth; } } g2d.dispose(); } /** * Returns the grid color for the table header. * * @param header * Table header. * @return Grid color. */ protected static Color getGridColor(JTableHeader header) { ComponentState currState = (header.isEnabled() && header.getTable() .isEnabled()) ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED; Color gridColor = SubstanceColorSchemeUtilities.getColorScheme(header, ColorSchemeAssociationKind.BORDER, currState).getLineColor(); return gridColor; } /** * Paints cell. * * @param g * Graphic context. * @param cellRect * Cell rectangle. * @param columnIndex * Column index. * @param isSelected * Selection indication. */ private void paintCell(Graphics g, Rectangle cellRect, int columnIndex, boolean isSelected) { Graphics2D g2d = (Graphics2D) g.create(); g2d.setComposite(TransitionLayout.getAlphaComposite(header, g)); // paint default background Component component = getHeaderRenderer(columnIndex); ComponentState prevState = getPrevColumnState(columnIndex); ComponentState currState = getColumnState(columnIndex); // Compute the alpha values for the animation. float startAlpha = SubstanceColorSchemeUtilities.getHighlightAlpha( header, prevState); float endAlpha = SubstanceColorSchemeUtilities.getHighlightAlpha( header, currState); FadeState state = SubstanceFadeUtilities.getFadeState(header, columnIndex, FadeKind.SELECTION, FadeKind.ROLLOVER); float totalHighlightAlpha = endAlpha; float fadeCoef = 0.0f; if (state != null) { fadeCoef = state.getFadePosition(); // compute the total alpha of the overlays. if (state.isFadingIn()) { totalHighlightAlpha = startAlpha + (endAlpha - startAlpha) * fadeCoef; } else { totalHighlightAlpha = startAlpha + (endAlpha - startAlpha) * (1.0f - fadeCoef); } if (state.isFadingIn()) fadeCoef = 1.0f - fadeCoef; } if (totalHighlightAlpha > 0.0f) { g2d.setComposite(TransitionLayout.getAlphaComposite(this.header, totalHighlightAlpha, g)); HighlightPainterUtils.paintHighlight(g2d, rendererPane, component, cellRect, 0.0f, null, currState, prevState, fadeCoef); g2d .setComposite(TransitionLayout.getAlphaComposite( this.header, g)); } rendererPane.paintComponent(g2d, component, header, cellRect.x, cellRect.y, cellRect.width, cellRect.height, true); g2d.dispose(); } /** * Retrieves view index for the specified column. * * @param aColumn * Table column. * @return View index for the specified column. */ private int viewIndexForColumn(TableColumn aColumn) { TableColumnModel cm = header.getColumnModel(); for (int column = 0; column < cm.getColumnCount(); column++) { if (cm.getColumn(column) == aColumn) { return column; } } return -1; } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void update(Graphics g, JComponent c) { // fix for issue 175 - table header under resize mode off // was painted in color scheme-agnostic (gray) color. ComponentState backgroundState = (this.header.isEnabled() && this.header .getTable().isEnabled()) ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED; // fix for issue 360 - respect the clip bounds of the // table header Rectangle clip = g.getClipBounds(); if (clip == null) clip = c.getBounds(); // do not use the highlight scheme for painting the // table header background SubstanceColorScheme fillScheme = SubstanceColorSchemeUtilities .getColorScheme(c, backgroundState); SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities .getColorScheme(c, ColorSchemeAssociationKind.BORDER, backgroundState); HighlightPainterUtils.paintHighlight(g, null, c, clip, 0.0f, null, fillScheme, fillScheme, borderScheme, borderScheme, 0.0f); paint(g, c); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTableHeaderUI#uninstallUI(javax.swing.JComponent * ) */ @Override public void uninstallUI(JComponent c) { for (int i = 0; i < header.getColumnModel().getColumnCount(); i++) { TableColumn aColumn = header.getColumnModel().getColumn(i); TableCellRenderer renderer = aColumn.getHeaderRenderer(); if (renderer == null) { renderer = header.getDefaultRenderer(); } Component rendComp = renderer.getTableCellRendererComponent(header .getTable(), aColumn.getHeaderValue(), false, false, -1, i); SwingUtilities.updateComponentTreeUI(rendComp); } super.uninstallUI(c); } /** * Returns the previous state for the specified column. * * @param columnIndex * Column index. * @return The previous state for the specified column. */ public ComponentState getPrevColumnState(int columnIndex) { if (this.header.isEnabled() && this.header.getTable().isEnabled() && SubstanceDefaultTableHeaderCellRenderer.isColumnSorted( this.header.getTable(), columnIndex)) return ComponentState.SELECTED; if (prevStateMap.containsKey(columnIndex)) return prevStateMap.get(columnIndex); return getColumnState(columnIndex); } /** * Returns the current state for the specified cell. * * @param columnIndex * Column index. * @return The current state for the specified column. */ public ComponentState getColumnState(int columnIndex) { ButtonModel synthModel = new DefaultButtonModel(); boolean toEnable = header.isEnabled(); // get the rollover column index from the table UI delegate JTable table = this.header.getTable(); if (table != null) { toEnable = toEnable && table.isEnabled(); TableUI ui = table.getUI(); if (ui instanceof SubstanceTableUI) { SubstanceTableUI tableUI = (SubstanceTableUI) table.getUI(); int rolledOverIndex = tableUI.getRolloverColumnIndex(); synthModel.setRollover((rolledOverIndex >= 0) && (rolledOverIndex == columnIndex)); } } if (toEnable && SubstanceDefaultTableHeaderCellRenderer.isColumnSorted( this.header.getTable(), columnIndex)) return ComponentState.SELECTED; synthModel.setEnabled(toEnable); // set selection on the model. TableColumnModel columnModel = header.getColumnModel(); synthModel .setSelected(columnModel.getColumnSelectionAllowed() && columnModel.getSelectionModel().isSelectedIndex( columnIndex)); return ComponentState.getState(synthModel, null); } /** * Returns the animation callback for the specified column. * * @param columnIndex * Column index. * @return Animation callback for the specified column. */ public FadeTrackerCallback getCallback(int columnIndex) { return new ColumnHeaderRepaintCallback(this.header, columnIndex); } /** * Returns the scroll pane corner filler component. This method is used in * {@link SubstanceScrollPaneUI} to put a consistent filler for tables. * * @return Scroll pane corner filler. */ public JComponent getScrollPaneCornerFiller() { return new ScrollPaneCornerFiller(this.header); } /** * Corner filler for tables wrapped in scroll panes. * * @author Kirill Grouchnikov */ protected static class ScrollPaneCornerFiller extends JComponent implements UIResource { /** * Associated table header. */ protected JTableHeader header; /** * Creates a new corner filler. * * @param header * Table header. */ public ScrollPaneCornerFiller(JTableHeader header) { this.header = header; } @Override protected void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g.create(); // System.err.println("Painting " + this.hashCode() + " from " // + ((header == null) ? "null" : header.hashCode())); boolean ltr = header.getComponentOrientation().isLeftToRight(); final ComponentState backgroundState = (header.isEnabled() && header .getTable().isEnabled()) ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED; HighlightPainterUtils.paintHighlight(g2d, null, this.header, new Rectangle(0, 0, this.getWidth(), this.getHeight()), 0.0f, null, backgroundState, backgroundState, 0.0f); g2d.setColor(getGridColor(this.header)); float strokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(header)); g2d.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setComposite(TransitionLayout.getAlphaComposite(this.header, 0.7f, g)); int x = ltr ? (int) strokeWidth / 2 : getWidth() - 1 - (int) strokeWidth / 2; g2d.drawLine(x, 0, x, getHeight()); g2d.dispose(); } } /** * Processes the events on model changes on the table column model. * * @param oldModel * Old column model. * @param newModel * New column model. */ public void processColumnModelChangeEvent(TableColumnModel oldModel, TableColumnModel newModel) { if (oldModel != null) { oldModel.getSelectionModel().removeListSelectionListener( substanceFadeSelectionListener); } if (newModel != null) { newModel.getSelectionModel().addListSelectionListener( substanceFadeSelectionListener); } selectedIndices.clear(); prevStateMap.clear(); nextStateMap.clear(); } /** * Repaints a single column header during the fade animation cycle. * * @author Kirill Grouchnikov */ protected class ColumnHeaderRepaintCallback extends FadeTrackerAdapter { /** * Associated table header. */ protected JTableHeader header; /** * Associated (animated) column index. */ protected int columnIndex; /** * Creates a new animation repaint callback. * * @param header * Associated table header. * @param columnIndex * Associated (animated) column index. */ public ColumnHeaderRepaintCallback(JTableHeader header, int columnIndex) { this.header = header; this.columnIndex = columnIndex; } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.utils.FadeTracker$FadeTrackerCallback#fadeEnded * (org.jvnet.lafwidget.utils.FadeTracker.FadeKind) */ @Override public void fadeEnded(FadeKind fadeKind) { if ((SubstanceTableHeaderUI.this.header == header) && (columnIndex < header.getColumnModel().getColumnCount())) { ComponentState currState = getColumnState(columnIndex); if (currState == ComponentState.DEFAULT) { prevStateMap.remove(columnIndex); nextStateMap.remove(columnIndex); } else { prevStateMap.put(columnIndex, currState); nextStateMap.put(columnIndex, currState); } // System.out.println(tabIndex + "->" // + prevStateMap.get(tabIndex).name()); } repaintColumnHeader(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.animation.FadeTrackerAdapter#fadeReversed(org * .jvnet.lafwidget.animation.FadeKind, boolean, float) */ @Override public void fadeReversed(FadeKind fadeKind, boolean isFadingIn, float fadeCycle10) { if ((SubstanceTableHeaderUI.this.header == header) && (columnIndex < header.getColumnModel().getColumnCount())) { ComponentState nextState = nextStateMap.get(columnIndex); if (nextState == null) { prevStateMap.remove(columnIndex); } else { prevStateMap.put(columnIndex, nextState); } // System.out.println(tabIndex + "->" // + prevStateMap.get(tabIndex).name()); } repaintColumnHeader(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.utils.FadeTracker$FadeTrackerCallback#fadePerformed * (org.jvnet.lafwidget.utils.FadeTracker.FadeKind, float) */ @Override public void fadePerformed(FadeKind fadeKind, float fade) { if ((SubstanceTableHeaderUI.this.header == header) && (columnIndex < header.getColumnModel().getColumnCount())) { nextStateMap.put(columnIndex, getColumnState(columnIndex)); } repaintColumnHeader(); } /** * Repaints the associated cell. */ private void repaintColumnHeader() { SwingUtilities.invokeLater(new Runnable() { public void run() { if (header == null) { // may happen if the LAF was switched in the meantime return; } try { // maybeUpdateLayoutState(); int cellCount = header.getColumnModel() .getColumnCount(); if ((cellCount > 0) && (columnIndex < cellCount)) { // need to retrieve the cell rectangle since the // cells can be moved while animating Rectangle rect = header.getHeaderRect(columnIndex); Rectangle damaged = new Rectangle(rect.x - 5, rect.y, rect.width + 10, rect.height); header.repaint(damaged); } } catch (RuntimeException re) { return; } } }); } } } substance-5.3.orig/src/org/jvnet/substance/plugin/0000755000175000017500000000000011256731150022175 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/plugin/SubstanceSkinPlugin.java0000644000175000017500000000475011136475562027012 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.plugin; import java.util.Set; import org.jvnet.lafplugin.LafPlugin; import org.jvnet.substance.skin.SkinInfo; /** * Plugin for skin extension. This class is for internal use only. * * @author Kirill Grouchnikov */ public interface SubstanceSkinPlugin extends LafPlugin { /** * XML tag that contains fully-qualified class name of skin plugin class. */ public static final String TAG_SKIN_PLUGIN_CLASS = "skin-plugin-class"; /** * Returns information on all available skins in this plugin. * * @return Information on all available skins in this plugin. */ public Set getSkins(); /** * Returns the class name of the default skin. * * @return The class name of the default skin. */ public String getDefaultSkinClassName(); } substance-5.3.orig/src/org/jvnet/substance/plugin/BaseSkinPlugin.java0000644000175000017500000001170611246400744025724 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.plugin; import java.util.HashSet; import java.util.Set; import org.jvnet.substance.api.skin.*; import org.jvnet.substance.skin.*; /** * Core plugin for skins. See * {@link org.jvnet.substance.plugin.SubstanceSkinPlugin} interface. This class * is for internal use only. * * @author Kirill Grouchnikov. */ public class BaseSkinPlugin implements SubstanceSkinPlugin { /** * Creates info object on a single skin. * * @param displayName * Skin display name. * @param skinClass * Skin class. * @param isDefault * Indication whether the specified skin is default. * @return Info object on the specified skin. */ private static SkinInfo create(String displayName, Class skinClass, boolean isDefault) { SkinInfo result = new SkinInfo(displayName, skinClass.getName()); result.setDefault(isDefault); return result; } /* * (non-Javadoc) * * @see org.jvnet.substance.plugin.SubstanceSkinPlugin#getSkins() */ public Set getSkins() { Set result = new HashSet(); // result.add(create(AutumnSkin.NAME, AutumnSkin.class, false)); result.add(create(BusinessSkin.NAME, BusinessSkin.class, false)); result.add(create(BusinessBlackSteelSkin.NAME, BusinessBlackSteelSkin.class, false)); result.add(create(BusinessBlueSteelSkin.NAME, BusinessBlueSteelSkin.class, false)); result.add(create(CremeSkin.NAME, CremeSkin.class, false)); result.add(create(ModerateSkin.NAME, ModerateSkin.class, false)); result.add(create(SaharaSkin.NAME, SaharaSkin.class, false)); result.add(create(MagmaSkin.NAME, MagmaSkin.class, false)); result.add(create(OfficeBlue2007Skin.NAME, OfficeBlue2007Skin.class, false)); result.add(create(OfficeSilver2007Skin.NAME, OfficeSilver2007Skin.class, false)); result.add(create(RavenSkin.NAME, RavenSkin.class, false)); result.add(create(RavenGraphiteSkin.NAME, RavenGraphiteSkin.class, false)); result.add(create(RavenGraphiteGlassSkin.NAME, RavenGraphiteGlassSkin.class, false)); result .add(create(GraphiteAquaSkin.NAME, GraphiteAquaSkin.class, false)); result.add(create(ChallengerDeepSkin.NAME, ChallengerDeepSkin.class, false)); result.add(create(EmeraldDuskSkin.NAME, EmeraldDuskSkin.class, false)); result.add(create(NebulaSkin.NAME, NebulaSkin.class, false)); result.add(create(NebulaBrickWallSkin.NAME, NebulaBrickWallSkin.class, false)); result.add(create(MistSilverSkin.NAME, MistSilverSkin.class, false)); result.add(create(MistAquaSkin.NAME, MistAquaSkin.class, false)); result.add(create(AutumnSkin.NAME, AutumnSkin.class, false)); result.add(create(CremeCoffeeSkin.NAME, CremeCoffeeSkin.class, false)); result.add(create(DustSkin.NAME, DustSkin.class, false)); result.add(create(DustCoffeeSkin.NAME, DustCoffeeSkin.class, false)); result.add(create(TwilightSkin.NAME, TwilightSkin.class, false)); result.add(create(MagellanSkin.NAME, MagellanSkin.class, false)); result.add(create(GeminiSkin.NAME, GeminiSkin.class, false)); return result; } /* * (non-Javadoc) * * @see * org.jvnet.substance.plugin.SubstanceSkinPlugin#getDefaultSkinClassName() */ public String getDefaultSkinClassName() { return null; } } substance-5.3.orig/src/org/jvnet/substance/plugin/BasePlugin.java0000644000175000017500000003112711205530402025064 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.plugin; import java.awt.*; import java.awt.geom.GeneralPath; import java.awt.image.BufferedImage; import java.util.*; import java.util.List; import javax.swing.Icon; import javax.swing.UIDefaults; import javax.swing.plaf.*; import org.jvnet.lafplugin.LafComponentPlugin; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.fonts.FontSet; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.icon.SubstanceIconFactory; import contrib.ch.randelshofer.quaqua.ButtonStateIcon; import contrib.ch.randelshofer.quaqua.util.Images; /** * Core plugin for additional UI delegates. Contains information on Quaqua and * Xoetrope color chooser panels. This class is for internal use only. * * @author Kirill Grouchnikov */ public class BasePlugin implements LafComponentPlugin { /** * Common directory for Quaqua images. */ protected final static String commonDir = "/contrib/ch/randelshofer/quaqua/images/"; /** * Color chooser class name from Quaqua. */ protected final static String quaquaColorChooserClassName = "contrib.ch.randelshofer.quaqua.Quaqua14ColorChooserUI"; /** * Indication whether the Quaqua color chooser is available. The lite * version strips away the Quaqua color chooser. */ protected boolean hasQuaquaColorChooser; /** * Creates the base plugin. */ public BasePlugin() { try { Class.forName(quaquaColorChooserClassName); this.hasQuaquaColorChooser = true; } catch (ClassNotFoundException cnfe) { this.hasQuaquaColorChooser = false; } } /** * From Quaqua */ protected Icon createButtonStateIcon(final String location, final int states) { BufferedImage[] images = Images.split(Toolkit.getDefaultToolkit() .getImage(this.getClass().getResource(location)), states, true); return new ButtonStateIcon(images); } /** * From Quaqua */ protected Object makeImage(String location) { return new UIDefaults.ProxyLazyValue( "contrib.ch.randelshofer.quaqua.QuaquaIconFactory", "createImage", new Object[] { location }); } protected static Object makeButtonStateIcon(String location, int states) { return new UIDefaults.ProxyLazyValue( "contrib.ch.randelshofer.quaqua.QuaquaIconFactory", "createButtonStateIcon", new Object[] { location, new Integer(states) }); } protected Object makeBufferedImage(String location) { return new UIDefaults.ProxyLazyValue( "contrib.ch.randelshofer.quaqua.QuaquaIconFactory", "createBufferedImage", new Object[] { location }); } public static Object makeIcon(Class baseClass, String location) { return new UIDefaults.ProxyLazyValue( "contrib.ch.randelshofer.quaqua.QuaquaIconFactory", "createIcon", new Object[] { baseClass, location }); } /* * (non-Javadoc) * * @see org.jvnet.lafplugin.LafComponentPlugin#getDefaults(java.lang.Object) */ public Object[] getDefaults(Object mSkin) { ResourceBundle bundle = ResourceBundle .getBundle("contrib.ch.randelshofer.quaqua.Labels"); List labelsList = new LinkedList(); for (Enumeration i = bundle.getKeys(); i.hasMoreElements();) { String key = (String) i.nextElement(); labelsList.add(key); labelsList.add(bundle.getObject(key)); } if (this.hasQuaquaColorChooser) { SubstanceSkin skin = (SubstanceSkin) mSkin; final SubstanceColorScheme colorScheme = skin .getMainActiveColorScheme(DecorationAreaType.NONE); InsetsUIResource visualMargin = new InsetsUIResource(0, 0, 0, 0); Color foregroundColor = new ColorUIResource(colorScheme .getForegroundColor()); Object[] mainDefaults = new Object[] { // quaqua "Slider.upThumbSmall", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceIconFactory .getSliderHorizontalIcon( SubstanceSizeUtils .getSliderIconSize(SubstanceSizeUtils .getControlFontSize()) - 2, true); } }, // quaqua "Slider.leftThumbSmall", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceIconFactory .getSliderVerticalIcon( SubstanceSizeUtils .getSliderIconSize(SubstanceSizeUtils .getControlFontSize()) - 2, true); } }, // quaqua "Component.visualMargin", visualMargin, // quaqua "ColorChooser.foreground", foregroundColor, // class names of default choosers "ColorChooser.defaultChoosers", new String[] { "contrib.ch.randelshofer.quaqua.colorchooser.ColorWheelChooser", "contrib.ch.randelshofer.quaqua.colorchooser.ColorSlidersChooser", "contrib.ch.randelshofer.quaqua.colorchooser.ColorPalettesChooser", "contrib.ch.randelshofer.quaqua.colorchooser.SwatchesChooser", "contrib.ch.randelshofer.quaqua.colorchooser.CrayonsChooser", "contrib.ch.randelshofer.quaqua.colorchooser.Quaqua15ColorPicker", "contrib.net.xoetrope.editor.color.ColorWheelPanel" }, // "ColorChooser.swatchesDefaultRecentColor", ..., // "ColorChooser.swatchesRecentSwatchSize", ..., "ColorChooser.swatchesSwatchSize", new DimensionUIResource(5, 5), "ColorChooser.resetMnemonic", new Integer(-1), "ColorChooser.crayonsImage", makeImage(commonDir + "big_crayons.png"), "ColorChooser.textSliderGap", new Integer(0), "ColorChooser.colorPalettesIcon", makeButtonStateIcon(commonDir + "palette.png", 1), "ColorChooser.colorSlidersIcon", makeButtonStateIcon(commonDir + "chart_bar.png", 1), "ColorChooser.colorSwatchesIcon", makeButtonStateIcon(commonDir + "color_swatch.png", 1), "ColorChooser.colorWheelIcon", makeButtonStateIcon(commonDir + "color_wheel.png", 1), "ColorChooser.crayonsIcon", makeButtonStateIcon(commonDir + "pencil.png", 1), "ColorChooser.imagePalettesIcon", makeButtonStateIcon(commonDir + "image.png", 1), // Icon of the color picker tool "ColorChooser.colorPickerIcon", new UIDefaults.LazyValue() { @Override public Object createValue(UIDefaults table) { return new IconUIResource(SubstanceImageCreator .getSearchIcon(15, colorScheme, true)); } }, // Magnifying glass used as the cursor image "ColorChooser.colorPickerMagnifier", new UIDefaults.LazyValue() { @Override public Object createValue(UIDefaults table) { BufferedImage result = SubstanceCoreUtilities .getBlankImage(48, 48); Graphics2D g = result.createGraphics(); g.setColor(Color.black); g.translate(-4, -6); int xc = 20; int yc = 22; int r = 15; g.setStroke(new BasicStroke(2.5f)); g.drawOval(xc - r, yc - r, 2 * r, 2 * r); g.setStroke(new BasicStroke(4.0f)); GeneralPath handle = new GeneralPath(); handle.moveTo((float) (xc + r / Math.sqrt(2.0)), (float) (yc + r / Math.sqrt(2.0))); handle.lineTo(45, 47); g.draw(handle); g.translate(4, 6); g.setStroke(new BasicStroke(1.0f)); g.drawLine(16, 4, 16, 13); g.drawLine(4, 16, 13, 16); g.drawLine(16, 19, 16, 28); g.drawLine(19, 16, 28, 16); return result; } }, // makeBufferedImage(commonDir + "zoomer.png"), // Hot spot of the magnifier cursor "ColorChooser.colorPickerHotSpot", new UIDefaults.ProxyLazyValue("java.awt.Point", new Object[] { new Integer(29), new Integer(29) }), // Pick point relative to hot spot "ColorChooser.colorPickerPickOffset", new UIDefaults.ProxyLazyValue("java.awt.Point", new Object[] { new Integer(-13), new Integer(-13) }), // Rectangle used for drawing the mask of the magnifying // glass "ColorChooser.colorPickerGlassRect", new UIDefaults.ProxyLazyValue("java.awt.Rectangle", new Object[] { new Integer(3), new Integer(3), new Integer(26), new Integer(26) }), // Capture rectangle. Width and height must be equal sized // and must be odd. // The position of the capture rectangle is relative to the // hot spot. "ColorChooser.colorPickerCaptureRect", new UIDefaults.ProxyLazyValue("java.awt.Rectangle", new Object[] { new Integer(-15), new Integer(-15), new Integer(5), new Integer(5) }), // Zoomed (magnified) capture image. Width and height must // be a multiple of the capture rectangles size. "ColorChooser.colorPickerZoomRect", new UIDefaults.ProxyLazyValue("java.awt.Rectangle", new Object[] { new Integer(4), new Integer(4), new Integer(25), new Integer(25) }), // // Localization support // "Labels", // ResourceBundleUtil // .getBundle("contrib.ch.randelshofer.quaqua.Labels"), }; Object[] colorDefaults = null; FontSet substanceFontSet = SubstanceLookAndFeel.getFontPolicy() .getFontSet("Substance", null); Font controlFont = substanceFontSet.getControlFont(); Font fontBoldBaseP1 = new FontUIResource(controlFont.deriveFont( Font.BOLD, controlFont.getSize() + 1)); Font fontPlainBaseM2 = new FontUIResource(controlFont .deriveFont((float) (controlFont.getSize() - 2))); colorDefaults = new Object[] { "ColorChooserUI", "org.jvnet.substance.SubstanceColorChooserUI", "ColorChooser.font", controlFont, "ColorChooser.smallFont", fontPlainBaseM2, "ColorChooser.crayonsFont", fontBoldBaseP1 }; Object[] labelDefaults = new Object[mainDefaults.length + labelsList.size()]; for (int i = 0; i < mainDefaults.length; i++) labelDefaults[i] = mainDefaults[i]; int start = mainDefaults.length; for (int i = 0; i < labelsList.size(); i++) labelDefaults[start + i] = labelsList.get(i); mainDefaults = labelDefaults; if (colorDefaults != null) { Object[] defaults = new Object[mainDefaults.length + colorDefaults.length]; for (int i = 0; i < mainDefaults.length; i++) defaults[i] = mainDefaults[i]; start = mainDefaults.length; for (int i = 0; i < colorDefaults.length; i++) defaults[start + i] = colorDefaults[i]; return defaults; } return mainDefaults; } else { Object[] defaults = new Object[labelsList.size()]; for (int i = 0; i < labelsList.size(); i++) defaults[i] = labelsList.get(i); return defaults; } } /* * (non-Javadoc) * * @see org.jvnet.lafplugin.LafPlugin#uninitialize() */ public void uninitialize() { } /* * (non-Javadoc) * * @see org.jvnet.lafplugin.LafPlugin#initialize() */ public void initialize() { } } substance-5.3.orig/src/org/jvnet/substance/SubstanceSeparatorUI.java0000644000175000017500000001014111247214744025612 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import javax.swing.*; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicSeparatorUI; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.painter.utils.SeparatorPainterUtils; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.SubstanceSizeUtils; import org.jvnet.substance.utils.menu.MenuUtilities; import org.jvnet.substance.utils.menu.SubstanceMenuBackgroundDelegate; /** * UI for separators in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceSeparatorUI extends BasicSeparatorUI { public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceSeparatorUI(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSeparatorUI#paint(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void paint(Graphics g, JComponent c) { Component parent = c.getParent(); if (!(parent instanceof JPopupMenu)) { SeparatorPainterUtils.paintSeparator(c, g, c.getWidth(), c .getHeight(), ((JSeparator) c).getOrientation()); return; } Graphics2D graphics = (Graphics2D) g.create(); int xOffset = MenuUtilities.getTextOffset(c, parent); SubstanceMenuBackgroundDelegate.paintBackground(graphics, c, xOffset); Dimension s = c.getSize(); int startX = 0; int width = s.width; if (parent.getComponentOrientation().isLeftToRight()) { startX = xOffset - 2; width = s.width - startX; } else { startX = 0; width = xOffset - 4; } graphics.translate(startX, 0); graphics.setComposite(TransitionLayout.getAlphaComposite(parent)); SeparatorPainterUtils.paintSeparator(c, graphics, width, s.height, ((JSeparator) c).getOrientation(), true, 2); graphics.dispose(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicSeparatorUI#getPreferredSize(javax.swing. * JComponent) */ @Override public Dimension getPreferredSize(JComponent c) { float borderStrokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(c)); int prefSize = (int) (Math.ceil(2.0 * borderStrokeWidth)); if (((JSeparator) c).getOrientation() == SwingConstants.VERTICAL) return new Dimension(prefSize, 0); else return new Dimension(0, prefSize); } } substance-5.3.orig/src/org/jvnet/substance/utils/0000755000175000017500000000000011256731150022037 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/utils/LocaleChangeListener.java0000644000175000017500000000360211136475562026727 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; /** * Listener for the locale changes. * * @author Kirill Grouchnikov */ public interface LocaleChangeListener { /** * Called when the locale is changed. */ public void localeChanged(); } substance-5.3.orig/src/org/jvnet/substance/utils/SkinUtilities.java0000644000175000017500000011703511245437060025512 0ustar drazzibdrazzibpackage org.jvnet.substance.utils; import java.awt.*; import java.awt.event.KeyEvent; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.plaf.*; import javax.swing.plaf.basic.BasicBorders; import javax.swing.plaf.basic.BasicBorders.MarginBorder; import javax.swing.table.JTableHeader; import javax.swing.text.DefaultEditorKit; import javax.swing.text.JTextComponent; import org.jvnet.substance.api.*; import org.jvnet.substance.api.renderers.SubstanceDefaultListCellRenderer; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.utils.border.*; import org.jvnet.substance.utils.icon.*; import org.jvnet.substance.utils.scroll.SubstanceScrollPaneBorder; public class SkinUtilities { /** * Adds skin-specific entries to the UI defaults table. * * @param table * UI defaults table. */ public static void addCustomEntriesToTable(UIDefaults table, SubstanceSkin skin) { Object menuArrowIcon = new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return new MenuArrowIcon(null); } }; Object listCellRendererActiveValue = new UIDefaults.ActiveValue() { public Object createValue(UIDefaults table) { return new SubstanceDefaultListCellRenderer.SubstanceUIResource(); } }; SubstanceColorScheme mainActiveScheme = skin.getMainActiveColorScheme(); SubstanceColorScheme mainDefaultScheme = skin .getMainDefaultColorScheme(); SubstanceColorScheme mainDisabledScheme = skin .getMainDisabledColorScheme(); Color controlText = new ColorUIResource(mainActiveScheme .getLightColor()); Color foregroundColor = SubstanceColorUtilities .getForegroundColor(mainDefaultScheme); Color backgroundActiveColor = new ColorUIResource(mainActiveScheme .getBackgroundFillColor()); Color backgroundDefaultColor = new ColorUIResource(mainDefaultScheme .getBackgroundFillColor()); Color textBackgroundColor = new ColorUIResource(mainActiveScheme .getTextBackgroundFillColor()); Color disabledForegroundColor = SubstanceColorUtilities .getForegroundColor(mainDisabledScheme); Color disabledTextComponentForegroundColor = disabledForegroundColor; float alpha = skin.getAlpha(null, ComponentState.DISABLED_UNSELECTED); if (alpha < 1.0f) { ColorUIResource defaultTextBackgroundColor = SubstanceColorUtilities .getDefaultBackgroundColor(JTextComponent.class, skin, false); disabledTextComponentForegroundColor = new ColorUIResource( SubstanceColorUtilities.getInterpolatedColor( disabledTextComponentForegroundColor, defaultTextBackgroundColor, alpha)); } Color lineColor = new ColorUIResource(mainActiveScheme.getLineColor()); Color lineColorDefault = new ColorUIResource(mainDefaultScheme .getLineColor()); int lcb = SubstanceColorUtilities .getColorBrightness(lineColor.getRGB()); Color lineBwColor = new ColorUIResource(new Color(lcb, lcb, lcb)); SubstanceColorScheme textHighlightColorScheme = skin.getColorScheme( (Component) null, ColorSchemeAssociationKind.TEXT_HIGHLIGHT, ComponentState.SELECTED); if (textHighlightColorScheme == null) { textHighlightColorScheme = skin.getColorScheme(null, ComponentState.ROLLOVER_SELECTED); } Color selectionTextBackgroundColor = new ColorUIResource( textHighlightColorScheme.getSelectionBackgroundColor()); Color selectionTextForegroundColor = new ColorUIResource( textHighlightColorScheme.getSelectionForegroundColor()); Color selectionCellForegroundColor = new ColorUIResource( textHighlightColorScheme.getForegroundColor()); Color selectionCellBackgroundColor = new ColorUIResource( textHighlightColorScheme.getBackgroundFillColor()); Object regularMarginBorder = new UIDefaults.LazyValue() { @Override public Object createValue(UIDefaults table) { return new BorderUIResource.CompoundBorderUIResource( new SubstanceBorder(), new BasicBorders.MarginBorder()); } }; Object textBorder = new UIDefaults.LazyValue() { @Override public Object createValue(UIDefaults table) { return new BorderUIResource.CompoundBorderUIResource( new SubstanceBorder(SubstanceSizeUtils .getTextBorderInsets(SubstanceSizeUtils .getControlFontSize())), new BasicBorders.MarginBorder()); } }; Object textMarginBorder = new UIDefaults.LazyValue() { @Override public Object createValue(UIDefaults table) { return new BasicBorders.MarginBorder(); } }; Object tooltipBorder = new UIDefaults.LazyValue() { @Override public Object createValue(UIDefaults table) { return new SubstanceBorder(SubstanceSizeUtils .getToolTipBorderInsets(SubstanceSizeUtils .getControlFontSize())); } }; Object comboBorder = new UIDefaults.LazyValue() { @Override public Object createValue(UIDefaults table) { return new SubstanceBorder(SubstanceSizeUtils .getComboBorderInsets(SubstanceSizeUtils .getControlFontSize())); } }; Object spinnerBorder = new UIDefaults.LazyValue() { @Override public Object createValue(UIDefaults table) { return new BorderUIResource.CompoundBorderUIResource( new SubstanceBorder(SubstanceSizeUtils .getSpinnerBorderInsets(SubstanceSizeUtils .getControlFontSize())), new BasicBorders.MarginBorder()); } }; // SubstanceColorSchemeBundle titlePaneBundle = // skin.colorSchemeBundleMap // .containsKey(DecorationAreaType.PRIMARY_TITLE_PANE) ? // skin.colorSchemeBundleMap // .get(DecorationAreaType.PRIMARY_TITLE_PANE) // : skin.colorSchemeBundleMap.get(DecorationAreaType.NONE); final SubstanceColorScheme titlePaneScheme = skin.getColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE, ColorSchemeAssociationKind.FILL, ComponentState.ACTIVE); // // titlePaneBundle.getActiveColorScheme(); Object menuItemInsets = new UIDefaults.LazyValue() { @Override public Object createValue(UIDefaults table) { int menuItemMargin = SubstanceSizeUtils .getMenuItemMargin(SubstanceSizeUtils .getComponentFontSize(null)); return new InsetsUIResource(menuItemMargin, menuItemMargin, menuItemMargin, menuItemMargin); } }; Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] { "ctrl C", DefaultEditorKit.copyAction, "ctrl V", DefaultEditorKit.pasteAction, "ctrl X", DefaultEditorKit.cutAction, "COPY", DefaultEditorKit.copyAction, "PASTE", DefaultEditorKit.pasteAction, "CUT", DefaultEditorKit.cutAction, "shift LEFT", DefaultEditorKit.selectionBackwardAction, "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction, "shift RIGHT", DefaultEditorKit.selectionForwardAction, "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction, "ctrl LEFT", DefaultEditorKit.previousWordAction, "ctrl KP_LEFT", DefaultEditorKit.previousWordAction, "ctrl RIGHT", DefaultEditorKit.nextWordAction, "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction, "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction, "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction, "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction, "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction, "ctrl A", DefaultEditorKit.selectAllAction, "HOME", DefaultEditorKit.beginLineAction, "END", DefaultEditorKit.endLineAction, "shift HOME", DefaultEditorKit.selectionBeginLineAction, "shift END", DefaultEditorKit.selectionEndLineAction, "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, "ctrl H", DefaultEditorKit.deletePrevCharAction, "DELETE", DefaultEditorKit.deleteNextCharAction, "RIGHT", DefaultEditorKit.forwardAction, "LEFT", DefaultEditorKit.backwardAction, "KP_RIGHT", DefaultEditorKit.forwardAction, "KP_LEFT", DefaultEditorKit.backwardAction, "ENTER", JTextField.notifyAction, "ctrl BACK_SLASH", "unselect"/* DefaultEditorKit.unselectAction */, "control shift O", "toggle-componentOrientation"/* * DefaultEditorKit. * toggleComponentOrientation */ }); Object passwordInputMap = new UIDefaults.LazyInputMap(new Object[] { "ctrl C", DefaultEditorKit.copyAction, "ctrl V", DefaultEditorKit.pasteAction, "ctrl X", DefaultEditorKit.cutAction, "COPY", DefaultEditorKit.copyAction, "PASTE", DefaultEditorKit.pasteAction, "CUT", DefaultEditorKit.cutAction, "shift LEFT", DefaultEditorKit.selectionBackwardAction, "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction, "shift RIGHT", DefaultEditorKit.selectionForwardAction, "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction, "ctrl LEFT", DefaultEditorKit.beginLineAction, "ctrl KP_LEFT", DefaultEditorKit.beginLineAction, "ctrl RIGHT", DefaultEditorKit.endLineAction, "ctrl KP_RIGHT", DefaultEditorKit.endLineAction, "ctrl shift LEFT", DefaultEditorKit.selectionBeginLineAction, "ctrl shift KP_LEFT", DefaultEditorKit.selectionBeginLineAction, "ctrl shift RIGHT", DefaultEditorKit.selectionEndLineAction, "ctrl shift KP_RIGHT", DefaultEditorKit.selectionEndLineAction, "ctrl A", DefaultEditorKit.selectAllAction, "HOME", DefaultEditorKit.beginLineAction, "END", DefaultEditorKit.endLineAction, "shift HOME", DefaultEditorKit.selectionBeginLineAction, "shift END", DefaultEditorKit.selectionEndLineAction, "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, "ctrl H", DefaultEditorKit.deletePrevCharAction, "DELETE", DefaultEditorKit.deleteNextCharAction, "RIGHT", DefaultEditorKit.forwardAction, "LEFT", DefaultEditorKit.backwardAction, "KP_RIGHT", DefaultEditorKit.forwardAction, "KP_LEFT", DefaultEditorKit.backwardAction, "ENTER", JTextField.notifyAction, "ctrl BACK_SLASH", "unselect", "control shift O", "toggle-componentOrientation" }); Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] { "ctrl C", DefaultEditorKit.copyAction, "ctrl V", DefaultEditorKit.pasteAction, "ctrl X", DefaultEditorKit.cutAction, "COPY", DefaultEditorKit.copyAction, "PASTE", DefaultEditorKit.pasteAction, "CUT", DefaultEditorKit.cutAction, "shift LEFT", DefaultEditorKit.selectionBackwardAction, "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction, "shift RIGHT", DefaultEditorKit.selectionForwardAction, "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction, "ctrl LEFT", DefaultEditorKit.previousWordAction, "ctrl KP_LEFT", DefaultEditorKit.previousWordAction, "ctrl RIGHT", DefaultEditorKit.nextWordAction, "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction, "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction, "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction, "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction, "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction, "ctrl A", DefaultEditorKit.selectAllAction, "HOME", DefaultEditorKit.beginLineAction, "END", DefaultEditorKit.endLineAction, "shift HOME", DefaultEditorKit.selectionBeginLineAction, "shift END", DefaultEditorKit.selectionEndLineAction, "UP", DefaultEditorKit.upAction, "KP_UP", DefaultEditorKit.upAction, "DOWN", DefaultEditorKit.downAction, "KP_DOWN", DefaultEditorKit.downAction, "PAGE_UP", DefaultEditorKit.pageUpAction, "PAGE_DOWN", DefaultEditorKit.pageDownAction, "shift PAGE_UP", "selection-page-up", "shift PAGE_DOWN", "selection-page-down", "ctrl shift PAGE_UP", "selection-page-left", "ctrl shift PAGE_DOWN", "selection-page-right", "shift UP", DefaultEditorKit.selectionUpAction, "shift KP_UP", DefaultEditorKit.selectionUpAction, "shift DOWN", DefaultEditorKit.selectionDownAction, "shift KP_DOWN", DefaultEditorKit.selectionDownAction, "ENTER", DefaultEditorKit.insertBreakAction, "BACK_SPACE", DefaultEditorKit.deletePrevCharAction, "ctrl H", DefaultEditorKit.deletePrevCharAction, "DELETE", DefaultEditorKit.deleteNextCharAction, "RIGHT", DefaultEditorKit.forwardAction, "LEFT", DefaultEditorKit.backwardAction, "KP_RIGHT", DefaultEditorKit.forwardAction, "KP_LEFT", DefaultEditorKit.backwardAction, "TAB", DefaultEditorKit.insertTabAction, "ctrl BACK_SLASH", "unselect", "ctrl HOME", DefaultEditorKit.beginAction, "ctrl END", DefaultEditorKit.endAction, "ctrl shift HOME", DefaultEditorKit.selectionBeginAction, "ctrl shift END", DefaultEditorKit.selectionEndAction, "ctrl T", "next-link-action", "ctrl shift T", "previous-link-action", "ctrl SPACE", "activate-link-action", "control shift O", "toggle-componentOrientation" }); Object emptyIcon = new UIDefaults.LazyValue() { @Override public Object createValue(UIDefaults table) { return new IconUIResource(new Icon() { public int getIconHeight() { // return the value that matches the core height, so // that the DefaultTreeCellEditor.EditorContainer // returns the correct value in its getPreferredSize // when it consults the "editingIcon" height. return 16; } public int getIconWidth() { return 2; } public void paintIcon(Component c, Graphics g, int x, int y) { } }); } }; Object[] defaults = new Object[] { "control", controlText, "TextField.focusInputMap", fieldInputMap, "PasswordField.focusInputMap", passwordInputMap, "TextArea.focusInputMap", multilineInputMap, "TextPane.focusInputMap", multilineInputMap, "EditorPane.focusInputMap", multilineInputMap, "Button.defaultButtonFollowsFocus", Boolean.FALSE, "Button.disabledText", disabledForegroundColor, "Button.foreground", foregroundColor, "Button.margin", new InsetsUIResource(0, 0, 0, 0), "CheckBox.background", SubstanceColorUtilities.getDefaultBackgroundColor( JCheckBox.class, skin, false), "CheckBox.border", new BorderUIResource.CompoundBorderUIResource( SubstanceSizeUtils.getCheckBoxBorder(SubstanceSizeUtils .getControlFontSize()), new MarginBorder()), "CheckBox.disabledText", disabledForegroundColor, "CheckBox.foreground", foregroundColor, "CheckBoxMenuItem.acceleratorForeground", foregroundColor, "CheckBoxMenuItem.acceleratorSelectionForeground", foregroundColor, "CheckBoxMenuItem.background", SubstanceColorUtilities.getDefaultBackgroundColor( JCheckBoxMenuItem.class, skin, false), "CheckBoxMenuItem.borderPainted", Boolean.FALSE, "CheckBoxMenuItem.checkIcon", new CheckBoxMenuItemIcon(null, 1 + SubstanceSizeUtils .getMenuCheckMarkSize(SubstanceSizeUtils .getControlFontSize())), "CheckBoxMenuItem.disabledForeground", disabledForegroundColor, "CheckBoxMenuItem.foreground", foregroundColor, "CheckBoxMenuItem.margin", menuItemInsets, "CheckBoxMenuItem.selectionForeground", selectionCellForegroundColor, "ColorChooser.background", SubstanceColorUtilities.getDefaultBackgroundColor( JColorChooser.class, skin, false), "ColorChooser.foreground", foregroundColor, "ComboBox.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] { "ESCAPE", "hidePopup", "PAGE_UP", "pageUpPassThrough", "PAGE_DOWN", "pageDownPassThrough", "HOME", "homePassThrough", "END", "endPassThrough", "DOWN", "selectNext", "KP_DOWN", "selectNext", "alt DOWN", "togglePopup", "alt KP_DOWN", "togglePopup", "alt UP", "togglePopup", "alt KP_UP", "togglePopup", "SPACE", "spacePopup", "ENTER", "enterPressed", "UP", "selectPrevious", "KP_UP", "selectPrevious" }), "ComboBox.background", SubstanceColorUtilities.getDefaultBackgroundColor( JComboBox.class, skin, false), "ComboBox.border", comboBorder, "ComboBox.disabledBackground", textBackgroundColor, "ComboBox.disabledForeground", disabledForegroundColor, "ComboBox.foreground", foregroundColor, "ComboBox.selectionBackground", selectionCellBackgroundColor, "ComboBox.selectionForeground", selectionCellForegroundColor, "DesktopIcon.border", regularMarginBorder, "DesktopIcon.width", new Integer(140), "Desktop.background", new ColorUIResource(new Color(0x0, true)), "Desktop.foreground", foregroundColor, "Dialog.background", SubstanceColorUtilities.getDefaultBackgroundColor( JDialog.class, skin, false), "EditorPane.background", SubstanceColorUtilities.getDefaultBackgroundColor( JEditorPane.class, skin, false), "EditorPane.border", textMarginBorder, "EditorPane.foreground", foregroundColor, "EditorPane.caretForeground", foregroundColor, "EditorPane.disabledBackground", SubstanceColorUtilities.getDefaultBackgroundColor( JEditorPane.class, skin, true), "EditorPane.inactiveBackground", SubstanceColorUtilities.getDefaultBackgroundColor( JEditorPane.class, skin, true), "EditorPane.inactiveForeground", disabledTextComponentForegroundColor, "EditorPane.selectionBackground", selectionTextBackgroundColor, "EditorPane.selectionForeground", selectionTextForegroundColor, "FileChooser.upFolderIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceCoreUtilities .getIcon("resource/go-up.png"); } }, "FileChooser.newFolderIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceCoreUtilities .getIcon("resource/folder-new.png"); } }, "FileChooser.homeFolderIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceCoreUtilities .getIcon("resource/user-home.png"); } }, "FileChooser.listViewIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceCoreUtilities .getIcon("resource/application_view_list.png"); } }, "FileChooser.detailsViewIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceCoreUtilities .getIcon("resource/application_view_detail.png"); } }, "FileChooser.viewMenuLabelText", "View", "FileChooser.refreshActionLabelText", "Refresh", "FileChooser.newFolderActionLabelText", "New Folder", "FileChooser.listViewActionLabelText", "List", "FileChooser.detailsViewActionLabelText", "Details", "FileChooser.lookInLabelMnemonic", new Integer(KeyEvent.VK_I), "FileChooser.fileNameLabelMnemonic", new Integer(KeyEvent.VK_N), "FileChooser.filesOfTypeLabelMnemonic", new Integer(KeyEvent.VK_T), "FileChooser.usesSingleFilePane", Boolean.TRUE, "FileChooser.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] { "ESCAPE", "cancelSelection", "F2", "editFileName", "F5", "refresh", "BACK_SPACE", "Go Up", "ENTER", "approveSelection" }), "FileView.computerIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceCoreUtilities .getIcon("resource/computer.png"); } }, "FileView.directoryIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceCoreUtilities .getIcon("resource/folder.png"); } }, "FileView.fileIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceCoreUtilities .getIcon("resource/text-x-generic.png"); } }, "FileView.floppyDriveIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceCoreUtilities .getIcon("resource/media-floppy.png"); } }, "FileView.hardDriveIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceCoreUtilities .getIcon("resource/drive-harddisk.png"); } }, "FormattedTextField.background", SubstanceColorUtilities.getDefaultBackgroundColor( JFormattedTextField.class, skin, false), "FormattedTextField.border", textBorder, "FormattedTextField.caretForeground", foregroundColor, "FormattedTextField.disabledBackground", SubstanceColorUtilities.getDefaultBackgroundColor( JFormattedTextField.class, skin, true), "FormattedTextField.foreground", foregroundColor, "FormattedTextField.inactiveBackground", SubstanceColorUtilities.getDefaultBackgroundColor( JFormattedTextField.class, skin, true), "FormattedTextField.inactiveForeground", disabledTextComponentForegroundColor, "FormattedTextField.selectionBackground", selectionTextBackgroundColor, "FormattedTextField.selectionForeground", selectionTextForegroundColor, "InternalFrame.activeTitleBackground", selectionTextForegroundColor, "InternalFrame.inactiveTitleBackground", foregroundColor, "InternalFrame.border", new BorderUIResource(new SubstancePaneBorder()), "InternalFrame.closeIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceImageCreator.getCloseIcon( titlePaneScheme, titlePaneScheme); } }, "InternalFrame.iconifyIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceImageCreator.getMinimizeIcon( titlePaneScheme, titlePaneScheme); } }, "InternalFrame.maximizeIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceImageCreator.getMaximizeIcon( titlePaneScheme, titlePaneScheme); } }, "InternalFrame.minimizeIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceImageCreator.getRestoreIcon( titlePaneScheme, titlePaneScheme); } }, "InternalFrame.paletteCloseIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceImageCreator.getCloseIcon( titlePaneScheme, titlePaneScheme); } }, "Label.background", SubstanceColorUtilities.getDefaultBackgroundColor(JLabel.class, skin, false), "Label.foreground", foregroundColor, "Label.disabledText", disabledForegroundColor, "Label.disabledForeground", disabledForegroundColor, "List.background", SubstanceColorUtilities.getDefaultBackgroundColor(JList.class, skin, false), "List.cellRenderer", listCellRendererActiveValue, "List.focusCellHighlightBorder", new SubstanceBorder(new Insets(1, 1, 1, 1)), "List.focusSelectedCellHighlightBorder", new BorderUIResource.EmptyBorderUIResource(1, 1, 1, 1), "List.foreground", foregroundColor, "List.selectionBackground", selectionCellBackgroundColor, "List.selectionForeground", selectionCellForegroundColor, "Menu.arrowIcon", menuArrowIcon, "Menu.background", SubstanceColorUtilities.getDefaultBackgroundColor(JMenu.class, skin, false), "Menu.borderPainted", Boolean.FALSE, "Menu.checkIcon", null, "Menu.disabledForeground", disabledForegroundColor, "Menu.foreground", foregroundColor, "Menu.margin", menuItemInsets, "Menu.selectionForeground", selectionCellForegroundColor, "MenuBar.background", skin.isRegisteredAsDecorationArea(DecorationAreaType.HEADER) ? new ColorUIResource( skin .getMainActiveColorScheme( DecorationAreaType.HEADER) .getMidColor()) : SubstanceColorUtilities.getDefaultBackgroundColor( JMenuBar.class, skin, false), "MenuBar.foreground", new ColorUIResource(skin.getMainActiveColorScheme( DecorationAreaType.HEADER).getForegroundColor()), "MenuBar.border", null, "MenuItem.acceleratorForeground", foregroundColor, "MenuItem.acceleratorSelectionForeground", foregroundColor, "MenuItem.background", SubstanceColorUtilities.getDefaultBackgroundColor( JMenuItem.class, skin, false), "MenuItem.borderPainted", Boolean.FALSE, "MenuItem.checkIcon", null, "MenuItem.disabledForeground", disabledForegroundColor, "MenuItem.foreground", foregroundColor, "MenuItem.margin", menuItemInsets, "MenuItem.selectionForeground", selectionCellForegroundColor, "OptionPane.background", SubstanceColorUtilities.getDefaultBackgroundColor( JOptionPane.class, skin, false), "OptionPane.errorIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceCoreUtilities .getIcon("resource/32/dialog-error.png"); } }, "OptionPane.foreground", foregroundColor, "OptionPane.informationIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceCoreUtilities .getIcon("resource/32/dialog-information.png"); } }, "OptionPane.messageForeground", foregroundColor, "OptionPane.questionIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceCoreUtilities .getIcon("resource/32/help-browser.png"); } }, "OptionPane.warningIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return SubstanceCoreUtilities .getIcon("resource/32/dialog-warning.png"); } }, "Panel.background", SubstanceColorUtilities.getDefaultBackgroundColor(JPanel.class, skin, false), "Panel.foreground", foregroundColor, "PasswordField.background", SubstanceColorUtilities.getDefaultBackgroundColor( JPasswordField.class, skin, false), "PasswordField.border", textBorder, "PasswordField.caretForeground", foregroundColor, "PasswordField.disabledBackground", SubstanceColorUtilities.getDefaultBackgroundColor( JPasswordField.class, skin, true), "PasswordField.foreground", foregroundColor, "PasswordField.inactiveBackground", SubstanceColorUtilities.getDefaultBackgroundColor( JPasswordField.class, skin, true), "PasswordField.inactiveForeground", disabledTextComponentForegroundColor, "PasswordField.selectionBackground", selectionTextBackgroundColor, "PasswordField.selectionForeground", selectionTextForegroundColor, "PopupMenu.background", SubstanceColorUtilities.getDefaultBackgroundColor( JPopupMenu.class, skin, false), "PopupMenu.border", regularMarginBorder, "ProgressBar.border", new BorderUIResource(new SubstanceBorder()), "ProgressBar.cycleTime", new Integer(1000), "ProgressBar.repaintInterval", new Integer(50), "ProgressBar.horizontalSize", new DimensionUIResource(146, SubstanceSizeUtils .getControlFontSize()), "ProgressBar.verticalSize", new DimensionUIResource( SubstanceSizeUtils.getControlFontSize(), 146), "ProgressBar.selectionBackground", foregroundColor, "ProgressBar.selectionForeground", foregroundColor, "RadioButton.background", SubstanceColorUtilities.getDefaultBackgroundColor( JRadioButton.class, skin, false), "RadioButton.border", new BorderUIResource.CompoundBorderUIResource( SubstanceSizeUtils .getRadioButtonBorder(SubstanceSizeUtils .getControlFontSize()), new MarginBorder()), "RadioButton.foreground", foregroundColor, "RadioButton.disabledText", disabledForegroundColor, "RadioButtonMenuItem.acceleratorForeground", foregroundColor, "RadioButtonMenuItem.acceleratorSelectionForeground", foregroundColor, "RadioButtonMenuItem.background", SubstanceColorUtilities.getDefaultBackgroundColor( JRadioButtonMenuItem.class, skin, false), "RadioButtonMenuItem.borderPainted", Boolean.FALSE, "RadioButtonMenuItem.checkIcon", new RadioButtonMenuItemIcon(null, SubstanceSizeUtils .getMenuCheckMarkSize(SubstanceSizeUtils .getControlFontSize())), "RadioButtonMenuItem.disabledForeground", disabledForegroundColor, "RadioButtonMenuItem.foreground", foregroundColor, "RadioButtonMenuItem.margin", menuItemInsets, "RadioButtonMenuItem.selectionForeground", selectionCellForegroundColor, "RootPane.background", SubstanceColorUtilities.getDefaultBackgroundColor( JRootPane.class, skin, false), "RootPane.border", new SubstancePaneBorder(), "ScrollBar.background", SubstanceColorUtilities.getDefaultBackgroundColor( JScrollBar.class, skin, false), "ScrollBar.width", new Integer(SubstanceSizeUtils .getScrollBarWidth(SubstanceSizeUtils .getControlFontSize())), "ScrollBar.minimumThumbSize", new DimensionUIResource(SubstanceSizeUtils .getScrollBarWidth(SubstanceSizeUtils .getControlFontSize()) - 2, SubstanceSizeUtils .getScrollBarWidth(SubstanceSizeUtils .getControlFontSize()) - 2), "ScrollPane.background", SubstanceColorUtilities.getDefaultBackgroundColor( JScrollPane.class, skin, false), "ScrollPane.foreground", foregroundColor, "ScrollPane.border", new SubstanceScrollPaneBorder(), "Separator.background", backgroundDefaultColor, "Separator.foreground", lineBwColor, "Slider.altTrackColor", lineColor, "Slider.background", SubstanceColorUtilities.getDefaultBackgroundColor( JSlider.class, skin, false), "Slider.darkShadow", lineColor, "Slider.focus", lineColor, "Slider.focusInsets", new InsetsUIResource(2, 2, 0, 2), "Slider.foreground", lineColor, "Slider.highlight", textBackgroundColor, "Slider.shadow", lineColor, "Slider.tickColor", foregroundColor, "Spinner.arrowButtonInsets", SubstanceSizeUtils .getSpinnerArrowButtonInsets(SubstanceSizeUtils .getControlFontSize()), "Spinner.background", SubstanceColorUtilities.getDefaultBackgroundColor( JSpinner.class, skin, false), "Spinner.border", spinnerBorder, "Spinner.disableOnBoundaryValues", Boolean.TRUE, "Spinner.foreground", foregroundColor, "Spinner.editorBorderPainted", Boolean.TRUE, "SplitPane.background", SubstanceColorUtilities.getDefaultBackgroundColor( JSplitPane.class, skin, false), "SplitPane.foreground", foregroundColor, "SplitPane.dividerFocusColor", backgroundDefaultColor, "SplitPaneDivider.draggingColor", backgroundActiveColor, "SplitPane.border", new BorderUIResource(new EmptyBorder(0, 0, 0, 0)), "SplitPane.dividerSize", (int) (SubstanceSizeUtils.getArrowIconWidth(SubstanceSizeUtils .getControlFontSize()) + SubstanceSizeUtils .getAdjustedSize(SubstanceSizeUtils .getControlFontSize(), -1, 6, -1, true)), "SplitPaneDivider.border", new BorderUIResource(new EmptyBorder(1, 1, 1, 1)), "TabbedPane.tabAreaBackground", backgroundDefaultColor, "TabbedPane.unselectedBackground", backgroundDefaultColor, "TabbedPane.background", SubstanceColorUtilities.getDefaultBackgroundColor( JTabbedPane.class, skin, false), "TabbedPane.borderHightlightColor", new ColorUIResource(mainActiveScheme.getMidColor()), "TabbedPane.contentAreaColor", null, "TabbedPane.contentBorderInsets", new InsetsUIResource(4, 4, 4, 4), "TabbedPane.contentOpaque", Boolean.FALSE, "TabbedPane.darkShadow", new ColorUIResource(skin.getColorScheme((Component) null, ColorSchemeAssociationKind.BORDER, ComponentState.SELECTED).getLineColor()), "TabbedPane.focus", foregroundColor, "TabbedPane.foreground", foregroundColor, "TabbedPane.highlight", new ColorUIResource(mainActiveScheme.getLightColor()), "TabbedPane.light", mainDefaultScheme.isDark() ? new ColorUIResource( SubstanceColorUtilities.getAlphaColor(mainDefaultScheme .getUltraDarkColor(), 100)) : new ColorUIResource(mainDefaultScheme.getLightColor()), "TabbedPane.selected", new ColorUIResource(mainActiveScheme.getExtraLightColor()), "TabbedPane.selectedForeground", foregroundColor, "TabbedPane.selectHighlight", new ColorUIResource(mainActiveScheme.getMidColor()), "TabbedPane.shadow", new ColorUIResource(SubstanceColorUtilities .getInterpolatedColor(mainDefaultScheme .getExtraLightColor(), mainDefaultScheme .getLightColor(), 0.5)), "TabbedPane.tabRunOverlay", new Integer(0), "Table.background", SubstanceColorUtilities.getDefaultBackgroundColor(JTable.class, skin, false), "Table.focusCellBackground", backgroundActiveColor, "Table.focusCellForeground", foregroundColor, "Table.focusCellHighlightBorder", new SubstanceBorder(), "Table.foreground", foregroundColor, "Table.gridColor", lineColorDefault, "Table.scrollPaneBorder", new SubstanceScrollPaneBorder(), "Table.selectionBackground", selectionCellBackgroundColor, "Table.selectionForeground", selectionCellForegroundColor, "TableHeader.cellBorder", null, "TableHeader.foreground", foregroundColor, "TableHeader.background", SubstanceColorUtilities.getDefaultBackgroundColor( JTableHeader.class, skin, false), "TextArea.background", SubstanceColorUtilities.getDefaultBackgroundColor( JTextArea.class, skin, false), "TextArea.border", textMarginBorder, "TextArea.caretForeground", foregroundColor, "TextArea.disabledBackground", SubstanceColorUtilities.getDefaultBackgroundColor( JTextArea.class, skin, true), "TextArea.foreground", foregroundColor, "TextArea.inactiveBackground", SubstanceColorUtilities.getDefaultBackgroundColor( JTextArea.class, skin, true), "TextArea.inactiveForeground", disabledTextComponentForegroundColor, "TextArea.selectionBackground", selectionTextBackgroundColor, "TextArea.selectionForeground", selectionTextForegroundColor, "TextField.background", SubstanceColorUtilities.getDefaultBackgroundColor( JTextField.class, skin, false), "TextField.border", textBorder, "TextField.caretForeground", foregroundColor, "TextField.disabledBackground", SubstanceColorUtilities.getDefaultBackgroundColor( JTextField.class, skin, true), "TextField.foreground", foregroundColor, "TextField.inactiveBackground", SubstanceColorUtilities.getDefaultBackgroundColor( JTextField.class, skin, true), "TextField.inactiveForeground", disabledTextComponentForegroundColor, "TextField.selectionBackground", selectionTextBackgroundColor, "TextField.selectionForeground", selectionTextForegroundColor, "TextPane.background", SubstanceColorUtilities.getDefaultBackgroundColor( JTextPane.class, skin, false), "TextPane.border", textMarginBorder, "TextPane.disabledBackground", SubstanceColorUtilities.getDefaultBackgroundColor( JTextPane.class, skin, true), "TextPane.foreground", foregroundColor, "TextPane.caretForeground", foregroundColor, "TextPane.inactiveBackground", SubstanceColorUtilities.getDefaultBackgroundColor( JTextPane.class, skin, true), "TextPane.inactiveForeground", disabledTextComponentForegroundColor, "TextPane.selectionBackground", selectionTextBackgroundColor, "TextPane.selectionForeground", selectionTextForegroundColor, "TitledBorder.titleColor", foregroundColor, "TitledBorder.border", new SubstanceEtchedBorder(), "ToggleButton.foreground", foregroundColor, "ToggleButton.disabledText", disabledForegroundColor, "ToggleButton.margin", new InsetsUIResource(0, 0, 0, 0), "ToolBar.background", SubstanceColorUtilities.getDefaultBackgroundColor( JToolBar.class, skin, false), "ToolBar.border", new BorderUIResource(new SubstanceToolBarBorder()), "ToolBar.isRollover", Boolean.TRUE, "ToolBar.foreground", foregroundColor, "ToolBarSeparator.background", SubstanceColorUtilities.getDefaultBackgroundColor( JToolBar.class, skin, false), "ToolBarSeparator.foreground", lineBwColor, "ToolBar.separatorSize", null, "ToolTip.border", tooltipBorder, "ToolTip.borderInactive", tooltipBorder, "ToolTip.background", SubstanceColorUtilities.getDefaultBackgroundColor( JToolTip.class, skin, false), "ToolTip.backgroundInactive", SubstanceColorUtilities.getDefaultBackgroundColor( JTextPane.class, skin, true), "ToolTip.foreground", foregroundColor, "ToolTip.foregroundInactive", disabledForegroundColor, "Tree.closedIcon", emptyIcon, "Tree.collapsedIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return new IconUIResource(SubstanceIconFactory .getTreeIcon(null, true)); } }, "Tree.expandedIcon", new UIDefaults.LazyValue() { public Object createValue(UIDefaults table) { return new IconUIResource(SubstanceIconFactory .getTreeIcon(null, false)); } }, "Tree.leafIcon", emptyIcon, "Tree.openIcon", emptyIcon, "Tree.background", SubstanceColorUtilities.getDefaultBackgroundColor(JTree.class, skin, false), "Tree.selectionBackground", selectionCellBackgroundColor, "Tree.foreground", foregroundColor, "Tree.hash", lineColorDefault, "Tree.rowHeight", new Integer(0), "Tree.selectionBorderColor", lineColor, "Tree.selectionForeground", selectionCellForegroundColor, "Tree.textBackground", backgroundDefaultColor, "Tree.textForeground", foregroundColor, "Viewport.background", backgroundDefaultColor, "Viewport.foreground", foregroundColor, }; table.putDefaults(defaults); } } substance-5.3.orig/src/org/jvnet/substance/utils/RolloverMenuItemListener.java0000644000175000017500000000772511136475562027704 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.event.MouseEvent; import javax.swing.ButtonModel; import javax.swing.JMenuItem; import javax.swing.event.MouseInputListener; /** * Menu item listener for rollover effects. Tracks the mouse motion interaction * for the associated menu item. This class is for internal use only. * * @author Kirill Grouchnikov */ public class RolloverMenuItemListener implements MouseInputListener { /** * If the mouse pointer is currently inside the associated menu item area, * this flag is true. */ private boolean isMouseInside; /** * The associated menu item. */ private JMenuItem item; /** * Simple constructor. * * @param item * The associated menu item. */ public RolloverMenuItemListener(JMenuItem item) { this.item = item; this.isMouseInside = false; } /* * (non-Javadoc) * * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent) */ public void mouseEntered(MouseEvent e) { this.isMouseInside = true; this.item.getModel().setRollover(true); } /* * (non-Javadoc) * * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent) */ public void mouseExited(MouseEvent e) { this.isMouseInside = false; this.item.getModel().setRollover(false); } /* * (non-Javadoc) * * @see * java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent) */ public void mouseReleased(MouseEvent e) { ButtonModel model = this.item.getModel(); model.setRollover(false); } /* * (non-Javadoc) * * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) */ public void mouseClicked(MouseEvent e) { } /* * (non-Javadoc) * * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) */ public void mousePressed(MouseEvent e) { } /* * (non-Javadoc) * * @see * java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent * ) */ public void mouseDragged(MouseEvent e) { } /* * (non-Javadoc) * * @see * java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent) */ public void mouseMoved(MouseEvent e) { this.item.getModel().setRollover(this.isMouseInside); } } substance-5.3.orig/src/org/jvnet/substance/utils/Sideable.java0000644000175000017500000000423611136475562024430 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import org.jvnet.substance.api.SubstanceConstants; /** * Interface for components that have a side. An example of such a component is * scroll bar button or spinner button. * * @author Kirill Grouchnikov */ public interface Sideable { /** * Returns side that corresponds to the orientation of the associated * button. * * @return Side that corresponds to the orientation of the associated * button. */ public SubstanceConstants.Side getSide(); } substance-5.3.orig/src/org/jvnet/substance/utils/TraitInfoImpl.java0000644000175000017500000000625211136475562025441 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import org.jvnet.substance.api.trait.SubstanceTraitInfo; /** * Basic class for trait info. * * @author Kirill Grouchnikov */ public class TraitInfoImpl implements SubstanceTraitInfo { /** * The display name of the associated trait. */ private String displayName; /** * The class name of the associated trait. */ private String className; /** * Indication whether the associated trait is default in the application. */ private boolean isDefault; /** * Simple constructor. * * @param displayName * Display name of the associated trait. * @param className * Class name of the associated trait. */ public TraitInfoImpl(String displayName, String className) { this.displayName = displayName; this.className = className; } /* * (non-Javadoc) * * @see org.jvnet.substance.utils.SubstanceTraitInfo#getClassName() */ public String getClassName() { return this.className; } /* * (non-Javadoc) * * @see org.jvnet.substance.utils.SubstanceTrait#getDisplayName() */ public String getDisplayName() { return this.displayName; } /* * (non-Javadoc) * * @see org.jvnet.substance.utils.SubstanceTraitInfo#isDefault() */ public boolean isDefault() { return this.isDefault; } /* * (non-Javadoc) * * @see org.jvnet.substance.utils.SubstanceTraitInfo#setDefault(boolean) */ public void setDefault(boolean isDefault) { this.isDefault = isDefault; } } substance-5.3.orig/src/org/jvnet/substance/utils/RolloverButtonListener.java0000644000175000017500000001277411136475562027434 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.MouseInfo; import java.awt.PointerInfo; import java.awt.event.*; import java.security.AccessControlException; import javax.swing.AbstractButton; import javax.swing.plaf.basic.BasicButtonListener; /** * Button listener for rollover effects. Tracks the mouse motion and focus * interaction for the associated button. This class is for internal use * only. * * @author Kirill Grouchnikov */ public class RolloverButtonListener extends BasicButtonListener { /** * If the mouse pointer is currently inside the associated button area, * this flag is true. */ private boolean isMouseInside; /** * The associated button. */ private AbstractButton button; /** * Simple constructor. * * @param b * The associated button. */ public RolloverButtonListener(AbstractButton b) { super(b); this.button = b; this.isMouseInside = false; } /* * (non-Javadoc) * * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent) */ @Override public void mouseEntered(MouseEvent e) { super.mouseEntered(e); this.isMouseInside = true; boolean isMouseDrag = ((e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0); // System.err.println("ENTERED : " + e.getModifiers() + ":" // + e.getModifiersEx()); if (!isMouseDrag) { this.button.getModel().setRollover(true); } } /* * (non-Javadoc) * * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent) */ @Override public void mouseExited(MouseEvent e) { super.mouseExited(e); // AbstractButton button = (AbstractButton) e.getSource(); this.isMouseInside = false; this.button.getModel().setRollover(false); // FadeTracker.getInstance().trackFadeOut(FadeKind.ROLLOVER, button, // false, null); } /* * (non-Javadoc) * * @see * java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent) */ @Override public void mouseReleased(MouseEvent e) { super.mouseReleased(e); for (ActionListener al : this.button.getActionListeners()) if (al instanceof SubstanceInternalFrameTitlePane.ClickListener) return; this.button.getModel().setRollover(this.isMouseInside); // button.getModel().setRollover(this.isMouseInside); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicButtonListener#mouseMoved(java.awt.event. * MouseEvent) */ @Override public void mouseMoved(MouseEvent e) { super.mouseMoved(e); for (ActionListener al : this.button.getActionListeners()) if (al instanceof SubstanceInternalFrameTitlePane.ClickListener) return; this.button.getModel().setRollover(this.isMouseInside); } // // @Override // public void mouseDragged(MouseEvent e) { // super.mouseDragged(e); // System.err.println("DRAGGED : " + e.getModifiers()); // } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicButtonListener#focusGained(java.awt.event * .FocusEvent) */ @Override public void focusGained(FocusEvent e) { super.focusGained(e); if (!this.button.isShowing()) { // shouldn't happen. Is some lurking Swing bug return; } try { PointerInfo pi = MouseInfo.getPointerInfo(); int px = pi.getLocation().x - this.button.getLocationOnScreen().x; int py = pi.getLocation().y - this.button.getLocationOnScreen().y; this.button.getModel().setRollover(this.button.contains(px, py)); } catch (AccessControlException ace) { // sandbox - give up } } /* * (non-Javadoc) * * @seejavax.swing.plaf.basic.BasicButtonListener#focusLost(java.awt.event. * FocusEvent) */ @Override public void focusLost(FocusEvent e) { super.focusLost(e); this.button.getModel().setRollover(false); // FadeTracker.getInstance().trackFadeOut(button); } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceSplitPaneDivider.java0000644000175000017500000004507611245202246027771 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.*; import java.awt.event.MouseEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.plaf.basic.BasicSplitPaneDivider; import javax.swing.plaf.basic.BasicSplitPaneUI; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.SubstanceSplitPaneUI; import org.jvnet.substance.api.*; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.utils.icon.TransitionAwareIcon; /** * Split pane divider in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceSplitPaneDivider extends BasicSplitPaneDivider implements Trackable { /** * Listener for fade animations. */ private RolloverControlListener substanceRolloverListener; /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /** * Listener on property change events. */ private PropertyChangeListener substancePropertyChangeListener; /** * Surrogate button model for tracking the thumb transitions. */ private ButtonModel gripModel; /** * Simple constructor. * * @param ui * Associated UI. */ public SubstanceSplitPaneDivider(SubstanceSplitPaneUI ui) { super(ui); this.setLayout(new SubstanceDividerLayout()); } @Override public void setBasicSplitPaneUI(BasicSplitPaneUI newUI) { if (this.splitPane != null) { // fix for defect 358 - multiple listeners were installed // on the same split pane this.uninstall(); } if (newUI != null) { // installing this.splitPane = newUI.getSplitPane(); this.gripModel = new DefaultButtonModel(); this.gripModel.setArmed(false); this.gripModel.setSelected(false); this.gripModel.setPressed(false); this.gripModel.setRollover(false); this.gripModel.setEnabled(this.splitPane.isEnabled()); // fix for defect 109 - memory leak on changing skin this.substanceRolloverListener = new RolloverControlListener(this, this.gripModel); this.addMouseListener(this.substanceRolloverListener); this.addMouseMotionListener(this.substanceRolloverListener); this.substancePropertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("enabled".equals(evt.getPropertyName())) { boolean isEnabled = splitPane.isEnabled(); gripModel.setEnabled(isEnabled); if (leftButton != null) leftButton.setEnabled(isEnabled); if (rightButton != null) rightButton.setEnabled(isEnabled); setEnabled(isEnabled); } } }; // System.out.println("Registering " + this.hashCode() + ":" // + this.substancePropertyChangeListener.hashCode() + " on " // + this.splitPane.hashCode()); this.splitPane .addPropertyChangeListener(this.substancePropertyChangeListener); this.substanceFadeStateListener = new FadeStateListener(this, this.gripModel, SubstanceCoreUtilities.getFadeCallback( this.splitPane, this.gripModel, false, false, this)); this.substanceFadeStateListener.registerListeners(false); } else { uninstall(); } super.setBasicSplitPaneUI(newUI); } /** * Uninstalls this divider. */ private void uninstall() { // uninstalling // fix for defect 109 - memory leak on changing skin this.removeMouseListener(this.substanceRolloverListener); this.removeMouseMotionListener(this.substanceRolloverListener); this.substanceRolloverListener = null; if (this.substancePropertyChangeListener != null) { // System.out.println("Unregistering " + this.hashCode() + ":" // + this.substancePropertyChangeListener.hashCode() // + " from " + this.splitPane.hashCode()); this.splitPane .removePropertyChangeListener(this.substancePropertyChangeListener); this.substancePropertyChangeListener = null; } if (this.substanceFadeStateListener != null) { this.substanceFadeStateListener.unregisterListeners(); this.substanceFadeStateListener = null; } } /* * (non-Javadoc) * * @see java.awt.Component#paint(java.awt.Graphics) */ @Override public void paint(Graphics g) { if (SubstanceCoreUtilities.hasFlatAppearance(this.splitPane, true)) { BackgroundPaintingUtils.updateIfOpaque(g, this.splitPane); } Graphics2D graphics = (Graphics2D) g.create(); ComponentState currState = ComponentState.getState(this.gripModel, this.splitPane); ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(this.splitPane); float alpha = SubstanceColorSchemeUtilities.getAlpha(this.splitPane, currState); if (alpha < 1.0f) { graphics.setComposite(TransitionLayout.getAlphaComposite( this.splitPane, alpha, g)); } FadeState fadeState = SubstanceFadeUtilities.getFadeState(this, FadeKind.ROLLOVER, FadeKind.SELECTION, FadeKind.PRESS); float cyclePos = 1.0f; if (fadeState != null) { cyclePos = fadeState.getFadePosition(); if (fadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; } // compute the grip handle dimension int minSizeForGripPresence = SubstanceSizeUtils.getAdjustedSize( SubstanceSizeUtils.getComponentFontSize(this), 30, 1, 2, false); int maxGripSize = SubstanceSizeUtils.getAdjustedSize(SubstanceSizeUtils .getComponentFontSize(this), 40, 1, 3, false); if (this.splitPane.getOrientation() == JSplitPane.HORIZONTAL_SPLIT) { int thumbHeight = this.getHeight(); if (thumbHeight >= minSizeForGripPresence) { int gripHeight = thumbHeight / 4; if (gripHeight > maxGripSize) gripHeight = maxGripSize; int thumbWidth = this.getWidth(); int gripX = 0; int gripY = (thumbHeight - gripHeight) / 2; // draw the grip bumps SubstanceImageCreator.paintSplitDividerBumpImage(graphics, this, gripX, gripY, thumbWidth, gripHeight, false, currState, SubstanceColorSchemeUtilities .getColorScheme(this, ColorSchemeAssociationKind.MARK, currState), SubstanceColorSchemeUtilities.getColorScheme(this, ColorSchemeAssociationKind.MARK, prevState), cyclePos); } } else { int thumbWidth = this.getWidth(); if (thumbWidth >= minSizeForGripPresence) { int gripWidth = thumbWidth / 4; if (gripWidth > maxGripSize) gripWidth = maxGripSize; int thumbHeight = this.getHeight(); // int gripHeight = thumbHeight * 2 / 3; int gripX = (thumbWidth - gripWidth) / 2; int gripY = 1; // draw the grip bumps SubstanceImageCreator.paintSplitDividerBumpImage(graphics, this, gripX, gripY, gripWidth, thumbHeight, true, currState, SubstanceColorSchemeUtilities .getColorScheme(this, ColorSchemeAssociationKind.MARK, currState), SubstanceColorSchemeUtilities.getColorScheme(this, ColorSchemeAssociationKind.MARK, prevState), cyclePos); } } graphics.dispose(); super.paint(g); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicSplitPaneDivider#createLeftOneTouchButton() */ @Override protected JButton createLeftOneTouchButton() { JButton oneTouchButton = new JButton() { // Don't want the button to participate in focus traversable. @Override public boolean isFocusable() { return false; } }; Icon verticalSplit = new TransitionAwareIcon(oneTouchButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { int fontSize = SubstanceSizeUtils .getComponentFontSize(splitPane); return SubstanceImageCreator.getArrowIcon( SubstanceSizeUtils .getSplitPaneArrowIconWidth(fontSize), SubstanceSizeUtils .getSplitPaneArrowIconHeight(fontSize), SubstanceSizeUtils .getArrowStrokeWidth(fontSize), SwingConstants.NORTH, scheme); } }, "substance.splitPane.left.vertical"); Icon horizontalSplit = new TransitionAwareIcon(oneTouchButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { int fontSize = SubstanceSizeUtils .getComponentFontSize(splitPane); return SubstanceImageCreator.getArrowIcon( SubstanceSizeUtils .getSplitPaneArrowIconWidth(fontSize), SubstanceSizeUtils .getSplitPaneArrowIconHeight(fontSize), SubstanceSizeUtils .getArrowStrokeWidth(fontSize), SwingConstants.WEST, scheme); } }, "substance.splitPane.left.horizontal"); oneTouchButton .setIcon(this.splitPane.getOrientation() == JSplitPane.VERTICAL_SPLIT ? verticalSplit : horizontalSplit); oneTouchButton.putClientProperty( SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY, Boolean.TRUE); // fix for issue 281 - set empty border so that the arrow // icon is not cropped oneTouchButton.setBorder(new EmptyBorder(0, 0, 0, 0)); oneTouchButton.setRequestFocusEnabled(false); oneTouchButton .setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); oneTouchButton.setFocusPainted(false); oneTouchButton.setBorderPainted(false); return oneTouchButton; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicSplitPaneDivider#createRightOneTouchButton() */ @Override protected JButton createRightOneTouchButton() { JButton oneTouchButton = new JButton() { // Don't want the button to participate in focus traversable. @Override public boolean isFocusable() { return false; } }; Icon verticalSplit = new TransitionAwareIcon(oneTouchButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { int fontSize = SubstanceSizeUtils .getComponentFontSize(splitPane); return SubstanceImageCreator.getArrowIcon( SubstanceSizeUtils .getSplitPaneArrowIconWidth(fontSize), SubstanceSizeUtils .getSplitPaneArrowIconHeight(fontSize), SubstanceSizeUtils .getArrowStrokeWidth(fontSize), SwingConstants.SOUTH, scheme); } }, "substance.splitPane.right.vertical"); Icon horizontalSplit = new TransitionAwareIcon(oneTouchButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { int fontSize = SubstanceSizeUtils .getComponentFontSize(splitPane); return SubstanceImageCreator.getArrowIcon( SubstanceSizeUtils .getSplitPaneArrowIconWidth(fontSize), SubstanceSizeUtils .getSplitPaneArrowIconHeight(fontSize), SubstanceSizeUtils .getArrowStrokeWidth(fontSize), SwingConstants.EAST, scheme); } }, "substance.splitPane.right.horizontal"); oneTouchButton .setIcon(this.splitPane.getOrientation() == JSplitPane.VERTICAL_SPLIT ? verticalSplit : horizontalSplit); oneTouchButton.putClientProperty( SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY, Boolean.TRUE); // fix for issue 281 - set empty border so that the arrow // icon is not cropped oneTouchButton.setBorder(new EmptyBorder(0, 0, 0, 0)); oneTouchButton .setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); oneTouchButton.setFocusPainted(false); oneTouchButton.setBorderPainted(false); oneTouchButton.setRequestFocusEnabled(false); // b.setOpaque(false); return oneTouchButton; } /** * Updates the one-touch buttons. * * @param orientation * Split pane orientation. */ public void updateOneTouchButtons(int orientation) { if (orientation == JSplitPane.VERTICAL_SPLIT) { if (this.leftButton != null) { this.leftButton.setIcon(new TransitionAwareIcon( this.leftButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon( SubstanceColorScheme scheme) { int fontSize = SubstanceSizeUtils .getComponentFontSize(splitPane); return SubstanceImageCreator .getArrowIcon( SubstanceSizeUtils .getSplitPaneArrowIconWidth(fontSize), SubstanceSizeUtils .getSplitPaneArrowIconHeight(fontSize), SubstanceSizeUtils .getArrowStrokeWidth(fontSize), SwingConstants.NORTH, scheme); } }, "substance.splitPane.left.vertical")); } if (this.rightButton != null) { this.rightButton.setIcon(new TransitionAwareIcon( this.rightButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon( SubstanceColorScheme scheme) { int fontSize = SubstanceSizeUtils .getComponentFontSize(splitPane); return SubstanceImageCreator .getArrowIcon( SubstanceSizeUtils .getSplitPaneArrowIconWidth(fontSize), SubstanceSizeUtils .getSplitPaneArrowIconHeight(fontSize), SubstanceSizeUtils .getArrowStrokeWidth(fontSize), SwingConstants.SOUTH, scheme); } }, "substance.splitPane.right.vertical")); } } else { if (this.leftButton != null) { this.leftButton.setIcon(new TransitionAwareIcon( this.leftButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon( SubstanceColorScheme scheme) { int fontSize = SubstanceSizeUtils .getComponentFontSize(splitPane); return SubstanceImageCreator .getArrowIcon( SubstanceSizeUtils .getSplitPaneArrowIconWidth(fontSize), SubstanceSizeUtils .getSplitPaneArrowIconHeight(fontSize), SubstanceSizeUtils .getArrowStrokeWidth(fontSize), SwingConstants.WEST, scheme); } }, "substance.splitPane.left.horizontal")); } if (this.rightButton != null) { this.rightButton.setIcon(new TransitionAwareIcon( this.rightButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon( SubstanceColorScheme scheme) { int fontSize = SubstanceSizeUtils .getComponentFontSize(splitPane); return SubstanceImageCreator .getArrowIcon( SubstanceSizeUtils .getSplitPaneArrowIconWidth(fontSize), SubstanceSizeUtils .getSplitPaneArrowIconHeight(fontSize), SubstanceSizeUtils .getArrowStrokeWidth(fontSize), SwingConstants.EAST, scheme); } }, "substance.splitPane.right.horizontal")); } } } /* * (non-Javadoc) * * @see * org.jvnet.substance.utils.Trackable#isInside(java.awt.event.MouseEvent) */ public boolean isInside(MouseEvent me) { // entire area is sensitive return true; } /** * Layout manager for the split pane divider. * * @author Kirill Grouchnikov */ protected class SubstanceDividerLayout extends DividerLayout { @Override public void layoutContainer(Container c) { if (leftButton != null && rightButton != null && c == SubstanceSplitPaneDivider.this) { if (splitPane.isOneTouchExpandable()) { Insets insets = getInsets(); if (orientation == JSplitPane.VERTICAL_SPLIT) { int extraX = (insets != null) ? insets.left : 0; int blockSize = getHeight(); if (insets != null) { blockSize -= (insets.top + insets.bottom); blockSize = Math.max(blockSize, 0); } int y = (c.getSize().height - blockSize) / 2; int offset = SubstanceSizeUtils .getSplitPaneButtonOffset(SubstanceSizeUtils .getComponentFontSize(splitPane)); leftButton.setBounds(extraX + offset, y, leftButton .getPreferredSize().width * 2 / 3, blockSize); rightButton.setBounds(leftButton.getX() + leftButton.getWidth(), y, rightButton .getPreferredSize().width * 2 / 3, blockSize); } else { int extraY = (insets != null) ? insets.top : 0; int blockSize = getWidth(); if (insets != null) { blockSize -= (insets.left + insets.right); blockSize = Math.max(blockSize, 0); } int x = (c.getSize().width - blockSize) / 2; int offset = SubstanceSizeUtils .getSplitPaneButtonOffset(SubstanceSizeUtils .getComponentFontSize(splitPane)); leftButton.setBounds(x, extraY + offset, blockSize, leftButton.getPreferredSize().height * 2 / 3); rightButton.setBounds(x, leftButton.getY() + leftButton.getHeight(), blockSize, leftButton .getPreferredSize().height * 2 / 3); } } else { leftButton.setBounds(-5, -5, 1, 1); rightButton.setBounds(-5, -5, 1, 1); } } } } } substance-5.3.orig/src/org/jvnet/substance/utils/menu/0000755000175000017500000000000011256731152023005 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/utils/menu/MenuUtilities.java0000644000175000017500000010074311247215132026450 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.menu; import java.awt.*; import java.awt.event.KeyEvent; import java.awt.geom.Area; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.plaf.ButtonUI; import javax.swing.plaf.basic.BasicHTML; import javax.swing.text.View; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.animation.FadeState; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.api.SubstanceConstants.MenuGutterFillKind; import org.jvnet.substance.utils.*; /** * Menu-related utilities. * * @author Kirill Grouchnikov */ public class MenuUtilities { /** * Key to store the layout metrics. The value should be an instance of * {@link MenuLayoutMetrics}. */ private static final String LAYOUT_METRICS = "substancelaf.internal.menus.layoutMetrics"; /** * Key to store the gutter X location. The value should be an instance of * {@link Integer}. */ private static final String GUTTER_X = "substancelaf.internal.menus.gutterX"; public static final String LAYOUT_INFO = "substancelaf.internal.menus.layoutInfo"; /** * Listener to track changes in the menu items. Once any property has been * changed, the popup layout metrics on the menu item and its parent popup * menu are cleared. * * @author Kirill Grouchnikov */ public static class MenuPropertyListener implements PropertyChangeListener { /** * Associated menu item. */ private JMenuItem menuItem; /** * Runnable instance to clean the layout metrics. */ private Runnable cleanLayoutMetricsRunnable; /** * Creates a new listener. * * @param menuItem * Menu item. */ public MenuPropertyListener(final JMenuItem menuItem) { this.menuItem = menuItem; this.cleanLayoutMetricsRunnable = new Runnable() { public void run() { MenuUtilities.cleanPopupLayoutMetrics(menuItem); } }; } /** * Installs the property change listener on the associated menu item. */ public void install() { this.menuItem.addPropertyChangeListener(this); } /** * Uninstalls the property change listener from the associated menu * item. */ public void uninstall() { this.menuItem.removePropertyChangeListener(this); } /* * (non-Javadoc) * * @seejava.beans.PropertyChangeListener#propertyChange(java.beans. * PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent evt) { if (!evt.getPropertyName().equals(MenuUtilities.LAYOUT_METRICS)) { SwingUtilities.invokeLater(cleanLayoutMetricsRunnable); } } } /** * Layout information for a single menu item. * * @author Kirill Grouchnikov */ public static class MenuLayoutInfo { /** * View rectangle. */ public Rectangle viewRect; /** * Icon rectangle. */ public Rectangle iconRect; /** * Check icon rectangle. */ public Rectangle checkIconRect; /** * Text rectangle. */ public Rectangle textRect; /** * Accelerator rectangle. */ public Rectangle acceleratorRect; /** * Arrow icon rectangle. */ public Rectangle arrowIconRect; /** * Menu item text. */ public String text; } /** * Layout metrics for a single popup menu. All menu items in a popup menu * share the same metrics so that different parts (icons, check icons, * texts, accelerator texts and arrow icons) are vertically aligned. * * @author Kirill Grouchnikov */ public static class MenuLayoutMetrics { /** * Maximum width of icons of the menu items of this popup menu. */ public int maxIconWidth; /** * Maximum width of check icons of the menu items of this popup menu. */ public int maxCheckIconWidth; /** * Maximum width of texts of the menu items of this popup menu. */ public int maxTextWidth; /** * Maximum width of accelerator texts of the menu items of this popup * menu. */ public int maxAcceleratorWidth; /** * Maximum width of arrow icons of the menu items of this popup menu. */ public int maxArrowIconWidth; /** * Maximum gap between icon and text of the menu items of this popup * menu. */ public int maxIconTextGap; } /** * Returns the layout info for the specified menu item. * * @param menuItem * Menu item. * @param acceleratorFont * Font for the accelerator text. * @param checkIcon * Check icon. * @param arrowIcon * Arrow icon. * @param defaultTextIconGap * Gap between the icon and the text. * @return Layout info for the specified menu item. */ public static MenuLayoutInfo getMenuLayoutInfo(boolean forPainting, JMenuItem menuItem, Font acceleratorFont, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { Insets i = menuItem.getInsets(); Rectangle iconRect = new Rectangle(0, 0, 0, 0); Rectangle textRect = new Rectangle(0, 0, 0, 0); Rectangle acceleratorRect = new Rectangle(0, 0, 0, 0); Rectangle checkIconRect = new Rectangle(0, 0, 0, 0); Rectangle arrowIconRect = new Rectangle(0, 0, 0, 0); Rectangle viewRect = new Rectangle(Short.MAX_VALUE, Short.MAX_VALUE); if (forPainting) { // fix for issue 379 - setting the available // bounds only during the painting. int menuWidth = menuItem.getWidth(); int menuHeight = menuItem.getHeight(); if ((menuWidth > 0) && (menuHeight > 0)) viewRect.setBounds(0, 0, menuWidth, menuHeight); viewRect.x += i.left; viewRect.y += i.top; viewRect.width -= (i.right + viewRect.x); viewRect.height -= (i.bottom + viewRect.y); } FontMetrics fm = menuItem.getFontMetrics(menuItem.getFont()); FontMetrics fmAccel = menuItem.getFontMetrics(acceleratorFont); // get Accelerator text KeyStroke accelerator = menuItem.getAccelerator(); String acceleratorText = ""; if (accelerator != null) { int modifiers = accelerator.getModifiers(); if (modifiers > 0) { acceleratorText = KeyEvent.getKeyModifiersText(modifiers); // acceleratorText += "-"; acceleratorText += UIManager .getString("MenuItem.acceleratorDelimiter"); } int keyCode = accelerator.getKeyCode(); if (keyCode != 0) { acceleratorText += KeyEvent.getKeyText(keyCode); } else { acceleratorText += accelerator.getKeyChar(); } } // layout the text and icon String text = layoutMenuItem(menuItem, fm, menuItem.getText(), fmAccel, acceleratorText, menuItem.getIcon(), checkIcon, arrowIcon, menuItem.getVerticalAlignment(), menuItem .getHorizontalAlignment(), menuItem .getVerticalTextPosition(), menuItem .getHorizontalTextPosition(), viewRect, iconRect, textRect, acceleratorRect, checkIconRect, arrowIconRect, menuItem.getText() == null ? 0 : defaultTextIconGap, defaultTextIconGap); MenuLayoutInfo mlInfo = new MenuLayoutInfo(); mlInfo.checkIconRect = checkIconRect; mlInfo.iconRect = iconRect; mlInfo.textRect = textRect; mlInfo.viewRect = viewRect; mlInfo.acceleratorRect = acceleratorRect; mlInfo.arrowIconRect = arrowIconRect; mlInfo.text = text; return mlInfo; } /** * Compute and return the location of the icons origin, the location of * origin of the text baseline, and a possibly clipped version of the * compound labels string. Locations are computed relative to the viewRect * rectangle. */ private static String layoutMenuItem(JMenuItem menuItem, FontMetrics fm, String text, FontMetrics fmAccel, String acceleratorText, Icon icon, Icon checkIcon, Icon arrowIcon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, Rectangle viewRect, Rectangle iconRect, Rectangle textRect, Rectangle acceleratorRect, Rectangle checkIconRect, Rectangle arrowIconRect, int textIconGap, int menuItemGap) { SwingUtilities.layoutCompoundLabel(menuItem, fm, text, icon, verticalAlignment, horizontalAlignment, verticalTextPosition, horizontalTextPosition, viewRect, iconRect, textRect, textIconGap); /* * Initialize the acceelratorText bounds rectangle textRect. If a null * or and empty String was specified we substitute "" here and use * 0,0,0,0 for acceleratorTextRect. */ if ((acceleratorText == null) || acceleratorText.equals("")) { acceleratorRect.width = acceleratorRect.height = 0; acceleratorText = ""; } else { acceleratorRect.width = fmAccel.stringWidth(acceleratorText); acceleratorRect.height = fmAccel.getHeight(); } /* * Initialize the checkIcon bounds rectangle's width & height. */ if (useCheckAndArrow(menuItem)) { if (checkIcon != null) { checkIconRect.width = checkIcon.getIconWidth(); checkIconRect.height = checkIcon.getIconHeight(); } else { checkIconRect.width = checkIconRect.height = 0; } /* * Initialize the arrowIcon bounds rectangle width & height. */ if (arrowIcon != null) { arrowIconRect.width = arrowIcon.getIconWidth(); arrowIconRect.height = arrowIcon.getIconHeight(); } else { arrowIconRect.width = arrowIconRect.height = 0; } } Rectangle labelRect = iconRect.union(textRect); if (menuItem.getComponentOrientation().isLeftToRight()) { textRect.x += menuItemGap; iconRect.x += menuItemGap; // Position the Accelerator text rect acceleratorRect.x = viewRect.x + viewRect.width - arrowIconRect.width - menuItemGap - acceleratorRect.width; // Position the Check and Arrow Icons if (useCheckAndArrow(menuItem)) { checkIconRect.x = viewRect.x + menuItemGap; textRect.x += menuItemGap + checkIconRect.width; iconRect.x += menuItemGap + checkIconRect.width; arrowIconRect.x = viewRect.x + viewRect.width - menuItemGap - arrowIconRect.width; } } else { textRect.x -= menuItemGap; iconRect.x -= menuItemGap; // Position the Accelerator text rect acceleratorRect.x = viewRect.x + arrowIconRect.width + menuItemGap; // Position the Check and Arrow Icons if (useCheckAndArrow(menuItem)) { checkIconRect.x = viewRect.x + viewRect.width - menuItemGap - checkIconRect.width; textRect.x -= menuItemGap + checkIconRect.width; iconRect.x -= menuItemGap + checkIconRect.width; arrowIconRect.x = viewRect.x + menuItemGap; } } // Align the accelertor text and the check and arrow icons vertically // with the center of the label rect. acceleratorRect.y = labelRect.y + (labelRect.height / 2) - (acceleratorRect.height / 2); if (useCheckAndArrow(menuItem)) { arrowIconRect.y = labelRect.y + (labelRect.height / 2) - (arrowIconRect.height / 2); checkIconRect.y = labelRect.y + (labelRect.height / 2) - (checkIconRect.height / 2); } /* * System.out.println("Layout: text="+menuItem.getText()+"\n\tv=" * +viewRect+"\n\tc="+checkIconRect+"\n\ti=" * +iconRect+"\n\tt="+textRect+"\n\tacc=" * +acceleratorRect+"\n\ta="+arrowIconRect+"\n"); */ return text; } /* * Returns false if the component is a JMenu and it is a top level menu (on * the menubar). */ private static boolean useCheckAndArrow(JMenuItem menuItem) { boolean b = true; if ((menuItem instanceof JMenu) && (((JMenu) menuItem).isTopLevelMenu())) { b = false; } return b; } private static JComponent getMenuItemParent(JMenuItem mi) { Container parent = mi.getParent(); if ((parent instanceof JComponent) && (!(mi instanceof JMenu) || !((JMenu) mi).isTopLevelMenu())) { return (JComponent) parent; } else { return null; } } /** * Paints the specified menu item. * * @param g * Graphics context. * @param menuItem * Menu item. * @param checkIcon * Check icon. * @param arrowIcon * Arrow icon. * @param defaultTextIconGap * Gap between the icon and the text. */ public static void paintMenuItem(Graphics g, JMenuItem menuItem, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { if (!SubstanceLookAndFeel.isCurrentLookAndFeel()) return; Graphics2D g2d = (Graphics2D) g.create(); // special handling of menu items covered by lightweight popups // for the defect 297 if (Boolean.TRUE .equals(menuItem .getClientProperty(SubstanceCoreUtilities.IS_COVERED_BY_LIGHTWEIGHT_POPUPS))) { JRootPane rootPane = SwingUtilities.getRootPane(menuItem); if (rootPane != null) { Component[] popups = rootPane.getLayeredPane() .getComponentsInLayer(JLayeredPane.POPUP_LAYER); if (popups != null) { int popupIndexToStartWith = SubstanceCoreUtilities .getPopupParentIndexOf(menuItem, popups) - 1; Area clip = new Area(g2d.getClip()); for (int i = popupIndexToStartWith; i >= 0; i--) { Component popup = popups[i]; // convert the popup bounds to the menu item coordinate // system Rectangle popupArea = SwingUtilities.convertRectangle( rootPane.getLayeredPane(), popup.getBounds(), menuItem); // and subtract this area from the clip clip.subtract(new Area(popupArea)); } // at this point we have the original clip minus // all the overlapping lightweight popups that are painted // after this menu item g2d.setClip(clip); } } } ButtonModel model = menuItem.getModel(); SubstanceMenu menuUi = (SubstanceMenu) menuItem.getUI(); Font f = menuItem.getFont(); g2d.setFont(f); // get Accelerator text KeyStroke accelerator = menuItem.getAccelerator(); String acceleratorText = ""; if (accelerator != null) { int modifiers = accelerator.getModifiers(); if (modifiers > 0) { acceleratorText = KeyEvent.getKeyModifiersText(modifiers); acceleratorText += UIManager .getString("MenuItem.acceleratorDelimiter"); } int keyCode = accelerator.getKeyCode(); if (keyCode != 0) { acceleratorText += KeyEvent.getKeyText(keyCode); } else { acceleratorText += accelerator.getKeyChar(); } } Icon icon = menuItem.getIcon(); // MenuLayoutInfo mli = MenuUtilities.getMenuLayoutInfo(menuItem, menuUi // .getAcceleratorFont(), menuUi.getCheckIcon(), menuUi // .getArrowIcon(), menuUi.getDefaultTextIconGap()); MenuLayoutInfo mli = MenuUtilities.getMenuLayoutInfo(true, menuItem, menuUi.getAcceleratorFont(), menuUi.getCheckIcon(), menuUi .getArrowIcon(), menuUi.getDefaultTextIconGap()); MenuLayoutMetrics popupMetrics = MenuUtilities.getPopupLayoutMetrics( menuItem, true); Insets i = menuItem.getInsets(); if (popupMetrics != null) { MenuGutterFillKind gutterFillKind = SubstanceCoreUtilities .getMenuGutterFillKind(); boolean needExtraIconTextGap = (gutterFillKind != null) && (gutterFillKind != MenuGutterFillKind.NONE); int gap = popupMetrics.maxIconTextGap; if (menuItem.getComponentOrientation().isLeftToRight()) { int currX = i.left + gap / 2; if (checkIcon != null) { mli.checkIconRect = new Rectangle(currX, i.top, checkIcon .getIconWidth(), checkIcon.getIconHeight()); int bump = (popupMetrics.maxCheckIconWidth - checkIcon .getIconWidth()) / 2; mli.checkIconRect.x += bump; } if (popupMetrics.maxCheckIconWidth > 0) { currX += (popupMetrics.maxCheckIconWidth + gap); } if (icon != null) { mli.iconRect = new Rectangle(currX, i.top, icon .getIconWidth(), icon.getIconHeight()); int bump = (popupMetrics.maxIconWidth - icon.getIconWidth()) / 2; mli.iconRect.x += bump; } if (popupMetrics.maxIconWidth > 0) { currX += (popupMetrics.maxIconWidth + gap); } menuItem.putClientProperty(GUTTER_X, currX + gap / 2); if (needExtraIconTextGap) currX += gap; if (menuItem.getText() != null) { mli.textRect = new Rectangle(currX, mli.textRect.y, popupMetrics.maxTextWidth, mli.textRect.height); mli.text = menuItem.getText(); } currX += (popupMetrics.maxTextWidth + gap); if (popupMetrics.maxAcceleratorWidth > 0) { currX += 5 * gap; // accelerator text is right-aligned mli.acceleratorRect = new Rectangle(currX + popupMetrics.maxAcceleratorWidth - mli.acceleratorRect.width, mli.textRect.y, mli.acceleratorRect.width, mli.textRect.height); } if (popupMetrics.maxAcceleratorWidth > 0) { currX += (popupMetrics.maxAcceleratorWidth + gap); } if (arrowIcon != null) { mli.arrowIconRect = new Rectangle(currX, i.top, popupMetrics.maxArrowIconWidth, arrowIcon .getIconHeight()); } Rectangle labelRect = new Rectangle(0, 0, menuItem.getWidth(), menuItem.getHeight()); if (mli.textRect != null) labelRect = mli.textRect; if (mli.iconRect != null) { mli.iconRect.y = labelRect.y + (labelRect.height / 2) - (mli.iconRect.height / 2); } if (mli.arrowIconRect != null) { mli.arrowIconRect.y = labelRect.y + (labelRect.height / 2) - (mli.arrowIconRect.height / 2); } if (mli.checkIconRect != null) { mli.checkIconRect.y = labelRect.y + (labelRect.height / 2) - (mli.checkIconRect.height / 2); } } else { int currX = menuItem.getWidth() - i.right - gap / 2; if (checkIcon != null) { mli.checkIconRect = new Rectangle(currX - popupMetrics.maxCheckIconWidth, i.top, checkIcon .getIconWidth(), checkIcon.getIconHeight()); int bump = (popupMetrics.maxCheckIconWidth - checkIcon .getIconWidth()) / 2; mli.checkIconRect.x += bump; } if (popupMetrics.maxCheckIconWidth > 0) { currX -= (popupMetrics.maxCheckIconWidth + gap); } if (icon != null) { // icons are center-aligned mli.iconRect = new Rectangle(currX - popupMetrics.maxIconWidth, i.top, icon .getIconWidth(), icon.getIconHeight()); int bump = (popupMetrics.maxIconWidth - icon.getIconWidth()) / 2; mli.iconRect.x += bump; } if (popupMetrics.maxIconWidth > 0) { currX -= (popupMetrics.maxIconWidth + gap); } menuItem.putClientProperty(GUTTER_X, currX + gap / 2); if (needExtraIconTextGap) currX -= gap; if (menuItem.getText() != null) { // text is right-aligned mli.textRect = new Rectangle(currX - mli.textRect.width, mli.textRect.y, popupMetrics.maxTextWidth, mli.textRect.height); mli.text = menuItem.getText(); } currX -= (popupMetrics.maxTextWidth + gap); if (popupMetrics.maxAcceleratorWidth > 0) { currX -= 5 * gap; // accelerator text is left-aligned mli.acceleratorRect = new Rectangle(currX - popupMetrics.maxAcceleratorWidth, mli.textRect.y, mli.acceleratorRect.width, mli.textRect.height); } if (popupMetrics.maxAcceleratorWidth > 0) { currX -= (popupMetrics.maxAcceleratorWidth + gap); } if (arrowIcon != null) { mli.arrowIconRect = new Rectangle(currX - popupMetrics.maxArrowIconWidth, i.top, popupMetrics.maxArrowIconWidth, arrowIcon .getIconHeight()); } Rectangle labelRect = new Rectangle(0, 0, menuItem.getWidth(), menuItem.getHeight()); if (mli.textRect != null) labelRect = mli.textRect; if (mli.iconRect != null) { mli.iconRect.y = labelRect.y + (labelRect.height / 2) - (mli.iconRect.height / 2); } if (mli.arrowIconRect != null) { mli.arrowIconRect.y = labelRect.y + (labelRect.height / 2) - (mli.arrowIconRect.height / 2); } if (mli.checkIconRect != null) { mli.checkIconRect.y = labelRect.y + (labelRect.height / 2) - (mli.checkIconRect.height / 2); } } } menuItem.putClientProperty(LAYOUT_INFO, mli); Component parent = menuItem.getParent(); if (parent instanceof JPopupMenu) { ((JPopupMenu) parent).putClientProperty(GUTTER_X, menuItem .getClientProperty(GUTTER_X)); } paintBackground(g2d, menuItem); paintHighlights(g2d, menuItem); Graphics2D graphics = (Graphics2D) g2d.create(); if (mli.text != null) { View v = (View) menuItem.getClientProperty(BasicHTML.propertyKey); if (v != null) { v.paint(graphics, mli.textRect); } else { SubstanceTextUtilities.paintText(graphics, menuItem, mli.textRect, mli.text, menuItem .getDisplayedMnemonicIndex()); } } // Draw the Accelerator Text if (acceleratorText != null && !acceleratorText.equals("")) { SubstanceTextUtilities.paintText(graphics, menuItem, mli.acceleratorRect, acceleratorText, -1); } float textAlpha = SubstanceColorSchemeUtilities.getAlpha(menuItem, ComponentState.getState(menuItem.getModel(), menuItem, true)); graphics.setComposite(TransitionLayout.getAlphaComposite(menuItem, textAlpha, g2d)); // Paint the Check if (checkIcon != null) { if (useCheckAndArrow(menuItem)) checkIcon.paintIcon(menuItem, graphics, mli.checkIconRect.x, mli.checkIconRect.y); } // Paint the Icon if (icon != null) { if (!model.isEnabled()) { icon = menuItem.getDisabledIcon(); } else if (model.isPressed() && model.isArmed()) { icon = menuItem.getPressedIcon(); if (icon == null) { // Use default icon icon = menuItem.getIcon(); } } else { icon = menuItem.getIcon(); } if (icon != null) { boolean useThemed = SubstanceCoreUtilities .useThemedDefaultIcon(); if (!useThemed) { icon.paintIcon(menuItem, g2d, mli.iconRect.x, mli.iconRect.y); } else { Icon themed = SubstanceCoreUtilities.getThemedIcon( menuItem, icon); boolean useRegularVersion = model.isPressed() || model.isSelected(); if (useRegularVersion) { icon.paintIcon(menuItem, g2d, mli.iconRect.x, mli.iconRect.y); } else { FadeState state = SubstanceFadeUtilities.getFadeState( menuItem, FadeKind.ARM, FadeKind.ROLLOVER); if (state != null) { float alpha = state.getFadePosition(); themed.paintIcon(menuItem, g2d, mli.iconRect.x, mli.iconRect.y); g2d.setComposite(TransitionLayout .getAlphaComposite(menuItem, alpha, g)); // System.out.println("Themed to regular at " + // alpha); icon.paintIcon(menuItem, g2d, mli.iconRect.x, mli.iconRect.y); g2d.setComposite(TransitionLayout .getAlphaComposite(menuItem, g)); } else { if (model.isRollover() || model.isArmed()) { icon.paintIcon(menuItem, g2d, mli.iconRect.x, mli.iconRect.y); } else { themed.paintIcon(menuItem, g2d, mli.iconRect.x, mli.iconRect.y); } } } } } } // Paint the Arrow if (arrowIcon != null) { if (useCheckAndArrow(menuItem)) arrowIcon.paintIcon(menuItem, graphics, mli.arrowIconRect.x, mli.arrowIconRect.y); } graphics.dispose(); // g2d.setColor(Color.red); // if (mli.iconRect != null) // g2d.draw(mli.iconRect); // if (mli.checkIconRect != null) // g2d.draw(mli.checkIconRect); // if (mli.textRect != null) // g2d.draw(mli.textRect); // g2d.setColor(Color.red); // g2d.drawRect(mli.checkIconRect.x, mli.checkIconRect.y, // mli.checkIconRect.width, mli.checkIconRect.height); // g2d.drawRect(mli.iconRect.x, mli.iconRect.y, mli.iconRect.width, // mli.iconRect.height); // g2d.drawRect(mli.textRect.x, mli.textRect.y, mli.textRect.width, // mli.textRect.height); // g2d.drawRect(mli.arrowIconRect.x, mli.arrowIconRect.y, // mli.arrowIconRect.width, mli.arrowIconRect.height); // g2d.drawRect(mli.acceleratorRect.x, mli.acceleratorRect.y, // mli.acceleratorRect.width, mli.acceleratorRect.height); g2d.dispose(); } /** * Paints the background of the specified menu item. * * @param g * Graphics context. * @param menuItem * Menu item. */ private static void paintBackground(Graphics g, JMenuItem menuItem) { int textOffset = MenuUtilities.getTextOffset(menuItem, menuItem .getParent()); SubstanceMenuBackgroundDelegate .paintBackground(g, menuItem, textOffset); } /** * Paints the highlights of the specified menu item. * * @param g * Graphics context. * @param menuItem * Menu item. */ private static void paintHighlights(Graphics g, JMenuItem menuItem) { SubstanceMenuBackgroundDelegate.paintHighlights(g, menuItem, 0.5f); } /** * Returns the layout metrics of the specified popup menu. * * @param popupMenu * Popup menu. * @return Layout metrics of the specified popup menu. */ protected static MenuLayoutMetrics getMetrics(JPopupMenu popupMenu, boolean forPainting) { MenuLayoutMetrics metrics = new MenuLayoutMetrics(); for (int i = 0; i < popupMenu.getComponentCount(); i++) { Component comp = popupMenu.getComponent(i); if (comp instanceof JMenuItem) { JMenuItem childMenuItem = (JMenuItem) comp; ButtonUI bui = childMenuItem.getUI(); if (!(bui instanceof SubstanceMenu)) continue; SubstanceMenu ui = (SubstanceMenu) bui; MenuLayoutInfo mli = MenuUtilities.getMenuLayoutInfo( forPainting, childMenuItem, ui.getAcceleratorFont(), ui .getCheckIcon(), ui.getArrowIcon(), ui .getDefaultTextIconGap()); metrics.maxIconWidth = Math.max(metrics.maxIconWidth, mli.iconRect.width); metrics.maxCheckIconWidth = Math.max(metrics.maxCheckIconWidth, mli.checkIconRect.width); metrics.maxTextWidth = Math.max(metrics.maxTextWidth, mli.textRect.width); metrics.maxAcceleratorWidth = Math.max( metrics.maxAcceleratorWidth, mli.acceleratorRect.width); metrics.maxArrowIconWidth = Math.max(metrics.maxArrowIconWidth, mli.arrowIconRect.width); metrics.maxIconTextGap = Math.max(metrics.maxIconTextGap, ui .getDefaultTextIconGap()); } } return metrics; } /** * Returns the layout metrics of the popup menu of the specified menu item. * * @param menuItem * Menu item. * @return Layout metrics of the popup menu of the specified menu item. */ public static MenuLayoutMetrics getPopupLayoutMetrics(JMenuItem menuItem, boolean forPainting) { Component comp = menuItem.getParent(); if (comp instanceof JPopupMenu) { JPopupMenu popupMenu = (JPopupMenu) comp; return getPopupLayoutMetrics(popupMenu, forPainting); } // fix for issue 347 - menu item in menu bar is not // covered by the code above if (!(comp instanceof JMenu)) { ButtonUI bui = menuItem.getUI(); if (bui instanceof SubstanceMenu) { SubstanceMenu ui = (SubstanceMenu) bui; MenuLayoutInfo mli = MenuUtilities.getMenuLayoutInfo( forPainting, menuItem, ui.getAcceleratorFont(), ui .getCheckIcon(), ui.getArrowIcon(), ui .getDefaultTextIconGap()); MenuLayoutMetrics metrics = new MenuLayoutMetrics(); metrics.maxIconWidth = mli.iconRect.width; metrics.maxCheckIconWidth = mli.checkIconRect.width; metrics.maxTextWidth = mli.textRect.width; metrics.maxAcceleratorWidth = mli.acceleratorRect.width; metrics.maxArrowIconWidth = mli.arrowIconRect.width; metrics.maxIconTextGap = ui.getDefaultTextIconGap(); return metrics; } } // If here, the parent is not popup menu - this is a top-level menu // in a menu bar. No need to align the different rectangles return null; } public static MenuLayoutMetrics getPopupLayoutMetrics(JPopupMenu popupMenu, boolean forPainting) { Object prop = popupMenu.getClientProperty(LAYOUT_METRICS); if (prop instanceof MenuLayoutMetrics) { return (MenuLayoutMetrics) prop; } MenuLayoutMetrics metrics = getMetrics(popupMenu, forPainting); popupMenu.putClientProperty(LAYOUT_METRICS, metrics); return metrics; } /** * Cleans the layout metrics of the popup menu of the specified menu item. * * @param menuItem * Menu item. */ private static void cleanPopupLayoutMetrics(JMenuItem menuItem) { Component comp = menuItem.getParent(); if (comp instanceof JPopupMenu) { JPopupMenu popupMenu = (JPopupMenu) comp; cleanPopupLayoutMetrics(popupMenu); } } /** * Cleans the layout metrics of the specified popup menu. * * @param popupMenu * Popup menu. */ public static void cleanPopupLayoutMetrics(JPopupMenu popupMenu) { if (popupMenu != null) { popupMenu.putClientProperty(LAYOUT_METRICS, null); } } /** * Returns the preferred width of the specified menu item. The preferred * width depends on the layout metrics of the entire popup menu of this menu * item. * * @param menuItem * Menu item. * @return Preferred width of the specified menu item */ public static int getPreferredWidth(JMenuItem menuItem) { Insets ins = menuItem.getInsets(); MenuLayoutMetrics popupMetrics = MenuUtilities.getPopupLayoutMetrics( menuItem, false); int width = popupMetrics.maxCheckIconWidth + popupMetrics.maxIconWidth + popupMetrics.maxTextWidth + popupMetrics.maxAcceleratorWidth + popupMetrics.maxArrowIconWidth + ins.left + ins.right; int gapsToAdd = 0; if (popupMetrics.maxCheckIconWidth > 0) gapsToAdd++; if (popupMetrics.maxIconWidth > 0) gapsToAdd++; if (popupMetrics.maxAcceleratorWidth > 0) gapsToAdd++; if (popupMetrics.maxArrowIconWidth > 0) gapsToAdd++; int gap = popupMetrics.maxIconTextGap; width += ((1 + gapsToAdd) * gap); if (popupMetrics.maxAcceleratorWidth > 0) { // at least one menu item has accelerator text width += 5 * gap; } MenuGutterFillKind gutterFillKind = SubstanceCoreUtilities .getMenuGutterFillKind(); boolean needExtraIconTextGap = (gutterFillKind != null) && (gutterFillKind != MenuGutterFillKind.NONE); if (needExtraIconTextGap) width += gap; return width; } /** * Returns the text offset of the specified menu item. * * @param menuItem * Menu item. * @param menuItemParent * Menu item parent. * @return Text offset of the specified menu item. */ public static int getTextOffset(JComponent menuItem, Component menuItemParent) { if (!(menuItemParent instanceof JPopupMenu)) { return 0; } Object itemProp = menuItem.getClientProperty(GUTTER_X); if (itemProp instanceof Integer) { return (Integer) itemProp; } JPopupMenu popupMenu = (JPopupMenu) menuItemParent; Object parentProp = popupMenu.getClientProperty(GUTTER_X); if (parentProp instanceof Integer) { return (Integer) parentProp; } return 0; } } substance-5.3.orig/src/org/jvnet/substance/utils/menu/SubstanceMenu.java0000644000175000017500000000606511136475562026442 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.menu; import java.awt.Font; import javax.swing.Icon; import javax.swing.JMenuItem; /** * Base interface for all menu-related UI delegates. * * @author Kirill Grouchnikov */ public interface SubstanceMenu { /** * Name for internal client property that holds the cached text offset. */ // public static final String SINGLE_MENU_TEXT_OFFSET = // "substancelaf.internal.singleMenuTextOffset"; /** * Returns the font of the accelerator string of this UI * delegate. * * @return The font of the accelerator string of this UI * delegate. */ public Font getAcceleratorFont(); /** * Returns the checkmark icon of this UI delegate. * * @return The checkmark icon of this UI delegate. */ public Icon getCheckIcon(); /** * Returns the arrow icon of this UI delegate. * * @return The arrow icon of this UI delegate. */ public Icon getArrowIcon(); /** * Returns the default gap between the icon and the text for * this delegate. * * @return The default gap between the icon and the text for * this delegate. */ public int getDefaultTextIconGap(); /** * Returns the associated menu item. * * @return The associated menu item. */ public JMenuItem getAssociatedMenuItem(); } substance-5.3.orig/src/org/jvnet/substance/utils/menu/SubstanceMenuBackgroundDelegate.java0000644000175000017500000002235111247417466032073 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.menu; import java.awt.*; import java.awt.MultipleGradientPaint.CycleMethod; import javax.swing.*; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.animation.FadeState; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.SubstanceConstants.MenuGutterFillKind; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.painter.utils.HighlightPainterUtils; import org.jvnet.substance.utils.*; /** * Delegate for painting background of menu items. * * @author Kirill Grouchnikov */ public class SubstanceMenuBackgroundDelegate { /** * Updates the specified menu item with the background that matches the * provided parameters. * * @param g * Graphic context. * @param menuItem * Menu item. * @param bgColor * Current background color. * @param borderAlpha * Border alpha. * @param textOffset * The offset of the menu item text. */ public static void paintBackground(Graphics g, Component menuItem, int textOffset) { if (!menuItem.isShowing()) return; int menuWidth = menuItem.getWidth(); int menuHeight = menuItem.getHeight(); Graphics2D graphics = (Graphics2D) g.create(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); BackgroundPaintingUtils.update(graphics, menuItem, false); if (menuItem.getParent() instanceof JPopupMenu) { if (menuItem.getComponentOrientation().isLeftToRight()) { MenuGutterFillKind fillKind = SubstanceCoreUtilities .getMenuGutterFillKind(); if (fillKind != MenuGutterFillKind.NONE) { SubstanceColorScheme scheme = SubstanceColorSchemeUtilities .getColorScheme(menuItem, ComponentState.DEFAULT); Color leftColor = ((fillKind == MenuGutterFillKind.SOFT_FILL) || (fillKind == MenuGutterFillKind.HARD)) ? scheme .getUltraLightColor() : scheme.getLightColor(); Color rightColor = ((fillKind == MenuGutterFillKind.SOFT_FILL) || (fillKind == MenuGutterFillKind.SOFT)) ? scheme .getUltraLightColor() : scheme.getLightColor(); LinearGradientPaint gp = new LinearGradientPaint(0, 0, textOffset, 0, new float[] { 0.0f, 1.0f }, new Color[] { leftColor, rightColor }, CycleMethod.REPEAT); graphics.setComposite(TransitionLayout.getAlphaComposite( menuItem, 0.7f, g)); // System.out.println(menuItem.getText() // + "[" // + menuItem.isEnabled() // + "] : " // + ((AlphaComposite) graphics.getComposite()) // .getAlpha() + ", " + leftColor + "->" // + rightColor); // graphics.setPaint(gp); graphics.fillRect(0, 0, textOffset - 2, menuHeight); } } else { // fix for defect 125 - support of RTL menus MenuGutterFillKind fillKind = SubstanceCoreUtilities .getMenuGutterFillKind(); if (fillKind != MenuGutterFillKind.NONE) { SubstanceColorScheme scheme = SubstanceColorSchemeUtilities .getColorScheme(menuItem, ComponentState.DEFAULT); Color leftColor = ((fillKind == MenuGutterFillKind.HARD_FILL) || (fillKind == MenuGutterFillKind.HARD)) ? scheme .getLightColor() : scheme.getUltraLightColor(); Color rightColor = ((fillKind == MenuGutterFillKind.HARD_FILL) || (fillKind == MenuGutterFillKind.SOFT)) ? scheme .getLightColor() : scheme.getUltraLightColor(); LinearGradientPaint gp = new LinearGradientPaint( textOffset, 0, menuWidth, 0, new float[] { 0.0f, 1.0f }, new Color[] { leftColor, rightColor }, CycleMethod.REPEAT); graphics.setComposite(TransitionLayout.getAlphaComposite( menuItem, 0.7f, g)); graphics.setPaint(gp); graphics.fillRect(textOffset - 2, 0, menuWidth, menuHeight); } } } // } graphics.dispose(); } /** * Paints menu highlights. * * @param g * Graphics context. * @param menuItem * Menu item. * @param borderAlpha * Alpha channel for painting the border. */ public static void paintHighlights(Graphics g, JMenuItem menuItem, float borderAlpha) { Graphics2D graphics = (Graphics2D) g.create(); ButtonModel model = menuItem.getModel(); // int menuWidth = menuItem.getWidth(); // int menuHeight = menuItem.getHeight(); ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(menuItem); ComponentState currState = ComponentState.getState(model, menuItem, !(menuItem instanceof JMenu)); // Compute the alpha values for the animation (the highlights // have separate alpha channels, so that rollover animation can start // from 0.0 alpha and goes to 0.4 alpha on non-selected cells, // but on selected cells can go from 0.7 to 0.9). We need to respect // these border values for proper visual transitions float startAlpha = SubstanceColorSchemeUtilities.getHighlightAlpha( menuItem, prevState); float endAlpha = SubstanceColorSchemeUtilities.getHighlightAlpha( menuItem, currState); FadeState state = SubstanceFadeUtilities.getFadeState(menuItem, FadeKind.SELECTION, FadeKind.ARM, FadeKind.ROLLOVER); float fadeCoef = 0.0f; float totalAlpha = endAlpha; if (state != null) { fadeCoef = state.getFadePosition(); // compute the total alpha of the overlays. if (state.isFadingIn()) { totalAlpha = startAlpha + (endAlpha - startAlpha) * fadeCoef; } else { totalAlpha = startAlpha + (endAlpha - startAlpha) * (1.0f - fadeCoef); } if (state.isFadingIn()) fadeCoef = 1.0f - fadeCoef; // System.out.println(menuItem.getText() + " from " + // prevState.name() // + "[" + alphaForPrevBackground + "] to " + currState.name() // + "[" + alphaForCurrBackground + "] at " + fadeCoef); // System.out.println("From " + prevScheme.getDisplayName() + // " to :" // + currScheme.getDisplayName()); } // System.out.println(menuItem.getText() + "[" + currState.name() + "]:" // + prevScheme.getDisplayName() + "[" + alphaForPrevBackground // + "]:" + currScheme.getDisplayName() + "[" // + alphaForCurrBackground + "]"); // System.out.println("ARM:" + menuItem.getModel().isArmed() + ", ENA:" // + menuItem.getModel().isEnabled() + ", PRE:" // + menuItem.getModel().isPressed() + ", ROL:" // + menuItem.getModel().isRollover() + ", SEL:" // + menuItem.getModel().isSelected()); // fix for defect 103 - no rollover effects on menu items // that are not in the selected menu path MenuElement[] selectedMenuPath = MenuSelectionManager.defaultManager() .getSelectedPath(); boolean isRollover = (selectedMenuPath.length == 0); for (MenuElement elem : selectedMenuPath) { if (elem == menuItem) { isRollover = true; break; } } isRollover = isRollover && model.isRollover(); boolean hasHighlight = (state != null) || model.isArmed() || isRollover || ((menuItem instanceof JMenu) && model.isSelected()); if (hasHighlight && (totalAlpha > 0.0f)) { graphics.setComposite(TransitionLayout.getAlphaComposite(menuItem, totalAlpha, g)); HighlightPainterUtils.paintHighlight(graphics, null, menuItem, new Rectangle(0, 0, menuItem.getWidth(), menuItem .getHeight()), borderAlpha, null, currState, prevState, fadeCoef); graphics.setComposite(TransitionLayout.getAlphaComposite(menuItem, g)); } graphics.dispose(); } } substance-5.3.orig/src/org/jvnet/substance/utils/SoftHashMap.java0000644000175000017500000001104011136475562025064 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.io.Serializable; import java.lang.ref.*; import java.util.*; /** * This implementation is taken from The Java * Specialists' Newsletter [Issue 098] with permission of the original * author. * * @author Dr. Heinz M. Kabutz */ class SoftHashMap extends AbstractMap implements Serializable { /** The internal HashMap that will hold the SoftReference. */ private final Map> hash = new HashMap>(); private final Map, K> reverseLookup = new HashMap, K>(); /** Reference queue for cleared SoftReference objects. */ private final ReferenceQueue queue = new ReferenceQueue(); @Override public V get(Object key) { expungeStaleEntries(); V result = null; // We get the SoftReference represented by that key SoftReference soft_ref = hash.get(key); if (soft_ref != null) { // From the SoftReference we get the value, which can be // null if it has been garbage collected result = soft_ref.get(); if (result == null) { // If the value has been garbage collected, remove the // entry from the HashMap. hash.remove(key); reverseLookup.remove(soft_ref); } } return result; } private void expungeStaleEntries() { Reference sv; while ((sv = queue.poll()) != null) { hash.remove(reverseLookup.remove(sv.get())); } } @Override public V put(K key, V value) { expungeStaleEntries(); SoftReference soft_ref = new SoftReference(value, queue); reverseLookup.put(soft_ref, key); SoftReference result = hash.put(key, soft_ref); if (result == null) return null; return result.get(); } @Override public V remove(Object key) { expungeStaleEntries(); SoftReference result = hash.remove(key); if (result == null) return null; return result.get(); } @Override public void clear() { hash.clear(); reverseLookup.clear(); } @Override public int size() { expungeStaleEntries(); return hash.size(); } /** * Returns a copy of the key/values in the map at the point of calling. * However, setValue still sets the value in the actual SoftHashMap. */ @Override public Set> entrySet() { expungeStaleEntries(); Set> result = new LinkedHashSet>(); for (final Entry> entry : hash.entrySet()) { final V value = entry.getValue().get(); if (value != null) { result.add(new Entry() { public K getKey() { return entry.getKey(); } public V getValue() { return value; } public V setValue(V v) { entry.setValue(new SoftReference(v, queue)); return value; } }); } } return result; } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceFadeUtilities.java0000644000175000017500000001441711136475562027325 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.Component; import java.util.Set; import org.jvnet.lafwidget.animation.*; /** * Fade-related utilities. * * @author Kirill Grouchnikov. */ public class SubstanceFadeUtilities { /** * Returns the component that is being tracked by the {@link FadeTracker} * with the highest value of the fade cycle. * * @param fadeKind * Fade kind. * @param comps * Components. * @return The component that is being tracked by the {@link FadeTracker} * with the highest value of the fade cycle. May be * null. */ public static Component getTracked(FadeKind fadeKind, Component... comps) { FadeTracker tracker = FadeTracker.getInstance(); Component result = null; float highest = -1.0f; for (Component comp : comps) { if (tracker.isTracked(comp, fadeKind)) { float fade = tracker.getFade(comp, fadeKind); if (fade > highest) { result = comp; highest = fade; } } } return result; } /** * Returns the highest fade cycle for the specified component and the fade * kind. * * @param fadeKind * Fade kind. * @param comps * Components. * @return The highest fade cycle for the specified component and the fade * kind. */ public static FadeState getFadeStateWithHighestFadeCycle(FadeKind fadeKind, Component... comps) { FadeTracker tracker = FadeTracker.getInstance(); FadeState result = null; float highest = -1.0f; for (Component comp : comps) { FadeState curr = tracker.getFadeState(comp, fadeKind); if (curr != null) { if (curr.getFadePosition() > highest) { result = curr; highest = curr.getFadePosition(); } } } return result; } /** * Returns the first matching fade state for the specified component. * * @param comp * Component. * @param fadeKinds * A list of fade kinds. The list is scanned from the start. The * first fade kind that is currently "happening" on the specified * component will be used to fetch the fade state. * @return The first matching fade state for the specified component. */ public static FadeState getFadeState(Component comp, FadeKind... fadeKinds) { FadeTracker tracker = FadeTracker.getInstance(); for (FadeKind fadeKind : fadeKinds) { FadeState result = tracker.getFadeState(comp, fadeKind); if (result != null) return result; } return null; } /** * Returns the first matching fade state for the specified component. * * @param comp * Component. * @param comparable * Identifier of a sub-entity. * @param fadeKinds * A list of fade kinds. The list is scanned from the start. The * first fade kind that is currently "happening" on the specified * component will be used to fetch the fade state. * @return The first matching fade state for the specified component. */ public static FadeState getFadeState(Component comp, Comparable comparable, FadeKind... fadeKinds) { FadeTracker tracker = FadeTracker.getInstance(); for (FadeKind fadeKind : fadeKinds) { FadeState result = tracker.getFadeState(comp, comparable, fadeKind); if (result != null) return result; } return null; } /** * Returns the first matching fade state for the specified component. * * @param comp * Component. * @param comparables * Identifiers of sub-entities. * @param fadeKinds * Fade kinds. The list is scanned from the start. The first fade * kind that is currently "happening" on the specified component * will be used to fetch the fade state. * @return The first matching fade state for the specified component. */ public static FadeState getFadeState(Component comp, Comparable[] comparables, FadeKind[] fadeKinds) { FadeTracker tracker = FadeTracker.getInstance(); for (FadeKind fadeKind : fadeKinds) { for (Comparable comparable : comparables) { FadeState result = tracker.getFadeState(comp, comparable, fadeKind); if (result != null) return result; } } return null; } /** * Cancels the specified fade sequences. * * @param initiatedFadeSequences * Fade sequence IDs to cancel. */ public static void cancelFades(Set initiatedFadeSequences) { FadeTracker fadeTrackerInstance = FadeTracker.getInstance(); for (long fadeId : initiatedFadeSequences) { fadeTrackerInstance.cancelFadeInstance(fadeId); } } } substance-5.3.orig/src/org/jvnet/substance/utils/icon/0000755000175000017500000000000011256731152022771 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/utils/icon/TransitionAwareIcon.java0000644000175000017500000002350711244733120027560 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.icon; import java.awt.*; import java.awt.image.BufferedImage; import javax.swing.*; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.animation.FadeState; import org.jvnet.substance.api.*; import org.jvnet.substance.utils.*; /** * Icon with transition-aware capabilities. Has a delegate that does the actual * painting based on the transition color schemes. This class is used heavily on * Substance-provided icons, such as title pane button icons, arrow icons on * scroll bars and combos etc. * * @author Kirill Grouchnikov */ @TransitionAware public class TransitionAwareIcon implements Icon { /** * The delegate needs to implement the method in this interface based on the * provided color scheme. The color scheme is computed based on the * transitions that are happening on the associated button. * * @author Kirill Grouchnikov */ public static interface Delegate { /** * Returns the icon that matches the specified scheme. * * @param scheme * Color scheme. * @return Icon that matches the specified scheme. */ public Icon getColorSchemeIcon(SubstanceColorScheme scheme); } public static interface ColorSchemeAssociationKindDelegate { public ColorSchemeAssociationKind getColorSchemeAssociationKind( ComponentState state); } /** * The associated component. */ private JComponent comp; /** * The associated model. */ private ButtonModel model; /** * Delegate to compute the actual icons. */ protected Delegate delegate; protected ColorSchemeAssociationKindDelegate colorSchemeAssociationKindDelegate; protected String uniqueIconTypeId; /** * Icon cache to speed up the subsequent icon painting. The basic assumption * is that the {@link #delegate} returns an icon that paints the same for * the same parameters. */ private static LazyResettableHashMap iconMap = new LazyResettableHashMap( "TransitionAwareIcon"); private int iconWidth; private int iconHeight; /** * Creates a new transition-aware icon. * * @param button * Associated button. * @param delegate * Delegate to compute the actual icons. */ public TransitionAwareIcon(AbstractButton button, Delegate delegate, String uniqueIconTypeId) { this(button, (button == null) ? null : button.getModel(), delegate, uniqueIconTypeId); } /** * Creates a new transition-aware icon. * * @param comp * Associated component. * @param model * Associated model. * @param delegate * Delegate to compute the actual icons. */ public TransitionAwareIcon(JComponent comp, ButtonModel model, Delegate delegate, String uniqueIconTypeId) { this(comp, model, delegate, null, uniqueIconTypeId); } /** * Creates a new transition-aware icon. * * @param comp * Associated component. * @param model * Associated model. * @param delegate * Delegate to compute the actual icons. */ public TransitionAwareIcon( JComponent comp, ButtonModel model, Delegate delegate, ColorSchemeAssociationKindDelegate colorSchemeAssociationKindDelegate, String uniqueIconTypeId) { this.comp = comp; this.model = model; this.delegate = delegate; this.colorSchemeAssociationKindDelegate = colorSchemeAssociationKindDelegate; this.uniqueIconTypeId = uniqueIconTypeId; this.iconWidth = this.delegate.getColorSchemeIcon( SubstanceColorSchemeUtilities .getColorScheme(comp, ColorSchemeAssociationKind.MARK, ComponentState.DEFAULT)).getIconWidth(); this.iconHeight = this.delegate.getColorSchemeIcon( SubstanceColorSchemeUtilities .getColorScheme(comp, ColorSchemeAssociationKind.MARK, ComponentState.DEFAULT)).getIconHeight(); } /** * Returns the current icon to paint. * * @return Icon to paint. */ private Icon getIconToPaint() { ComponentState currState = ComponentState.getState(this.model, this.comp); ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(this.comp); if (!currState.isKindActive(FadeKind.ENABLE)) prevState = currState; float cyclePos = currState.getCyclePosition(); ColorSchemeAssociationKind currColorSchemeAssociationKind = (this.colorSchemeAssociationKindDelegate == null) ? ColorSchemeAssociationKind.MARK : this.colorSchemeAssociationKindDelegate .getColorSchemeAssociationKind(currState); SubstanceColorScheme currScheme = SubstanceColorSchemeUtilities .getColorScheme(this.comp, currColorSchemeAssociationKind, currState); SubstanceColorScheme prevScheme = currScheme; FadeState fadeState = SubstanceFadeUtilities.getFadeState(this.comp, FadeKind.ROLLOVER, FadeKind.SELECTION, FadeKind.PRESS, FadeKind.ARM); if (fadeState != null) { ColorSchemeAssociationKind prevColorSchemeAssociationKind = (this.colorSchemeAssociationKindDelegate == null) ? ColorSchemeAssociationKind.MARK : this.colorSchemeAssociationKindDelegate .getColorSchemeAssociationKind(prevState); prevScheme = SubstanceColorSchemeUtilities.getColorScheme( this.comp, prevColorSchemeAssociationKind, prevState); cyclePos = fadeState.getFadePosition(); if (!fadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; } float currAlpha = SubstanceColorSchemeUtilities.getAlpha(this.comp, currState); float prevAlpha = SubstanceColorSchemeUtilities.getAlpha(this.comp, prevState); HashMapKey key = SubstanceCoreUtilities.getHashKey( this.uniqueIconTypeId, SubstanceSizeUtils .getComponentFontSize(this.comp), currScheme .getDisplayName(), prevScheme.getDisplayName(), currAlpha, prevAlpha, cyclePos); // System.out.println(key); if (!iconMap.containsKey(key)) { Icon icon = this.delegate.getColorSchemeIcon(currScheme); Icon prevIcon = this.delegate.getColorSchemeIcon(prevScheme); BufferedImage temp = SubstanceCoreUtilities.getBlankImage(icon .getIconWidth(), icon.getIconHeight()); Graphics2D g2d = temp.createGraphics(); if (currScheme == prevScheme) { // same color scheme - can paint just the current icon, no // matter what the cycle position is. g2d.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, currAlpha)); icon.paintIcon(this.comp, g2d, 0, 0); } else { // make optimizations for limit values of the cycle position. if (cyclePos < 1.0f) { g2d.setComposite(AlphaComposite.SrcOver.derive(prevAlpha)); prevIcon.paintIcon(this.comp, g2d, 0, 0); } if (cyclePos > 0.0f) { g2d.setComposite(AlphaComposite.SrcOver.derive(currAlpha * cyclePos)); icon.paintIcon(this.comp, g2d, 0, 0); } } iconMap.put(key, new ImageIcon(temp)); g2d.dispose(); } Icon result = iconMap.get(key); // if (result.getIconHeight() != this.getIconHeight()) // throw new IllegalStateException("Component " // + comp.getClass().getSimpleName() + "[@" + comp.hashCode() // + "] in " + comp.getParent().getClass().getSimpleName() // + "[@" + comp.getParent().hashCode() // + "] - unexpected height mismatch : " // + result.getIconHeight() + ":" + this.getIconHeight()); // if (result.getIconWidth() != this.getIconWidth()) // throw new IllegalStateException("Component " // + comp.getClass().getSimpleName() + "[@" + comp.hashCode() // + "] in " + comp.getParent().getClass().getSimpleName() // + "[@" + comp.getParent().hashCode() // + "] - unexpected width mismatch : " // + result.getIconWidth() + ":" + this.getIconWidth()); return result; } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconHeight() */ public int getIconHeight() { return this.iconHeight; } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconWidth() */ public int getIconWidth() { return this.iconWidth; } /* * (non-Javadoc) * * @see javax.swing.Icon#paintIcon(java.awt.Component, java.awt.Graphics, * int, int) */ public void paintIcon(Component c, Graphics g, int x, int y) { this.getIconToPaint().paintIcon(c, g, x, y); } } substance-5.3.orig/src/org/jvnet/substance/utils/icon/MenuArrowIcon.java0000644000175000017500000000603011162645226026365 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.icon; import java.awt.Component; import java.awt.Graphics; import javax.swing.*; import javax.swing.plaf.UIResource; /** * Icon for the cascading {@link JMenu}s. * * @author Kirill Grouchnikov */ public class MenuArrowIcon implements Icon, UIResource { /** * Icon for left-to-right {@link JMenu}s. */ private Icon ltrIcon; /** * Icon for right-to-left {@link JMenu}s. */ private Icon rtlIcon; /** * Creates the arrow icon for the specified menu. * * @param menu * Menu. */ public MenuArrowIcon(JMenu menu) { this.ltrIcon = new ArrowButtonTransitionAwareIcon(menu, SwingConstants.EAST); this.rtlIcon = new ArrowButtonTransitionAwareIcon(menu, SwingConstants.WEST); } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconHeight() */ public int getIconHeight() { return this.ltrIcon.getIconHeight(); } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconWidth() */ public int getIconWidth() { return this.ltrIcon.getIconWidth(); } /* * (non-Javadoc) * * @see javax.swing.Icon#paintIcon(java.awt.Component, java.awt.Graphics, * int, int) */ public void paintIcon(Component c, Graphics g, int x, int y) { if (c.getComponentOrientation().isLeftToRight()) { this.ltrIcon.paintIcon(c, g, x, y); } else { this.rtlIcon.paintIcon(c, g, x, y); } } } substance-5.3.orig/src/org/jvnet/substance/utils/icon/ArrowButtonTransitionAwareIcon.java0000644000175000017500000001734311174353534032001 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.icon; import java.awt.*; import java.awt.image.BufferedImage; import javax.swing.*; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.animation.FadeState; import org.jvnet.substance.api.*; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.icon.TransitionAwareIcon.Delegate; /** * Transition aware implementation of arrow button icons. Used for implementing * icons of scroll bar buttons, combobox buttons, menus and more. * * @author Kirill Grouchnikov */ @TransitionAware public class ArrowButtonTransitionAwareIcon implements Icon { /** * Icon cache to speed up the subsequent icon painting. The basic assumption * is that the {@link #delegate} returns an icon that paints the same for * the same parameters. */ private static LazyResettableHashMap iconMap = new LazyResettableHashMap( "ButtonArrowTransitionAwareIcon"); /** * Arrow icon orientation. Must be one of {@link SwingConstants#NORTH}, * {@link SwingConstants#SOUTH}, {@link SwingConstants#EAST} or * {@link SwingConstants#WEST}. */ private int orientation; /** * Icon width. */ protected int iconWidth; /** * Icon height. */ protected int iconHeight; /** * Delegate to compute the actual icons. */ protected Delegate delegate; /** * Creates an arrow icon. * * @param button * Arrow button. * @param orientation * Arrow icon orientation. */ public ArrowButtonTransitionAwareIcon(final AbstractButton button, final int orientation) { this.orientation = orientation; this.delegate = new TransitionAwareIcon.Delegate() { @Override public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { // System.out.println(scheme.getDisplayName()); int fontSize = SubstanceSizeUtils.getComponentFontSize(button); return SubstanceImageCreator.getArrowIcon(fontSize, orientation, scheme); } }; this.iconWidth = this.delegate.getColorSchemeIcon( SubstanceColorSchemeUtilities.getColorScheme(button, ComponentState.DEFAULT)).getIconWidth(); this.iconHeight = this.delegate.getColorSchemeIcon( SubstanceColorSchemeUtilities.getColorScheme(button, ComponentState.DEFAULT)).getIconHeight(); } @Override public void paintIcon(Component c, Graphics g, int x, int y) { this.getIconToPaint((AbstractButton) c).paintIcon(c, g, x, y); } /** * Returns the icon to be painted for the current state of the button. * * @param button * Arrow button. * @return Icon to be painted. */ private Icon getIconToPaint(AbstractButton button) { ButtonModel model = button.getModel(); ComponentState currState = ComponentState.getState(model, button, (button instanceof JMenu)); ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(button); if (!currState.isKindActive(FadeKind.ENABLE)) prevState = currState; float cyclePos = currState.getCyclePosition(); // Use HIGHLIGHT for rollover menus (arrow icons) // and MARK for the rest SubstanceColorScheme currScheme = SubstanceColorSchemeUtilities .getColorScheme( button, (button instanceof JMenu) && currState.isKindActive(FadeKind.ROLLOVER) ? ColorSchemeAssociationKind.HIGHLIGHT : ColorSchemeAssociationKind.MARK, currState); SubstanceColorScheme prevScheme = currScheme; FadeState fadeState = SubstanceFadeUtilities.getFadeState(button, FadeKind.ROLLOVER, FadeKind.SELECTION, FadeKind.PRESS, FadeKind.ARM); if (fadeState != null) { // Use HIGHLIGHT for rollover menus (arrow icons) // and MARK for the rest prevScheme = SubstanceColorSchemeUtilities .getColorScheme( button, (button instanceof JMenu) && prevState .isKindActive(FadeKind.ROLLOVER) ? ColorSchemeAssociationKind.HIGHLIGHT : ColorSchemeAssociationKind.MARK, prevState); cyclePos = fadeState.getFadePosition(); if (!fadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; } float currAlpha = SubstanceColorSchemeUtilities.getAlpha(button, currState); float prevAlpha = SubstanceColorSchemeUtilities.getAlpha(button, prevState); // if (button instanceof JMenu) { // System.out.println(button.getText() + ":" + prevState + "->" // + currState); // System.out.println(prevScheme.getDisplayName() + " -> " // + currScheme.getDisplayName()); // } HashMapKey key = SubstanceCoreUtilities.getHashKey(button.getClass() .getName(), this.orientation, SubstanceSizeUtils .getComponentFontSize(button), currScheme.getDisplayName(), prevScheme.getDisplayName(), currAlpha, prevAlpha, cyclePos); if (!iconMap.containsKey(key)) { Icon icon = this.delegate.getColorSchemeIcon(currScheme); Icon prevIcon = this.delegate.getColorSchemeIcon(prevScheme); BufferedImage temp = SubstanceCoreUtilities.getBlankImage(icon .getIconWidth(), icon.getIconHeight()); Graphics2D g2d = temp.createGraphics(); if (currScheme == prevScheme) { // same scheme - can paint just the current icon, no matter // what the cycle position is. g2d.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, currAlpha)); icon.paintIcon(button, g2d, 0, 0); } else { // make optimizations for limit values of the cycle position. if (cyclePos < 1.0f) { g2d.setComposite(AlphaComposite.SrcOver.derive(prevAlpha)); prevIcon.paintIcon(button, g2d, 0, 0); } if (cyclePos > 0.0f) { g2d.setComposite(AlphaComposite.SrcOver.derive(currAlpha * cyclePos)); icon.paintIcon(button, g2d, 0, 0); } } iconMap.put(key, new ImageIcon(temp)); g2d.dispose(); } return iconMap.get(key); } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconHeight() */ public int getIconHeight() { return this.iconHeight; } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconWidth() */ public int getIconWidth() { return this.iconWidth; } } substance-5.3.orig/src/org/jvnet/substance/utils/icon/GlowingIcon.java0000644000175000017500000001046611136475562026071 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.icon; import java.awt.*; import java.awt.image.BufferedImage; import java.util.HashMap; import java.util.Map; import javax.swing.Icon; import javax.swing.ImageIcon; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.animation.FadeTracker; import org.jvnet.substance.utils.SubstanceColorUtilities; import org.jvnet.substance.utils.SubstanceCoreUtilities; public class GlowingIcon implements Icon { protected Icon delegate; protected Component component; protected Map iconMap; public GlowingIcon(Icon delegate, Component component) { this.delegate = delegate; this.component = component; this.iconMap = new HashMap(); } public Icon getDelegate() { return this.delegate; } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconHeight() */ public int getIconHeight() { if (this.delegate == null) return 0; return this.delegate.getIconHeight(); } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconWidth() */ public int getIconWidth() { if (this.delegate == null) return 0; return this.delegate.getIconWidth(); } /* * (non-Javadoc) * * @see javax.swing.Icon#paintIcon(java.awt.Component, java.awt.Graphics, * int, int) */ /* * (non-Javadoc) * * @see javax.swing.Icon#paintIcon(java.awt.Component, java.awt.Graphics, * int, int) */ public void paintIcon(Component c, Graphics g, int x, int y) { if (this.delegate == null) return; float fadePos = FadeTracker.getInstance().getFade(this.component, FadeKind.ICON_GLOW); // System.out.println(fadePos); Icon toPaint = this.iconMap.get(fadePos); if (toPaint == null) { int width = this.getIconWidth(); int height = this.getIconHeight(); BufferedImage image = SubstanceCoreUtilities.getBlankImage(width, height); Graphics2D graphics = (Graphics2D) image.getGraphics(); this.delegate.paintIcon(c, graphics, 0, 0); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { int rgba = image.getRGB(i, j); int transp = (rgba >>> 24) & 0xFF; double coef = Math.sin(2.0 * Math.PI * fadePos / 2.0) / 3.0; Color newColor = (coef >= 0.0) ? SubstanceColorUtilities .getLighterColor(new Color(rgba), coef) : SubstanceColorUtilities.getDarkerColor(new Color( rgba), -coef); image.setRGB(i, j, (transp << 24) | (newColor.getRed() << 16) | (newColor.getGreen() << 8) | newColor.getBlue()); } } toPaint = new ImageIcon(image); this.iconMap.put(fadePos, toPaint); } toPaint.paintIcon(c, g, x, y); } } substance-5.3.orig/src/org/jvnet/substance/utils/icon/SubstanceIconFactory.java0000644000175000017500000010444611162714656027743 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.icon; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.geom.Ellipse2D; import java.awt.geom.GeneralPath; import java.awt.image.BufferedImage; import java.lang.reflect.Field; import java.util.*; import javax.swing.*; import javax.swing.plaf.SliderUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicSliderUI; import org.jvnet.lafwidget.animation.*; import org.jvnet.substance.*; import org.jvnet.substance.api.*; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; import org.jvnet.substance.utils.*; /** * Icon factory for dynamically-changing icons. This class is for internal * use only. * * @author Kirill Grouchnikov */ public class SubstanceIconFactory { /** * Icons for horizontal slider in {@link SubstanceSliderUI}. */ private static LazyResettableHashMap sliderHorizontalIcons = new LazyResettableHashMap( "SubstanceIconFactory.sliderHorizontalIcon"); /** * Icons for horizontal slider in {@link SubstanceSliderUI}. */ private static LazyResettableHashMap sliderRoundIcons = new LazyResettableHashMap( "SubstanceIconFactory.sliderRoundIcon"); /** * Icons for vertical slider in {@link SubstanceSliderUI}. */ private static LazyResettableHashMap sliderVerticalIcons = new LazyResettableHashMap( "SubstanceIconFactory.sliderVerticalIcon"); /** * Icons for tree collapse / expand in {@link SubstanceTreeUI}. */ private static LazyResettableHashMap treeIcons = new LazyResettableHashMap( "SubstanceIconFactory.treeIcon"); /** * Retrieves icon for horizontal slider in {@link SubstanceSliderUI}. * * @param size * The size of the icon to retrieve. * @param isMirrorred * Indication whether the icon should be mirrored. * @return Icon for horizontal slider in {@link SubstanceSliderUI}. */ public static Icon getSliderHorizontalIcon(int size, boolean isMirrorred) { HashMapKey key = SubstanceCoreUtilities.getHashKey(size, isMirrorred); if (SubstanceIconFactory.sliderHorizontalIcons.get(key) == null) { Icon icon = new SliderHorizontalIcon(size, isMirrorred); SubstanceIconFactory.sliderHorizontalIcons.put(key, icon); } return SubstanceIconFactory.sliderHorizontalIcons.get(key); } /** * Retrieves round icon for slider in {@link SubstanceSliderUI}. * * @param size * The size of the icon to retrieve. * @return Round icon for slider in {@link SubstanceSliderUI}. */ public static Icon getSliderRoundIcon(int size) { HashMapKey key = SubstanceCoreUtilities.getHashKey(size); if (SubstanceIconFactory.sliderRoundIcons.get(key) == null) { Icon icon = new SliderRoundIcon(size); SubstanceIconFactory.sliderRoundIcons.put(key, icon); } return SubstanceIconFactory.sliderRoundIcons.get(key); } /** * Retrieves icon for vertical slider in {@link SubstanceSliderUI}. * * @param size * The size of the icon to retrieve. * @param isMirrorred * Indication whether the icon should be mirrored. * @return Icon for vertical slider in {@link SubstanceSliderUI}. */ public static Icon getSliderVerticalIcon(int size, boolean isMirrorred) { HashMapKey key = SubstanceCoreUtilities.getHashKey(size, isMirrorred); if (SubstanceIconFactory.sliderVerticalIcons.get(key) == null) { Icon icon = new SliderVerticalIcon(size, isMirrorred); SubstanceIconFactory.sliderVerticalIcons.put(key, icon); } return SubstanceIconFactory.sliderVerticalIcons.get(key); } public static Icon getTreeIcon(JTree tree, boolean isCollapsed) { int fontSize = SubstanceSizeUtils.getComponentFontSize(tree); int size = SubstanceSizeUtils.getTreeIconSize(fontSize); HashMapKey key = SubstanceCoreUtilities.getHashKey(size, isCollapsed); if (SubstanceIconFactory.treeIcons.get(key) == null) { Icon icon = new TreeIcon(size, isCollapsed); SubstanceIconFactory.treeIcons.put(key, icon); } return SubstanceIconFactory.treeIcons.get(key); } /** * Trackable slider (for sliders that do not use {@link SubstanceSliderUI} * as their UI (such as * {@link contrib.ch.randelshofer.quaqua.colorchooser.ColorSliderUI}from * Quaqua). Uses reflection to implement the {@link Trackable}interface, * fetching the value of {@link BasicSliderUI#thumbRect}field. * * @author Kirill Grouchnikov */ private static class TrackableSlider implements Trackable { /** * The associated slider. */ private JSlider slider; /** * Reflection reference to {@link BasicSliderUI#thumbRect}field. If * reflection failed, or no such field (for example the custom UI * implements {@link SliderUI}directly, this field is * null. */ private Field thumbRectField; /** * Simple constructor. * * @param slider * The associated slider. */ public TrackableSlider(JSlider slider) { this.slider = slider; SliderUI sliderUI = slider.getUI(); if (sliderUI instanceof BasicSliderUI) { try { this.thumbRectField = BasicSliderUI.class .getDeclaredField("thumbRect"); this.thumbRectField.setAccessible(true); } catch (Exception exc) { this.thumbRectField = null; } } } /* * (non-Javadoc) * * @see * org.jvnet.substance.Trackable#isInside(java.awt.event.MouseEvent) */ public boolean isInside(MouseEvent me) { try { Rectangle thumbB = (Rectangle) this.thumbRectField .get(this.slider.getUI()); if (thumbB == null) return false; return thumbB.contains(me.getX(), me.getY()); } catch (Exception exc) { return false; } } } /** * Icon for horizontal slider in {@link SubstanceSliderUI}. * * @author Kirill Grouchnikov */ private static class SliderHorizontalIcon implements Icon, UIResource { /** * Icon hash. */ private static LazyResettableHashMap icons = new LazyResettableHashMap( "SubstanceIconFactory.SliderHorizontalIcon"); /** * The size of this icon. */ private int size; /** * Indication whether the icon is mirrorred. */ private boolean isMirrorred; /** * Contains models for the sliders whose UI is not * {@link SubstanceSliderUI}. A model is used for rollover effects (as * in {@link SubstanceSliderUI}and {@link SubstanceScrollBarUI}). Note * that this is weak map (on keys) to allow disposing of unused keys. */ private WeakHashMap models = new WeakHashMap(); /** * Simple constructor. * * @param size * The size of this icon. * @param isMirrorred * Indication whether the icon should be mirrored. */ public SliderHorizontalIcon(int size, boolean isMirrorred) { this.size = size; this.isMirrorred = isMirrorred; } /** * Retrieves icon that matches the specified state of the slider thumb. * * @param state * Slider state. * @param prevState * The previous slider state. * @param slider * The slider itself. * @param sliderIcon * The slider icon. * @return Icon that matches the specified state of the slider thumb. */ private static Icon getIcon(ComponentState state, ComponentState prevState, JSlider slider, SliderHorizontalIcon sliderIcon) { float cyclePos = state.getCyclePosition(); SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(slider, state); SubstanceColorScheme colorScheme2 = SubstanceColorSchemeUtilities .getColorScheme(slider, prevState); SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities .getColorScheme(slider, ColorSchemeAssociationKind.BORDER, state); SubstanceColorScheme borderScheme2 = SubstanceColorSchemeUtilities .getColorScheme(slider, ColorSchemeAssociationKind.BORDER, prevState); FadeTracker fadeTracker = FadeTracker.getInstance(); int width = 2 * sliderIcon.size / 3; FadeState rolloverFadeState = fadeTracker.getFadeState(slider, FadeKind.ROLLOVER); FadeState pressFadeState = fadeTracker.getFadeState(slider, FadeKind.PRESS); if (rolloverFadeState != null) { cyclePos = rolloverFadeState.getFadePosition(); if (rolloverFadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; width = (int) (sliderIcon.size * (2.0 + rolloverFadeState.getFadePosition()) / 3.0); } else if (pressFadeState != null) { cyclePos = pressFadeState.getFadePosition(); if (pressFadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; width = sliderIcon.size; } else { switch (state) { case ROLLOVER_UNSELECTED: case ROLLOVER_SELECTED: case ACTIVE: case PRESSED_SELECTED: case PRESSED_UNSELECTED: width = sliderIcon.size; } } width = Math.min(width, sliderIcon.size - 2); int delta = (sliderIcon.size - width) / 2; HashMapKey key = SubstanceCoreUtilities.getHashKey(sliderIcon.size, width, colorScheme.getDisplayName(), colorScheme2 .getDisplayName(), borderScheme.getDisplayName(), borderScheme2.getDisplayName(), cyclePos); Icon result = SliderHorizontalIcon.icons.get(key); if (result != null) return result; SubstanceGradientPainter painter = SubstanceCoreUtilities .getGradientPainter(slider); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(slider); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(slider)) / 2.0); Shape contour = SubstanceOutlineUtilities.getTriangleButtonOutline( width, sliderIcon.size - 1, 2, borderDelta); BufferedImage stateImage = SubstanceCoreUtilities.getBlankImage( sliderIcon.size - 1, sliderIcon.size - 1); Graphics2D g2d = stateImage.createGraphics(); g2d.translate(delta, 0); painter.paintContourBackground(g2d, slider, width, sliderIcon.size - 1, contour, false, colorScheme, colorScheme2, cyclePos, true, colorScheme != colorScheme2); // BufferedImage biResult = SubstanceCoreUtilities.getBlankImage( // sliderIcon.size - 1, sliderIcon.size - 1); // Graphics2D bg2d = (Graphics2D) biResult.getGraphics(); // bg2d.translate(delta, 0); // bg2d.drawImage(stateImage, 0, 0, null); int borderThickness = (int) SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(slider)); GeneralPath contourInner = SubstanceOutlineUtilities .getTriangleButtonOutline(width, sliderIcon.size - 1, 2, borderThickness + borderDelta); borderPainter.paintBorder(g2d, slider, width, sliderIcon.size - 1, contour, contourInner, borderScheme, borderScheme2, cyclePos, borderScheme != borderScheme2); g2d.translate(-delta, 0); if (sliderIcon.isMirrorred) stateImage = SubstanceImageCreator.getRotated(stateImage, 2); // Graphics g = stateImage.getGraphics(); // g.setColor(Color.red); // g.drawRect(0, 0, stateImage.getWidth()-1, // stateImage.getHeight()-1); result = new ImageIcon(stateImage); SliderHorizontalIcon.icons.put(key, result); return result; } /* * (non-Javadoc) * * @see javax.swing.Icon#paintIcon(java.awt.Component, * java.awt.Graphics, int, int) */ public void paintIcon(Component c, Graphics g, int x, int y) { if (!(g instanceof Graphics2D)) { return; } JSlider slider = (JSlider) c; SliderUI sliderUI = slider.getUI(); ComponentState state = ComponentState.ACTIVE; if (sliderUI instanceof SubstanceSliderUI) { state = ComponentState.getState(((SubstanceSliderUI) sliderUI) .getButtonModel(), null); } else { ButtonModel buttonModel = this.models.get(slider); if (buttonModel == null) { buttonModel = new DefaultButtonModel(); buttonModel.setEnabled(slider.isEnabled()); RolloverControlListener listener = new RolloverControlListener( new TrackableSlider(slider), buttonModel); slider.addMouseListener(listener); slider.addMouseMotionListener(listener); this.models.put(slider, buttonModel); } state = ComponentState.getState(buttonModel, null); } ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(slider); Icon iconToDraw = SliderHorizontalIcon.getIcon(state, prevState, slider, this); iconToDraw.paintIcon(c, g, x, y); } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconWidth() */ public int getIconWidth() { return this.size - 1; } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconHeight() */ public int getIconHeight() { return this.size - 1; } } /** * Round icon for sliders in {@link SubstanceSliderUI}. * * @author Kirill Grouchnikov */ private static class SliderRoundIcon implements Icon, UIResource { /** * Icon hash. */ private static LazyResettableHashMap icons = new LazyResettableHashMap( "SubstanceIconFactory.SliderRoundIcon"); /** * The size of this icon. */ private int size; /** * Contains models for the sliders whose UI is not * {@link SubstanceSliderUI}. A model is used for rollover effects (as * in {@link SubstanceSliderUI}and {@link SubstanceScrollBarUI}). Note * that this is weak map (on keys) to allow disposing of unused keys. */ private WeakHashMap models = new WeakHashMap(); /** * Simple constructor. * * @param size * The size of this icon. */ public SliderRoundIcon(int size) { this.size = size; } /** * Retrieves icon that matches the specified state of the slider thumb. * * @param state * Slider state. * @param prevState * The previous slider state. * @param slider * The slider itself. * @param sliderIcon * The slider icon. * @return Icon that matches the specified state of the slider thumb. */ private static Icon getIcon(ComponentState state, ComponentState prevState, JSlider slider, SliderRoundIcon sliderIcon) { // System.out.println("Curr : " + state.name() + ", prev : " + // prevState.name()); float cyclePos = state.getCyclePosition(); SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(slider, state); SubstanceColorScheme colorScheme2 = SubstanceColorSchemeUtilities .getColorScheme(slider, prevState); SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities .getColorScheme(slider, ColorSchemeAssociationKind.BORDER, state); SubstanceColorScheme borderScheme2 = SubstanceColorSchemeUtilities .getColorScheme(slider, ColorSchemeAssociationKind.BORDER, prevState); FadeTracker fadeTracker = FadeTracker.getInstance(); int width = 2 * sliderIcon.size / 3; FadeState rolloverFadeState = fadeTracker.getFadeState(slider, FadeKind.ROLLOVER); FadeState pressFadeState = fadeTracker.getFadeState(slider, FadeKind.PRESS); if (rolloverFadeState != null) { cyclePos = rolloverFadeState.getFadePosition(); if (rolloverFadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; width = (int) (sliderIcon.size * (2.0 + rolloverFadeState.getFadePosition()) / 3.0); } else if (pressFadeState != null) { cyclePos = pressFadeState.getFadePosition(); if (pressFadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; width = sliderIcon.size; } else { switch (state) { case ROLLOVER_UNSELECTED: case ROLLOVER_SELECTED: case ACTIVE: case PRESSED_SELECTED: case PRESSED_UNSELECTED: width = sliderIcon.size; } } width = Math.min(width, sliderIcon.size - 2); if (width % 2 == 0) width--; int delta = (sliderIcon.size - width) / 2; HashMapKey key = SubstanceCoreUtilities.getHashKey(sliderIcon.size, width, colorScheme.getDisplayName(), colorScheme2 .getDisplayName(), borderScheme.getDisplayName(), borderScheme2.getDisplayName(), cyclePos); Icon result = SliderRoundIcon.icons.get(key); if (result != null) return result; SubstanceGradientPainter painter = SubstanceCoreUtilities .getGradientPainter(slider); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(slider); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(slider)) / 2.0); Shape contour = new Ellipse2D.Float(borderDelta, borderDelta, width - 2 * borderDelta - 1, width - 2 * borderDelta - 1); BufferedImage stateImage = SubstanceCoreUtilities.getBlankImage( sliderIcon.size - 1, sliderIcon.size - 1); Graphics2D g2d = stateImage.createGraphics(); g2d.translate(delta, delta); painter.paintContourBackground(g2d, slider, width, sliderIcon.size - 1, contour, false, colorScheme, colorScheme2, cyclePos, true, colorScheme != colorScheme2); // BufferedImage biResult = SubstanceCoreUtilities.getBlankImage( // sliderIcon.size - 1, sliderIcon.size - 1); // Graphics2D bg2d = (Graphics2D) biResult.getGraphics(); // // bg2d.setColor(Color.red); // // bg2d.drawRect(0, 0, sliderIcon.size-2, sliderIcon.size-2); // bg2d.drawImage(stateImage, 0, 0, null); int borderThickness = (int) SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(slider)); Shape contourInner = new Ellipse2D.Float(borderDelta + borderThickness, borderDelta + borderThickness, width - 2 * borderDelta - 2 * borderThickness - 1, width - 2 * borderDelta - 2 * borderThickness - 1); borderPainter.paintBorder(g2d, slider, width, sliderIcon.size - 1, contour, contourInner, borderScheme, borderScheme2, cyclePos, borderScheme != borderScheme2); // bg2d.translate(-delta, -delta); result = new ImageIcon(stateImage); SliderRoundIcon.icons.put(key, result); return result; } /* * (non-Javadoc) * * @see javax.swing.Icon#paintIcon(java.awt.Component, * java.awt.Graphics, int, int) */ public void paintIcon(Component c, Graphics g, int x, int y) { if (!(g instanceof Graphics2D)) { return; } JSlider slider = (JSlider) c; SliderUI sliderUI = slider.getUI(); ComponentState state = ComponentState.ACTIVE; if (sliderUI instanceof SubstanceSliderUI) { state = ComponentState.getState(((SubstanceSliderUI) sliderUI) .getButtonModel(), null); } else { ButtonModel buttonModel = this.models.get(slider); if (buttonModel == null) { buttonModel = new DefaultButtonModel(); buttonModel.setEnabled(slider.isEnabled()); RolloverControlListener listener = new RolloverControlListener( new TrackableSlider(slider), buttonModel); slider.addMouseListener(listener); slider.addMouseMotionListener(listener); this.models.put(slider, buttonModel); } state = ComponentState.getState(buttonModel, null); } ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(slider); Icon iconToDraw = SliderRoundIcon.getIcon(state, prevState, slider, this); iconToDraw.paintIcon(c, g, x, y); } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconWidth() */ public int getIconWidth() { return this.size - 1; } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconHeight() */ public int getIconHeight() { return this.size - 1; } } /** * Icon for vertical slider in {@link SubstanceSliderUI}. * * @author Kirill Grouchnikov */ private static class SliderVerticalIcon implements Icon, UIResource { /** * Icon hash. */ private static LazyResettableHashMap icons = new LazyResettableHashMap( "SubstanceIconFactory.SliderVerticalIcon"); /** * The size of this icon. */ private int size; /** * Indication whether the icon is mirrorred. */ private boolean isMirrorred; /** * Contains models for the sliders whose UI is not * {@link SubstanceSliderUI}. A model is used for rollover effects (as * in {@link SubstanceSliderUI}and {@link SubstanceScrollBarUI}). Note * that this is weak map (on keys) to allow disposing of unused keys. */ private WeakHashMap models = new WeakHashMap(); /** * Simple constructor. * * @param size * The size of this icon. * @param isMirrorred * Indication whether the icon should be mirrored. */ public SliderVerticalIcon(int size, boolean isMirrorred) { this.size = size; this.isMirrorred = isMirrorred; } /** * Retrieves icon that matches the specified state of the slider thumb. * * @param state * Slider state. * @param prevState * The previous slider state. * @param slider * The slider itself. * @param sliderIcon * The slider icon. * @return Icon that matches the specified state of the slider thumb. */ private static Icon getIcon(ComponentState state, ComponentState prevState, JSlider slider, SliderVerticalIcon sliderIcon) { float cyclePos = state.getCyclePosition(); SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(slider, state); SubstanceColorScheme colorScheme2 = SubstanceColorSchemeUtilities .getColorScheme(slider, prevState); SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities .getColorScheme(slider, ColorSchemeAssociationKind.BORDER, state); SubstanceColorScheme borderScheme2 = SubstanceColorSchemeUtilities .getColorScheme(slider, ColorSchemeAssociationKind.BORDER, prevState); FadeTracker fadeTracker = FadeTracker.getInstance(); int height = 2 * sliderIcon.size / 3; FadeState rolloverFadeState = fadeTracker.getFadeState(slider, FadeKind.ROLLOVER); FadeState pressFadeState = fadeTracker.getFadeState(slider, FadeKind.PRESS); if (rolloverFadeState != null) { cyclePos = rolloverFadeState.getFadePosition(); if (rolloverFadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; height = (int) (sliderIcon.size * (2.0 + rolloverFadeState.getFadePosition()) / 3.0); } else if (pressFadeState != null) { cyclePos = pressFadeState.getFadePosition(); if (pressFadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; height = sliderIcon.size; } else { switch (state) { case ROLLOVER_UNSELECTED: case ROLLOVER_SELECTED: case ACTIVE: case PRESSED_SELECTED: case PRESSED_UNSELECTED: height = sliderIcon.size; } } height = Math.min(height, sliderIcon.size - 2); int delta = (sliderIcon.size - height) / 2 - 1; HashMapKey key = SubstanceCoreUtilities.getHashKey(sliderIcon.size, height, slider.getComponentOrientation(), colorScheme .getDisplayName(), colorScheme2.getDisplayName(), borderScheme.getDisplayName(), borderScheme2 .getDisplayName(), cyclePos); Icon result = SliderVerticalIcon.icons.get(key); if (result != null) return result; SubstanceGradientPainter painter = SubstanceCoreUtilities .getGradientPainter(slider); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(slider); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(slider)) / 2.0); Shape contour = SubstanceOutlineUtilities.getTriangleButtonOutline( height, sliderIcon.size, 2, borderDelta); BufferedImage stateImage = SubstanceCoreUtilities.getBlankImage( sliderIcon.size - 1, sliderIcon.size - 1); Graphics2D g2d = stateImage.createGraphics(); g2d.translate(delta, 0); painter.paintContourBackground(g2d, slider, height, sliderIcon.size, contour, false, colorScheme, colorScheme2, cyclePos, true, colorScheme != colorScheme2); // BufferedImage biResult = SubstanceCoreUtilities.getBlankImage( // sliderIcon.size - 1, sliderIcon.size - 1); // Graphics2D bg2d = (Graphics2D) biResult.getGraphics(); // bg2d.translate(delta, 0); // bg2d.drawImage(stateImage, 0, 0, null); int borderThickness = (int) SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(slider)); GeneralPath contourInner = SubstanceOutlineUtilities .getTriangleButtonOutline(height, sliderIcon.size, 2, borderThickness + borderDelta); borderPainter.paintBorder(g2d, slider, height, sliderIcon.size - 1, contour, contourInner, borderScheme, borderScheme2, cyclePos, borderScheme != borderScheme2); // bg2d.translate(-delta, 0); if (sliderIcon.isMirrorred) stateImage = SubstanceImageCreator.getRotated(stateImage, 1); else stateImage = SubstanceImageCreator.getRotated(stateImage, 3); if (!slider.getComponentOrientation().isLeftToRight()) { stateImage = SubstanceImageCreator.getRotated(stateImage, 2); } // Graphics g = stateImage.getGraphics(); // g.setColor(Color.red); // g.drawRect(0, 0, stateImage.getWidth()-1, // stateImage.getHeight()-1); result = new ImageIcon(stateImage); SliderVerticalIcon.icons.put(key, result); return result; } /* * (non-Javadoc) * * @see javax.swing.Icon#paintIcon(java.awt.Component, * java.awt.Graphics, int, int) */ public void paintIcon(Component c, Graphics g, int x, int y) { if (!(g instanceof Graphics2D)) { return; } JSlider slider = (JSlider) c; SliderUI sliderUI = slider.getUI(); ComponentState state = ComponentState.ACTIVE; if (sliderUI instanceof SubstanceSliderUI) { state = ComponentState.getState(((SubstanceSliderUI) sliderUI) .getButtonModel(), null); } else { ButtonModel buttonModel = this.models.get(slider); if (buttonModel == null) { buttonModel = new DefaultButtonModel(); buttonModel.setEnabled(slider.isEnabled()); RolloverControlListener listener = new RolloverControlListener( new TrackableSlider(slider), buttonModel); slider.addMouseListener(listener); slider.addMouseMotionListener(listener); this.models.put(slider, buttonModel); } state = ComponentState.getState(buttonModel, null); } ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(slider); Icon iconToDraw = SliderVerticalIcon.getIcon(state, prevState, slider, this); iconToDraw.paintIcon(c, g, x, y); } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconWidth() */ public int getIconWidth() { return this.size - 1; } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconHeight() */ public int getIconHeight() { return this.size - 1; } } /** * Collapse / expand icons for JTrees in {@link SubstanceTreeUI}. * * @author Kirill Grouchnikov */ private static class TreeIcon implements Icon, UIResource { /** * Icon hash. */ private static LazyResettableHashMap icons = new LazyResettableHashMap( "SubstanceIconFactory.TreeIcon"); /** * The collapsed indication of this icon */ private boolean isCollapsed; private int size; /** * Simple constructor. * * @param isCollapsed * The collapsed indication of this icon. */ public TreeIcon(int size, boolean isCollapsed) { this.isCollapsed = isCollapsed; this.size = size; } /** * Retrieves icon that matches the specified state of the slider thumb. * * @param state * Slider state. * @param prevState * The previous slider state. * @param slider * The slider itself. * @param sliderIcon * The slider icon. * @return Icon that matches the specified state of the slider thumb. */ private static Icon getIcon(JTree tree, boolean isCollapsed) { ComponentState state = ((tree == null) || tree.isEnabled()) ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED; SubstanceColorScheme fillScheme = SubstanceColorSchemeUtilities .getColorScheme(tree, state); SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities .getColorScheme(tree, ColorSchemeAssociationKind.BORDER, state); int fontSize = SubstanceSizeUtils.getComponentFontSize(tree); HashMapKey key = SubstanceCoreUtilities.getHashKey(fontSize, fillScheme.getDisplayName(), borderScheme.getDisplayName(), isCollapsed); Icon result = TreeIcon.icons.get(key); if (result != null) return result; result = new ImageIcon(SubstanceImageCreator.getTreeIcon(tree, fillScheme, borderScheme, isCollapsed)); TreeIcon.icons.put(key, result); return result; } /* * (non-Javadoc) * * @see javax.swing.Icon#paintIcon(java.awt.Component, * java.awt.Graphics, int, int) */ public void paintIcon(Component c, Graphics g, int x, int y) { if (!(g instanceof Graphics2D)) { return; } // The following check is here because some applications // (like JIDE's ExpandablePanel) may decide to use the // "Tree.collapsedIcon" and "Tree.expandedIcon" UIManager // entries to paint on non-JTree components. Sigh. JTree tree = (c instanceof JTree) ? (JTree) c : null; Icon iconToDraw = TreeIcon.getIcon(tree, this.isCollapsed); iconToDraw.paintIcon(c, g, x, y); } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconWidth() */ public int getIconWidth() { return this.size; } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconHeight() */ public int getIconHeight() { return this.size; } } /** * Icon kind of a title pane button. * * @author Kirill Grocuhnikov. */ public enum IconKind { /** * Icon of a close button. */ CLOSE, /** * Icon of a minimize button. */ MINIMIZE, /** * Icon of a maximize button. */ MAXIMIZE, /** * Icon of a restore button. */ RESTORE; } /** * Cache of title pane icons. */ private static final Map> titlePaneIcons = SubstanceIconFactory .createTitlePaneIcons(); /** * Creates an empty map of title pane icons. * * @return Empty map of title pane icons. */ private static Map> createTitlePaneIcons() { Map> result = new HashMap>(); result.put(IconKind.CLOSE, new LazyResettableHashMap( "Close title pane icons")); result.put(IconKind.MINIMIZE, new LazyResettableHashMap( "Minimize title pane icons")); result.put(IconKind.MAXIMIZE, new LazyResettableHashMap( "Maximize title pane icons")); result.put(IconKind.RESTORE, new LazyResettableHashMap( "Restore title pane icons")); return result; } /** * Returns title pane icon of the specified kind. * * @param iconKind * Icon kind. * @param scheme * Color scheme. * @return Title pane icon of the specified kind. */ public static Icon getTitlePaneIcon(IconKind iconKind, SubstanceColorScheme scheme, SubstanceColorScheme backgroundScheme) { LazyResettableHashMap kindMap = SubstanceIconFactory.titlePaneIcons .get(iconKind); HashMapKey key = SubstanceCoreUtilities.getHashKey(scheme .getDisplayName(), backgroundScheme.getDisplayName()); Icon result = kindMap.get(key); if (result != null) return result; switch (iconKind) { case CLOSE: result = SubstanceImageCreator.getCloseIcon(scheme, backgroundScheme); break; case MINIMIZE: result = SubstanceImageCreator.getMinimizeIcon(scheme, backgroundScheme); break; case MAXIMIZE: result = SubstanceImageCreator.getMaximizeIcon(scheme, backgroundScheme); break; case RESTORE: result = SubstanceImageCreator.getRestoreIcon(scheme, backgroundScheme); break; } kindMap.put(key, result); return result; } }substance-5.3.orig/src/org/jvnet/substance/utils/icon/CheckBoxMenuItemIcon.java0000644000175000017500000001530211166401544027577 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.icon; import java.awt.Component; import java.awt.Graphics; import javax.swing.*; import javax.swing.plaf.UIResource; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.animation.FadeState; import org.jvnet.substance.api.*; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; import org.jvnet.substance.utils.*; /** * Icon for the {@link JCheckBoxMenuItem}s. * * @author Kirill Grouchnikov */ public class CheckBoxMenuItemIcon implements Icon, UIResource { /** * The size of this icon. */ private int size; /** * The associated menu item. */ private JMenuItem menuItem; /** * Icon cache to speed up the painting. */ private static LazyResettableHashMap iconMap = new LazyResettableHashMap( "CheckBoxMenuItemIcon"); /** * Creates a new icon. * * @param menuItem * The corresponding menu item. * @param size * The size of this icon. */ public CheckBoxMenuItemIcon(JMenuItem menuItem, int size) { this.menuItem = menuItem; this.size = size; } /** * Returns the current icon to paint. * * @return Icon to paint. */ private Icon getIconToPaint() { if (this.menuItem == null) return null; ComponentState currState = ComponentState.getState(this.menuItem .getModel(), this.menuItem, false); ComponentState prevState = SubstanceCoreUtilities .getPrevSelComponentState(this.menuItem); float checkMarkVisibility = currState.isKindActive(FadeKind.SELECTION) ? 10 : 0; boolean isCheckMarkFadingOut = false; SubstanceColorScheme currFillColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.FILL, currState); SubstanceColorScheme prevFillColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.FILL, prevState); SubstanceColorScheme currMarkColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.MARK, currState); SubstanceColorScheme prevMarkColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.MARK, prevState); SubstanceColorScheme currBorderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.BORDER, currState); SubstanceColorScheme prevBorderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.BORDER, prevState); float cyclePos = 0; FadeState fadeState = SubstanceFadeUtilities.getFadeState( this.menuItem, FadeKind.SELECTION, FadeKind.ROLLOVER, FadeKind.PRESS, FadeKind.ARM); if (fadeState != null) { cyclePos = fadeState.getFadePosition(); if (fadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; if (fadeState.fadeKind == FadeKind.SELECTION) { checkMarkVisibility = fadeState.getFadePosition(); isCheckMarkFadingOut = !fadeState.isFadingIn(); } } SubstanceGradientPainter fillPainter = SubstanceCoreUtilities .getGradientPainter(this.menuItem); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(this.menuItem); int fontSize = SubstanceSizeUtils.getComponentFontSize(this.menuItem); HashMapKey key = SubstanceCoreUtilities.getHashKey(fontSize, currState .name(), prevState.name(), currFillColorScheme.getDisplayName(), prevFillColorScheme .getDisplayName(), currMarkColorScheme.getDisplayName(), prevMarkColorScheme .getDisplayName(), currBorderColorScheme .getDisplayName(), prevBorderColorScheme .getDisplayName(), cyclePos, checkMarkVisibility, this.size); // System.out.println(key); Icon result = iconMap.get(key); if (result != null) return result; result = new ImageIcon(SubstanceImageCreator.getCheckBox(this.menuItem, fillPainter, borderPainter, this.size + 3, currState, prevState, currFillColorScheme, prevFillColorScheme, currMarkColorScheme, prevMarkColorScheme, currBorderColorScheme, prevBorderColorScheme, cyclePos, checkMarkVisibility / 10.f, isCheckMarkFadingOut)); // if (this.menuItem.isSelected()) { // System.out.println("Sel menu : " + currState + " : " // + scheme.getDisplayName()); // } iconMap.put(key, result); return result; } /* * (non-Javadoc) * * @see javax.swing.Icon#paintIcon(java.awt.Component, java.awt.Graphics, * int, int) */ public void paintIcon(Component c, Graphics g, int x, int y) { Icon iconToDraw = this.getIconToPaint(); if (iconToDraw != null) iconToDraw.paintIcon(c, g, x, y); } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconWidth() */ public int getIconWidth() { return this.size + 2; } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconHeight() */ public int getIconHeight() { return this.size + 2; } } substance-5.3.orig/src/org/jvnet/substance/utils/icon/TransitionAware.java0000644000175000017500000000350111136475562026754 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.icon; import java.lang.annotation.*; @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface TransitionAware { } substance-5.3.orig/src/org/jvnet/substance/utils/icon/RadioButtonMenuItemIcon.java0000644000175000017500000001467611166402356030362 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.icon; import java.awt.Component; import java.awt.Graphics; import javax.swing.*; import javax.swing.plaf.UIResource; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.animation.FadeState; import org.jvnet.substance.api.*; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; import org.jvnet.substance.utils.*; /** * Icon for the {@link JRadioButtonMenuItem}s. * * @author Kirill Grouchnikov */ public class RadioButtonMenuItemIcon implements Icon, UIResource { /** * The size of this icon. */ private int size; /** * The associated menu item. */ private JMenuItem menuItem; /** * Icon cache to speed up the painting. */ private static LazyResettableHashMap iconMap = new LazyResettableHashMap( "RadioButtonMenuItemIcon"); /** * Creates a new icon. * * @param menuItem * The corresponding menu item. * @param size * The size of this icon. */ public RadioButtonMenuItemIcon(JMenuItem menuItem, int size) { this.menuItem = menuItem; this.size = size; } /** * Returns the current icon to paint. * * @return Icon to paint. */ private Icon getIconToPaint() { if (this.menuItem == null) return null; ComponentState currState = ComponentState.getState(this.menuItem); ComponentState prevState = SubstanceCoreUtilities .getPrevSelComponentState(this.menuItem); float visibility = currState.isKindActive(FadeKind.SELECTION) ? 10 : 0; SubstanceColorScheme currFillColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.FILL, currState); SubstanceColorScheme prevFillColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.FILL, prevState); SubstanceColorScheme currMarkColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.MARK, currState); SubstanceColorScheme prevMarkColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.MARK, prevState); SubstanceColorScheme currBorderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.BORDER, currState); SubstanceColorScheme prevBorderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.BORDER, prevState); float cyclePos = 0; FadeState fadeState = SubstanceFadeUtilities.getFadeState( this.menuItem, FadeKind.SELECTION, FadeKind.ROLLOVER, FadeKind.PRESS, FadeKind.ARM); if (fadeState != null) { cyclePos = fadeState.getFadePosition(); if (fadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; if (fadeState.fadeKind == FadeKind.SELECTION) { visibility = fadeState.getFadePosition(); } } SubstanceGradientPainter fillPainter = SubstanceCoreUtilities .getGradientPainter(this.menuItem); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(this.menuItem); int fontSize = SubstanceSizeUtils.getComponentFontSize(this.menuItem); HashMapKey key = SubstanceCoreUtilities.getHashKey(fontSize, currState .name(), prevState.name(), fillPainter.getDisplayName(), borderPainter.getDisplayName(), currFillColorScheme .getDisplayName(), prevFillColorScheme.getDisplayName(), currMarkColorScheme .getDisplayName(), prevMarkColorScheme.getDisplayName(), currBorderColorScheme .getDisplayName(), prevBorderColorScheme .getDisplayName(), cyclePos, visibility, this.size); // System.out.println(key); Icon result = iconMap.get(key); if (result != null) return result; result = new ImageIcon(SubstanceImageCreator.getRadioButton( this.menuItem, fillPainter, borderPainter, this.size, currState, prevState, 2, currFillColorScheme, prevFillColorScheme, currMarkColorScheme, prevMarkColorScheme, currBorderColorScheme, prevBorderColorScheme, cyclePos, visibility / 10.f)); iconMap.put(key, result); return result; } /* * (non-Javadoc) * * @see javax.swing.Icon#paintIcon(java.awt.Component, java.awt.Graphics, * int, int) */ public void paintIcon(Component c, Graphics g, int x, int y) { Icon iconToDraw = this.getIconToPaint(); if (iconToDraw != null) iconToDraw.paintIcon(c, g, x, y); } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconWidth() */ public int getIconWidth() { return this.size + 2; } /* * (non-Javadoc) * * @see javax.swing.Icon#getIconHeight() */ public int getIconHeight() { return this.size + 2; } } substance-5.3.orig/src/org/jvnet/substance/utils/border/0000755000175000017500000000000011256731150023314 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/utils/border/SubstanceToolBarBorder.java0000644000175000017500000001207511162714212030530 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.border; import java.awt.*; import javax.swing.JToolBar; import javax.swing.SwingConstants; import javax.swing.border.AbstractBorder; import javax.swing.plaf.UIResource; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.*; import org.jvnet.substance.utils.*; /** * Border for toolbar. * * @author Kirill Grouchnikov */ public class SubstanceToolBarBorder extends AbstractBorder implements UIResource { /* * (non-Javadoc) * * @see javax.swing.border.Border#paintBorder(java.awt.Component, * java.awt.Graphics, int, int, int, int) */ @Override public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { // failsafe for LAF change if (!SubstanceLookAndFeel.isCurrentLookAndFeel()) return; Graphics2D graphics = (Graphics2D) g; graphics.translate(x, y); if (((JToolBar) c).isFloatable()) { SubstanceColorScheme scheme = SubstanceColorSchemeUtilities .getColorScheme(c, ColorSchemeAssociationKind.SEPARATOR, ComponentState.DEFAULT); int dragBumpsWidth = (int) (0.75 * SubstanceSizeUtils .getToolBarDragInset(SubstanceSizeUtils .getComponentFontSize(c))); if (((JToolBar) c).getOrientation() == SwingConstants.HORIZONTAL) { // fix for defect 3 on NB module int height = c.getHeight() - 4; if (height > 0) { if (c.getComponentOrientation().isLeftToRight()) { graphics.drawImage(SubstanceImageCreator.getDragImage( c, scheme, dragBumpsWidth, height, 2), 2, 1, null); } else { graphics.drawImage(SubstanceImageCreator.getDragImage( c, scheme, dragBumpsWidth, height, 2), c .getBounds().width - dragBumpsWidth - 2, 1, null); } } } else // vertical { // fix for defect 3 on NB module int width = c.getWidth() - 4; if (width > 0) { graphics.drawImage(SubstanceImageCreator.getDragImage(c, scheme, width, dragBumpsWidth, 2), 2, 2, null); } } } graphics.translate(-x, -y); } /* * (non-Javadoc) * * @see javax.swing.border.Border#getBorderInsets(java.awt.Component) */ @Override public Insets getBorderInsets(Component c) { return this.getBorderInsets(c, new Insets(0, 0, 0, 0)); } /* * (non-Javadoc) * * @see * javax.swing.border.AbstractBorder#getBorderInsets(java.awt.Component, * java.awt.Insets) */ @Override public Insets getBorderInsets(Component c, Insets newInsets) { Insets defaultInsets = SubstanceSizeUtils .getToolBarInsets(SubstanceSizeUtils.getComponentFontSize(c)); newInsets.set(defaultInsets.top, defaultInsets.left, defaultInsets.bottom, defaultInsets.right); JToolBar toolbar = (JToolBar) c; if (toolbar.isFloatable()) { int dragInset = SubstanceSizeUtils .getToolBarDragInset(SubstanceSizeUtils .getComponentFontSize(c)); if (toolbar.getOrientation() == SwingConstants.HORIZONTAL) { if (toolbar.getComponentOrientation().isLeftToRight()) { newInsets.left = dragInset; } else { newInsets.right = dragInset; } } else {// vertical newInsets.top = dragInset; } } Insets margin = toolbar.getMargin(); if (margin != null) { newInsets.left += margin.left; newInsets.top += margin.top; newInsets.right += margin.right; newInsets.bottom += margin.bottom; } return newInsets; } } substance-5.3.orig/src/org/jvnet/substance/utils/border/SubstanceBorder.java0000644000175000017500000002153411174265506027257 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.border; import java.awt.*; import java.awt.image.BufferedImage; import javax.swing.border.Border; import javax.swing.plaf.UIResource; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.animation.FadeTracker; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.*; import org.jvnet.substance.utils.*; /** * Gradient border for the Substance look and feel. This class is for * internal use only. * * @author Kirill Grouchnikov */ public class SubstanceBorder implements Border, UIResource { /** * Insets of this border. */ protected Insets myInsets; /** * Border opacity. */ protected float alpha; /** * When the border is painted, the default radius is multiplied by this * factor. */ protected float radiusScaleFactor; /** * Cache of small border images. */ private static LazyResettableHashMap smallImageCache = new LazyResettableHashMap( "SubstanceBorder"); /** * Creates a new border with dynamic insets (computed at the invocation time * of {@link #getBorderInsets(Component)} call). */ public SubstanceBorder() { super(); this.alpha = 1.0f; this.radiusScaleFactor = 0.5f; } /** * Creates a new border with dynamic insets (computed at the invocation time * of {@link #getBorderInsets(Component)} call). * * @param radiusScaleFactor * Radius scale factor. */ public SubstanceBorder(float radiusScaleFactor) { this(); this.radiusScaleFactor = radiusScaleFactor; } /** * Creates a new border with the specified insets. * * @param insets * Insets. */ public SubstanceBorder(Insets insets) { this(); this.myInsets = new Insets(insets.top, insets.left, insets.bottom, insets.right); } /** * Sets the alpha for this border. * * @param alpha * Alpha factor. */ public void setAlpha(float alpha) { this.alpha = alpha; } /** * Paints border instance for the specified component. * * @param c * The component. * @param g * Graphics context. * @param x * Component left X (in graphics context). * @param y * Component top Y (in graphics context). * @param width * Component width. * @param height * Component height. * @param isEnabled * Component enabled status. * @param hasFocus * Component focus ownership status. * @param alpha * Alpha value. */ private void paintBorder(Component c, Graphics g, int x, int y, int width, int height, boolean isEnabled, boolean hasFocus, float alpha) { // failsafe for LAF change if (!SubstanceLookAndFeel.isCurrentLookAndFeel()) { return; } if ((width <= 0) || (height <= 0)) return; Graphics2D graphics = (Graphics2D) g.create(); float cyclePos = 1.0f; FadeTracker fadeTracker = FadeTracker.getInstance(); boolean isFocusAnimated = fadeTracker.isTracked(c, FadeKind.FOCUS); float radius = this.radiusScaleFactor * SubstanceSizeUtils .getClassicButtonCornerRadius(SubstanceSizeUtils .getComponentFontSize(c)); ComponentState state = isEnabled ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED; SubstanceColorScheme borderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(c, ColorSchemeAssociationKind.BORDER, state); SubstanceColorScheme borderColorScheme2 = borderColorScheme; float finalAlpha = alpha; if (isFocusAnimated || c.hasFocus()) { if (isFocusAnimated) { cyclePos = fadeTracker.getFade(c, FadeKind.FOCUS); } borderColorScheme2 = SubstanceColorSchemeUtilities.getColorScheme( c, ColorSchemeAssociationKind.BORDER, ComponentState.SELECTED); } else { finalAlpha *= SubstanceColorSchemeUtilities.getAlpha(c, state); } graphics.setComposite(TransitionLayout.getAlphaComposite(c, finalAlpha, g)); if (width * height < 100000) { HashMapKey hashKey = SubstanceCoreUtilities .getHashKey(SubstanceCoreUtilities.getBorderPainter(c) .getDisplayName(), SubstanceSizeUtils .getComponentFontSize(c), width, height, radius, borderColorScheme.getDisplayName(), borderColorScheme2.getDisplayName(), cyclePos); if (!smallImageCache.containsKey(hashKey)) { BufferedImage toCache = SubstanceCoreUtilities.getBlankImage( width, height); Graphics2D g2d = toCache.createGraphics(); SubstanceImageCreator .paintBorder(c, g2d, 0, 0, width, height, radius, borderColorScheme, borderColorScheme2, cyclePos); g2d.dispose(); smallImageCache.put(hashKey, toCache); } graphics.drawImage(smallImageCache.get(hashKey), x, y, null); } else { // for borders larger than 100000 pixels, use simple // painting // SubstanceBorderPainter borderPainter = SubstanceCoreUtilities // .getBorderPainter(c); // if (borderPainter instanceof InnerDelegateBorderPainter) { // InnerDelegateBorderPainter inner = (InnerDelegateBorderPainter) // borderPainter; // int componentFontSize = SubstanceSizeUtils // .getComponentFontSize(c); // // int borderDelta = (int) Math.floor(SubstanceSizeUtils // // .getBorderStrokeWidth(componentFontSize) / 2.0); // int borderThickness = (int) SubstanceSizeUtils // .getBorderStrokeWidth(componentFontSize); // graphics.translate(x + borderThickness, y + borderThickness); // SubstanceImageCreator.paintSimpleBorder(c, graphics, width - 2 // * borderThickness, height - 2 * borderThickness, inner // .getShiftScheme(borderColorScheme), inner // .getShiftScheme(borderColorScheme2), cyclePos); // graphics.translate(-x - borderThickness, -y - borderThickness); // } graphics.translate(x, y); SubstanceImageCreator.paintSimpleBorder(c, graphics, width, height, borderColorScheme, borderColorScheme2, cyclePos); // SubstanceImageCreator.paintBorder(c, graphics, x, y, width, // height, // radius, borderColorScheme, borderColorScheme2, cyclePos); } graphics.dispose(); } /* * (non-Javadoc) * * @see javax.swing.border.Border#paintBorder(java.awt.Component, * java.awt.Graphics, int, int, int, int) */ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { paintBorder(c, g, x, y, width, height, c.isEnabled(), c.hasFocus(), this.alpha); } /* * (non-Javadoc) * * @see javax.swing.border.Border#getBorderInsets(java.awt.Component) */ public Insets getBorderInsets(Component c) { if (this.myInsets == null) { return SubstanceSizeUtils.getDefaultBorderInsets(SubstanceSizeUtils .getComponentFontSize(c)); } return this.myInsets; } /* * (non-Javadoc) * * @see javax.swing.border.Border#isBorderOpaque() */ public boolean isBorderOpaque() { return false; } /** * Returns the radius scale factor of this border. * * @return The radius scale factor of this border. */ public float getRadiusScaleFactor() { return this.radiusScaleFactor; } } substance-5.3.orig/src/org/jvnet/substance/utils/border/SubstancePaneBorder.java0000644000175000017500000001204711213200410030033 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.border; import java.awt.*; import javax.swing.SwingUtilities; import javax.swing.border.AbstractBorder; import javax.swing.plaf.UIResource; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.*; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.utils.SubstanceCoreUtilities; /** * Root pane and internal frame border in Substance look and feel. This * class is for internal use only. * * @author Kirill Grouchnikov */ public class SubstancePaneBorder extends AbstractBorder implements UIResource { /** * Default border thickness. */ private static final int BORDER_THICKNESS = 4; /** * Default insets. */ private static final Insets INSETS = new Insets( SubstancePaneBorder.BORDER_THICKNESS, SubstancePaneBorder.BORDER_THICKNESS, SubstancePaneBorder.BORDER_THICKNESS, SubstancePaneBorder.BORDER_THICKNESS); /* * (non-Javadoc) * * @see javax.swing.border.Border#paintBorder(java.awt.Component, * java.awt.Graphics, int, int, int, int) */ @Override public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { SubstanceSkin skin = SubstanceCoreUtilities.getSkin(c); if (skin == null) return; SubstanceColorScheme scheme = skin .getBackgroundColorScheme(DecorationAreaType.PRIMARY_TITLE_PANE); Component titlePaneComp = SubstanceLookAndFeel .getTitlePaneComponent(SwingUtilities.windowForComponent(c)); SubstanceColorScheme borderScheme = skin.getColorScheme(titlePaneComp, ColorSchemeAssociationKind.BORDER, ComponentState.DEFAULT); Graphics2D graphics = (Graphics2D) g; // bottom and right in ultra dark graphics.setColor(borderScheme.getUltraDarkColor()); graphics.drawLine(x, y + h - 1, x + w - 1, y + h - 1); graphics.drawLine(x + w - 1, y, x + w - 1, y + h - 1); // top and left graphics.setColor(borderScheme.getDarkColor()); graphics.drawLine(x, y, x + w - 2, y); graphics.drawLine(x, y, x, y + h - 2); // inner bottom and right graphics.setColor(scheme.getMidColor()); graphics.drawLine(x + 1, y + h - 2, x + w - 2, y + h - 2); graphics.drawLine(x + w - 2, y + 1, x + w - 2, y + h - 2); // inner top and left graphics.setColor(scheme.getMidColor()); graphics.drawLine(x + 1, y + 1, x + w - 3, y + 1); graphics.drawLine(x + 1, y + 1, x + 1, y + h - 3); // inner 2 and 3 graphics.setColor(scheme.getLightColor()); graphics.drawRect(x + 2, y + 2, w - 5, h - 5); graphics.drawRect(x + 3, y + 3, w - 7, h - 7); } /* * (non-Javadoc) * * @see javax.swing.border.Border#getBorderInsets(java.awt.Component) */ @Override public Insets getBorderInsets(Component c) { return SubstancePaneBorder.INSETS; } /* * (non-Javadoc) * * @see * javax.swing.border.AbstractBorder#getBorderInsets(java.awt.Component, * java.awt.Insets) */ @Override public Insets getBorderInsets(Component c, Insets newInsets) { newInsets.top = SubstancePaneBorder.INSETS.top; newInsets.left = SubstancePaneBorder.INSETS.left; newInsets.bottom = SubstancePaneBorder.INSETS.bottom; newInsets.right = SubstancePaneBorder.INSETS.right; return newInsets; } /* * (non-Javadoc) * * @see javax.swing.border.Border#isBorderOpaque() */ @Override public boolean isBorderOpaque() { return false; } } substance-5.3.orig/src/org/jvnet/substance/utils/border/SubstanceButtonBorder.java0000644000175000017500000000571311136475562030457 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.border; import java.awt.Component; import java.awt.Graphics; import javax.swing.border.Border; import javax.swing.plaf.UIResource; /** * Base class for button borders in Substance look-and-feel. This class * is for internal use only. * * @author Kirill Grouchnikov */ public abstract class SubstanceButtonBorder implements Border, UIResource { /** * The associated button shaper class. */ private Class buttonShaperClass; /** * Simple constructor. * * @param buttonShaperClass * The associated button shaper class. */ public SubstanceButtonBorder(Class buttonShaperClass) { this.buttonShaperClass = buttonShaperClass; } /* * (non-Javadoc) * * @see javax.swing.border.Border#isBorderOpaque() */ public boolean isBorderOpaque() { return false; } /* * (non-Javadoc) * * @see javax.swing.border.Border#paintBorder(java.awt.Component, * java.awt.Graphics, int, int, int, int) */ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { } /** * Returns the associated button shaper class. * * @return The associated button shaper class. */ public Class getButtonShaperClass() { return this.buttonShaperClass; } } substance-5.3.orig/src/org/jvnet/substance/utils/border/SubstanceEtchedBorder.java0000644000175000017500000001262211213537174030367 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.border; import java.awt.*; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import javax.swing.border.Border; import org.jvnet.lafwidget.utils.RenderingUtils; import org.jvnet.substance.api.*; import org.jvnet.substance.utils.*; /** * Custom implementation of etched border. * * @author Kirill Grouchnikov */ public class SubstanceEtchedBorder implements Border { /** * Returns the highlight color for the specified component. * * @param c * Component. * @return Matching highlight color. */ public Color getHighlightColor(Component c) { SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(c, ColorSchemeAssociationKind.SEPARATOR, ComponentState.DEFAULT); boolean isDark = colorScheme.isDark(); Color foreDark = isDark ? colorScheme.getExtraLightColor() : SubstanceColorUtilities.getInterpolatedColor(colorScheme .getMidColor(), colorScheme.getDarkColor(), 0.4); return SubstanceColorUtilities.getAlphaColor(foreDark, 196); } /** * Returns the shadow color for the specified component. * * @param c * Component. * @return Matching shadow color. */ public Color getShadowColor(Component c) { SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(c, ColorSchemeAssociationKind.SEPARATOR, ComponentState.DEFAULT); Color back = colorScheme.isDark() ? colorScheme.getDarkColor() : colorScheme.getUltraLightColor(); return SubstanceColorUtilities.getAlphaColor(back, 196); } public boolean isBorderOpaque() { return false; } public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { int w = width; int h = height; Graphics2D g2d = (Graphics2D) g.create(); float strokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(c)); g2d.setStroke(new BasicStroke(strokeWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.translate(x, y); g2d.setColor(getShadowColor(c)); // this is to prevent clipping of thick outer borders. int delta = (int) Math.floor(strokeWidth / 2.0); g2d.draw(new Rectangle2D.Float(delta, delta, w - delta - 2 * strokeWidth, h - delta - 2 * strokeWidth)); // g2d.drawRect(0, 0, w - 2, h - 2); g2d.setColor(getHighlightColor(c)); g2d.draw(new Line2D.Float(strokeWidth, h - 3 * strokeWidth, strokeWidth, strokeWidth)); // g2d.drawLine(1, h - 3, 1, 1); g2d.draw(new Line2D.Float(delta + strokeWidth, delta + strokeWidth, w - delta - 3 * strokeWidth, delta + strokeWidth)); // g2d.drawLine(1, 1, w - 3, 1); g2d.draw(new Line2D.Float(delta, h - delta - strokeWidth, w - delta - strokeWidth, h - delta - strokeWidth)); // g2d.drawLine(0, h - 1, w - 1, h - 1); g2d.draw(new Line2D.Float(w - delta - strokeWidth, h - delta - strokeWidth, w - delta - strokeWidth, delta)); // g2d.drawLine(w - 1, h - 1, w - 1, 0); g2d.dispose(); // this is a fix for defect 248 - in order to paint the TitledBorder // text respecting the AA settings of the display, we have to // set rendering hints on the passed Graphics object. RenderingUtils.installDesktopHints((Graphics2D) g, c); } /* * (non-Javadoc) * * @see javax.swing.border.Border#getBorderInsets(java.awt.Component) */ public Insets getBorderInsets(Component c) { float borderStrokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(c)); int prefSize = (int) (Math.ceil(2.0 * borderStrokeWidth)); return new Insets(prefSize, prefSize, prefSize, prefSize); } } substance-5.3.orig/src/org/jvnet/substance/utils/combo/0000755000175000017500000000000011256731150023136 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/utils/combo/SubstanceComboBoxButton.java0000644000175000017500000000655011136475562030574 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.combo; import java.awt.Insets; import javax.swing.*; import org.jvnet.lafwidget.animation.FadeConfigurationManager; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.utils.SubstanceArrowButton; import org.jvnet.substance.utils.SubstanceSizeUtils; /** * Combo box button in Substance look and feel. * * @author Kirill Grouchnikov */ @SubstanceArrowButton public final class SubstanceComboBoxButton extends JButton { static { FadeConfigurationManager.getInstance().disallowFades( FadeKind.GHOSTING_BUTTON_PRESS, SubstanceComboBoxButton.class); FadeConfigurationManager.getInstance().disallowFades( FadeKind.GHOSTING_ICON_ROLLOVER, SubstanceComboBoxButton.class); } /** * Simple constructor. * * @param comboBox * The owner combo box. * @param comboIcon * The button icon (down arrow). */ public SubstanceComboBoxButton(JComboBox comboBox) { super(""); this.setModel(new DefaultButtonModel() { @Override public void setArmed(boolean armed) { super.setArmed(this.isPressed() || armed); } }); this.setEnabled(comboBox.isEnabled()); this.setFocusable(false); this.setRequestFocusEnabled(comboBox.isEnabled()); int fontSize = SubstanceSizeUtils.getComponentFontSize(comboBox); int tbInset = SubstanceSizeUtils.getAdjustedSize(fontSize, 1, 2, 1, false); int lrInset = SubstanceSizeUtils.getAdjustedSize(fontSize, 0, 2, 1, false); this.setMargin(new Insets(tbInset, lrInset, tbInset, tbInset)); this.putClientProperty(SubstanceLookAndFeel.USE_THEMED_DEFAULT_ICONS, Boolean.FALSE); } } substance-5.3.orig/src/org/jvnet/substance/utils/combo/SubstanceComboBoxEditor.java0000644000175000017500000000444011201074240030520 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.combo; import javax.swing.JTextField; import javax.swing.plaf.basic.BasicComboBoxEditor; /** * Combobox editor. * * @author Kirill Grouchnikov */ public class SubstanceComboBoxEditor extends BasicComboBoxEditor { /** * Creates a new editor. */ public SubstanceComboBoxEditor() { super(); this.editor = new JTextField("", 9); this.editor.setBorder(null); } /** * Combobox editor that implements the marker * {@link javax.swing.plaf.UIResource} interface. * * @author Kirill Grouchnikov */ public static class UIResource extends SubstanceComboBoxEditor implements javax.swing.plaf.UIResource { } } substance-5.3.orig/src/org/jvnet/substance/utils/combo/SubstanceComboPopup.java0000644000175000017500000001640411177773730027755 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.combo; import java.awt.*; import javax.swing.*; import javax.swing.plaf.basic.BasicComboPopup; import org.jvnet.substance.SubstanceListUI; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.border.SubstanceBorder; /** * Combo popup implementation in Substance look-and-feel. This class is * for internal use only. * * @author Kirill Grouchnikov */ public class SubstanceComboPopup extends BasicComboPopup { /** * Creates combo popup for the specified combobox. * * @param combo * Combobox. */ public SubstanceComboPopup(JComboBox combo) { super(combo); // fix for defect 154 this.setOpaque(true); this.list.setBackground(combo.getBackground()); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboPopup#configurePopup() */ @Override protected void configurePopup() { super.configurePopup(); setBorder(new SubstanceBorder(new Insets(0, 2, 2, 2))); } /** * Sets the list selection index to the selectedIndex. This method is used * to synchronize the list selection with the combo box selection. * * @param selectedIndex * the index to set the list */ private void setListSelection(int selectedIndex) { if (selectedIndex == -1) { this.list.clearSelection(); } else { this.list.setSelectedIndex(selectedIndex); this.list.ensureIndexIsVisible(selectedIndex); } } /** * Calculates the upper left location of the popup. * * @return The upper left location of the popup. */ private Point getPopupLocation() { Dimension popupSize = this.comboBox.getSize(); Insets insets = this.getInsets(); // reduce the width of the scrollpane by the insets so that the popup // is the same width as the combo box. popupSize.setSize(popupSize.width - (insets.right + insets.left), this .getPopupHeightForRowCount(this.comboBox.getMaximumRowCount())); Rectangle popupBounds = this.computePopupBounds(0, this.comboBox .getBounds().height, popupSize.width, popupSize.height); Dimension scrollSize = popupBounds.getSize(); Point popupLocation = popupBounds.getLocation(); this.scroller.setMaximumSize(scrollSize); this.scroller.setPreferredSize(scrollSize); this.scroller.setMinimumSize(scrollSize); this.list.revalidate(); return new Point(popupLocation.x, popupLocation.y); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboPopup#computePopupBounds(int, int, * int, int) */ @Override protected Rectangle computePopupBounds(int px, int py, int pw, int ph) { int popupFlyoutOrientation = SubstanceCoreUtilities .getPopupFlyoutOrientation(this.comboBox); int dx = 0; int dy = 0; switch (popupFlyoutOrientation) { case SwingConstants.NORTH: dy = -ph - (int) this.comboBox.getSize().getHeight(); break; case SwingConstants.CENTER: dy = -ph / 2 - (int) this.comboBox.getSize().getHeight() / 2; break; case SwingConstants.EAST: dx = pw; dy = -(int) this.comboBox.getSize().getHeight(); break; case SwingConstants.WEST: dx = -pw; dy = -(int) this.comboBox.getSize().getHeight(); } Toolkit toolkit = Toolkit.getDefaultToolkit(); Rectangle screenBounds; // Calculate the desktop dimensions relative to the combo box. GraphicsConfiguration gc = this.comboBox.getGraphicsConfiguration(); Point p = new Point(); SwingUtilities.convertPointFromScreen(p, this.comboBox); if (gc != null) { Insets screenInsets = toolkit.getScreenInsets(gc); screenBounds = gc.getBounds(); screenBounds.width -= (screenInsets.left + screenInsets.right); screenBounds.height -= (screenInsets.top + screenInsets.bottom); screenBounds.x += (p.x + screenInsets.left); screenBounds.y += (p.y + screenInsets.top); } else { screenBounds = new Rectangle(p, toolkit.getScreenSize()); } Rectangle rect = new Rectangle(px + dx, py + dy, pw, ph); if ((py + ph > screenBounds.y + screenBounds.height) && (ph < screenBounds.height)) { rect.y = -rect.height; } // The following has been taken from JGoodies' Looks implementation // for the popup prototype value Object popupPrototypeDisplayValue = SubstanceCoreUtilities .getComboPopupPrototypeDisplayValue(this.comboBox); if (popupPrototypeDisplayValue != null) { ListCellRenderer renderer = this.list.getCellRenderer(); Component c = renderer.getListCellRendererComponent(this.list, popupPrototypeDisplayValue, -1, true, true); int npw = c.getPreferredSize().width; boolean hasVerticalScrollBar = this.comboBox.getItemCount() > this.comboBox .getMaximumRowCount(); if (hasVerticalScrollBar) { // Add the scrollbar width. JScrollBar verticalBar = this.scroller.getVerticalScrollBar(); npw += verticalBar.getPreferredSize().width; } pw = Math.max(pw, npw); rect.width = pw; } return rect; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboPopup#show() */ @Override public void show() { this.setListSelection(this.comboBox.getSelectedIndex()); Point location = this.getPopupLocation(); this.show(this.comboBox, location.x, location.y); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicComboPopup#hide() */ @Override public void hide() { super.hide(); SubstanceListUI ui = (SubstanceListUI) this.list.getUI(); ui.resetRolloverIndex(); // this.list.putClientProperty(SubstanceListUI.ROLLED_OVER_INDEX, null); } public JComboBox getCombobox() { return this.comboBox; } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceWidgetManager.java0000644000175000017500000001111411136475562027277 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.util.*; import javax.swing.JRootPane; import org.jvnet.substance.api.SubstanceConstants.SubstanceWidgetType; public class SubstanceWidgetManager { private static SubstanceWidgetManager instance; private Set globalAllowed; private Set globalDisallowed; private WeakHashMap> specificAllowed; private WeakHashMap> specificDisallowed; public static synchronized SubstanceWidgetManager getInstance() { if (instance == null) instance = new SubstanceWidgetManager(); return instance; } private SubstanceWidgetManager() { this.globalAllowed = EnumSet.noneOf(SubstanceWidgetType.class); this.globalDisallowed = EnumSet.noneOf(SubstanceWidgetType.class); this.specificAllowed = new WeakHashMap>(); this.specificDisallowed = new WeakHashMap>(); } public void register(JRootPane rootPane, boolean isAllowed, SubstanceWidgetType... substanceWidgets) { if (rootPane == null) { for (SubstanceWidgetType widget : substanceWidgets) { if (isAllowed) { this.globalAllowed.add(widget); this.globalDisallowed.remove(widget); } else { this.globalDisallowed.add(widget); this.globalAllowed.remove(widget); } } } else { Set toAddTo = null; Set toRemoveFrom = null; if (isAllowed) { toAddTo = this.specificAllowed.get(rootPane); if (toAddTo == null) { toAddTo = EnumSet.noneOf(SubstanceWidgetType.class); this.specificAllowed.put(rootPane, toAddTo); } toRemoveFrom = this.specificDisallowed.get(rootPane); } else { toAddTo = this.specificDisallowed.get(rootPane); if (toAddTo == null) { toAddTo = EnumSet.noneOf(SubstanceWidgetType.class); this.specificDisallowed.put(rootPane, toAddTo); } toRemoveFrom = this.specificAllowed.get(rootPane); } for (SubstanceWidgetType widget : substanceWidgets) { toAddTo.add(widget); if (toRemoveFrom != null) toRemoveFrom.remove(widget); } } } public boolean isAllowed(JRootPane rootPane, SubstanceWidgetType widget) { if (this.specificDisallowed.containsKey(rootPane)) { if (this.specificDisallowed.get(rootPane).contains(widget)) return false; } if (this.specificAllowed.containsKey(rootPane)) { if (this.specificAllowed.get(rootPane).contains(widget)) return true; } if (this.globalDisallowed.contains(widget)) return false; if (this.globalAllowed.contains(widget)) return true; return false; } public boolean isAllowedAnywhere(SubstanceWidgetType widget) { if (specificAllowed.size() > 0) return true; if (this.globalDisallowed.contains(widget)) return false; if (this.globalAllowed.contains(widget)) return true; return false; } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceColorUtilities.java0000644000175000017500000010037311247452542027535 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.Color; import java.awt.Component; import javax.swing.*; import javax.swing.plaf.ColorUIResource; import javax.swing.plaf.UIResource; import javax.swing.text.JTextComponent; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.animation.FadeState; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.*; /** * Various color-related utilities. This class is for internal use only. * * @author Kirill Grouchnikov */ public class SubstanceColorUtilities { /** * Returns the color of the top portion of border in control backgrounds. * * @param scheme1 * The first color scheme. * @param scheme2 * The second color scheme. * @param cycleCoef * Cycle position. Is used for rollover and pulsation effects. * Must be in 0.0 .. 1.0 range. * @return The color of the top portion of border in control backgrounds. */ public static Color getTopBorderColor(SubstanceColorScheme scheme1, SubstanceColorScheme scheme2, double cycleCoef) { return SubstanceColorUtilities.getInterpolatedColor(scheme1 .getUltraDarkColor(), scheme2.getUltraDarkColor(), cycleCoef); } /** * Returns the color of the middle portion of border in control backgrounds. * * @param scheme1 * The first color scheme. * @param scheme2 * The second color scheme. * @param cycleCoef * Cycle position. Is used for rollover and pulsation effects. * Must be in 0.0 .. 1.0 range. * @return The color of the middle portion of border in control backgrounds. */ public static Color getMidBorderColor(SubstanceColorScheme scheme1, SubstanceColorScheme scheme2, double cycleCoef) { return SubstanceColorUtilities.getInterpolatedColor(scheme1 .getDarkColor(), scheme2.getDarkColor(), cycleCoef); } /** * Returns the color of the bottom portion of border in control backgrounds. * * @param scheme1 * The first color scheme. * @param scheme2 * The second color scheme. * @param cycleCoef * Cycle position. Is used for rollover and pulsation effects. * Must be in 0.0 .. 1.0 range. * @return The color of the bottom portion of border in control backgrounds. */ public static Color getBottomBorderColor(SubstanceColorScheme scheme1, SubstanceColorScheme scheme2, double cycleCoef) { Color c1 = SubstanceColorUtilities.getInterpolatedColor(scheme1 .getDarkColor(), scheme1.getMidColor(), 0.5); Color c2 = SubstanceColorUtilities.getInterpolatedColor(scheme2 .getDarkColor(), scheme2.getMidColor(), 0.5); return SubstanceColorUtilities.getInterpolatedColor(c1, c2, cycleCoef); } /** * Returns the color of the top portion of fill in control backgrounds. * * @param scheme1 * The first color scheme. * @param scheme2 * The second color scheme. * @param cycleCoef * Cycle position. Is used for rollover and pulsation effects. * Must be in 0.0 .. 1.0 range. * @param useCyclePosAsInterpolation * Indicates the algorithm to use for computing various colors. * If true, the cyclePos is used to * interpolate colors between different color components of both * color schemes. If false, the * cyclePos is used to interpolate colors between * different color components of the first color scheme. * @return The color of the top portion of fill in control backgrounds. */ public static Color getTopFillColor(SubstanceColorScheme scheme1, SubstanceColorScheme scheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { if (!useCyclePosAsInterpolation) { Color c = SubstanceColorUtilities.getInterpolatedColor(scheme1 .getDarkColor(), scheme1.getMidColor(), 0.4); return SubstanceColorUtilities.getInterpolatedColor(c, scheme2 .getLightColor(), cycleCoef); } else { Color c1 = SubstanceColorUtilities.getInterpolatedColor(scheme1 .getDarkColor(), scheme1.getMidColor(), 0.4); Color c2 = SubstanceColorUtilities.getInterpolatedColor(scheme2 .getDarkColor(), scheme2.getMidColor(), 0.4); return SubstanceColorUtilities.getInterpolatedColor(c1, c2, cycleCoef); } } /** * Returns the color of the middle portion of fill in control backgrounds. * * @param scheme1 * The first color scheme. * @param scheme2 * The second color scheme. * @param cycleCoef * Cycle position. Is used for rollover and pulsation effects. * Must be in 0.0 .. 1.0 range. * @param useCyclePosAsInterpolation * Indicates the algorithm to use for computing various colors. * If true, the cyclePos is used to * interpolate colors between different color components of both * color schemes. If false, the * cyclePos is used to interpolate colors between * different color components of the first color scheme. * @return The color of the middle portion of fill in control backgrounds. */ public static Color getMidFillColor(SubstanceColorScheme scheme1, SubstanceColorScheme scheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { if (!useCyclePosAsInterpolation) { return SubstanceColorUtilities.getInterpolatedColor(scheme1 .getMidColor(), scheme2.getLightColor(), cycleCoef); } else { return SubstanceColorUtilities.getInterpolatedColor(scheme1 .getMidColor(), scheme2.getMidColor(), cycleCoef); } } /** * Returns the color of the bottom portion of fill in control backgrounds. * * @param scheme1 * The first color scheme. * @param scheme2 * The second color scheme. * @param cycleCoef * Cycle position. Is used for rollover and pulsation effects. * Must be in 0.0 .. 1.0 range. * @param useCyclePosAsInterpolation * Indicates the algorithm to use for computing various colors. * If true, the cyclePos is used to * interpolate colors between different color components of both * color schemes. If false, the * cyclePos is used to interpolate colors between * different color components of the first color scheme. * @return The color of the bottom portion of fill in control backgrounds. */ public static Color getBottomFillColor(SubstanceColorScheme scheme1, SubstanceColorScheme scheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { if (!useCyclePosAsInterpolation) { return SubstanceColorUtilities.getInterpolatedColor(scheme1 .getUltraLightColor(), scheme2.getExtraLightColor(), cycleCoef); } else { return SubstanceColorUtilities.getInterpolatedColor(scheme1 .getUltraLightColor(), scheme2.getUltraLightColor(), cycleCoef); } } /** * Returns the color of the top portion of shine in control backgrounds. * * @param scheme1 * The first color scheme. * @param scheme2 * The second color scheme. * @param cycleCoef * Cycle position. Is used for rollover and pulsation effects. * Must be in 0.0 .. 1.0 range. * @param useCyclePosAsInterpolation * Indicates the algorithm to use for computing various colors. * If true, the cyclePos is used to * interpolate colors between different color components of both * color schemes. If false, the * cyclePos is used to interpolate colors between * different color components of the first color scheme. * @return The color of the top portion of shine in control backgrounds. */ public static Color getTopShineColor(SubstanceColorScheme scheme1, SubstanceColorScheme scheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return getBottomFillColor(scheme1, scheme2, cycleCoef, useCyclePosAsInterpolation); } /** * Returns the color of the bottom portion of shine in control backgrounds. * * @param scheme1 * The first color scheme. * @param scheme2 * The second color scheme. * @param cycleCoef * Cycle position. Is used for rollover and pulsation effects. * Must be in 0.0 .. 1.0 range. * @param useCyclePosAsInterpolation * Indicates the algorithm to use for computing various colors. * If true, the cyclePos is used to * interpolate colors between different color components of both * color schemes. If false, the * cyclePos is used to interpolate colors between * different color components of the first color scheme. * @return The color of the bottom portion of shine in control backgrounds. */ public static Color getBottomShineColor(SubstanceColorScheme scheme1, SubstanceColorScheme scheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { if (!useCyclePosAsInterpolation) { return SubstanceColorUtilities.getInterpolatedColor(scheme1 .getLightColor(), scheme2.getUltraLightColor(), cycleCoef); } else { return SubstanceColorUtilities.getInterpolatedColor(scheme1 .getLightColor(), scheme2.getLightColor(), cycleCoef); } } /** * Interpolates color. * * @param color1 * The first color * @param color2 * The second color * @param color1Likeness * The closer this value is to 0.0, the closer the resulting * color will be to color2. * @return Interpolated RGB value. */ public static int getInterpolatedRGB(Color color1, Color color2, double color1Likeness) { if ((color1Likeness < 0.0) || (color1Likeness > 1.0)) throw new IllegalArgumentException( "Color likeness should be in 0.0-1.0 range [is " + color1Likeness + "]"); int lr = color1.getRed(); int lg = color1.getGreen(); int lb = color1.getBlue(); int la = color1.getAlpha(); int dr = color2.getRed(); int dg = color2.getGreen(); int db = color2.getBlue(); int da = color2.getAlpha(); // using some interpolation values (such as 0.29 from issue 401) // results in an incorrect final value without Math.round. int r = (lr == dr) ? lr : (int) Math.round(color1Likeness * lr + (1.0 - color1Likeness) * dr); int g = (lg == dg) ? lg : (int) Math.round(color1Likeness * lg + (1.0 - color1Likeness) * dg); int b = (lb == db) ? lb : (int) Math.round(color1Likeness * lb + (1.0 - color1Likeness) * db); int a = (la == da) ? la : (int) Math.round(color1Likeness * la + (1.0 - color1Likeness) * da); return (a << 24) | (r << 16) | (g << 8) | b; } /** * Interpolates color. * * @param color1 * The first color * @param color2 * The second color * @param color1Likeness * The closer this value is to 0.0, the closer the resulting * color will be to color2. * @return Interpolated color. */ public static Color getInterpolatedColor(Color color1, Color color2, double color1Likeness) { if (color1.equals(color2)) return color1; if (color1Likeness == 1.0) return color1; if (color1Likeness == 0.0) return color2; return new Color(getInterpolatedRGB(color1, color2, color1Likeness), true); } /** * Inverts the specified color. * * @param color * The original color. * @return The inverted color. */ public static Color invertColor(Color color) { return new Color(255 - color.getRed(), 255 - color.getGreen(), 255 - color.getBlue(), color.getAlpha()); } /** * Returns a negative of the specified color. * * @param color * Color. * @return Negative of the specified color. */ public static Color getNegativeColor(Color color) { return new Color(255 - color.getRed(), 255 - color.getGreen(), 255 - color.getBlue(), color.getAlpha()); } /** * Returns a negative of the specified color. * * @param rgb * Color RGB. * @return Negative of the specified color. */ public static int getNegativeColor(int rgb) { int transp = (rgb >>> 24) & 0xFF; int r = (rgb >>> 16) & 0xFF; int g = (rgb >>> 8) & 0xFF; int b = (rgb >>> 0) & 0xFF; return (transp << 24) | ((255 - r) << 16) | ((255 - g) << 8) | (255 - b); } /** * Returns a translucent of the specified color. * * @param color * Color. * @param alpha * Alpha channel value. * @return Translucent of the specified color that matches the requested * alpha channel value. */ public static Color getAlphaColor(Color color, int alpha) { return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha); } /** * Returns saturated version of the specified color. * * @param color * Color. * @param factor * Saturation factor. * @return Saturated color. */ public static Color getSaturatedColor(Color color, double factor) { float[] hsbvals = new float[3]; Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsbvals); float sat = hsbvals[1]; if (factor > 0.0) { sat = sat + (float) factor * (1.0f - sat); } else { sat = sat + (float) factor * sat; } return new Color(Color.HSBtoRGB(hsbvals[0], sat, hsbvals[2])); } /** * Returns hue-shifted (in HSV space) version of the specified color. * * @param color * Color. * @param hueShift * hue shift factor. * @return Hue-shifted (in HSV space) color. */ public static Color getHueShiftedColor(Color color, double hueShift) { float[] hsbvals = new float[3]; Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsbvals); float hue = hsbvals[0]; hue += hueShift; if (hue < 0.0) hue += 1.0; if (hue > 1.0) hue -= 1.0; return new Color(Color.HSBtoRGB(hue, hsbvals[1], hsbvals[2])); } /** * Derives a color based on the original color and a brightness source. The * resulting color has the same hue and saturation as the original color, * but its brightness is shifted towards the brightness of the brightness * source. Thus, a light red color shifted towards dark green will become * dark red. * * @param original * Original color. * @param brightnessSource * Brightness source. * @return Derived color that has the same hue and saturation as the * original color, but its brightness is shifted towards the * brightness of the brightness source. */ public static Color deriveByBrightness(Color original, Color brightnessSource) { float[] hsbvalsOrig = new float[3]; Color.RGBtoHSB(original.getRed(), original.getGreen(), original .getBlue(), hsbvalsOrig); float[] hsbvalsBrightnessSrc = new float[3]; Color.RGBtoHSB(brightnessSource.getRed(), brightnessSource.getGreen(), brightnessSource.getBlue(), hsbvalsBrightnessSrc); return new Color(Color.HSBtoRGB(hsbvalsOrig[0], hsbvalsOrig[1], (hsbvalsBrightnessSrc[2] + hsbvalsOrig[2]) / 2.0f)); } /** * Returns the foreground color of the specified color scheme. * * @param scheme * Color scheme. * @return Color scheme foreground color. */ public static ColorUIResource getForegroundColor(SubstanceColorScheme scheme) { return new ColorUIResource(scheme.getForegroundColor()); } /** * Returns lighter version of the specified color. * * @param color * Color. * @param diff * Difference factor (values closer to 0.0 will produce results * closer to white color). * @return Lighter version of the specified color. */ public static Color getLighterColor(Color color, double diff) { int r = color.getRed() + (int) (diff * (255 - color.getRed())); int g = color.getGreen() + (int) (diff * (255 - color.getGreen())); int b = color.getBlue() + (int) (diff * (255 - color.getBlue())); return new Color(r, g, b); } /** * Returns darker version of the specified color. * * @param color * Color. * @param diff * Difference factor (values closer to 1.0 will produce results * closer to black color). * @return Darker version of the specified color. */ public static Color getDarkerColor(Color color, double diff) { int r = (int) ((1.0 - diff) * color.getRed()); int g = (int) ((1.0 - diff) * color.getGreen()); int b = (int) ((1.0 - diff) * color.getBlue()); return new Color(r, g, b); } /** * Returns the brightness of the specified color. * * @param rgb * RGB value of a color. * @return The brightness of the specified color. */ public static int getColorBrightness(int rgb) { int oldR = (rgb >>> 16) & 0xFF; int oldG = (rgb >>> 8) & 0xFF; int oldB = (rgb >>> 0) & 0xFF; return (222 * oldR + 707 * oldG + 71 * oldB) / 1000; } /** * Returns the color of the focus ring for the specified component. * * @param comp * Component. * @return The color of the focus ring for the specified component. */ public static Color getFocusColor(Component comp) { SubstanceColorScheme activeScheme = SubstanceColorSchemeUtilities .getColorScheme(comp, ComponentState.ACTIVE); if (comp instanceof AbstractButton) { AbstractButton ab = (AbstractButton) comp; ButtonModel model = ab.getModel(); ComponentState currState = ComponentState.getState(model, ab); SubstanceColorScheme currScheme = SubstanceColorSchemeUtilities .getColorScheme(comp, ColorSchemeAssociationKind.MARK, currState); Color currColor = currScheme.getFocusRingColor(); FadeState fadeState = SubstanceFadeUtilities.getFadeState(comp, FadeKind.PRESS, FadeKind.SELECTION, FadeKind.ROLLOVER); if (fadeState != null) { // the component is currently animating ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(ab); SubstanceColorScheme prevScheme = SubstanceColorSchemeUtilities .getColorScheme(comp, ColorSchemeAssociationKind.MARK, prevState); Color prevColor = prevScheme.getFocusRingColor(); float likeness = fadeState.getFadePosition(); if (fadeState.isFadingIn()) likeness = 1.0f - likeness; return SubstanceColorUtilities.getInterpolatedColor(prevColor, currColor, likeness); } else { return currColor; } } Color color = activeScheme.getFocusRingColor(); return color; } /** * Returns the color strength. * * @param color * Color. * @return Color strength. */ public static float getColorStrength(Color color) { return Math.max(getColorBrightness(color.getRGB()), getColorBrightness(getNegativeColor(color.getRGB()))) / 255.0f; } /** * Returns the color of mark icons (checkbox, radio button, scrollbar * arrows, combo arrows, menu arrows etc) for the specified color scheme. * * @param colorScheme * Color scheme. * @param isEnabled * If true, the mark should be painted in enabled * state. * @return Color of mark icons. */ public static Color getMarkColor(SubstanceColorScheme colorScheme, boolean isEnabled) { if (colorScheme.isDark()) { if (!isEnabled) { return colorScheme.getDarkColor(); } else { return getInterpolatedColor(colorScheme.getForegroundColor(), colorScheme.getUltraLightColor(), 0.9); } } else { Color color1 = isEnabled ? colorScheme.getUltraDarkColor() : colorScheme.getUltraDarkColor(); Color color2 = isEnabled ? colorScheme.getDarkColor() : colorScheme .getLightColor(); return getInterpolatedColor(color1, color2, 0.9); } } /** * Returns the foreground text color of the specified component. * * @param component * Component. * @param state * Component current state. * @param prevState * Component previous state. * @return The foreground text color of the specified component. */ public static Color getForegroundColor(Component component, ComponentState state, ComponentState prevState) { boolean isMenuItem = (component instanceof JMenuItem); ColorSchemeAssociationKind currAssocKind = ColorSchemeAssociationKind.FILL; // use HIGHLIGHT on active menu items if (isMenuItem && state.isKindActive(FadeKind.ENABLE) && (state != ComponentState.DEFAULT)) currAssocKind = ColorSchemeAssociationKind.HIGHLIGHT; SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(component, currAssocKind, state); if (!state.isKindActive(FadeKind.ENABLE)) { return colorScheme.getForegroundColor(); } SubstanceColorScheme prevColorScheme = colorScheme; if (prevState != state) { ColorSchemeAssociationKind prevAssocKind = ColorSchemeAssociationKind.FILL; // use HIGHLIGHT on active menu items if (isMenuItem && prevState.isKindActive(FadeKind.ENABLE) && (prevState != ComponentState.DEFAULT)) prevAssocKind = ColorSchemeAssociationKind.HIGHLIGHT; prevColorScheme = SubstanceColorSchemeUtilities.getColorScheme( component, prevAssocKind, prevState); } if (isMenuItem) { return SubstanceColorUtilities.getInterpolatedForegroundColor( component, null, colorScheme, state, prevColorScheme, prevState, FadeKind.ROLLOVER, FadeKind.SELECTION, FadeKind.PRESS, FadeKind.ARM); } else { return SubstanceColorUtilities.getInterpolatedForegroundColor( component, null, colorScheme, state, prevColorScheme, prevState, FadeKind.ROLLOVER, FadeKind.SELECTION, FadeKind.PRESS); } } /** * Returns the foreground text color of the specified tabbed pane tab. * * @param tabPane * Tabbed pane. * @param tabIndex * Tab index. * @param state * Component current state. * @param prevState * Component previous state. * @return The foreground text color of the specified tabbed pane tab. */ public static Color getForegroundColor(JTabbedPane tabPane, int tabIndex, ComponentState state, ComponentState prevState) { SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(tabPane, tabIndex, ColorSchemeAssociationKind.TAB, state); SubstanceColorScheme prevColorScheme = (prevState != state) ? SubstanceColorSchemeUtilities .getColorScheme(tabPane, tabIndex, ColorSchemeAssociationKind.TAB, prevState) : colorScheme; return SubstanceColorUtilities.getInterpolatedForegroundColor(tabPane, tabIndex, colorScheme, state, prevColorScheme, prevState, FadeKind.ROLLOVER, FadeKind.SELECTION, FadeKind.PRESS); } /** * Returns the foreground color for the specified component. * * @param comp * Component. * @param componentId * Optional component ID. Can be used to differentiate sub-parts * of the component, such as tabs in tabbed pane, cells in list * etc. * @param colorScheme * Component color scheme. * @param state * Component current state. * @param prevState * Component previous state. * @param kinds * Animation kinds to consult for computing the foreground color. * @return Foreground color. */ public static Color getInterpolatedForegroundColor(Component comp, Comparable componentId, SubstanceColorScheme colorScheme, ComponentState state, SubstanceColorScheme prevColorScheme, ComponentState prevState, FadeKind... kinds) { // SubstanceColorScheme colorScheme2 = colorScheme; float cyclePos = state.getCyclePosition(); FadeState fadeState = SubstanceFadeUtilities.getFadeState(comp, componentId, kinds); if (fadeState != null) { cyclePos = fadeState.getFadePosition(); if (!fadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; } // System.out.println(colorScheme.getDisplayName() + ":" // + prevColorScheme.getDisplayName() + ":" + cyclePos); Color c1 = colorScheme.getForegroundColor(); Color c2 = prevColorScheme.getForegroundColor(); return getInterpolatedColor(c1, c2, cyclePos); } /** * Returns the background fill color of the specified component. * * @param component * Component. * @return The background fill color of the specified component. */ public static Color getBackgroundFillColor(Component component) { // special case - sliders, check boxes and radio buttons. For this, // switch to component parent // boolean isColorized = hasColorization(component); if ((component instanceof JCheckBox) || (component instanceof JRadioButton) || (component instanceof JSlider)) { component = component.getParent(); } else { // Fix for 325 - respect the opacity setting of the text // component if (component instanceof JTextComponent && !component.isOpaque()) component = component.getParent(); } Color backgr = component.getBackground(); // do not change the background color on cell // renderers if (SwingUtilities .getAncestorOfClass(CellRendererPane.class, component) != null) return backgr; boolean isBackgroundUiResource = backgr instanceof UIResource; if (!isBackgroundUiResource) { // special case for issue 386 - if the colorization // is 1.0, return the component background if ((SubstanceCoreUtilities.getColorizationFactor(component) == 1.0f) && component.isEnabled()) { return backgr; } SubstanceColorScheme scheme = SubstanceColorSchemeUtilities .getColorScheme(component, component.isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED); backgr = scheme.getBackgroundFillColor(); } else { ComponentState state = component.isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED; if (component instanceof JTextComponent) { // special case - enabled uneditable text components if (component.isEnabled() && !((JTextComponent) component).isEditable()) { state = ComponentState.DISABLED_SELECTED; } } // menu items always use the same background color so that the // menu looks continuous if (component instanceof JMenuItem) { state = ComponentState.DEFAULT; } backgr = SubstanceColorUtilities.getDefaultBackgroundColor( component, state); if (!state.isKindActive(FadeKind.ENABLE)) { float alpha = SubstanceColorSchemeUtilities.getAlpha(component, state); if (alpha < 1.0f) { Color defaultColor = SubstanceColorUtilities .getDefaultBackgroundColor(component, ComponentState.DEFAULT); backgr = SubstanceColorUtilities.getInterpolatedColor( backgr, defaultColor, 1.0f - (1.0f - alpha) / 2.0f); } } } return backgr; } /** * Returns the default background color for the components of the specified * class. * * @param componentClass * Component class. * @param skin * Skin. * @param isDisabled * Indication whether the result should be for disabled * components. * @return The default background color for the components of the specified * class. */ public static ColorUIResource getDefaultBackgroundColor( Class componentClass, SubstanceSkin skin, boolean isDisabled) { boolean isTextControl = (JTextComponent.class .isAssignableFrom(componentClass)) || (JComboBox.class.isAssignableFrom(componentClass)) || (JSpinner.class.isAssignableFrom(componentClass)); if (isTextControl || isDisabled) return new ColorUIResource(skin.getMainDefaultColorScheme() .getTextBackgroundFillColor()); return new ColorUIResource(skin.getMainDefaultColorScheme() .getBackgroundFillColor()); } /** * Returns the default background color for the specified component. * * @param comp * Component. * @param compState * Component state. * @return The default background color for the components of the specified * class. */ public static ColorUIResource getDefaultBackgroundColor(Component comp, ComponentState compState) { // SubstanceSkin skin = SubstanceCoreUtilities.getSkin(comp); if ((comp instanceof JTextComponent) || (comp instanceof JComboBox) || (comp instanceof JSpinner)) { // special case for text-based components - use lighter // background fill color. return new ColorUIResource(SubstanceColorSchemeUtilities .getColorScheme(comp, compState) .getTextBackgroundFillColor()); } return new ColorUIResource(SubstanceCoreUtilities.getSkin(comp) .getBackgroundColorScheme( SubstanceLookAndFeel.getDecorationType(comp)) .getBackgroundFillColor()); // SubstanceColorSchemeUtilities // .getColorScheme(comp, compState).getBackgroundFillColor()); } /** * Returns the striped background for the specified component. This method * is relevant for components such as trees, tables and lists that use * odd-even striping for the alternating rows. * * @param component * Component. * @param rowIndex * Row index. * @return The striped background for the specified component. */ public static Color getStripedBackground(JComponent component, int rowIndex) { Color backgr = getBackgroundFillColor(component); if (backgr == null) return null; if (rowIndex % 2 == 0) return backgr; int r = backgr.getRed(); int g = backgr.getGreen(); int b = backgr.getBlue(); double coef = 0.96; if (!component.isEnabled()) coef = 1.0 - (1.0 - coef) / 2.0; Color darkerColor = new ColorUIResource((int) (coef * r), (int) (coef * g), (int) (coef * b)); return darkerColor; } public static String encode(int number) { if ((number < 0) || (number > 255)) throw new IllegalArgumentException("" + number); String hex = "0123456789ABCDEF"; char c1 = hex.charAt(number / 16); char c2 = hex.charAt(number % 16); return c1 + "" + c2; } public static String encode(Color color) { return "#" + encode(color.getRed()) + encode(color.getGreen()) + encode(color.getBlue()); } } substance-5.3.orig/src/org/jvnet/substance/utils/ButtonVisualStateTracker.java0000644000175000017500000001243311136475562027672 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.AbstractButton; import org.jvnet.lafwidget.animation.FadeStateListener; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.utils.combo.SubstanceComboBoxButton; import org.jvnet.substance.utils.scroll.SubstanceScrollButton; /** * Utility class to track transitions in visual state of buttons. * * @author Kirill Grouchnikov */ public class ButtonVisualStateTracker { /** * The rollover button listener. */ private RolloverButtonListener substanceButtonListener; /** * Property change listener. Listens on changes to the * {@link SubstanceLookAndFeel#BUTTON_SHAPER_PROPERTY} property and * {@link AbstractButton#MODEL_CHANGED_PROPERTY} property. */ protected PropertyChangeListener substancePropertyListener; /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /** * Installs tracking listeners on the specified button. * * @param b * Button. * @param toInstallRolloverListener * If true, the button will have the rollover * listener installed on it. */ public void installListeners(final AbstractButton b, boolean toInstallRolloverListener) { if (toInstallRolloverListener) { this.substanceButtonListener = new RolloverButtonListener(b); b.addMouseListener(this.substanceButtonListener); b.addMouseMotionListener(this.substanceButtonListener); b.addFocusListener(this.substanceButtonListener); b.addPropertyChangeListener(this.substanceButtonListener); b.addChangeListener(this.substanceButtonListener); } this.substancePropertyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (AbstractButton.MODEL_CHANGED_PROPERTY.equals(evt .getPropertyName())) { if (substanceFadeStateListener != null) substanceFadeStateListener.unregisterListeners(); boolean toRepaintParent = (b instanceof SubstanceScrollButton) || (b instanceof SubstanceSpinnerButton) || (b instanceof SubstanceComboBoxButton); substanceFadeStateListener = new FadeStateListener(b, b .getModel(), SubstanceCoreUtilities .getFadeCallback(b, toRepaintParent)); substanceFadeStateListener .registerListeners(toRepaintParent); } } }; b.addPropertyChangeListener(this.substancePropertyListener); boolean toRepaintParent = (b instanceof SubstanceScrollButton) || (b instanceof SubstanceSpinnerButton) || (b instanceof SubstanceComboBoxButton); this.substanceFadeStateListener = new FadeStateListener(b, b.getModel(), SubstanceCoreUtilities.getFadeCallback(b, toRepaintParent)); this.substanceFadeStateListener.registerListeners(toRepaintParent); } /** * Uninstalls the tracking listeners from the specified button. * * @param b * Button. */ public void uninstallListeners(AbstractButton b) { if (this.substanceButtonListener != null) { b.removeMouseListener(this.substanceButtonListener); b.removeMouseMotionListener(this.substanceButtonListener); b.removeFocusListener(this.substanceButtonListener); b.removePropertyChangeListener(this.substanceButtonListener); b.removeChangeListener(this.substanceButtonListener); this.substanceButtonListener = null; } b.removePropertyChangeListener(this.substancePropertyListener); this.substancePropertyListener = null; this.substanceFadeStateListener.unregisterListeners(); this.substanceFadeStateListener = null; } } substance-5.3.orig/src/org/jvnet/substance/utils/Trackable.java0000644000175000017500000000456711136475562024617 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.event.MouseEvent; /** * General interface for UIs that wish to provide transition effects on one of * their components. This class is for internal use only. * * @author Kirill Grouchnikov */ public interface Trackable { /** * Checks whether the mouse position of the specified event lies inside the * area of the component designated for transition effects. * * @param me * Mouse event. * @return true if the mouse position of the specified event * lies inside the area of the component designated for transition * effects, false otherwise. */ public boolean isInside(MouseEvent me); } substance-5.3.orig/src/org/jvnet/substance/utils/TabCloseListenerManager.java0000644000175000017500000001460611136475562027417 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.util.*; import javax.swing.JTabbedPane; import org.jvnet.substance.api.tabbed.BaseTabCloseListener; /** * Manages the listeners registered on tab-close events. This class is for * internal use only. * * @author Kirill Grouchnikov */ public class TabCloseListenerManager { /** * Listeners registered on all tabbed panes. */ private Set generalListeners; /** * Listeners registered on specific tabbed panes. */ private Map> specificListeners; /** * A single instance of this manager. */ private static TabCloseListenerManager instance = new TabCloseListenerManager(); /** * Returns the single instance of this class. * * @return The single instance of this class. */ public static TabCloseListenerManager getInstance() { return instance; } /** * Simple constructor. */ public TabCloseListenerManager() { this.generalListeners = new HashSet(); this.specificListeners = new HashMap>(); } /** * Unregisters the specified tabbed pane. * * @param tabbedPane * Tabbed pane to unregister. */ public synchronized void unregisterTabbedPane(JTabbedPane tabbedPane) { this.specificListeners.remove(tabbedPane); } /** * Registers the specified listener on tab-close events on all tabbed * panes. * * @param listener * Listener to register. */ public synchronized void registerListener(BaseTabCloseListener listener) { this.generalListeners.add(listener); } /** * Unregisters the specified listener on tab-close events on all * tabbed panes. * * @param listener * Listener to unregister. */ public synchronized void unregisterListener(BaseTabCloseListener listener) { this.generalListeners.remove(listener); } /** * Returns the set of all listeners registered on tab-close events on * all tabbed panes. * * @return Set of all listeners registered on tab-close events on all * tabbed panes. */ public synchronized Set getListeners() { return Collections.unmodifiableSet(this.generalListeners); } /** * Registers the specified listener on tab-close events on the * specified tabbed pane. * * @param tabbedPane * Tabbed pane. If null, the tab close listener is * registered globally (for all tabbed panes). * @param listener * Listener to register. */ public synchronized void registerListener(JTabbedPane tabbedPane, BaseTabCloseListener listener) { if (tabbedPane == null) { this.registerListener(listener); } else { Set listeners = this.specificListeners .get(tabbedPane); if (listeners == null) { listeners = new HashSet(); this.specificListeners.put(tabbedPane, listeners); } listeners.add(listener); } } /** * Unregisters the specified listener on tab-close events on the * specified tabbed pane. * * @param tabbedPane * Tabbed pane. If null, the tab close listener is * unregistered globally (for all tabbed panes). * @param listener * Listener to unregister. */ public synchronized void unregisterListener(JTabbedPane tabbedPane, BaseTabCloseListener listener) { if (tabbedPane == null) { this.unregisterListener(listener); } else { Set listeners = this.specificListeners .get(tabbedPane); if (listeners != null) listeners.remove(listener); } } /** * Returns the set of all listeners registered on tab-close events on the * specified tabbed pane. * * @param tabbedPane * Tabbed pane. If null, all globally registered tab * close listeners are returned. * @return The set of all listeners registered on tab-close events on the * specified tabbed pane. */ public synchronized Set getListeners( JTabbedPane tabbedPane) { if (tabbedPane == null) return this.getListeners(); Set result = new HashSet(); for (BaseTabCloseListener listener : this.generalListeners) result.add(listener); Set listeners = this.specificListeners .get(tabbedPane); if (listeners != null) { for (BaseTabCloseListener listener : listeners) result.add(listener); } return Collections.unmodifiableSet(result); } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceOutlineUtilities.java0000644000175000017500000002420611246720170030070 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.Component; import java.awt.Insets; import java.awt.geom.Arc2D; import java.awt.geom.GeneralPath; import java.util.Set; import org.jvnet.substance.api.SubstanceConstants.Side; /** * Provides common functionality that can be used by button shapers. This class * is for internal use only. * * @author Kirill Grouchnikov */ public class SubstanceOutlineUtilities { /** * Returns basic outline for the specified component. The basic outline is a * rectangle with rounded corners. Some corners may not be rounded based on * the contents of straightSide parameter. * * @param comp * Component. * @param radius * Corner radius. * @param straightSides * Contains all sides which are straight. * @return The basic outline for the specified parameters. */ public static GeneralPath getBaseOutline(Component comp, float radius, Set straightSides) { int width = comp.getWidth(); int height = comp.getHeight(); return getBaseOutline(width, height, radius, straightSides); } /** * Returns basic outline for the specified parameters. The basic outline is * a rectangle with rounded corners. Some corners may not be rounded based * on the contents of straightSide parameter. * * @param width * Width of some UI component. * @param height * Height of some UI component. * @param radius * Corner radius. * @param straightSides * Contains all sides which are straight. * @return The basic outline for the specified parameters. */ public static GeneralPath getBaseOutline(int width, int height, float radius, Set straightSides) { return getBaseOutline(width, height, radius, straightSides, null); } /** * Returns basic outline for the specified parameters. The basic outline is * a rectangle with rounded corners. Some corners may not be rounded based * on the contents of straightSides parameter. * * @param width * Width of some UI component. * @param height * Height of some UI component. * @param radius * Corner radius. * @param straightSides * Contains all sides which are straight. * @param insets * Shape insets. * @return The basic outline for the specified parameters. */ public static GeneralPath getBaseOutline(int width, int height, float radius, Set straightSides, int insets) { return getBaseOutline(width, height, radius, straightSides, new Insets( insets, insets, insets, insets)); } /** * Returns basic outline for the specified parameters. The basic outline is * a rectangle with rounded corners. Some corners may not be rounded based * on the contents of straightSides parameter. * * @param width * Width of some UI component. * @param height * Height of some UI component. * @param radius * Corner radius. * @param straightSides * Contains all sides which are straight. * @param insets * Shape insets. * @return The basic outline for the specified parameters. */ public static GeneralPath getBaseOutline(int width, int height, float radius, Set straightSides, Insets insets) { boolean isTopLeftCorner = (straightSides != null) && (straightSides.contains(Side.LEFT) || straightSides .contains(Side.TOP)); boolean isTopRightCorner = (straightSides != null) && (straightSides.contains(Side.RIGHT) || straightSides .contains(Side.TOP)); boolean isBottomRightCorner = (straightSides != null) && (straightSides.contains(Side.RIGHT) || straightSides .contains(Side.BOTTOM)); boolean isBottomLeftCorner = (straightSides != null) && (straightSides.contains(Side.LEFT) || straightSides .contains(Side.BOTTOM)); int xs = (insets == null) ? 0 : insets.left; int ys = (insets == null) ? 0 : insets.top; if (insets != null) { width -= (insets.right + insets.left); } if (insets != null) { height -= (insets.top + insets.bottom); } GeneralPath result = new GeneralPath(); // float radius3 = (float) (radius / (1.5 * Math.pow(height, 0.5))); // if (Math.max(width, height) < 15) // radius3 /= 2; if (isTopLeftCorner) { result.moveTo(xs, ys); } else { result.moveTo(xs + radius, ys); } if (isTopRightCorner) { result.lineTo(xs + width - 1, ys); } else { if (isTopLeftCorner || ((xs + width - radius - 1) >= radius)) { result.lineTo(xs + width - radius - 1, ys); } result.append(new Arc2D.Double(xs + width - 1 - 2 * radius, ys, 2 * radius, 2 * radius, 90, -90, Arc2D.OPEN), true); // result.quadTo(xs + width - 1 - radius3, ys + radius3, xs + width // - 1, ys + radius); } if (isBottomRightCorner) { result.lineTo(xs + width - 1, ys + height - 1); } else { if (isTopRightCorner || ((ys + height - radius - 1) >= radius)) { result.lineTo(xs + width - 1, ys + height - radius - 1); } result.append(new Arc2D.Double(xs + width - 2 * radius - 1, ys + height - 1 - 2 * radius, 2 * radius, 2 * radius, 0, -90, Arc2D.OPEN), true); // result.quadTo(xs + width - 1 - radius3, ys + height - 1 - // radius3, // xs + width - radius - 1, ys + height - 1); } if (isBottomLeftCorner) { result.lineTo(xs, ys + height - 1); } else { if (isBottomRightCorner || ((xs + width - radius - 1) >= radius)) { result.lineTo(xs + radius, ys + height - 1); } result.append(new Arc2D.Double(xs, ys + height - 2 * radius - 1, 2 * radius, 2 * radius, 270, -90, Arc2D.OPEN), true); // result.quadTo(xs + radius3, ys + height - 1 - radius3, xs, ys // + height - radius - 1); } if (isTopLeftCorner) { result.lineTo(xs, ys); } else { if (isBottomLeftCorner || ((ys + height - radius - 1) >= radius)) { result.lineTo(xs, ys + radius); } result.append(new Arc2D.Double(xs, ys, 2 * radius, 2 * radius, 180, -90, Arc2D.OPEN), true); // result.quadTo(xs + radius3, ys + radius3, xs + radius, ys); } return result; } /** * Returns outline that has a triangle poiting downwards. The top two * corners in the outline are rounded. This function can be used to draw * slider thumbs. * * @param width * Width of some UI component. * @param height * Height of some UI component. * @param radius * Corner radius for the top two corners. * @param insets * Insets to compute the outline. * @return Outline that has a triangle poiting downwards. */ public static GeneralPath getTriangleButtonOutline(int width, int height, float radius, int insets) { return getTriangleButtonOutline(width, height, radius, new Insets( insets, insets, insets, insets)); } /** * Returns outline that has a triangle poiting downwards. The top two * corners in the outline are rounded. This function can be used to draw * slider thumbs. * * @param width * Width of some UI component. * @param height * Height of some UI component. * @param radius * Corner radius for the top two corners. * @param insets * Insets to compute the outline. * @return Outline that has a triangle poiting downwards. */ public static GeneralPath getTriangleButtonOutline(int width, int height, float radius, Insets insets) { int xs = insets.left; int ys = insets.top; int xe = width - insets.right; xe--; int ye = height - insets.bottom; width -= (insets.right + insets.left); height -= (insets.top + insets.bottom); GeneralPath result = new GeneralPath(); float radius3 = (float) (radius / (1.5 * Math.pow(height, 0.5))); if (Math.max(width, height) < 15) radius3 /= 2; result.moveTo(radius + xs, ys); if ((xe - radius) >= radius) { result.lineTo(xe - radius, ys); } result.quadTo(xe - radius3, xs + radius3, xe, xs + radius); float h2 = (ye - 1.0f) / 2.0f; if (h2 >= radius) { result.lineTo(xe, h2); } result.lineTo((xe + insets.right) / 2.0f, ye - 1); result.lineTo(xs, h2); if (h2 >= radius) { result.lineTo(xs, h2); } if ((height - radius - 1) >= radius) { result.lineTo(xs, radius + ys); } result.quadTo(xs + radius3, ys + radius3, xs + radius, ys); return result; } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceWidgetSupport.java0000644000175000017500000002060411254157300027371 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.*; import javax.swing.*; import javax.swing.JInternalFrame.JDesktopIcon; import org.jvnet.lafwidget.LafWidgetSupport; import org.jvnet.lafwidget.utils.LafConstants.PasswordStrength; import org.jvnet.substance.*; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.SubstanceConstants.SubstanceWidgetType; import org.jvnet.substance.painter.decoration.DecorationAreaType; /** * Support for laf-widget layer. * This class is for internal use only. * * @author Kirill Grouchnikov */ public class SubstanceWidgetSupport extends LafWidgetSupport { /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.LafWidgetSupport#getComponentForHover(javax.swing * .JInternalFrame.JDesktopIcon) */ @Override public JComponent getComponentForHover(JDesktopIcon desktopIcon) { SubstanceDesktopIconUI ui = (SubstanceDesktopIconUI) desktopIcon .getUI(); return ui.getComponentForHover(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.LafWidgetSupport#toInstallMenuSearch(javax.swing. * JMenuBar) */ @Override public boolean toInstallMenuSearch(JMenuBar menuBar) { // if the menu search widget has not been allowed, // return false if (!SubstanceWidgetManager.getInstance().isAllowed( SwingUtilities.getRootPane(menuBar), SubstanceWidgetType.MENU_SEARCH)) return false; // don't install on menu bar of title panes if (menuBar instanceof SubstanceTitlePane.SubstanceMenuBar) return false; return super.toInstallMenuSearch(menuBar); } /* * (non-Javadoc) * * @see org.jvnet.lafwidget.LafWidgetSupport#getSearchIcon(int, * java.awt.ComponentOrientation) */ @Override public Icon getSearchIcon(int dimension, ComponentOrientation componentOrientation) { return SubstanceImageCreator.getSearchIcon(dimension, SubstanceColorSchemeUtilities.getColorScheme(null, ComponentState.ACTIVE), componentOrientation .isLeftToRight()); } /* * (non-Javadoc) * * @see org.jvnet.lafwidget.LafWidgetSupport#getArrowIcon(int) */ @Override public Icon getArrowIcon(int orientation) { return SubstanceImageCreator.getArrowIcon(SubstanceSizeUtils .getControlFontSize(), orientation, SubstanceColorSchemeUtilities.getColorScheme(null, ComponentState.ACTIVE)); } /* * (non-Javadoc) * * @see org.jvnet.lafwidget.LafWidgetSupport#getNumberIcon(int) */ @Override public Icon getNumberIcon(int number) { SubstanceColorScheme colorScheme = SubstanceLookAndFeel.getCurrentSkin( null).getMainActiveColorScheme(DecorationAreaType.HEADER); return SubstanceImageCreator.getHexaMarker(number, colorScheme); } /* * (non-Javadoc) * * @seeorg.jvnet.lafwidget.LafWidgetSupport#markButtonAsFlat(javax.swing. * AbstractButton) */ @Override public void markButtonAsFlat(AbstractButton button) { button.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); button.setOpaque(false); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.LafWidgetSupport#getRolloverTabIndex(javax.swing. * JTabbedPane) */ @Override public int getRolloverTabIndex(JTabbedPane tabbedPane) { SubstanceTabbedPaneUI ui = (SubstanceTabbedPaneUI) tabbedPane.getUI(); return ui.getRolloverTabIndex(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.LafWidgetSupport#setTabAreaInsets(javax.swing.JTabbedPane * , java.awt.Insets) */ @Override public void setTabAreaInsets(JTabbedPane tabbedPane, Insets tabAreaInsets) { SubstanceTabbedPaneUI ui = (SubstanceTabbedPaneUI) tabbedPane.getUI(); ui.setTabAreaInsets(tabAreaInsets); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.LafWidgetSupport#getTabAreaInsets(javax.swing.JTabbedPane * ) */ @Override public Insets getTabAreaInsets(JTabbedPane tabbedPane) { SubstanceTabbedPaneUI ui = (SubstanceTabbedPaneUI) tabbedPane.getUI(); return ui.getTabAreaInsets(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.LafWidgetSupport#getTabRectangle(javax.swing.JTabbedPane * , int) */ @Override public Rectangle getTabRectangle(JTabbedPane tabbedPane, int tabIndex) { SubstanceTabbedPaneUI ui = (SubstanceTabbedPaneUI) tabbedPane.getUI(); return ui.getTabRectangle(tabIndex); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.LafWidgetSupport#paintPasswordStrengthMarker(java * .awt.Graphics, int, int, int, int, * org.jvnet.lafwidget.utils.LafConstants.PasswordStrength) */ @Override public void paintPasswordStrengthMarker(Graphics g, int x, int y, int width, int height, PasswordStrength pStrength) { Graphics2D g2 = (Graphics2D) g.create(); SubstanceColorScheme colorScheme = null; if (pStrength == PasswordStrength.WEAK) colorScheme = SubstanceColorSchemeUtilities.ORANGE; if (pStrength == PasswordStrength.MEDIUM) colorScheme = SubstanceColorSchemeUtilities.YELLOW; if (pStrength == PasswordStrength.STRONG) colorScheme = SubstanceColorSchemeUtilities.GREEN; if (colorScheme != null) { SubstanceImageCreator.paintRectangularBackground(null, g, x, y, width, height, colorScheme, 0.5f, false); } g2.dispose(); } /* * (non-Javadoc) * * @see org.jvnet.lafwidget.LafWidgetSupport#hasLockIcon(java.awt.Component) */ @Override public boolean hasLockIcon(Component comp) { if (!SubstanceCoreUtilities.toShowExtraWidgets(comp)) return false; return super.hasLockIcon(comp); } /* * (non-Javadoc) * * @see org.jvnet.lafwidget.LafWidgetSupport#getLockIcon() */ @Override public Icon getLockIcon() { return SubstanceImageCreator.makeTransparent(null, SubstanceImageCreator .getSmallLockIcon(SubstanceColorSchemeUtilities .getColorScheme(null, ComponentState.DEFAULT)), 0.3); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.LafWidgetSupport#toInstallExtraElements(java.awt. * Component) */ @Override public boolean toInstallExtraElements(Component comp) { return SubstanceCoreUtilities.toShowExtraWidgets(comp); } /* * (non-Javadoc) * * @see org.jvnet.lafwidget.LafWidgetSupport#getLookupIconSize() */ @Override public int getLookupIconSize() { int result = 2 + SubstanceSizeUtils.getControlFontSize(); if (result % 2 != 0) result++; return result; } /* * (non-Javadoc) * * @see org.jvnet.lafwidget.LafWidgetSupport#getLookupButtonSize() */ @Override public int getLookupButtonSize() { return 4 + SubstanceSizeUtils.getControlFontSize(); } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceTextUtilities.java0000644000175000017500000003536411245202246027402 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.*; import java.awt.geom.AffineTransform; import java.awt.image.*; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.CompoundBorder; import javax.swing.plaf.basic.BasicGraphicsUtils; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.lafwidget.utils.RenderingUtils; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.utils.border.SubstanceBorder; import org.jvnet.substance.watermark.SubstanceWatermark; /** * Text-related utilities. This class if for internal use only. * * @author Kirill Grouchnikov */ public class SubstanceTextUtilities { public static final String ENFORCE_FG_COLOR = "substancelaf.internal.textUtilities.enforceFgColor"; /** * Paints text with drop shadow. * * @param c * Component. * @param g * Graphics context. * @param foregroundColor * Foreground color. * @param text * Text to paint. * @param width * Text rectangle width. * @param height * Text rectangle height. * @param xOffset * Text rectangle X offset. * @param yOffset * Text rectangle Y offset. */ public static void paintTextWithDropShadow(JComponent c, Graphics g, Color foregroundColor, String text, int width, int height, int xOffset, int yOffset) { Graphics2D graphics = (Graphics2D) g.create(); RenderingUtils.installDesktopHints(graphics, c); // blur the text shadow BufferedImage blurred = SubstanceCoreUtilities.getBlankImage(width, height); Graphics2D gBlurred = (Graphics2D) blurred.getGraphics(); gBlurred.setFont(graphics.getFont()); gBlurred.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); // Color neg = // SubstanceColorUtilities.getNegativeColor(foregroundColor); float luminFactor = SubstanceColorUtilities .getColorStrength(foregroundColor); gBlurred.setColor(SubstanceColorUtilities .getNegativeColor(foregroundColor)); ConvolveOp convolve = new ConvolveOp(new Kernel(3, 3, new float[] { .0f, .05f, .1f, .05f, .0f, .1f, .1f, .1f, .1f }), ConvolveOp.EDGE_NO_OP, null); gBlurred.drawString(text, xOffset + 1, yOffset + 1); blurred = convolve.filter(blurred, null); graphics.setComposite(TransitionLayout.getAlphaComposite(c, luminFactor, g)); graphics.drawImage(blurred, 0, 0, null); graphics.setComposite(TransitionLayout.getAlphaComposite(c, g)); FontMetrics fm = graphics.getFontMetrics(); SubstanceTextUtilities.paintText(graphics, c, new Rectangle(xOffset, yOffset - fm.getAscent(), width - xOffset, fm.getHeight()), text, -1, graphics.getFont(), foregroundColor, graphics .getClipBounds()); graphics.dispose(); } /** * Paints the specified text. * * @param g * Graphics context. * @param comp * Component. * @param textRect * Text rectangle. * @param text * Text to paint. * @param mnemonicIndex * Mnemonic index. * @param font * Font to use. * @param color * Color to use. * @param clip * Optional clip. Can be null. * @param transform * Optional transform to apply. Can be null. */ private static void paintText(Graphics g, JComponent comp, Rectangle textRect, String text, int mnemonicIndex, java.awt.Font font, java.awt.Color color, java.awt.Rectangle clip, java.awt.geom.AffineTransform transform) { if ((text == null) || (text.length() == 0)) return; Graphics2D g2d = (Graphics2D) g.create(); // workaroundBug6576507(g2d); // RenderingUtils.installDesktopHints(g2d); g2d.setFont(font); g2d.setColor(color); // fix for issue 420 - call clip() instead of setClip() to // respect the currently set clip shape if (clip != null) g2d.clip(clip); if (transform != null) g2d.transform(transform); BasicGraphicsUtils.drawStringUnderlineCharAt(g2d, text, mnemonicIndex, textRect.x, textRect.y + g2d.getFontMetrics().getAscent()); g2d.dispose(); } /** * Paints the specified text. * * @param g * Graphics context. * @param comp * Component. * @param textRect * Text rectangle. * @param text * Text to paint. * @param mnemonicIndex * Mnemonic index. * @param font * Font to use. * @param color * Color to use. * @param clip * Optional clip. Can be null. */ public static void paintText(Graphics g, JComponent comp, Rectangle textRect, String text, int mnemonicIndex, java.awt.Font font, java.awt.Color color, java.awt.Rectangle clip) { SubstanceTextUtilities.paintText(g, comp, textRect, text, mnemonicIndex, font, color, clip, null); } /** * Paints the specified vertical text. * * @param g * Graphics context. * @param comp * Component. * @param textRect * Text rectangle. * @param text * Text to paint. * @param mnemonicIndex * Mnemonic index. * @param font * Font to use. * @param color * Color to use. * @param clip * Optional clip. Can be null. * @param isFromBottomToTop * If true, the text will be painted from bottom to * top, otherwise the text will be painted from top to bottom. */ public static void paintVerticalText(Graphics g, JComponent comp, Rectangle textRect, String text, int mnemonicIndex, java.awt.Font font, java.awt.Color color, java.awt.Rectangle clip, boolean isFromBottomToTop) { if ((text == null) || (text.length() == 0)) return; AffineTransform at = null; if (!isFromBottomToTop) { at = AffineTransform.getTranslateInstance(textRect.x + textRect.width, textRect.y); at.rotate(Math.PI / 2); } else { at = AffineTransform.getTranslateInstance(textRect.x, textRect.y + textRect.height); at.rotate(-Math.PI / 2); } Rectangle newRect = new Rectangle(0, 0, textRect.width, textRect.height); SubstanceTextUtilities.paintText(g, comp, newRect, text, mnemonicIndex, font, color, clip, at); } /** * Paints the text of the specified button. * * @param g * Graphic context. * @param button * Button * @param textRect * Text rectangle * @param text * Text to paint * @param mnemonicIndex * Mnemonic index. */ public static void paintText(Graphics g, AbstractButton button, Rectangle textRect, String text, int mnemonicIndex) { paintText(g, button, button.getModel(), textRect, text, mnemonicIndex); } /** * Paints the text of the specified button. * * @param g * Graphic context. * @param button * Button * @param model * Button model. * @param textRect * Text rectangle * @param text * Text to paint * @param mnemonicIndex * Mnemonic index. */ public static void paintText(Graphics g, AbstractButton button, ButtonModel model, Rectangle textRect, String text, int mnemonicIndex) { // Ignore the selection state of the menu item. This is especially // relevant for dark color schemes. ComponentState state = ComponentState.getState(model, button, button instanceof JMenuItem); ComponentState prevState = (state == ComponentState.ACTIVE) ? state : SubstanceCoreUtilities.getPrevComponentState(button); // special case for enabled buttons with no background - // always use the color scheme for the default state. if (SubstanceCoreUtilities.isButtonNeverPainted(button) || !button.isContentAreaFilled() || (button instanceof JRadioButton) || (button instanceof JCheckBox)) { if (state.isKindActive(FadeKind.ENABLE)) { state = ComponentState.DEFAULT; prevState = ComponentState.DEFAULT; } } float buttonAlpha = SubstanceColorSchemeUtilities.getAlpha(button, ComponentState.getState(button)); paintText(g, button, textRect, text, mnemonicIndex, state, prevState, buttonAlpha); } /** * Paints the specified text. * * @param g * Graphics context. * @param component * Component. * @param textRect * Text rectangle. * @param text * Text to paint. * @param mnemonicIndex * Mnemonic index. * @param state * Component state. * @param prevState * Component previous state. * @param textAlpha * Alpha channel for painting the text. */ public static void paintText(Graphics g, JComponent component, Rectangle textRect, String text, int mnemonicIndex, ComponentState state, ComponentState prevState, float textAlpha) { Color fgColor = getForegroundColor(component, text, state, prevState, textAlpha); SubstanceTextUtilities.paintText(g, component, textRect, text, mnemonicIndex, component.getFont(), fgColor, null); } /** * Returns the foreground color for the specified component. * * @param component * Component. * @param text * Text. If empty or null, the result is * null. * @param state * Component state. * @param prevState * Component previous state. * @param textAlpha * Alpha channel for painting the text. If value is less than * 1.0, the result is an opaque color which is an interpolation * between the "real" foreground color and the background color * of the component. This is done to ensure that native text * rasterization will be performed on 6u10 on Windows. * @return The foreground color for the specified component. */ public static Color getForegroundColor(JComponent component, String text, ComponentState state, ComponentState prevState, float textAlpha) { if ((text == null) || (text.length() == 0)) return null; boolean toEnforceFgColor = (SwingUtilities.getAncestorOfClass( CellRendererPane.class, component) != null) || Boolean.TRUE.equals(component .getClientProperty(ENFORCE_FG_COLOR)); Color fgColor = toEnforceFgColor ? component.getForeground() : SubstanceColorUtilities.getForegroundColor(component, state, prevState); // System.out.println(text + ":" + prevState.name() + "->" + // state.name() + ":" + fgColor); if (textAlpha < 1.0f) { Color bgFillColor = SubstanceColorUtilities .getBackgroundFillColor(component); fgColor = SubstanceColorUtilities.getInterpolatedColor(fgColor, bgFillColor, textAlpha); } return fgColor; } /** * Paints background of the specified text component. * * @param g * Graphics context. * @param comp * Component. */ public static void paintTextCompBackground(Graphics g, JComponent comp) { paintTextCompBackground(g, comp, SubstanceColorUtilities .getBackgroundFillColor(comp), SubstanceCoreUtilities .toDrawWatermark(comp) || !comp.isOpaque()); } /** * Paints background of the specified text component. * * @param g * Graphics context. * @param comp * Component. * @param backgr * Background color. * @param toOverlayWatermark * If true, this method will paint the watermark * overlay on top of the background fill. */ private static void paintTextCompBackground(Graphics g, JComponent comp, Color backgr, boolean toOverlayWatermark) { Graphics2D g2d = (Graphics2D) g.create(); int componentFontSize = SubstanceSizeUtils.getComponentFontSize(comp); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(componentFontSize) / 2.0); Border compBorder = comp.getBorder(); boolean isSubstanceBorder = compBorder instanceof SubstanceBorder; if (compBorder instanceof CompoundBorder) { isSubstanceBorder = isSubstanceBorder || (((CompoundBorder) compBorder).getOutsideBorder() instanceof SubstanceBorder); } Shape contour = isSubstanceBorder ? SubstanceOutlineUtilities .getBaseOutline( comp.getWidth(), comp.getHeight(), SubstanceSizeUtils .getClassicButtonCornerRadius(componentFontSize), null, borderDelta) : new Rectangle(0, 0, comp.getWidth(), comp.getHeight()); BackgroundPaintingUtils.update(g, comp, false); g2d.setColor(backgr); g2d.fill(contour); if (toOverlayWatermark) { SubstanceWatermark watermark = SubstanceCoreUtilities.getSkin(comp) .getWatermark(); if (watermark != null) { watermark.drawWatermarkImage(g2d, comp, 0, 0, comp.getWidth(), comp.getHeight()); } } g2d.dispose(); } } substance-5.3.orig/src/org/jvnet/substance/utils/CompositeButtonModel.java0000644000175000017500000001071511136475562027036 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.util.LinkedList; import java.util.List; import javax.swing.*; /** * Composite button model that tracks changes to one primary and any number of * secondary button models for composite rollover effects. This model can be * used to "simulate" rollover effects on the primary component when the actual * rollover happens on one of the secondary components. An example is a scroll * bar. When the mouse enters one of the scroll buttons, the scroll track is * highlighted as well. * * @author Kirill Grouchnikov */ public class CompositeButtonModel extends DefaultButtonModel { /** * The primary model. */ protected ButtonModel primaryModel; /** * The secondary models. */ protected ButtonModel[] secondaryModels; /** * Creates a new composite button model. * * @param primaryModel * The primary model. * @param secondaryModels * The secondary models. */ public CompositeButtonModel(ButtonModel primaryModel, ButtonModel... secondaryModels) { this.primaryModel = primaryModel; this.secondaryModels = secondaryModels; } /** * Creates a new composite button model. * * @param primaryModel * The primary model. * @param secondaryButtons * The secondary buttons. */ public CompositeButtonModel(ButtonModel primaryModel, AbstractButton... secondaryButtons) { this.primaryModel = primaryModel; List bmList = new LinkedList(); for (AbstractButton secondary : secondaryButtons) { if (secondary != null) { bmList.add(secondary.getModel()); } } this.secondaryModels = bmList.toArray(new ButtonModel[0]); } /* * (non-Javadoc) * * @see javax.swing.DefaultButtonModel#isRollover() */ @Override public boolean isRollover() { if ((primaryModel != null) && primaryModel.isRollover()) return true; for (ButtonModel secondary : this.secondaryModels) { if ((secondary != null) && secondary.isRollover()) return true; } return false; } /* * (non-Javadoc) * * @see javax.swing.DefaultButtonModel#isArmed() */ public boolean isArmed() { return (primaryModel != null) && primaryModel.isArmed(); } /* * (non-Javadoc) * * @see javax.swing.DefaultButtonModel#isEnabled() */ public boolean isEnabled() { return (primaryModel != null) && primaryModel.isEnabled(); } /* * (non-Javadoc) * * @see javax.swing.DefaultButtonModel#isPressed() */ public boolean isPressed() { return (primaryModel != null) && primaryModel.isPressed(); } /* * (non-Javadoc) * * @see javax.swing.DefaultButtonModel#isSelected() */ public boolean isSelected() { return (primaryModel != null) && primaryModel.isSelected(); } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceArrowButton.java0000644000175000017500000000366011174265346027055 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.lang.annotation.*; /** * Annotation to mark arrow buttons used in various UI delegates. * * @author Kirill Grouchnikov */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface SubstanceArrowButton { } substance-5.3.orig/src/org/jvnet/substance/utils/LazyResettableHashMap.java0000644000175000017500000001227411246717336027115 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.util.*; import javax.swing.SwingUtilities; /** * Lazily initialized hash map for caching images. Note that this class is * not thread safe. In Substance, it is used only from EDT. * * @author Kirill Grouchnikov * @param * Class for the stored values. */ public class LazyResettableHashMap { /** * List of all existing maps. */ private static List> all; /** * The delegate cache. */ private Map cache; /** * Display name of this hash map. Is used for tracking the statistics. */ private String displayName; /** * Creates a new hash map. * * @param displayName * Display name of the new hash map. */ public LazyResettableHashMap(String displayName) { this.displayName = displayName; if (all == null) { all = new LinkedList>(); } all.add(this); } /** * Creates the delegate cache if necessary. */ private void createIfNecessary() { if (this.cache == null) this.cache = new SoftHashMap(); } /** * Puts a new key-value pair in the map. * * @param key * Pair key. * @param entry * Pair value. */ public void put(HashMapKey key, T entry) { if (!SwingUtilities.isEventDispatchThread()) throw new IllegalArgumentException( "Called outside Event Dispatch Thread"); this.createIfNecessary(); this.cache.put(key, entry); } /** * Returns the value registered for the specified key. * * @param key * Key. * @return Registered value or null if none. */ public T get(HashMapKey key) { if (this.cache == null) return null; return this.cache.get(key); } /** * Checks whether there is a value associated with the specified key. * * @param key * Key. * @return true if there is an associated value, * false otherwise. */ public boolean containsKey(HashMapKey key) { if (this.cache == null) return false; return this.cache.containsKey(key); } /** * Returns the number of key-value pairs of this hash map. * * @return The number of key-value pairs of this hash map. */ public int size() { if (this.cache == null) return 0; return this.cache.size(); } /** * Resets all existing hash maps. */ public static void reset() { if (all != null) { for (LazyResettableHashMap map : all) { if (map.cache != null) map.cache.clear(); } } } /** * Returns statistical information of the existing hash maps. * * @return Statistical information of the existing hash maps. */ public static List getStats() { if (all != null) { List result = new LinkedList(); Map mapCounter = new TreeMap(); Map entryCounter = new TreeMap(); for (LazyResettableHashMap map : all) { String key = map.displayName; if (!mapCounter.containsKey(key)) { mapCounter.put(key, 0); entryCounter.put(key, 0); } mapCounter.put(key, mapCounter.get(key) + 1); entryCounter.put(key, entryCounter.get(key) + map.size()); } for (Map.Entry entry : mapCounter.entrySet()) { String key = entry.getKey(); result.add(entry.getValue() + " " + key + " with " + entryCounter.get(key) + " entries total"); } return result; } return null; } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceStripingUtils.java0000644000175000017500000001045611136475562027411 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.Color; import javax.swing.JComponent; import org.jvnet.substance.SubstanceTableUI; /** *

* This class is used to speed up the striping of lists, tables, trees and * comboboxes that use Substance default renderers. This class if for internal * use only. *

* *

* The usage is this: *

*
    *
  • Call {@link #setup(JComponent)} before starting painting the component * cells. An example - * {@link SubstanceTableUI#paint(java.awt.Graphics, JComponent)} that should * call this method prior to the call to its paintCells.
  • *
  • The specific renderer should call * {@link #applyStripedBackground(JComponent, int, JComponent)}.
  • *
  • After all cells have been renderered, call {@link #tearDown(JComponent)}. *
* * @author Kirill Grouchnikov */ public class SubstanceStripingUtils { /** * Name of the client property that stores the background fill color of odd * rows. The value should be an instance of {@link Color}. */ private static final String ODD_COLOR = "substancelaf.internal.stripingColor.odd"; /** * Name of the client property that stores the background fill color of even * rows. The value should be an instance of {@link Color}. */ private static final String EVEN_COLOR = "substancelaf.internal.stripingColor.even"; /** * Sets up the specified component for the UI delegate striping. * * @param comp * Component. */ public static void setup(JComponent comp) { comp.putClientProperty(EVEN_COLOR, SubstanceColorUtilities .getStripedBackground(comp, 0)); comp.putClientProperty(ODD_COLOR, SubstanceColorUtilities .getStripedBackground(comp, 1)); } /** * Cleans the component after the UI delegate striping is over. * * @param comp * Component. Should be the same as passed to * {@link #setup(JComponent) * }. */ public static void tearDown(JComponent comp) { comp.putClientProperty(EVEN_COLOR, null); comp.putClientProperty(ODD_COLOR, null); } /** * Applies the striped background to the specified renderer. * * @param component * Component (should be the same as passed to * {@link #setup(JComponent) * }). * @param rowIndex * Row index. * @param renderer * Renderer component. */ public static void applyStripedBackground(JComponent component, int rowIndex, JComponent renderer) { Color backgr = (Color) component .getClientProperty((rowIndex % 2) == 0 ? EVEN_COLOR : ODD_COLOR); if (backgr == null) return; renderer.setBackground(backgr); } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceColorResource.java0000644000175000017500000000516311225564152027347 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.Color; /** * This class is used to propagate a color set by the application code to the * children / related components. For example, table and table header are two * different components, but are visually two parts of the same user-facing * control. Setting background on the table should be propagated to the table * header - unless the application code explicitly changed the background color * on the table header. This is where this class comes into play - to mark the * propagated color so that it can be replaced when the table background is * changed from the application code, but not reset during skin switch. * * @author Kirill Grouchnikov */ public class SubstanceColorResource extends Color { /** * Creates a new Substance color resource. * * @param c * Color. */ public SubstanceColorResource(Color c) { super(c.getRGB(), (c.getRGB() & 0xFF000000) != 0xFF000000); } } substance-5.3.orig/src/org/jvnet/substance/utils/RolloverControlListener.java0000644000175000017500000001522311136475562027571 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.Component; import java.awt.event.*; import javax.swing.ButtonModel; // import org.jvnet.lafwidget.utils.FadeTracker; // import org.jvnet.lafwidget.utils.FadeTracker.FadeKind; /** * Control listener for rollover effects. Tracks the mouse motion interaction * for the associated {@link org.jvnet.substance.utils.Trackable} control. This * class is for internal use only. * * @author Kirill Grouchnikov */ public class RolloverControlListener implements MouseListener, MouseMotionListener { /** * If the mouse pointer is currently inside the designated area (fetched * from the associated {@link #trackableUI}), this flag is * true. */ private boolean isMouseInside; /** * Surrogate model for tracking control status. */ private ButtonModel model; /** * Object that is queried for mouse events. This object is responsible for * handling the designated (hot-spot) area of the associated control. */ private Trackable trackableUI; /** * Simple constructor. * * @param trackableUI * Object that is queried for mouse events. * @param model * Surrogate model for tracking control status. */ public RolloverControlListener(Trackable trackableUI, ButtonModel model) { this.trackableUI = trackableUI; this.model = model; this.isMouseInside = false; } /* * (non-Javadoc) * * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent) */ public void mouseEntered(MouseEvent e) { Component component = (Component) e.getSource(); if (!component.isEnabled()) return; boolean isInside = this.trackableUI.isInside(e); // boolean isInsideChanged = (this.isMouseInside != isInside); this.isMouseInside = isInside; this.model.setRollover(isInside); this.model.setEnabled(component.isEnabled()); } /* * (non-Javadoc) * * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent) */ public void mouseExited(MouseEvent e) { Component component = (Component) e.getSource(); if (!component.isEnabled()) return; // boolean isInsideChanged = (this.isMouseInside != false); this.isMouseInside = false; this.model.setRollover(false); this.model.setEnabled(component.isEnabled()); } /* * (non-Javadoc) * * @see * java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent) */ public void mouseReleased(MouseEvent e) { // System.out.println("mouse released [" + e.getX() + ":" + e.getY() + // "]"); Component component = (Component) e.getSource(); if (!component.isEnabled()) return; boolean isInside = this.trackableUI.isInside(e); // boolean isInsideChanged = (this.isMouseInside != isInside); this.isMouseInside = isInside; this.model.setRollover(this.isMouseInside); this.model.setPressed(false); this.model.setArmed(false); this.model.setSelected(false); this.model.setEnabled(component.isEnabled()); } /* * (non-Javadoc) * * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) */ public void mousePressed(MouseEvent e) { // System.out.println("mouse pressed [" + e.getX() + ":" + e.getY() + // "]"); Component component = (Component) e.getSource(); if (!component.isEnabled()) return; boolean isInside = this.trackableUI.isInside(e); // boolean isInsideChanged = (this.isMouseInside != isInside); this.isMouseInside = isInside; this.model.setRollover(this.isMouseInside); if (this.isMouseInside) { this.model.setPressed(true); this.model.setArmed(true); this.model.setSelected(true); } this.model.setEnabled(component.isEnabled()); } /* * (non-Javadoc) * * @see * java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent * ) */ public void mouseDragged(MouseEvent e) { // System.out.println("mouse dragged [" + e.getX() + ":" + e.getY() + // "]"); Component component = (Component) e.getSource(); if (!component.isEnabled()) return; boolean isInside = this.trackableUI.isInside(e); // boolean isInsideChanged = (this.isMouseInside != isInside); this.isMouseInside = isInside; this.model.setEnabled(component.isEnabled()); } /* * (non-Javadoc) * * @see * java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent) */ public void mouseMoved(MouseEvent e) { // System.out.println("mouse moved [" + e.getX() + ":" + e.getY() + // "]"); Component component = (Component) e.getSource(); if (!component.isEnabled()) return; boolean isInside = this.trackableUI.isInside(e); // System.out.println("inside"); // boolean isInsideChanged = (this.isMouseInside != isInside); this.isMouseInside = isInside; this.model.setRollover(isInside); this.model.setEnabled(component.isEnabled()); } /* * (non-Javadoc) * * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) */ public void mouseClicked(MouseEvent e) { } } substance-5.3.orig/src/org/jvnet/substance/utils/filters/0000755000175000017500000000000011256731152023511 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/utils/filters/NegatedFilter.java0000644000175000017500000000512211136475562027100 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.filters; import java.awt.image.BufferedImage; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * @author Kirill Grouchnikov */ public class NegatedFilter extends AbstractFilter { /** * @throws IllegalArgumentException * if scheme is null */ public NegatedFilter() { } /** * {@inheritDoc} */ @Override public BufferedImage filter(BufferedImage src, BufferedImage dst) { if (dst == null) { dst = createCompatibleDestImage(src, null); } int width = src.getWidth(); int height = src.getHeight(); int[] pixels = new int[width * height]; getPixels(src, 0, 0, width, height, pixels); negateColor(pixels); setPixels(dst, 0, 0, width, height, pixels); return dst; } private void negateColor(int[] pixels) { for (int i = 0; i < pixels.length; i++) { int argb = pixels[i]; pixels[i] = SubstanceColorUtilities.getNegativeColor(argb); } } } substance-5.3.orig/src/org/jvnet/substance/utils/filters/ColorSchemeFilter.java0000644000175000017500000001713711252260306027730 0ustar drazzibdrazzib/* * $Id: ColorSchemeFilter.java,v 1.5 2009/09/11 05:25:41 kirillcool Exp $ * * Dual-licensed under LGPL (Sun and Romain Guy) and BSD (Romain Guy). * * Copyright 2005 Sun Microsystems, Inc., 4150 Network Circle, * Santa Clara, California 95054, U.S.A. All rights reserved. * * Copyright (c) 2006 Romain Guy * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.filters; import java.awt.Color; import java.awt.image.BufferedImage; import java.util.*; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.*; /** * @author Romain Guy * @author Kirill Grouchnikov */ public class ColorSchemeFilter extends AbstractFilter { private int[] interpolated; public static final int MAPSTEPS = 512; protected final static LazyResettableHashMap filters = new LazyResettableHashMap( "ColorSchemeFilter"); protected float originalBrightnessFactor; public static ColorSchemeFilter getColorSchemeFilter( SubstanceColorScheme scheme, float originalBrightnessFactor) { HashMapKey key = SubstanceCoreUtilities.getHashKey(scheme .getDisplayName(), originalBrightnessFactor); if (filters.containsKey(key)) return filters.get(key); ColorSchemeFilter result = new ColorSchemeFilter(scheme, originalBrightnessFactor); filters.put(key, result); return result; } /** * @throws IllegalArgumentException * if scheme is null */ private ColorSchemeFilter(SubstanceColorScheme scheme, float originalBrightnessFactor) { if (scheme == null) { throw new IllegalArgumentException("mixColor cannot be null"); } this.originalBrightnessFactor = originalBrightnessFactor; // collect the brightness factors of the color scheme Map schemeColorMapping = new TreeMap(); schemeColorMapping.put(SubstanceColorUtilities .getColorBrightness(scheme.getUltraLightColor().getRGB()), scheme.getUltraLightColor()); schemeColorMapping.put(SubstanceColorUtilities .getColorBrightness(scheme.getExtraLightColor().getRGB()), scheme.getExtraLightColor()); schemeColorMapping.put(SubstanceColorUtilities .getColorBrightness(scheme.getLightColor().getRGB()), scheme .getLightColor()); schemeColorMapping.put(SubstanceColorUtilities .getColorBrightness(scheme.getMidColor().getRGB()), scheme .getMidColor()); schemeColorMapping.put(SubstanceColorUtilities .getColorBrightness(scheme.getDarkColor().getRGB()), scheme .getDarkColor()); schemeColorMapping.put(SubstanceColorUtilities .getColorBrightness(scheme.getUltraDarkColor().getRGB()), scheme.getUltraDarkColor()); List schemeBrightness = new ArrayList(); schemeBrightness.addAll(schemeColorMapping.keySet()); Collections.sort(schemeBrightness); int lowestSchemeBrightness = schemeBrightness.get(0); int highestSchemeBrightness = schemeBrightness.get(schemeBrightness .size() - 1); boolean hasSameBrightness = (highestSchemeBrightness == lowestSchemeBrightness); Map stretchedColorMapping = new TreeMap(); for (Map.Entry entry : schemeColorMapping.entrySet()) { int brightness = entry.getKey(); int stretched = hasSameBrightness ? brightness : 255 - 255 * (highestSchemeBrightness - brightness) / (highestSchemeBrightness - lowestSchemeBrightness); stretchedColorMapping.put(stretched, entry.getValue()); } schemeBrightness = new ArrayList(); schemeBrightness.addAll(stretchedColorMapping.keySet()); Collections.sort(schemeBrightness); this.interpolated = new int[MAPSTEPS]; for (int i = 0; i < MAPSTEPS; i++) { int brightness = (int) (256.0 * i / MAPSTEPS); if (schemeBrightness.contains(brightness)) { this.interpolated[i] = stretchedColorMapping.get(brightness) .getRGB(); } else { if (hasSameBrightness) { this.interpolated[i] = stretchedColorMapping.get( lowestSchemeBrightness).getRGB(); } else { int currIndex = 0; while (true) { int currStopValue = schemeBrightness.get(currIndex); int nextStopValue = schemeBrightness.get(currIndex + 1); if ((brightness > currStopValue) && (brightness < nextStopValue)) { // interpolate Color currStopColor = stretchedColorMapping .get(currStopValue); Color nextStopColor = stretchedColorMapping .get(nextStopValue); this.interpolated[i] = SubstanceColorUtilities .getInterpolatedRGB( currStopColor, nextStopColor, 1.0 - (double) (brightness - currStopValue) / (double) (nextStopValue - currStopValue)); break; } currIndex++; } } } } } /** * {@inheritDoc} */ @Override public BufferedImage filter(BufferedImage src, BufferedImage dst) { if (dst == null) { dst = createCompatibleDestImage(src, null); } int width = src.getWidth(); int height = src.getHeight(); int[] pixels = new int[width * height]; getPixels(src, 0, 0, width, height, pixels); mixColor(pixels); setPixels(dst, 0, 0, width, height, pixels); return dst; } private void mixColor(int[] pixels) { for (int i = 0; i < pixels.length; i++) { int argb = pixels[i]; int brightness = SubstanceColorUtilities.getColorBrightness(argb); int r = (argb >>> 16) & 0xFF; int g = (argb >>> 8) & 0xFF; int b = (argb >>> 0) & 0xFF; float[] hsb = Color.RGBtoHSB(r, g, b, null); int pixelColor = interpolated[brightness * MAPSTEPS / 256]; int ri = (pixelColor >>> 16) & 0xFF; int gi = (pixelColor >>> 8) & 0xFF; int bi = (pixelColor >>> 0) & 0xFF; float[] hsbi = Color.RGBtoHSB(ri, gi, bi, null); hsb[0] = hsbi[0]; hsb[1] = hsbi[1]; hsb[2] = this.originalBrightnessFactor * hsb[2] + (1.0f - this.originalBrightnessFactor) * hsbi[2]; int result = Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]); pixels[i] = (argb & 0xFF000000) | ((result >> 16) & 0xFF) << 16 | ((result >> 8) & 0xFF) << 8 | (result & 0xFF); } } } substance-5.3.orig/src/org/jvnet/substance/utils/filters/AbstractFilter.java0000644000175000017500000001224111006655354027267 0ustar drazzibdrazzib/* * $Id: AbstractFilter.java,v 1.1 2008/05/02 06:18:20 kirillcool Exp $ * * Dual-licensed under LGPL (Sun and Romain Guy) and BSD (Romain Guy). * * Copyright 2005 Sun Microsystems, Inc., 4150 Network Circle, * Santa Clara, California 95054, U.S.A. All rights reserved. * * Copyright (c) 2006 Romain Guy * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.filters; import java.awt.Rectangle; import java.awt.RenderingHints; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.image.*; /** *

* Provides an abstract implementation of the BufferedImageOp * interface. This class can be used to created new image filters based on * BufferedImageOp. *

* * @author Romain Guy */ public abstract class AbstractFilter implements BufferedImageOp { public abstract BufferedImage filter(BufferedImage src, BufferedImage dest); /** * {@inheritDoc} */ public Rectangle2D getBounds2D(BufferedImage src) { return new Rectangle(0, 0, src.getWidth(), src.getHeight()); } /** * {@inheritDoc} */ public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel destCM) { if (destCM == null) { destCM = src.getColorModel(); } return new BufferedImage(destCM, destCM.createCompatibleWritableRaster( src.getWidth(), src.getHeight()), destCM.isAlphaPremultiplied(), null); } /** * {@inheritDoc} */ public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) { return (Point2D) srcPt.clone(); } /** * {@inheritDoc} */ public RenderingHints getRenderingHints() { return null; } protected int[] getPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) { if (w == 0 || h == 0) { return new int[0]; } if (pixels == null) { pixels = new int[w * h]; } else if (pixels.length < w * h) { throw new IllegalArgumentException( "pixels array must have a length" + " >= w*h"); } int imageType = img.getType(); if (imageType == BufferedImage.TYPE_INT_ARGB || imageType == BufferedImage.TYPE_INT_RGB) { Raster raster = img.getRaster(); return (int[]) raster.getDataElements(x, y, w, h, pixels); } // Unmanages the image return img.getRGB(x, y, w, h, pixels, 0, w); } /** *

* Writes a rectangular area of pixels in the destination * BufferedImage. Calling this method on an image of type * different from BufferedImage.TYPE_INT_ARGB and * BufferedImage.TYPE_INT_RGB will unmanage the image. *

* * @param img * the destination image * @param x * the x location at which to start storing pixels * @param y * the y location at which to start storing pixels * @param w * the width of the rectangle of pixels to store * @param h * the height of the rectangle of pixels to store * @param pixels * an array of pixels, stored as integers * @throws IllegalArgumentException * is pixels is non-null and of length < w*h */ protected void setPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) { if (pixels == null || w == 0 || h == 0) { return; } else if (pixels.length < w * h) { throw new IllegalArgumentException( "pixels array must have a length" + " >= w*h"); } int imageType = img.getType(); if (imageType == BufferedImage.TYPE_INT_ARGB || imageType == BufferedImage.TYPE_INT_RGB) { WritableRaster raster = img.getRaster(); raster.setDataElements(x, y, w, h, pixels); } else { // Unmanages the image img.setRGB(x, y, w, h, pixels, 0, w); } } } substance-5.3.orig/src/org/jvnet/substance/utils/filters/TranslucentFilter.java0000644000175000017500000000523411136475562030037 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.filters; import java.awt.image.BufferedImage; /** * @author Kirill Grouchnikov */ public class TranslucentFilter extends AbstractFilter { private double alpha; public TranslucentFilter(double alpha) { this.alpha = alpha; } /** * {@inheritDoc} */ @Override public BufferedImage filter(BufferedImage src, BufferedImage dst) { if (dst == null) { dst = createCompatibleDestImage(src, null); } int width = src.getWidth(); int height = src.getHeight(); int[] pixels = new int[width * height]; getPixels(src, 0, 0, width, height, pixels); translucentColor(pixels); setPixels(dst, 0, 0, width, height, pixels); return dst; } private void translucentColor(int[] pixels) { for (int i = 0; i < pixels.length; i++) { int argb = pixels[i]; int transp = (int) (alpha * ((argb >>> 24) & 0xFF)); int r = (argb >>> 16) & 0xFF; int g = (argb >>> 8) & 0xFF; int b = (argb >>> 0) & 0xFF; pixels[i] = (transp << 24) | (r << 16) | (g << 8) | b; } } } substance-5.3.orig/src/org/jvnet/substance/utils/filters/GrayscaleFilter.java0000644000175000017500000000530011136475562027441 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.filters; import java.awt.image.BufferedImage; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * @author Kirill Grouchnikov */ public class GrayscaleFilter extends AbstractFilter { /** * @throws IllegalArgumentException * if scheme is null */ public GrayscaleFilter() { } /** * {@inheritDoc} */ @Override public BufferedImage filter(BufferedImage src, BufferedImage dst) { if (dst == null) { dst = createCompatibleDestImage(src, null); } int width = src.getWidth(); int height = src.getHeight(); int[] pixels = new int[width * height]; getPixels(src, 0, 0, width, height, pixels); grayScaleColor(pixels); setPixels(dst, 0, 0, width, height, pixels); return dst; } private void grayScaleColor(int[] pixels) { for (int i = 0; i < pixels.length; i++) { int argb = pixels[i]; int brightness = SubstanceColorUtilities.getColorBrightness(argb); pixels[i] = (argb & 0xFF000000) | brightness << 16 | brightness << 8 | brightness; } } } substance-5.3.orig/src/org/jvnet/substance/utils/PerlinNoiseGenerator.java0000644000175000017500000000745411126424404027007 0ustar drazzibdrazzibpackage org.jvnet.substance.utils; /** * A class for producing Perlin-inspired noise. The code written by Ken Perlin. * * @author Ken Perlin http://mrl.nyu.edu/~perlin/ */ public class PerlinNoiseGenerator { /** * Returns noise for the specified coordinates. * * @param x * X coordinate. * @param y * Y coordinate. * @param z * Z coordinate. * @return Noise for the specified coordinates. */ static public double noise(double x, double y, double z) { int X = (int) Math.floor(x) & 255, // FIND UNIT CUBE THAT Y = (int) Math.floor(y) & 255, // CONTAINS POINT. Z = (int) Math.floor(z) & 255; x -= Math.floor(x); // FIND RELATIVE X,Y,Z y -= Math.floor(y); // OF POINT IN CUBE. z -= Math.floor(z); double u = fade(x), // COMPUTE FADE CURVES v = fade(y), // FOR EACH OF X,Y,Z. w = fade(z); int A = p[X] + Y, AA = p[A] + Z, AB = p[A + 1] + Z, // HASH COORDINATES // OF B = p[X + 1] + Y, BA = p[B] + Z, BB = p[B + 1] + Z; // THE 8 CUBE // CORNERS, return lerp(w, lerp(v, lerp(u, grad(p[AA], x, y, z), // AND ADD grad(p[BA], x - 1, y, z)), // BLENDED lerp(u, grad(p[AB], x, y - 1, z), // RESULTS grad(p[BB], x - 1, y - 1, z))),// FROM 8 lerp(v, lerp(u, grad(p[AA + 1], x, y, z - 1), // CORNERS grad(p[BA + 1], x - 1, y, z - 1)), // OF CUBE lerp(u, grad(p[AB + 1], x, y - 1, z - 1), grad( p[BB + 1], x - 1, y - 1, z - 1)))); } /** * Fades the specified value. * * @param t * Value to fade. * @return faded value. */ static double fade(double t) { return t * t * t * (t * (t * 6 - 15) + 10); } /** * Interpolates the specified value. * * @param t * Value. * @param a * Starting interpolation value. * @param b * Ending interpolation value. * @return Interpolated value. */ static double lerp(double t, double a, double b) { return a + t * (b - a); } /** * @param hash * @param x * @param y * @param z * @return */ static double grad(int hash, double x, double y, double z) { int h = hash & 15; // CONVERT LO 4 BITS OF HASH CODE double u = h < 8 ? x : y, // INTO 12 GRADIENT DIRECTIONS. v = h < 4 ? y : (h == 12) || (h == 14) ? x : z; return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v); } /** * Permutations. */ static final int p[] = new int[512]; /** * Permutations. */ static final int permutation[] = { 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180 }; static { for (int i = 0; i < 256; i++) p[256 + i] = p[i] = permutation[i]; } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceTitlePane.java0000644000175000017500000014603311246720104026442 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.*; import java.lang.ref.WeakReference; import java.text.SimpleDateFormat; import java.util.*; import javax.swing.*; import javax.swing.plaf.UIResource; import org.jvnet.lafwidget.animation.effects.GhostPaintingUtils; import org.jvnet.lafwidget.utils.RenderingUtils; import org.jvnet.lafwidget.utils.TrackableThread; import org.jvnet.substance.*; import org.jvnet.substance.api.*; import org.jvnet.substance.api.SubstanceConstants.SubstanceWidgetType; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.skin.SkinInfo; import org.jvnet.substance.utils.icon.SubstanceIconFactory; import org.jvnet.substance.utils.icon.TransitionAwareIcon; /** * Title pane for Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceTitlePane extends JComponent { /** * PropertyChangeListener added to the JRootPane. */ private PropertyChangeListener propertyChangeListener; /** * JMenuBar, typically renders the system menu items. */ protected JMenuBar menuBar; /** * Action used to close the Window. */ private Action closeAction; /** * Action used to iconify the Frame. */ private Action iconifyAction; /** * Action to restore the Frame size. */ private Action restoreAction; /** * Action to restore the Frame size. */ private Action maximizeAction; /** * Button used to maximize or restore the frame. */ protected JButton toggleButton; /** * Button used to minimize the frame */ protected JButton minimizeButton; /** * Button used to close the frame. */ protected JButton closeButton; /** * Listens for changes in the state of the Window listener to update the * state of the widgets. */ private WindowListener windowListener; /** * Window we're currently in. */ protected Window window; /** * JRootPane rendering for. */ protected JRootPane rootPane; /** * Buffered Frame.state property. As state isn't bound, this is kept to * determine when to avoid updating widgets. */ private int state; /** * SubstanceRootPaneUI that created us. */ private SubstanceRootPaneUI rootPaneUI; /** * The logfile name for the heap status panel. Can be null - in * this case the {@link HeapStatusThread} will not write heap information. */ private static String heapStatusLogfileName; /** * The heap status panel of this title pane. */ protected HeapStatusPanel heapStatusPanel; /** * The heap status toggle menu item of this title pane. */ protected JCheckBoxMenuItem heapStatusMenuItem; /** * Listens on changes to componentOrientation and * {@link SubstanceLookAndFeel#WINDOW_MODIFIED} properties. */ protected PropertyChangeListener propertyListener; /** * Client property to mark every child to be either leading or trailing. The * value must be one of {@link ExtraComponentKind}. * * @see #markExtraComponent(JComponent, ExtraComponentKind) * @see #getTitleTextRectangle() */ protected static final String EXTRA_COMPONENT_KIND = "substancelaf.internal.titlePane.extraComponentKind"; /** * The application icon to be displayed. */ protected Image appIcon; /** * Enumerates the types of children components. * * @author Kirill Grouchnikov */ protected enum ExtraComponentKind { /** * Leading child components (left on LTR and right on RTL). */ LEADING, /** * Trailing child components (right on LTR and left on RTL). */ TRAILING } /** * Panel that shows heap status and allows running the garbage collector. * * @author Kirill Grouchnikov */ public static class HeapStatusPanel extends JPanel { /** * The current heap size in kilobytes. */ private int currHeapSizeKB; /** * The current used portion of heap in kilobytes. */ private int currTakenHeapSizeKB; /** * History of used heap portion (in percents). Each value is in 0.0-1.0 * range. */ private LinkedList graphValues; /** * Creates new heap status panel. */ public HeapStatusPanel() { this.graphValues = new LinkedList(); HeapStatusThread.getInstance(); } /** * Updates the values for this heap status panel. * * @param currHeapSizeKB * The current heap size in kilobytes. * @param currTakenHeapSizeKB * The current used portion of heap in kilobytes. */ public synchronized void updateStatus(int currHeapSizeKB, int currTakenHeapSizeKB) { this.currHeapSizeKB = currHeapSizeKB; this.currTakenHeapSizeKB = currTakenHeapSizeKB; double newGraphValue = (double) currTakenHeapSizeKB / (double) currHeapSizeKB; this.graphValues.addLast(newGraphValue); this.repaint(); } /* * (non-Javadoc) * * @see javax.swing.JComponent#paint(java.awt.Graphics) */ @Override public synchronized void paint(Graphics g) { Graphics2D graphics = (Graphics2D) g.create(); SubstanceColorScheme scheme = SubstanceCoreUtilities.getSkin(this) .getMainActiveColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE); graphics.setColor(scheme.getDarkColor()); int w = this.getWidth(); int h = this.getHeight(); graphics.drawRect(0, 0, w - 1, h - 1); graphics.setColor(scheme.getExtraLightColor()); graphics.fillRect(1, 1, w - 2, h - 2); while (this.graphValues.size() > (w - 2)) this.graphValues.removeFirst(); int xOff = w - this.graphValues.size() - 1; graphics.setColor(scheme.getMidColor()); int count = 0; for (double value : this.graphValues) { int valueH = (int) (value * (h - 2)); graphics.drawLine(xOff + count, h - 1 - valueH, xOff + count, h - 2); count++; } graphics.setFont(UIManager.getFont("Panel.font")); FontMetrics fm = graphics.getFontMetrics(); StringBuffer longFormat = new StringBuffer(); Formatter longFormatter = new Formatter(longFormat); longFormatter.format("%.1fMB / %.1fMB", this.currTakenHeapSizeKB / 1024.f, this.currHeapSizeKB / 1024.f); int strW = fm.stringWidth(longFormat.toString()); int strH = fm.getAscent() + fm.getDescent(); graphics.setColor(scheme.getForegroundColor()); RenderingUtils.installDesktopHints(graphics, this); if (strW < (w - 5)) { graphics.drawString(longFormat.toString(), (w - strW) / 2, (h + strH) / 2 - 2); } else { String shortFormat = (this.currTakenHeapSizeKB / 1024) + "MB / " + (this.currHeapSizeKB / 1024) + "MB"; strW = fm.stringWidth(shortFormat); graphics.drawString(shortFormat, (w - strW) / 2, (h + strH) / 2 - 2); } graphics.dispose(); } /** * Returns the preferred width of this panel. * * @return Preferred width of this panel. */ public int getPreferredWidth() { BufferedImage dummy = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = dummy.createGraphics(); RenderingUtils.installDesktopHints(g2d, this); g2d.setFont(UIManager.getFont("Panel.font")); FontMetrics fm = g2d.getFontMetrics(); int result = fm.stringWidth("100.9MB / 200.9MB"); g2d.dispose(); return result; } } /** * Thread for heap status panel. */ public static class HeapStatusThread extends TrackableThread { /** * Current heap size in kilobytes. */ private int heapSizeKB; /** * Current used portion of heap in kilobytes. */ private int takenHeapSizeKB; /** * All heap status panels. */ private static Set> panels = new HashSet>(); /** * Single instance of this thread. */ private static HeapStatusThread instance; /** * Formatter object (for logfile). */ private SimpleDateFormat format; /** * Signifies whether a stop request has been issued on this * thread using the {@link #requestStop()} call. */ private boolean isStopRequested; /** * Simple constructor. Defined private for singleton. * * @see #getInstance() */ private HeapStatusThread() { this.format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSS"); this.isStopRequested = false; this.setName("Substance heap status"); } /** * Gets singleton instance of this thread. * * @return Singleton instance of this thread. */ public synchronized static HeapStatusThread getInstance() { if (HeapStatusThread.instance == null) { HeapStatusThread.instance = new HeapStatusThread(); HeapStatusThread.instance.start(); } return HeapStatusThread.instance; } /** * Registers new heap status panel with this thread. * * @param panel * Heap statuc panel. */ public static synchronized void registerPanel(HeapStatusPanel panel) { panels.add(new WeakReference(panel)); } /** * Unregisters new heap status panel from this thread. * * @param panel * Heap statuc panel. */ public static synchronized void unregisterPanel(HeapStatusPanel panel) { for (Iterator> it = panels .iterator(); it.hasNext();) { WeakReference ref = it.next(); HeapStatusPanel currPanel = ref.get(); if (panel == currPanel) { it.remove(); return; } } } /** * Updates the values of heap status. */ private synchronized void updateHeapCounts() { long heapSize = Runtime.getRuntime().totalMemory(); long heapFreeSize = Runtime.getRuntime().freeMemory(); this.heapSizeKB = (int) (heapSize / 1024); this.takenHeapSizeKB = (int) ((heapSize - heapFreeSize) / 1024); } /* * (non-Javadoc) * * @see java.lang.Thread#run() */ @Override public void run() { while (!this.isStopRequested) { try { // update every 0.5 seconds Thread.sleep(500); } catch (InterruptedException ie) { } if (!SubstanceWidgetManager.getInstance().isAllowedAnywhere( SubstanceWidgetType.TITLE_PANE_HEAP_STATUS)) continue; this.updateHeapCounts(); for (Iterator> it = panels .iterator(); it.hasNext();) { WeakReference refPanel = it.next(); HeapStatusPanel panel = refPanel.get(); if (panel == null) { // prune it.remove(); continue; } panel.updateStatus(this.heapSizeKB, this.takenHeapSizeKB); } // see if need to put info in log file if (SubstanceTitlePane.heapStatusLogfileName != null) { PrintWriter pw = null; try { pw = new PrintWriter(new FileWriter( SubstanceTitlePane.heapStatusLogfileName, true)); pw.println(this.format.format(new Date()) + " " + this.takenHeapSizeKB + "KB / " + this.heapSizeKB + "KB"); } catch (IOException ioe) { } finally { if (pw != null) { pw.close(); } } } } } @Override protected void requestStop() { this.isStopRequested = true; HeapStatusThread.instance = null; } } /** * Creates a new title pane. * * @param root * Root pane. * @param ui * Root pane UI. */ public SubstanceTitlePane(JRootPane root, SubstanceRootPaneUI ui) { this.rootPane = root; this.rootPaneUI = ui; this.state = -1; this.installSubcomponents(); this.installDefaults(); this.setLayout(this.createLayout()); this.setToolTipText(this.getTitle()); SubstanceLookAndFeel.setDecorationType(this, DecorationAreaType.PRIMARY_TITLE_PANE); this.setForeground(SubstanceColorUtilities .getForegroundColor(SubstanceColorSchemeUtilities .getColorScheme(this, ComponentState.ACTIVE))); } /** * Uninstalls the necessary state. */ public void uninstall() { this.uninstallListeners(); this.window = null; HeapStatusThread.unregisterPanel(this.heapStatusPanel); // Swing bug (?) - the updateComponentTree never gets to the // system menu (and in our case we have radio menu items with // rollover listeners). Fix for defect 109 - memory leak on skin // switch if ((this.menuBar != null) && (this.menuBar.getMenuCount() > 0)) { this.menuBar.getUI().uninstallUI(this.menuBar); SubstanceCoreUtilities.uninstallMenu(this.menuBar.getMenu(0)); } if (this.heapStatusPanel != null) { for (MouseListener listener : this.heapStatusPanel .getMouseListeners()) this.heapStatusPanel.removeMouseListener(listener); HeapStatusThread.unregisterPanel(this.heapStatusPanel); this.remove(this.heapStatusPanel); } if (this.menuBar != null) this.menuBar.removeAll(); this.removeAll(); } /** * Installs the necessary listeners. */ private void installListeners() { if (this.window != null) { this.windowListener = new WindowHandler(); this.window.addWindowListener(this.windowListener); this.propertyChangeListener = new PropertyChangeHandler(); this.window.addPropertyChangeListener(this.propertyChangeListener); } // Property change listener for pulsating close button // when window has been marked as changed. // Fix for defect 109 - memory leak on skin change. this.propertyListener = new PropertyChangeListener() { public void propertyChange(final PropertyChangeEvent evt) { if (SubstanceLookAndFeel.WINDOW_MODIFIED.equals(evt .getPropertyName())) { syncCloseButtonTooltip(); // if (Boolean.TRUE.equals(evt.getNewValue())) { // SubstanceTitlePane.this.closeButton // .setToolTipText(SubstanceLookAndFeel // .getLabelBundle().getString( // "SystemMenu.close") // + " [" // + SubstanceLookAndFeel // .getLabelBundle() // .getString( // "Tooltip.contentsNotSaved") // + "]"); // } else { // SubstanceTitlePane.this.closeButton // .setToolTipText(SubstanceLookAndFeel // .getLabelBundle().getString( // "SystemMenu.close")); // } // SubstanceTitlePane.this.closeButton.repaint(); } if ("componentOrientation".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (SubstanceTitlePane.this.menuBar != null) { SubstanceTitlePane.this.menuBar .applyComponentOrientation((ComponentOrientation) evt .getNewValue()); } } }); } } }; // Wire it on the frame itself and its root pane. this.rootPane.addPropertyChangeListener(this.propertyListener); if (this.getFrame() != null) this.getFrame().addPropertyChangeListener(this.propertyListener); } /** * Uninstalls the necessary listeners. */ private void uninstallListeners() { if (this.window != null) { this.window.removeWindowListener(this.windowListener); this.windowListener = null; this.window .removePropertyChangeListener(this.propertyChangeListener); this.propertyChangeListener = null; } // Fix for defect 109 - memory leak on skin change. this.rootPane.removePropertyChangeListener(this.propertyListener); if (this.getFrame() != null) this.getFrame().removePropertyChangeListener(this.propertyListener); this.propertyListener = null; } /** * Returns the JRootPane this was created for. */ @Override public JRootPane getRootPane() { return this.rootPane; } /** * Returns the decoration style of the JRootPane. * * @return Decoration style of the JRootPane. */ protected int getWindowDecorationStyle() { return this.getRootPane().getWindowDecorationStyle(); } /* * (non-Javadoc) * * @see java.awt.Component#addNotify() */ @Override public void addNotify() { super.addNotify(); this.uninstallListeners(); this.window = SwingUtilities.getWindowAncestor(this); if (this.window != null) { this.setActive(this.window.isActive()); if (this.window instanceof Frame) { this.setState(((Frame) this.window).getExtendedState()); } else { this.setState(0); } if (this.getComponentCount() == 0) { // fix for issue 385 - add the sub-components uninstalled // in the removeNotify. This happens when a decorated // dialog has been disposed and then reshown. this.installSubcomponents(); } this.installListeners(); } this.setToolTipText(this.getTitle()); this.updateAppIcon(); } /* * (non-Javadoc) * * @see java.awt.Component#removeNotify() */ @Override public void removeNotify() { super.removeNotify(); this.uninstall(); this.window = null; } /** * Adds any sub-Components contained in the SubstanceTitlePane. */ private void installSubcomponents() { int decorationStyle = this.getWindowDecorationStyle(); if (decorationStyle == JRootPane.FRAME) { this.createActions(); this.menuBar = this.createMenuBar(); if (this.menuBar != null) { this.add(this.menuBar); } this.createButtons(); this.add(this.minimizeButton); this.add(this.toggleButton); this.add(this.closeButton); this.heapStatusPanel = new HeapStatusPanel(); this.markExtraComponent(this.heapStatusPanel, ExtraComponentKind.TRAILING); this.add(this.heapStatusPanel); boolean isHeapStatusPanelShowing = SubstanceWidgetManager .getInstance().isAllowed(rootPane, SubstanceWidgetType.TITLE_PANE_HEAP_STATUS); this.heapStatusPanel.setVisible(isHeapStatusPanelShowing); this.heapStatusPanel.setPreferredSize(new Dimension(80, this .getPreferredSize().height)); this.heapStatusPanel.setToolTipText(SubstanceCoreUtilities .getResourceBundle(rootPane).getString( "Tooltip.heapStatusPanel")); this.heapStatusPanel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { System.gc(); } }); HeapStatusThread.registerPanel(this.heapStatusPanel); } else { if ((decorationStyle == JRootPane.PLAIN_DIALOG) || (decorationStyle == JRootPane.INFORMATION_DIALOG) || (decorationStyle == JRootPane.ERROR_DIALOG) || (decorationStyle == JRootPane.COLOR_CHOOSER_DIALOG) || (decorationStyle == JRootPane.FILE_CHOOSER_DIALOG) || (decorationStyle == JRootPane.QUESTION_DIALOG) || (decorationStyle == JRootPane.WARNING_DIALOG)) { this.createActions(); this.createButtons(); this.add(this.closeButton); } } } /** * Installs the fonts and necessary properties. */ private void installDefaults() { this.setFont(UIManager.getFont("InternalFrame.titleFont", this .getLocale())); } /** * Returns the JMenuBar displaying the appropriate system menu * items. * * @return JMenuBar displaying the appropriate system menu * items. */ protected JMenuBar createMenuBar() { this.menuBar = new SubstanceMenuBar(); this.menuBar.setFocusable(false); this.menuBar.setBorderPainted(true); this.menuBar.add(this.createMenu()); this.menuBar.setOpaque(false); // support for RTL this.menuBar.applyComponentOrientation(this.rootPane .getComponentOrientation()); this.markExtraComponent(this.menuBar, ExtraComponentKind.LEADING); return this.menuBar; } /** * Create the Actions that get associated with the buttons and * menu items. */ private void createActions() { this.closeAction = new CloseAction(); if (this.getWindowDecorationStyle() == JRootPane.FRAME) { this.iconifyAction = new IconifyAction(); this.restoreAction = new RestoreAction(); this.maximizeAction = new MaximizeAction(); } } /** * Returns the JMenu displaying the appropriate menu items for * manipulating the Frame. * * @return JMenu displaying the appropriate menu items for * manipulating the Frame. */ private JMenu createMenu() { JMenu menu = new JMenu(""); menu.setOpaque(false); menu.setBackground(null); if (this.getWindowDecorationStyle() == JRootPane.FRAME) { this.addMenuItems(menu); } return menu; } /** * Adds the necessary JMenuItems to the specified menu. * * @param menu * Menu. */ private void addMenuItems(JMenu menu) { menu.add(this.restoreAction); menu.add(this.iconifyAction); if (Toolkit.getDefaultToolkit().isFrameStateSupported( Frame.MAXIMIZED_BOTH)) { menu.add(this.maximizeAction); } if (SubstanceCoreUtilities.toShowExtraWidgets(rootPane)) { menu.addSeparator(); JMenu skinMenu = new JMenu(SubstanceCoreUtilities .getResourceBundle(rootPane).getString("SystemMenu.skins")); Map allSkins = SubstanceLookAndFeel.getAllSkins(); for (Map.Entry skinEntry : allSkins.entrySet()) { final String skinClassName = skinEntry.getValue() .getClassName(); JMenuItem jmiSkin = new JMenuItem(skinEntry.getKey()); jmiSkin.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(skinClassName); } }); } }); skinMenu.add(jmiSkin); } menu.add(skinMenu); } menu.addSeparator(); menu.add(this.closeAction); } /** * Returns a JButton appropriate for placement on the * TitlePane. * * @return Title button. */ private JButton createTitleButton() { JButton button = new SubstanceTitleButton(); button.setFocusPainted(false); button.setFocusable(false); button.setOpaque(true); this.markExtraComponent(button, ExtraComponentKind.TRAILING); return button; } /** * Creates the Buttons that will be placed on the TitlePane. */ private void createButtons() { this.closeButton = this.createTitleButton(); this.closeButton.setAction(this.closeAction); this.closeButton.setText(null); this.closeButton.setBorder(null); // this.closeButton.setToolTipText(SubstanceLookAndFeel // .getLabelBundle().getString( // "SystemMenu.close")); Icon closeIcon = new TransitionAwareIcon(closeButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { return SubstanceIconFactory .getTitlePaneIcon( SubstanceIconFactory.IconKind.CLOSE, scheme, SubstanceCoreUtilities .getSkin(rootPane) .getBackgroundColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE)); } }, "substance.titlePane.closeIcon"); this.closeButton.setIcon(closeIcon); this.closeButton.setFocusable(false); this.closeButton.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); this.closeButton.putClientProperty( SubstanceButtonUI.IS_TITLE_CLOSE_BUTTON, Boolean.TRUE); if (this.getWindowDecorationStyle() == JRootPane.FRAME) { this.minimizeButton = this.createTitleButton(); this.minimizeButton.setAction(this.iconifyAction); this.minimizeButton.setText(null); this.minimizeButton.setBorder(null); Icon minIcon = new TransitionAwareIcon(this.minimizeButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon( SubstanceColorScheme scheme) { return SubstanceIconFactory .getTitlePaneIcon( SubstanceIconFactory.IconKind.MINIMIZE, scheme, SubstanceCoreUtilities .getSkin(rootPane) .getBackgroundColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE)); } }, "substance.titlePane.minIcon"); this.minimizeButton.setIcon(minIcon); this.minimizeButton.setFocusable(false); this.minimizeButton.putClientProperty( SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); this.minimizeButton.setToolTipText(SubstanceCoreUtilities .getResourceBundle(rootPane) .getString("SystemMenu.iconify")); this.toggleButton = this.createTitleButton(); this.toggleButton.setAction(this.restoreAction); this.toggleButton.setBorder(null); this.toggleButton.setText(null); Icon maxIcon = new TransitionAwareIcon(this.toggleButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon( SubstanceColorScheme scheme) { return SubstanceIconFactory .getTitlePaneIcon( SubstanceIconFactory.IconKind.MAXIMIZE, scheme, SubstanceCoreUtilities .getSkin(rootPane) .getBackgroundColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE)); } }, "substance.titlePane.maxIcon"); this.toggleButton.setIcon(maxIcon); this.toggleButton.setToolTipText(SubstanceCoreUtilities .getResourceBundle(rootPane).getString( "SystemMenu.maximize")); this.toggleButton.setFocusable(false); this.toggleButton.putClientProperty( SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); } syncCloseButtonTooltip(); } /** * Returns the LayoutManager that should be installed on the * SubstanceTitlePane. * * @return Layout manager. */ protected LayoutManager createLayout() { return new TitlePaneLayout(); } /** * Updates state dependant upon the Window's active state. * * @param isActive * if true, the window is in active state. */ private void setActive(boolean isActive) { this.getRootPane().repaint(); } /** * Sets the state of the Window. * * @param state * Window state. */ private void setState(int state) { this.setState(state, false); } /** * Sets the state of the window. If updateRegardless is true * and the state has not changed, this will update anyway. * * @param state * Window state. * @param updateRegardless * if true, the update is done in any case. */ private void setState(int state, boolean updateRegardless) { Window w = this.getWindow(); if ((w != null) && (this.getWindowDecorationStyle() == JRootPane.FRAME)) { if ((this.state == state) && !updateRegardless) { return; } Frame frame = this.getFrame(); if (frame != null) { final JRootPane rootPane = this.getRootPane(); if (((state & Frame.MAXIMIZED_BOTH) != 0) && ((rootPane.getBorder() == null) || (rootPane .getBorder() instanceof UIResource)) && frame.isShowing()) { rootPane.setBorder(null); } else { if ((state & Frame.MAXIMIZED_BOTH) == 0) { // This is a croak, if state becomes bound, this can // be nuked. this.rootPaneUI.installBorder(rootPane); } } if (frame.isResizable()) { if ((state & Frame.MAXIMIZED_BOTH) != 0) { Icon restoreIcon = new TransitionAwareIcon( this.toggleButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon( SubstanceColorScheme scheme) { return SubstanceIconFactory .getTitlePaneIcon( SubstanceIconFactory.IconKind.RESTORE, scheme, SubstanceCoreUtilities .getSkin( rootPane) .getBackgroundColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE)); } }, "substance.titlePane.restoreIcon"); this .updateToggleButton(this.restoreAction, restoreIcon); this.toggleButton.setToolTipText(SubstanceCoreUtilities .getResourceBundle(rootPane).getString( "SystemMenu.restore")); this.maximizeAction.setEnabled(false); this.restoreAction.setEnabled(true); } else { Icon maxIcon = new TransitionAwareIcon( this.toggleButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon( SubstanceColorScheme scheme) { return SubstanceIconFactory .getTitlePaneIcon( SubstanceIconFactory.IconKind.MAXIMIZE, scheme, SubstanceCoreUtilities .getSkin( rootPane) .getBackgroundColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE)); } }, "substance.titlePane.maxIcon"); this.updateToggleButton(this.maximizeAction, maxIcon); this.toggleButton.setToolTipText(SubstanceCoreUtilities .getResourceBundle(rootPane).getString( "SystemMenu.maximize")); this.maximizeAction.setEnabled(true); this.restoreAction.setEnabled(false); } if ((this.toggleButton.getParent() == null) || (this.minimizeButton.getParent() == null)) { this.add(this.toggleButton); this.add(this.minimizeButton); this.revalidate(); this.repaint(); } this.toggleButton.setText(null); } else { this.maximizeAction.setEnabled(false); this.restoreAction.setEnabled(false); if (this.toggleButton.getParent() != null) { this.remove(this.toggleButton); this.revalidate(); this.repaint(); } } } else { // Not contained in a Frame this.maximizeAction.setEnabled(false); this.restoreAction.setEnabled(false); this.iconifyAction.setEnabled(false); this.remove(this.toggleButton); this.remove(this.minimizeButton); this.revalidate(); this.repaint(); } this.closeAction.setEnabled(true); this.state = state; } } /** * Updates the toggle button to contain the Icon icon, and * Action action. * * @param action * Action. * @param icon * Icon. */ private void updateToggleButton(Action action, Icon icon) { this.toggleButton.setAction(action); this.toggleButton.setIcon(icon); this.toggleButton.setText(null); } /** * Returns the Frame rendering in. This will return null if the * JRootPane is not contained in a Frame. * * @return Frame. */ private Frame getFrame() { Window window = this.getWindow(); if (window instanceof Frame) { return (Frame) window; } return null; } /** * Returns the Window the JRootPane is contained * in. This will return null if there is no parent ancestor of the * JRootPane. * * @return Window. */ private Window getWindow() { return this.window; } /** * Returns the String to display as the title. * * @return Display title. */ private String getTitle() { Window w = this.getWindow(); if (w instanceof Frame) { return ((Frame) w).getTitle(); } if (w instanceof Dialog) { return ((Dialog) w).getTitle(); } return null; } /* * (non-Javadoc) * * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) */ @Override public void paintComponent(Graphics g) { // long start = System.nanoTime(); // As state isn't bound, we need a convenience place to check // if it has changed. Changing the state typically changes the if (this.getFrame() != null) { this.setState(this.getFrame().getExtendedState()); } final JRootPane rootPane = this.getRootPane(); Window window = this.getWindow(); boolean leftToRight = (window == null) ? rootPane .getComponentOrientation().isLeftToRight() : window .getComponentOrientation().isLeftToRight(); int width = this.getWidth(); int height = this.getHeight(); SubstanceSkin skin = SubstanceCoreUtilities.getSkin(rootPane); if (skin == null) { SubstanceCoreUtilities .traceSubstanceApiUsage(this, "Substance delegate used when Substance is not the current LAF"); } SubstanceColorScheme scheme = skin .getMainDefaultColorScheme(DecorationAreaType.PRIMARY_TITLE_PANE); int xOffset = 0; String theTitle = this.getTitle(); if (theTitle != null) { Rectangle titleTextRect = this.getTitleTextRectangle(); FontMetrics fm = rootPane.getFontMetrics(g.getFont()); int titleWidth = titleTextRect.width - 20; String clippedTitle = SubstanceCoreUtilities.clipString(fm, titleWidth, theTitle); // show tooltip with full title only if necessary if (theTitle.equals(clippedTitle)) { this.setToolTipText(null); } else { this.setToolTipText(theTitle); } theTitle = clippedTitle; if (leftToRight) xOffset = titleTextRect.x; else xOffset = titleTextRect.x + titleTextRect.width - fm.stringWidth(theTitle); } Graphics2D graphics = (Graphics2D) g.create(); Font font = SubstanceLookAndFeel.getFontPolicy().getFontSet( "Substance", null).getWindowTitleFont(); graphics.setFont(font); BackgroundPaintingUtils .update(graphics, SubstanceTitlePane.this, false); // DecorationPainterUtils.paintDecorationBackground(graphics, // SubstanceTitlePane.this, false); // draw the title (if needed) if (theTitle != null) { FontMetrics fm = rootPane.getFontMetrics(graphics.getFont()); int yOffset = ((height - fm.getHeight()) / 2) + fm.getAscent(); SubstanceTextUtilities.paintTextWithDropShadow(this, graphics, SubstanceColorUtilities.getForegroundColor(scheme), theTitle, width, height, xOffset, yOffset); } GhostPaintingUtils.paintGhostImages(this, graphics); // long end = System.nanoTime(); // System.out.println(end - start); graphics.dispose(); } /** * Computes the rectangle of the title text. This method looks at all the * children components of the title pane, grouping them by leading and * trailing (based on {@link #EXTRA_COMPONENT_KIND} client property). The * title text rectangle is the space between the leading group and the * trailing group. * * @return Rectangle of the title text. * @throws IllegalStateException * If at least one child component of this title pane is not * marked with the {@link #EXTRA_COMPONENT_KIND} client * property. * @see #markExtraComponent(JComponent, ExtraComponentKind) * @see #EXTRA_COMPONENT_KIND */ protected Rectangle getTitleTextRectangle() { JRootPane rootPane = this.getRootPane(); Window window = this.getWindow(); boolean leftToRight = (window == null) ? rootPane .getComponentOrientation().isLeftToRight() : window .getComponentOrientation().isLeftToRight(); if (leftToRight) { int maxLeadingX = 0; int minTrailingX = this.getWidth(); for (int i = 0; i < this.getComponentCount(); i++) { Component child = this.getComponent(i); if (!child.isVisible()) continue; if (child instanceof JComponent) { ExtraComponentKind kind = (ExtraComponentKind) ((JComponent) child) .getClientProperty(EXTRA_COMPONENT_KIND); if (kind == null) { throw new IllegalStateException("Title pane child " + child.getClass().getName() + " is not marked as leading or trailing"); } if (kind == ExtraComponentKind.LEADING) { int cx = child.getX() + child.getWidth(); if (cx > maxLeadingX) maxLeadingX = cx; } else { int cx = child.getX(); if (cx < minTrailingX) minTrailingX = cx; } } } int start = maxLeadingX + 10; int end = minTrailingX - 5; return new Rectangle(start, 0, end - start, this.getHeight()); } else { int minLeadingX = this.getWidth(); int maxTrailingX = 0; for (int i = 0; i < this.getComponentCount(); i++) { Component child = this.getComponent(i); if (!child.isVisible()) continue; if (child instanceof JComponent) { ExtraComponentKind kind = (ExtraComponentKind) ((JComponent) child) .getClientProperty(EXTRA_COMPONENT_KIND); if (kind == null) { throw new IllegalStateException("Title pane child " + child.getClass().getName() + " is not marked as leading or trailing"); } if (kind == ExtraComponentKind.LEADING) { int cx = child.getX(); if (cx < minLeadingX) minLeadingX = cx; } else { int cx = child.getX() + child.getWidth(); if (cx > maxTrailingX) maxTrailingX = cx; } } } int start = maxTrailingX + 5; int end = minLeadingX - 10; return new Rectangle(start, 0, end - start, this.getHeight()); } } /** * Actions used to close the Window. */ private class CloseAction extends AbstractAction { /** * Creates a new close action. */ public CloseAction() { super(SubstanceCoreUtilities.getResourceBundle(rootPane).getString( "SystemMenu.close"), SubstanceImageCreator.getCloseIcon( SubstanceCoreUtilities.getSkin(rootPane) .getMainActiveColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE), SubstanceCoreUtilities.getSkin(rootPane) .getBackgroundColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE))); } public void actionPerformed(ActionEvent e) { Window window = SubstanceTitlePane.this.getWindow(); if (window != null) { window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING)); } } } /** * Actions used to iconfiy the Frame. */ private class IconifyAction extends AbstractAction { /** * Creates a new iconify action. */ public IconifyAction() { super( SubstanceCoreUtilities.getResourceBundle(rootPane) .getString("SystemMenu.iconify"), SubstanceImageCreator .getMinimizeIcon( SubstanceCoreUtilities .getSkin(rootPane) .getMainActiveColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE), SubstanceCoreUtilities .getSkin(rootPane) .getBackgroundColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE))); } public void actionPerformed(ActionEvent e) { Frame frame = SubstanceTitlePane.this.getFrame(); if (frame != null) { frame.setExtendedState(SubstanceTitlePane.this.state | Frame.ICONIFIED); } } } /** * Actions used to restore the Frame. */ private class RestoreAction extends AbstractAction { /** * Creates a new restore action. */ public RestoreAction() { super( SubstanceCoreUtilities.getResourceBundle(rootPane) .getString("SystemMenu.restore"), SubstanceImageCreator .getRestoreIcon( SubstanceCoreUtilities .getSkin(rootPane) .getMainActiveColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE), SubstanceCoreUtilities .getSkin(rootPane) .getBackgroundColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE))); } public void actionPerformed(ActionEvent e) { Frame frame = SubstanceTitlePane.this.getFrame(); if (frame == null) { return; } if ((SubstanceTitlePane.this.state & Frame.ICONIFIED) != 0) { frame.setExtendedState(SubstanceTitlePane.this.state & ~Frame.ICONIFIED); } else { frame.setExtendedState(SubstanceTitlePane.this.state & ~Frame.MAXIMIZED_BOTH); } } } /** * Actions used to restore the Frame. */ private class MaximizeAction extends AbstractAction { /** * Creates a new maximize action. */ public MaximizeAction() { super( SubstanceCoreUtilities.getResourceBundle(rootPane) .getString("SystemMenu.maximize"), SubstanceImageCreator .getMaximizeIcon( SubstanceCoreUtilities .getSkin(rootPane) .getMainActiveColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE), SubstanceCoreUtilities .getSkin(rootPane) .getMainDefaultColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE))); } public void actionPerformed(ActionEvent e) { Frame frame = SubstanceTitlePane.this.getFrame(); if (frame != null) { if (frame instanceof JFrame) { SubstanceRootPaneUI rpUI = (SubstanceRootPaneUI) ((JFrame) frame) .getRootPane().getUI(); rpUI.setMaximized(); } frame.setExtendedState(SubstanceTitlePane.this.state | Frame.MAXIMIZED_BOTH); } } } /** * Class responsible for drawing the system menu. Looks up the image to draw * from the Frame associated with the JRootPane. */ public class SubstanceMenuBar extends JMenuBar { @Override public void paint(Graphics g) { if (appIcon != null) { g.drawImage(appIcon, 0, 0, null); } else { Icon icon = UIManager.getIcon("InternalFrame.icon"); if (icon != null) { icon.paintIcon(this, g, 0, 0); } } } @Override public Dimension getMinimumSize() { return this.getPreferredSize(); } @Override public Dimension getPreferredSize() { Dimension size = super.getPreferredSize(); int iSize = SubstanceSizeUtils.getTitlePaneIconSize(); return new Dimension(Math.max(iSize, size.width), Math.max( size.height, iSize)); } } /** * Layout manager for the title pane. * * @author Kirill Graphics */ protected class TitlePaneLayout implements LayoutManager { /* * (non-Javadoc) * * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, * java.awt.Component) */ public void addLayoutComponent(String name, Component c) { } /* * (non-Javadoc) * * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component) */ public void removeLayoutComponent(Component c) { } /* * (non-Javadoc) * * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container) */ public Dimension preferredLayoutSize(Container c) { int height = this.computeHeight(); return new Dimension(height, height); } /** * Computes title pane height. * * @return Title pane height. */ private int computeHeight() { FontMetrics fm = SubstanceTitlePane.this.rootPane .getFontMetrics(SubstanceTitlePane.this.getFont()); int fontHeight = fm.getHeight(); fontHeight += 7; int iconHeight = 0; if (SubstanceTitlePane.this.getWindowDecorationStyle() == JRootPane.FRAME) { iconHeight = SubstanceSizeUtils.getTitlePaneIconSize(); } int finalHeight = Math.max(fontHeight, iconHeight); return finalHeight; } /* * (non-Javadoc) * * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container) */ public Dimension minimumLayoutSize(Container c) { return this.preferredLayoutSize(c); } /* * (non-Javadoc) * * @see java.awt.LayoutManager#layoutContainer(java.awt.Container) */ public void layoutContainer(Container c) { boolean leftToRight = (SubstanceTitlePane.this.window == null) ? SubstanceTitlePane.this .getRootPane().getComponentOrientation().isLeftToRight() : SubstanceTitlePane.this.window.getComponentOrientation() .isLeftToRight(); int w = SubstanceTitlePane.this.getWidth(); int x; int y = 3; int spacing; int buttonHeight; int buttonWidth; if ((SubstanceTitlePane.this.closeButton != null) && (SubstanceTitlePane.this.closeButton.getIcon() != null)) { buttonHeight = SubstanceTitlePane.this.closeButton.getIcon() .getIconHeight(); buttonWidth = SubstanceTitlePane.this.closeButton.getIcon() .getIconWidth(); } else { buttonHeight = SubstanceSizeUtils.getTitlePaneIconSize(); buttonWidth = SubstanceSizeUtils.getTitlePaneIconSize(); } y = (getHeight() - buttonHeight) / 2; // assumes all buttons have the same dimensions // these dimensions include the borders x = leftToRight ? w : 0; spacing = 5; x = leftToRight ? spacing : w - buttonWidth - spacing; if (SubstanceTitlePane.this.menuBar != null) { SubstanceTitlePane.this.menuBar.setBounds(x, y, buttonWidth, buttonHeight); // System.out.println(menuBar.getBounds()); } x = leftToRight ? w : 0; spacing = 3; x += leftToRight ? -spacing - buttonWidth : spacing; if (SubstanceTitlePane.this.closeButton != null) { SubstanceTitlePane.this.closeButton.setBounds(x, y, buttonWidth, buttonHeight); } if (!leftToRight) x += buttonWidth; if (SubstanceTitlePane.this.getWindowDecorationStyle() == JRootPane.FRAME) { if (Toolkit.getDefaultToolkit().isFrameStateSupported( Frame.MAXIMIZED_BOTH)) { if (SubstanceTitlePane.this.toggleButton.getParent() != null) { spacing = 10; x += leftToRight ? -spacing - buttonWidth : spacing; SubstanceTitlePane.this.toggleButton.setBounds(x, y, buttonWidth, buttonHeight); if (!leftToRight) { x += buttonWidth; } } } if ((SubstanceTitlePane.this.minimizeButton != null) && (SubstanceTitlePane.this.minimizeButton.getParent() != null)) { spacing = 2; x += leftToRight ? -spacing - buttonWidth : spacing; SubstanceTitlePane.this.minimizeButton.setBounds(x, y, buttonWidth, buttonHeight); if (!leftToRight) { x += buttonWidth; } } if ((SubstanceTitlePane.this.heapStatusPanel != null) && SubstanceTitlePane.this.heapStatusPanel.isVisible()) { spacing = 5; x += leftToRight ? (-spacing - SubstanceTitlePane.this.heapStatusPanel .getPreferredWidth()) : spacing; SubstanceTitlePane.this.heapStatusPanel.setBounds(x, 1, SubstanceTitlePane.this.heapStatusPanel .getPreferredWidth(), SubstanceTitlePane.this.getHeight() - 3); } } // buttonsWidth = leftToRight ? w - x : x; } } /** * PropertyChangeListener installed on the Window. Updates the necessary * state as the state of the Window changes. */ private class PropertyChangeHandler implements PropertyChangeListener { public void propertyChange(PropertyChangeEvent pce) { String name = pce.getPropertyName(); // Frame.state isn't currently bound. if ("resizable".equals(name) || "state".equals(name)) { Frame frame = SubstanceTitlePane.this.getFrame(); if (frame != null) { SubstanceTitlePane.this.setState(frame.getExtendedState(), true); } if ("resizable".equals(name)) { SubstanceTitlePane.this.getRootPane().repaint(); } } else { if ("title".equals(name)) { SubstanceTitlePane.this.repaint(); SubstanceTitlePane.this.setToolTipText((String) pce .getNewValue()); } else if ("componentOrientation" == name) { revalidate(); repaint(); } else if ("iconImage" == name) { updateAppIcon(); revalidate(); repaint(); } } } } /** * WindowListener installed on the Window, updates the state as necessary. */ private class WindowHandler extends WindowAdapter { @Override public void windowActivated(WindowEvent ev) { SubstanceTitlePane.this.setActive(true); } @Override public void windowDeactivated(WindowEvent ev) { SubstanceTitlePane.this.setActive(false); } } /** * Sets location for heap status logfile. Relevant if * {@link #setCanHaveHeapStatusPanel(boolean)} was called with * true. * * @param heapStatusLogfileName * Logfile for the heap status panel. */ public static void setHeapStatusLogfileName(String heapStatusLogfileName) { SubstanceTitlePane.heapStatusLogfileName = heapStatusLogfileName; } /** * Synchronizes the tooltip of the close button. */ protected void syncCloseButtonTooltip() { if (SubstanceCoreUtilities.isRootPaneModified(this.getRootPane())) { this.closeButton.setToolTipText(SubstanceCoreUtilities .getResourceBundle(rootPane).getString("SystemMenu.close") + " [" + SubstanceCoreUtilities.getResourceBundle(rootPane) .getString("Tooltip.contentsNotSaved") + "]"); } else { this.closeButton.setToolTipText(SubstanceCoreUtilities .getResourceBundle(rootPane).getString("SystemMenu.close")); } this.closeButton.repaint(); } /** * Marks the specified child component with the specified extra component * kind. * * @param comp * Child component. * @param kind * Extra kind. * @see #getTitleTextRectangle() * @see #EXTRA_COMPONENT_KIND */ protected void markExtraComponent(JComponent comp, ExtraComponentKind kind) { comp.putClientProperty(EXTRA_COMPONENT_KIND, kind); } /** * Updates the application icon. */ private void updateAppIcon() { Window window = getWindow(); if (window == null) { this.appIcon = null; return; } java.util.List icons = window.getIconImages(); if (icons.size() == 0) { this.appIcon = null; } else { int prefSize = SubstanceSizeUtils.getTitlePaneIconSize(); this.appIcon = SubstanceCoreUtilities.getScaledIconImage(icons, prefSize, prefSize); } } } substance-5.3.orig/src/org/jvnet/substance/utils/scroll/0000755000175000017500000000000011256731152023337 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/utils/scroll/SubstanceScrollPaneBorder.java0000644000175000017500000001741011136475562031264 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.scroll; import java.awt.*; import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.UIResource; import org.jvnet.substance.api.*; import org.jvnet.substance.painter.border.SimplisticSoftBorderPainter; import org.jvnet.substance.painter.border.StandardBorderPainter; import org.jvnet.substance.utils.SubstanceSizeUtils; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; /** * Default border on {@link JScrollPane}s. Provides continuous appearance of the * border + scroll bars. * * @author Kirill Grouchnikov */ public class SubstanceScrollPaneBorder implements Border, UIResource { /* * (non-Javadoc) * * @see javax.swing.border.Border#getBorderInsets(java.awt.Component) */ public Insets getBorderInsets(Component c) { float borderStrokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(c)); int ins = (int) borderStrokeWidth; return new Insets(ins, ins, ins, ins); } /* * (non-Javadoc) * * @see javax.swing.border.Border#isBorderOpaque() */ public boolean isBorderOpaque() { return false; } /* * (non-Javadoc) * * @see javax.swing.border.Border#paintBorder(java.awt.Component, * java.awt.Graphics, int, int, int, int) */ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { if (!(c instanceof JScrollPane)) { // Applications (such as NetBeans RCP) may incorrectly assume // that scroll pane border specified by the ""ScrollPane.border" // UIManager key by a look-and-feel can be installed on any // component. In case this component is not JScrollPane, do // nothing. return; } JScrollPane scrollPane = (JScrollPane) c; JScrollBar vertical = scrollPane.getVerticalScrollBar(); JScrollBar horizontal = scrollPane.getHorizontalScrollBar(); JViewport columnHeader = scrollPane.getColumnHeader(); StandardBorderPainter painter = new SimplisticSoftBorderPainter(); SubstanceColorScheme scheme = SubstanceColorSchemeUtilities .getColorScheme(c, ColorSchemeAssociationKind.BORDER, c .isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED); float borderStrokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(c)); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(c)) / 2.0); Graphics2D g2d = (Graphics2D) g.create(); g2d.setStroke(new BasicStroke(borderStrokeWidth, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER)); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); x += borderDelta; y += borderDelta; width -= 2 * borderDelta; height -= 2 * borderDelta; boolean horizontalVisible = (horizontal != null) && horizontal.isVisible(); boolean verticalVisible = (vertical != null) && vertical.isVisible(); if (scrollPane.getComponentOrientation().isLeftToRight()) { // top portion g2d.setColor(painter.getTopBorderColor(scheme, scheme, 0, false)); if (verticalVisible && (columnHeader == null)) { g2d.drawLine(x, y, x + width - vertical.getWidth(), y); } else { g2d.drawLine(x, y, x + width, y); } // left portion g2d.setColor(painter.getTopBorderColor(scheme, scheme, 0, false)); if (horizontalVisible) { g2d.drawLine(x, y, x, y + height - horizontal.getHeight()); } else { g2d.drawLine(x, y, x, y + height); } // bottom portion g2d .setColor(painter.getBottomBorderColor(scheme, scheme, 0, false)); if (horizontalVisible) { // g.drawLine(x + horizontal.getWidth(), y + height - 1, // x + width, y + height - 1); } else { if (verticalVisible) { g2d.drawLine(x, y + height - 1, x + width - vertical.getWidth(), y + height - 1); } else { g2d.drawLine(x, y + height - 1, x + width, y + height - 1); } } // right portion g2d .setColor(painter.getBottomBorderColor(scheme, scheme, 0, false)); if (verticalVisible) { // g.drawLine(x + width - 1, y + vertical.getHeight(), x + width // - 1, y + height); if (columnHeader != null) { g2d.drawLine(x + width - 1, y, x + width - 1, y + columnHeader.getHeight()); } } else { if (horizontalVisible) g2d.drawLine(x + width - 1, y, x + width - 1, y + height - horizontal.getHeight()); else g2d.drawLine(x + width - 1, y, x + width - 1, y + height); } } else { // top portion g2d.setColor(painter.getTopBorderColor(scheme, scheme, 0, false)); if (verticalVisible && (columnHeader == null)) { g2d.drawLine(x + vertical.getWidth(), y, x + width, y); } else { g2d.drawLine(x, y, x + width, y); } // left portion g2d .setColor(painter.getBottomBorderColor(scheme, scheme, 0, false)); if (verticalVisible) { // g.drawLine(x, y, x, y + height - horizontal.getHeight()); if (columnHeader != null) { g2d.drawLine(x, y, x, y + columnHeader.getHeight()); } } else { if (horizontalVisible) { g2d.drawLine(x, y, x, y + height - horizontal.getHeight()); } else { g2d.drawLine(x, y, x, y + height - 1); } } // bottom portion g2d .setColor(painter.getBottomBorderColor(scheme, scheme, 0, false)); if (horizontalVisible) { // g.drawLine(x + horizontal.getWidth(), y + height - 1, // x + width, y + height - 1); } else { if (verticalVisible) { g2d.drawLine(x + vertical.getWidth(), y + height - 1, x + width, y + height - 1); } else { g2d.drawLine(x, y + height - 1, x + width, y + height - 1); } } // right portion g2d.setColor(painter.getTopBorderColor(scheme, scheme, 0, false)); if (horizontalVisible) { g2d.drawLine(x + width - 1, y, x + width - 1, y + height - horizontal.getHeight()); } else { g2d.drawLine(x + width - 1, y, x + width - 1, y + height); } } g2d.dispose(); } } substance-5.3.orig/src/org/jvnet/substance/utils/scroll/SubstanceScrollButton.java0000644000175000017500000000732711136475562030524 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils.scroll; import java.awt.Insets; import javax.swing.JButton; import javax.swing.SwingConstants; import javax.swing.plaf.UIResource; import org.jvnet.lafwidget.animation.FadeConfigurationManager; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants; import org.jvnet.substance.utils.Sideable; import org.jvnet.substance.utils.SubstanceArrowButton; /** * Scroll bar button in Substance look and feel. * * @author Kirill Grouchnikov */ @SubstanceArrowButton public class SubstanceScrollButton extends JButton implements UIResource, Sideable { static { FadeConfigurationManager.getInstance().disallowFades( FadeKind.GHOSTING_BUTTON_PRESS, SubstanceScrollButton.class); FadeConfigurationManager.getInstance().disallowFades( FadeKind.GHOSTING_ICON_ROLLOVER, SubstanceScrollButton.class); } /** * Button orientation. */ private int orientation; /** * Simple constructor. * * @param scrollBarIcon * The icon. * @param orientation * The button icon arrow orientation. */ public SubstanceScrollButton(int orientation) { super(); this.setRequestFocusEnabled(false); this.setMargin(new Insets(0, 0, 0, 2)); this.orientation = orientation; this.putClientProperty(SubstanceLookAndFeel.USE_THEMED_DEFAULT_ICONS, Boolean.FALSE); } /* * (non-Javadoc) * * @see java.awt.Component#isFocusable() */ @Override public boolean isFocusable() { return false; } /* * (non-Javadoc) * * @see org.jvnet.substance.utils.Sideable#getSide() */ public SubstanceConstants.Side getSide() { switch (this.orientation) { case SwingConstants.NORTH: return SubstanceConstants.Side.BOTTOM; case SwingConstants.WEST: return SubstanceConstants.Side.RIGHT; case SwingConstants.SOUTH: return SubstanceConstants.Side.TOP; case SwingConstants.EAST: return SubstanceConstants.Side.LEFT; default: return null; } } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceCoreUtilities.java0000644000175000017500000024767511256343470027367 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.awt.image.VolatileImage; import java.net.URL; import java.util.*; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.CompoundBorder; import javax.swing.plaf.*; import javax.swing.text.JTextComponent; import org.jvnet.lafwidget.LafWidgetUtilities; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.lafwidget.utils.TrackableThread; import org.jvnet.substance.*; import org.jvnet.substance.api.*; import org.jvnet.substance.api.SubstanceConstants.*; import org.jvnet.substance.api.combo.ComboPopupPrototypeCallback; import org.jvnet.substance.api.tabbed.TabCloseCallback; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.decoration.SubstanceDecorationPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; import org.jvnet.substance.shaper.SubstanceButtonShaper; import org.jvnet.substance.utils.border.SubstanceBorder; import org.jvnet.substance.utils.combo.SubstanceComboBoxButton; import org.jvnet.substance.utils.combo.SubstanceComboPopup; import org.jvnet.substance.utils.icon.*; import org.jvnet.substance.utils.menu.SubstanceMenu; import org.jvnet.substance.utils.scroll.SubstanceScrollButton; /** * Various utility functions. This class is for internal use only. * * @author Kirill Grouchnikov * @author Romain Guy */ public class SubstanceCoreUtilities { /** * Client property name for the previous component state. The client * property value should be an instance of {@link ComponentState}. */ private static final String PREV_COMPONENT_STATE = "substancelaf.internal.prevComponentState"; /** * Client property name for the previous component state. The client * property value should be an instance of {@link ComponentState}. */ private static final String PREV_SEL_COMPONENT_STATE = "substancelaf.internal.prevSelComponentState"; /** * Client property name for the next component state. The client property * value should be an instance of {@link ComponentState}. */ private static final String NEXT_COMPONENT_STATE = "substancelaf.internal.nextComponentState"; /** * Client property name for the next component state. The client property * value should be an instance of {@link ComponentState}. */ private static final String NEXT_SEL_COMPONENT_STATE = "substancelaf.internal.nextSelComponentState"; /** * Client property name for marking components covered by lightweight * popups. This is tracking the fix for issue 297. The client property value * should be an instance of {@link Boolean}. */ public static final String IS_COVERED_BY_LIGHTWEIGHT_POPUPS = "substancelaf.internal.paint.isCoveredByLightweightPopups"; /** * Client property name to mark components that use highlights (such as * lists, trees, menus, tables and table headers). The client property value * should be an instance of {@link Boolean}. */ public static final String USE_HIGHLIGHT = "substancelaf.internal.highlightUse"; /** * Private constructor. Is here to enforce using static methods only. */ private SubstanceCoreUtilities() { } /** * Clips string based on specified font metrics and available width (in * pixels). Returns the clipped string, which contains the beginning and the * end of the input string separated by ellipses (...) in case the string is * too long to fit into the specified width, and the origianl string * otherwise. * * @param metrics * Font metrics. * @param availableWidth * Available width in pixels. * @param fullText * String to clip. * @return The clipped string, which contains the beginning and the end of * the input string separated by ellipses (...) in case the string * is too long to fit into the specified width, and the origianl * string otherwise. */ public static String clipString(FontMetrics metrics, int availableWidth, String fullText) { if (metrics.stringWidth(fullText) <= availableWidth) return fullText; String ellipses = "..."; int ellipsesWidth = metrics.stringWidth(ellipses); if (ellipsesWidth > availableWidth) return ""; String starter = ""; String ender = ""; int w = fullText.length(); int w2 = (w / 2) + (w % 2); String prevTitle = ""; for (int i = 0; i < w2; i++) { String newStarter = starter + fullText.charAt(i); String newEnder = ender; if ((w - i) > w2) newEnder = fullText.charAt(w - i - 1) + newEnder; String newTitle = newStarter + ellipses + newEnder; if (metrics.stringWidth(newTitle) <= availableWidth) { starter = newStarter; ender = newEnder; prevTitle = newTitle; continue; } return prevTitle; } return fullText; } /** * Checks whether the specified button has associated icon. * * @param button * Button. * @return If the button has associated icon, true is returned, * otherwise false. */ public static boolean hasIcon(AbstractButton button) { return (button.getIcon() != null); } /** * Checks whether the specified button has associated text. * * @param button * Button. * @return If the button has associated text, true is returned, * otherwise false. */ public static boolean hasText(AbstractButton button) { String text = button.getText(); if ((text != null) && (text.length() > 0)) { return true; } return false; } /** * Checks and answers if the specified button is in a combo box. * * @param button * the button to check * @return true if in combo box, false otherwise */ public static boolean isComboBoxButton(AbstractButton button) { Container parent = button.getParent(); return (parent != null) && ((parent instanceof JComboBox) || (parent.getParent() instanceof JComboBox)); } /** * Checks and answers if the specified button is in a scroll bar. * * @param button * the button to check * @return true if in scroll bar, false otherwise */ public static boolean isScrollBarButton(AbstractButton button) { Container parent = button.getParent(); return (parent != null) && ((parent instanceof JScrollBar) || (parent.getParent() instanceof JScrollBar)); } /** * Checks and answers if the specified button is in a spinner. * * @param button * the button to check * @return true if in spinner, false otherwise */ public static boolean isSpinnerButton(AbstractButton button) { Container parent = button.getParent(); if (!(button instanceof SubstanceSpinnerButton)) return false; return (parent != null) && ((parent instanceof JSpinner) || (parent.getParent() instanceof JSpinner)); } /** * Checks and answers if the specified button is in a toolbar. * * @param component * the button to check * @return true if in toolbar, false otherwise */ public static boolean isToolBarButton(JComponent component) { if (component instanceof SubstanceComboBoxButton) return false; if (component instanceof SubstanceSpinnerButton) return false; Container parent = component.getParent(); return (parent != null) && ((parent instanceof JToolBar) || (parent.getParent() instanceof JToolBar)); } /** * Checks answers if the specified component is a button in a scroll * control, such as scroll bar or tabbed pane (as tab scroller). * * @param comp * The component to check * @return true if the specified component is a button in a * scroll control, false otherwise */ public static boolean isScrollButton(JComponent comp) { return (comp instanceof SubstanceScrollButton); } /** * Checks whether the specified button never paints its background. * * @param button * Button. * @return true if the specified button never paints its * background, false otherwise. * @see SubstanceLookAndFeel#BUTTON_PAINT_NEVER_PROPERTY */ public static boolean isButtonNeverPainted(JComponent button) { // small optimizations for checkboxes and radio buttons if (button instanceof JCheckBox) return false; if (button instanceof JRadioButton) return false; Component c = button; while (c != null) { if (c instanceof JComponent) { JComponent jc = (JComponent) c; Object prop = jc .getClientProperty(SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY); if (prop != null) { if (Boolean.TRUE.equals(prop)) return true; if (Boolean.FALSE.equals(prop)) return false; } } c = c.getParent(); } return Boolean.TRUE.equals(UIManager .get(SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY)); } /** * Returns the focus ring kind of the specified component. * * @param component * Component. * @return The focus ring kind of the specified component. * @see SubstanceLookAndFeel#FOCUS_KIND */ public static FocusKind getFocusKind(Component component) { while (component != null) { if (component instanceof JComponent) { JComponent jcomp = (JComponent) component; Object jcompFocusKind = jcomp .getClientProperty(SubstanceLookAndFeel.FOCUS_KIND); if (jcompFocusKind instanceof FocusKind) return (FocusKind) jcompFocusKind; } component = component.getParent(); } Object globalFocusKind = UIManager.get(SubstanceLookAndFeel.FOCUS_KIND); if (globalFocusKind instanceof FocusKind) return (FocusKind) globalFocusKind; return FocusKind.ALL_INNER; } /** * Returns indication whether the watermark should be drawn on the specified * component. * * @param component * Component. * @return true if the watermark should be drawn on the * specified component, false otherwise. * @see SubstanceLookAndFeel#WATERMARK_VISIBLE */ public static boolean toDrawWatermark(Component component) { Component c = component; while (c != null) { if (c instanceof JComponent) { JComponent jcomp = (JComponent) component; Object obj = jcomp .getClientProperty(SubstanceLookAndFeel.WATERMARK_VISIBLE); if (obj != null) { if (Boolean.TRUE.equals(obj)) return true; if (Boolean.FALSE.equals(obj)) return false; } } c = c.getParent(); } Object obj = UIManager.get(SubstanceLookAndFeel.WATERMARK_VISIBLE); if (Boolean.TRUE.equals(obj)) return true; if (Boolean.FALSE.equals(obj)) return false; // special cases - lists, tables and trees that show watermarks only // when the WATERMARK_VISIBLE is set to Boolean.TRUE if (component instanceof JList) return false; if (component instanceof JTree) return false; if (component instanceof JTable) return false; if (component instanceof JTextComponent) return false; return true; } /** * Returns the button shaper of the specified button. * * @param comp * The button. * @return The button shaper of the specified button. * @see SubstanceLookAndFeel#BUTTON_SHAPER_PROPERTY * @see SubstanceSkin#getButtonShaper() */ public static SubstanceButtonShaper getButtonShaper(Component comp) { if (comp instanceof JComponent) { Object prop = ((JComponent) comp) .getClientProperty(SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY); if (prop instanceof SubstanceButtonShaper) return (SubstanceButtonShaper) prop; } SubstanceSkin skin = SubstanceCoreUtilities.getSkin(comp); if (skin == null) return null; return skin.getButtonShaper(); } /** * Returns the gradient painter of the specified component. * * @param comp * Component. * @return The gradient painter of the specified component. * @see SubstanceSkin#getGradientPainter() */ public static SubstanceGradientPainter getGradientPainter(Component comp) { return SubstanceCoreUtilities.getSkin(comp).getGradientPainter(); } /** * Retrieves the modified state for the specified component in * a tabbed pane. * * @param tabComponent * The associated tab component. * @return true if the specified component in a tabbed pane is * marked as modified, false otherwise. * @see SubstanceLookAndFeel#WINDOW_MODIFIED */ public static boolean isTabModified(Component tabComponent) { boolean isWindowModified = false; Component comp = tabComponent; if (comp instanceof JComponent) { JComponent jc = (JComponent) comp; isWindowModified = Boolean.TRUE.equals(jc .getClientProperty(SubstanceLookAndFeel.WINDOW_MODIFIED)); } return isWindowModified; } /** * Retrieves the modified state for the specified root pane. * * @param rootPane * The root pane. * @return true if the specified root pane is marked as * modified, false otherwise. * @see SubstanceLookAndFeel#WINDOW_MODIFIED */ public static boolean isRootPaneModified(JRootPane rootPane) { return Boolean.TRUE.equals(rootPane .getClientProperty(SubstanceLookAndFeel.WINDOW_MODIFIED)); } /** * Retrieves the modified state for the specified internal * frame. * * @param internalFrame * The internal frame. * @return true if the specified internal frame is marked as * modified, false otherwise. * @see SubstanceLookAndFeel#WINDOW_MODIFIED */ public static boolean isInternalFrameModified(JInternalFrame internalFrame) { Object frameProp = internalFrame .getClientProperty(SubstanceLookAndFeel.WINDOW_MODIFIED); if (Boolean.TRUE.equals(frameProp)) return true; if (Boolean.FALSE.equals(frameProp)) return false; return Boolean.TRUE.equals(internalFrame.getRootPane() .getClientProperty(SubstanceLookAndFeel.WINDOW_MODIFIED)); } /** * Checks whether the specified tab has a close button. * * @param tabbedPane * Tabbed pane. * @param tabIndex * Tab index. * @return true if the specified tab has a close button, * false otherwise. * @see SubstanceLookAndFeel#TABBED_PANE_CLOSE_BUTTONS_PROPERTY */ public static boolean hasCloseButton(JTabbedPane tabbedPane, int tabIndex) { int tabCount = tabbedPane.getTabCount(); if ((tabIndex < 0) || (tabIndex >= tabCount)) return false; // if tab is disabled, it doesn't have a close button if (!tabbedPane.isEnabledAt(tabIndex)) return false; // check property on tab component Component tabComponent = tabbedPane.getComponentAt(tabIndex); if (tabComponent instanceof JComponent) { Object compProp = ((JComponent) tabComponent) .getClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY); if (Boolean.TRUE.equals(compProp)) return true; if (Boolean.FALSE.equals(compProp)) return false; } // check property on tabbed pane Object tabProp = tabbedPane .getClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY); if (Boolean.TRUE.equals(tabProp)) return true; if (Boolean.FALSE.equals(tabProp)) return false; // check property in UIManager return UIManager .getBoolean(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY); } /** * Returns the size of the close button for a tab in the specified tabbed * pane. * * @param tabbedPane * Tabbed pane. * @param tabIndex * Tab index. * @return The size of the close button for a tab in the specified tabbed * pane. */ public static int getCloseButtonSize(JTabbedPane tabbedPane, int tabIndex) { if (!SubstanceCoreUtilities.hasCloseButton(tabbedPane, tabIndex)) return 0; return SubstanceSizeUtils.getTabCloseIconSize(SubstanceSizeUtils .getComponentFontSize(tabbedPane)); } /** * Returns the content border kind of the specified tabbed pane. * * @param tabbedPane * Tabbed pane. * @return Content border kind of the specified tabbed pane. * @see SubstanceLookAndFeel#TABBED_PANE_CONTENT_BORDER_KIND */ public static TabContentPaneBorderKind getContentBorderKind( JTabbedPane tabbedPane) { // check property on tabbed pane Object tabProp = tabbedPane .getClientProperty(SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND); if (tabProp instanceof TabContentPaneBorderKind) return (TabContentPaneBorderKind) tabProp; // check property in UIManager Object globalProp = UIManager .get(SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND); if (globalProp instanceof TabContentPaneBorderKind) return (TabContentPaneBorderKind) globalProp; return TabContentPaneBorderKind.DOUBLE_FULL; } /** * Checks whether the specified tab should show modified animation only on * its close button. * * @param tabbedPane * Tabbed pane. * @param tabIndex * Tab index. * @return true if the specified tab should show modified * animation only on its close button, false otherwise. * @see SubstanceLookAndFeel#TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION */ public static boolean toAnimateCloseIconOfModifiedTab( JTabbedPane tabbedPane, int tabIndex) { int tabCount = tabbedPane.getTabCount(); if ((tabIndex < 0) || (tabIndex >= tabCount)) return false; if (!hasCloseButton(tabbedPane, tabIndex)) return false; // check property on tab component Component tabComponent = tabbedPane.getComponentAt(tabIndex); if (tabComponent instanceof JComponent) { Object compProp = ((JComponent) tabComponent) .getClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION); if (Boolean.TRUE.equals(compProp)) return true; if (Boolean.FALSE.equals(compProp)) return false; } // check property on tabbed pane Object tabProp = tabbedPane .getClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION); if (Boolean.TRUE.equals(tabProp)) return true; if (Boolean.FALSE.equals(tabProp)) return false; // check property in UIManager return UIManager .getBoolean(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION); } /** * Retrieves transparent image of specified dimension. * * @param width * Image width. * @param height * Image height. * @return Transparent image of specified dimension. */ public static BufferedImage getBlankImage(int width, int height) { if (MemoryAnalyzer.isRunning()) { // see if the request is unusual if ((width >= 100) || (height >= 100)) { StackTraceElement[] stack = Thread.currentThread() .getStackTrace(); StringBuffer sb = new StringBuffer(); int count = 0; for (StackTraceElement stackEntry : stack) { if (count++ > 8) break; sb.append(stackEntry.getClassName() + "."); sb.append(stackEntry.getMethodName() + " ["); sb.append(stackEntry.getLineNumber() + "]"); sb.append("\n"); } MemoryAnalyzer.enqueueUsage("Blank " + width + "*" + height + "\n" + sb.toString()); } } GraphicsEnvironment e = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice d = e.getDefaultScreenDevice(); GraphicsConfiguration c = d.getDefaultConfiguration(); BufferedImage compatibleImage = c.createCompatibleImage(width, height, Transparency.TRANSLUCENT); return compatibleImage; } /** * Retrieves transparent image of specified dimension. * * @param width * Image width. * @param height * Image height. * @return Transparent image of specified dimension. */ public static VolatileImage getBlankVolatileImage(int width, int height) { if (MemoryAnalyzer.isRunning()) { // see if the request is unusual if ((width >= 100) || (height >= 100)) { StackTraceElement[] stack = Thread.currentThread() .getStackTrace(); StringBuffer sb = new StringBuffer(); int count = 0; for (StackTraceElement stackEntry : stack) { if (count++ > 8) break; sb.append(stackEntry.getClassName() + "."); sb.append(stackEntry.getMethodName() + " ["); sb.append(stackEntry.getLineNumber() + "]"); sb.append("\n"); } MemoryAnalyzer.enqueueUsage("Blank " + width + "*" + height + "\n" + sb.toString()); } } GraphicsEnvironment e = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice d = e.getDefaultScreenDevice(); GraphicsConfiguration c = d.getDefaultConfiguration(); VolatileImage compatibleImage = c.createCompatibleVolatileImage(width, height, Transparency.TRANSLUCENT); return compatibleImage; } /** * Checks whether the specified button should have minimal size. * * @param button * Button. * @return false if the specified button should have minimal * size, true otherwise. * @see SubstanceLookAndFeel#BUTTON_NO_MIN_SIZE_PROPERTY */ public static boolean hasNoMinSizeProperty(AbstractButton button) { Object noMinSizeProperty = button .getClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY); if (Boolean.TRUE.equals(noMinSizeProperty)) return true; if (Boolean.FALSE.equals(noMinSizeProperty)) return false; Container parent = button.getParent(); if (parent instanceof JComponent) { noMinSizeProperty = ((JComponent) parent) .getClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY); if (Boolean.TRUE.equals(noMinSizeProperty)) return true; if (Boolean.FALSE.equals(noMinSizeProperty)) return false; } return (Boolean.TRUE.equals(UIManager .get(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY))); } /** * Checks whether the specified component is flat. * * @param comp * Component. * @param defaultValue * The value to return if there is no * {@link SubstanceLookAndFeel#FLAT_PROPERTY} defined on button * hierarchy or {@link UIManager}. * @return false if the specified button is flat, * true otherwise. * @see SubstanceLookAndFeel#FLAT_PROPERTY */ public static boolean hasFlatAppearance(Component comp, boolean defaultValue) { // small optimizations for checkboxes and radio buttons if (comp instanceof JCheckBox) return defaultValue; if (comp instanceof JRadioButton) return defaultValue; Component c = comp; while (c != null) { if (c instanceof JComponent) { JComponent jcomp = (JComponent) c; Object flatProperty = jcomp .getClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY); if (flatProperty != null) { if (Boolean.TRUE.equals(flatProperty)) return true; if (Boolean.FALSE.equals(flatProperty)) return false; } } c = c.getParent(); } Object flatProperty = UIManager.get(SubstanceLookAndFeel.FLAT_PROPERTY); if (flatProperty != null) { if (Boolean.TRUE.equals(flatProperty)) return true; if (Boolean.FALSE.equals(flatProperty)) return false; } return defaultValue; } /** * Computes whether the specified button has flat appearance. * * @param button * Button. * @return true if the button has flat appearance, * false otherwise. */ public static boolean hasFlatAppearance(AbstractButton button) { // small optimizations for checkboxes and radio buttons if (button instanceof JCheckBox) return false; if (button instanceof JRadioButton) return false; return ((SubstanceCoreUtilities.isToolBarButton(button) && SubstanceCoreUtilities .hasFlatAppearance(button, true)) || SubstanceCoreUtilities .hasFlatAppearance(button, false)); } /** * Returns the popup flyout orientation for the specified combobox. * * @param combobox * Combobox. * @return The popup flyout orientation for the specified combobox. * @see SubstanceLookAndFeel#COMBO_BOX_POPUP_FLYOUT_ORIENTATION */ public static int getPopupFlyoutOrientation(JComboBox combobox) { Object comboProperty = combobox .getClientProperty(SubstanceLookAndFeel.COMBO_BOX_POPUP_FLYOUT_ORIENTATION); if (comboProperty instanceof Integer) return (Integer) comboProperty; Object globalProperty = UIManager .get(SubstanceLookAndFeel.COMBO_BOX_POPUP_FLYOUT_ORIENTATION); if (globalProperty instanceof Integer) return (Integer) globalProperty; return SwingConstants.SOUTH; } /** * Makes the specified component and all its descendants non-opaque. * * @param comp * Component. * @param opacitySnapshot * The "snapshot" map that will contain the original opacity * status of the specified component and all its descendants. */ public static void makeNonOpaque(Component comp, Map opacitySnapshot) { if (comp instanceof JComponent) { JComponent jcomp = (JComponent) comp; opacitySnapshot.put(comp, jcomp.isOpaque()); jcomp.setOpaque(false); } if (comp instanceof Container) { Container cont = (Container) comp; for (int i = 0; i < cont.getComponentCount(); i++) makeNonOpaque(cont.getComponent(i), opacitySnapshot); } } /** * Restores the opacity of the specified component and all its descendants. * * @param comp * Component. * @param opacitySnapshot * The "snapshot" map that contains the original opacity status * of the specified component and all its descendants. */ public static void restoreOpaque(Component comp, Map opacitySnapshot) { if (comp instanceof JComponent) { JComponent jcomp = (JComponent) comp; // fix for defect 159 - snapshot may not contain // opacity for table header of a table when it's used // inside tree cell renderer (wrapper in a scroll pane). if (opacitySnapshot.containsKey(comp)) jcomp.setOpaque(opacitySnapshot.get(comp)); else jcomp.setOpaque(true); } if (comp instanceof Container) { Container cont = (Container) comp; for (int i = 0; i < cont.getComponentCount(); i++) restoreOpaque(cont.getComponent(i), opacitySnapshot); } } /** * Makes the specified component and all its descendants non-double * buffered. * * @param comp * Component. * @param dbSnapshot * The "snapshot" map that will contain the original double * buffer status of the specified component and all its * descendants. */ public static void makeNonDoubleBuffered(Component comp, Map dbSnapshot) { if (comp instanceof JComponent) { JComponent jcomp = (JComponent) comp; dbSnapshot.put(comp, jcomp.isDoubleBuffered()); jcomp.setDoubleBuffered(false); } if (comp instanceof Container) { Container cont = (Container) comp; for (int i = 0; i < cont.getComponentCount(); i++) makeNonDoubleBuffered(cont.getComponent(i), dbSnapshot); } } /** * Restores the double buffer of the specified component and all its * descendants. * * @param comp * Component. * @param dbSnapshot * The "snapshot" map that contains the original double buffer * status of the specified component and all its descendants. */ public static void restoreDoubleBuffered(Component comp, Map dbSnapshot) { if (comp instanceof JComponent) { JComponent jcomp = (JComponent) comp; // fix for defect 159 - snapshot may not contain // opacity for table header of a table when it's used // inside tree cell renderer (wrapper in a scroll pane). if (dbSnapshot.containsKey(comp)) jcomp.setDoubleBuffered(dbSnapshot.get(comp)); else jcomp.setOpaque(true); } if (comp instanceof Container) { Container cont = (Container) comp; for (int i = 0; i < cont.getComponentCount(); i++) restoreDoubleBuffered(cont.getComponent(i), dbSnapshot); } } /** * Creates a compatible image (for efficient processing and drawing). * * @param image * The original image. * @return Compatible version of the original image. * @author Romain Guy */ public static BufferedImage createCompatibleImage(BufferedImage image) { GraphicsEnvironment e = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice d = e.getDefaultScreenDevice(); GraphicsConfiguration c = d.getDefaultConfiguration(); BufferedImage compatibleImage = c.createCompatibleImage(image .getWidth(), image.getHeight(), Transparency.TRANSLUCENT); Graphics g = compatibleImage.getGraphics(); g.drawImage(image, 0, 0, null); g.dispose(); return compatibleImage; } /** * Checks whether the specified component will show scheme-colorized icon in * the default state. * * @param comp * Component. * @return true if the specified component will show * scheme-colorized icon in the default state, false * otherwise. * @see SubstanceLookAndFeel#USE_THEMED_DEFAULT_ICONS */ public static boolean useThemedDefaultIcon() { return Boolean.TRUE.equals(UIManager .get(SubstanceLookAndFeel.USE_THEMED_DEFAULT_ICONS)); } /** * Returns the callback to be called upon tab closing (using the tab close * button). * * @param me * Mouse event. * @param tabbedPane * Tabbed pane. * @param tabIndex * Tab index. * @return Callback to be called upon tab closing (using the tab close * button). * @see SubstanceLookAndFeel#TABBED_PANE_CLOSE_CALLBACK */ public static TabCloseCallback getTabCloseCallback(MouseEvent me, JTabbedPane tabbedPane, int tabIndex) { int tabCount = tabbedPane.getTabCount(); if ((tabIndex < 0) || (tabIndex >= tabCount)) return null; // check property on tab component Component tabComponent = tabbedPane.getComponentAt(tabIndex); if (tabComponent instanceof JComponent) { Object compProp = ((JComponent) tabComponent) .getClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK); if (compProp instanceof TabCloseCallback) return (TabCloseCallback) compProp; } // check property on tabbed pane Object tabProp = tabbedPane .getClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK); if (tabProp instanceof TabCloseCallback) return (TabCloseCallback) tabProp; Object globProp = UIManager .get(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK); if (globProp instanceof TabCloseCallback) return (TabCloseCallback) globProp; return null; } /** * Blends two images along Y-axis. * * @param imageTop * The left image. * @param imageBottom * The right image. * @param start * Relative start of the blend area (in 0.0-1.0 range). * @param end * Relative end of the blend area (in 0.0-1.0 range). * @return Blended image. */ public static BufferedImage blendImagesVertical(BufferedImage imageTop, BufferedImage imageBottom, double start, double end) { int width = imageTop.getWidth(); if (width != imageBottom.getWidth()) throw new IllegalArgumentException("Widths are not the same: " + imageTop.getWidth() + " and " + imageBottom.getWidth()); int height = imageTop.getHeight(); if (height != imageBottom.getHeight()) throw new IllegalArgumentException("Heights are not the same: " + imageTop.getHeight() + " and " + imageBottom.getHeight()); BufferedImage result = getBlankImage(width, height); Graphics2D graphics = (Graphics2D) result.getGraphics().create(); int startY = (int) (start * height); int endY = (int) (end * height); int rampHeight = endY - startY; if (rampHeight == 0) { graphics.drawImage(imageTop, 0, 0, width, startY, 0, 0, width, startY, null); graphics.drawImage(imageBottom, 0, startY, width, height, 0, startY, width, height, null); } else { BufferedImage rampBottom = getBlankImage(width, rampHeight); Graphics2D rampBottomG = (Graphics2D) rampBottom.getGraphics(); rampBottomG.setPaint(new GradientPaint(new Point(0, 0), new Color( 0, 0, 0, 255), new Point(0, rampHeight), new Color(0, 0, 0, 0))); rampBottomG.fillRect(0, 0, width, rampHeight); BufferedImage tempBottom = getBlankImage(width, height - startY); Graphics2D tempBottomG = (Graphics2D) tempBottom.getGraphics(); tempBottomG.drawImage(imageBottom, 0, 0, width, height - startY, 0, startY, width, height, null); tempBottomG.setComposite(AlphaComposite.DstOut); tempBottomG.drawImage(rampBottom, 0, 0, null); tempBottomG.setComposite(AlphaComposite.SrcOver); graphics.drawImage(imageTop, 0, 0, null); graphics.drawImage(tempBottom, 0, startY, null); } graphics.dispose(); return result; } /** * Blends two images along X-axis. * * @param imageLeft * The left image. * @param imageRight * The right image. * @param start * Relative start of the blend area (in 0.0-1.0 range). * @param end * Relative end of the blend area (in 0.0-1.0 range). * @return Blended image. */ public static BufferedImage blendImagesHorizontal(BufferedImage imageLeft, BufferedImage imageRight, double start, double end) { int width = imageLeft.getWidth(); if (width != imageRight.getWidth()) throw new IllegalArgumentException("Widths are not the same: " + imageLeft.getWidth() + " and " + imageRight.getWidth()); int height = imageLeft.getHeight(); if (height != imageRight.getHeight()) throw new IllegalArgumentException("Heights are not the same: " + imageLeft.getHeight() + " and " + imageRight.getHeight()); BufferedImage result = getBlankImage(width, height); Graphics2D graphics = (Graphics2D) result.getGraphics().create(); int startX = (int) (start * width); int endX = (int) (end * width); int rampWidth = endX - startX; if (rampWidth == 0) { graphics.drawImage(imageLeft, 0, 0, startX, height, 0, 0, startX, height, null); graphics.drawImage(imageRight, startX, 0, width, height, startX, 0, width, height, null); } else { BufferedImage rampRight = getBlankImage(rampWidth, height); Graphics2D rampRightG = (Graphics2D) rampRight.getGraphics(); rampRightG .setPaint(new GradientPaint(new Point(0, 0), new Color(0, 0, 0, 255), new Point(rampWidth, 0), new Color(0, 0, 0, 0))); rampRightG.fillRect(0, 0, rampWidth, height); BufferedImage tempRight = getBlankImage(width - startX, height); Graphics2D tempRightG = (Graphics2D) tempRight.getGraphics(); tempRightG.drawImage(imageRight, 0, 0, width - startX, height, startX, 0, width, height, null); tempRightG.setComposite(AlphaComposite.DstOut); tempRightG.drawImage(rampRight, 0, 0, null); tempRightG.setComposite(AlphaComposite.SrcOver); graphics.drawImage(imageLeft, 0, 0, null); graphics.drawImage(tempRight, startX, 0, null); } graphics.dispose(); return result; } /** * Returns the color scheme for the icon of option panes with the specified * message type. * * @param messageType * Option pane message type. * @param mainScheme * Main color scheme. * @return Color scheme for the icon of option panes with the specified * message type. */ public static SubstanceColorScheme getOptionPaneColorScheme( int messageType, SubstanceColorScheme mainScheme) { if (!SubstanceLookAndFeel.isToUseConstantThemesOnDialogs()) return mainScheme; switch (messageType) { case JOptionPane.INFORMATION_MESSAGE: return new BottleGreenColorScheme(); case JOptionPane.QUESTION_MESSAGE: return new LightAquaColorScheme(); case JOptionPane.WARNING_MESSAGE: return new SunsetColorScheme(); case JOptionPane.ERROR_MESSAGE: return new SunfireRedColorScheme(); } return null; } /** * Returns the popup prototype display value for the specified combo box. * This value is used to compute the width of the combo popup. * * @param combo * Combo box. * @return The popup prototype display value for the specified combo box. * @see SubstanceLookAndFeel#COMBO_POPUP_PROTOTYPE */ public static Object getComboPopupPrototypeDisplayValue(JComboBox combo) { Object objProp = combo .getClientProperty(SubstanceLookAndFeel.COMBO_POPUP_PROTOTYPE); if (objProp == null) objProp = UIManager.get(SubstanceLookAndFeel.COMBO_POPUP_PROTOTYPE); if (objProp == null) return null; if (objProp instanceof ComboPopupPrototypeCallback) { ComboPopupPrototypeCallback callback = (ComboPopupPrototypeCallback) objProp; return callback.getPopupPrototypeDisplayValue(combo); } // check if this object is in the model ??? return objProp; } /** * Returns the scroll bar buttons kind of the specified scroll bar. * * @param scrollBar * Scroll bar. * @return The scroll bar buttons kind of the specified scroll bar. * @see SubstanceLookAndFeel#SCROLL_PANE_BUTTONS_POLICY */ public static ScrollPaneButtonPolicyKind getScrollPaneButtonsPolicyKind( JScrollBar scrollBar) { Component parent = scrollBar.getParent(); if (parent instanceof JScrollPane) { Object jspKind = ((JScrollPane) parent) .getClientProperty(SubstanceLookAndFeel.SCROLL_PANE_BUTTONS_POLICY); if (jspKind instanceof ScrollPaneButtonPolicyKind) return (ScrollPaneButtonPolicyKind) jspKind; } Object globalJspKind = UIManager .get(SubstanceLookAndFeel.SCROLL_PANE_BUTTONS_POLICY); if (globalJspKind instanceof ScrollPaneButtonPolicyKind) return (ScrollPaneButtonPolicyKind) globalJspKind; return ScrollPaneButtonPolicyKind.OPPOSITE; } /** * Returns the set of sides registered on the specified button. * * @param component * Button. * @param propertyName * Client property name for retrieving the registered sides. * @return Set of sides registered on the specified button. */ @SuppressWarnings("unchecked") public static Set getSides(JComponent component, String propertyName) { Object prop = component.getClientProperty(propertyName); if (prop instanceof Set) { return (Set) prop; } Set result = EnumSet.noneOf(Side.class); if (prop != null) { if (prop instanceof Side) { result.add((Side) prop); } } return result; } /** * Returns the corner radius of the specified toolbar button. * * @param button * Toolbar button. * @param insets * Button insets. * @return Corner radius of the specified toolbar button. * @see SubstanceLookAndFeel#CORNER_RADIUS */ public static float getToolbarButtonCornerRadius(JComponent button, Insets insets) { JToolBar toolbar = null; Component c = button.getParent(); while (c != null) { if (c instanceof JToolBar) { toolbar = (JToolBar) c; break; } c = c.getParent(); } if (toolbar == null) return 2.0f; int width = button.getWidth(); int height = button.getHeight(); if (insets != null) { width -= (insets.left + insets.right); height -= (insets.top + insets.bottom); } float maxRadius = (width > height) ? (height) / 2.0f : (width) / 2.0f; Object buttonProp = button .getClientProperty(SubstanceLookAndFeel.CORNER_RADIUS); if (buttonProp instanceof Float) return Math.min(maxRadius, ((Float) buttonProp).floatValue()); Object toolbarProp = toolbar .getClientProperty(SubstanceLookAndFeel.CORNER_RADIUS); if (toolbarProp instanceof Float) return Math.min(maxRadius, ((Float) toolbarProp).floatValue()); Object globalProp = UIManager.get(SubstanceLookAndFeel.CORNER_RADIUS); if (globalProp instanceof Float) return Math.min(maxRadius, ((Float) globalProp).floatValue()); return 2.0f; } /** * Returns the number of echo characters per each password chanaracter. * * @param jpf * Password field. * @return The number of echo characters per each password chanaracter. * @see SubstanceLookAndFeel#PASSWORD_ECHO_PER_CHAR */ public static int getEchoPerChar(JPasswordField jpf) { Object obj = jpf .getClientProperty(SubstanceLookAndFeel.PASSWORD_ECHO_PER_CHAR); if ((obj != null) && (obj instanceof Integer)) { int result = (Integer) obj; if (result >= 1) return result; } obj = UIManager.get(SubstanceLookAndFeel.PASSWORD_ECHO_PER_CHAR); if ((obj != null) && (obj instanceof Integer)) { int result = (Integer) obj; if (result >= 1) return result; } return 1; } /** * Creates a clip image for soft-clipping. Code taken from here. * * @param s * Clip shape. * @param width * Image width. * @param height * Image height. * @return Clip image. * @author Chris Campbell. */ public static BufferedImage createClipImage(Shape s, int width, int height) { // Create a translucent intermediate image in which we can perform // the soft clipping GraphicsEnvironment e = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice d = e.getDefaultScreenDevice(); GraphicsConfiguration c = d.getDefaultConfiguration(); BufferedImage img = c.createCompatibleImage(width, height, Transparency.TRANSLUCENT); Graphics2D g2 = img.createGraphics(); // Clear the image so all pixels have zero alpha g2.setComposite(AlphaComposite.Clear); g2.fillRect(0, 0, width, height); // Render our clip shape into the image. Note that we enable // antialiasing to achieve the soft clipping effect. Try // commenting out the line that enables antialiasing, and // you will see that you end up with the usual hard clipping. g2.setComposite(AlphaComposite.Src); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setColor(Color.WHITE); g2.fill(s); g2.dispose(); return img; } /** * Checks whether the specified component has extra Substance-specific UI * elements. * * @param component * Component. * @return true if the specified component has extra * Substance-specific UI elements, false otherwise. * @see SubstanceLookAndFeel#SHOW_EXTRA_WIDGETS */ public static boolean toShowExtraWidgets(Component component) { Component c = component; while (c != null) { if (c instanceof JComponent) { JComponent jcomp = (JComponent) c; Object componentProp = jcomp .getClientProperty(SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS); if (componentProp != null) { if (Boolean.TRUE.equals(componentProp)) return false; if (Boolean.FALSE.equals(componentProp)) return true; } } c = c.getParent(); } return Boolean.TRUE.equals(UIManager .get(SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS)); } /** * Returns indication whether the specified component's border is a * Substance-specific border. * * @param c * Component. * @return true if the specified component's border is a * Substance-specific border, false otherwise. */ public static boolean hasSubstanceBorder(JComponent c) { if (c == null) return false; Border border = c.getBorder(); if (border instanceof SubstanceBorder) return true; if (border instanceof CompoundBorder) { CompoundBorder cb = (CompoundBorder) border; if (cb.getOutsideBorder() instanceof SubstanceBorder) return true; } return false; } /** * Returns the active icon of the specified button. * * @param origIcon * Original icon. * @param button * Button. * @param glowingIcon * Glowing icon. * @param ignoreRolloverSetting * If true, the rollover status of the specified * button is ignored. * @return Active icon for the button. */ public static Icon getActiveIcon(Icon origIcon, AbstractButton button, Icon glowingIcon, boolean ignoreRolloverSetting) { if (origIcon == null) return null; ButtonModel model = button.getModel(); Icon result = origIcon; if (!(button instanceof JRadioButton) && !(button instanceof JCheckBox) && SubstanceCoreUtilities.useThemedDefaultIcon()) { boolean useThemedVersion = !model.isArmed() && !model.isPressed() && !model.isSelected() && !origIcon.getClass().isAnnotationPresent( TransitionAware.class); if (!ignoreRolloverSetting) useThemedVersion = useThemedVersion && !model.isRollover(); if (useThemedVersion) { result = getThemedIcon(button, result); } } if (FadeConfigurationManager.getInstance().fadeAllowed( FadeKind.ICON_GLOW, button) && model.isRollover() && (glowingIcon != null)) { result = glowingIcon; } return result; } public static Icon getThemedIcon(Component comp, Icon orig) { SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(comp, ComponentState.DEFAULT); float brightnessFactor = colorScheme.isDark() ? 0.2f : 0.8f; return new ImageIcon(SubstanceImageCreator.getColorSchemeImage(comp, orig, colorScheme, brightnessFactor)); } public static Icon getThemedIcon(JTabbedPane tab, int tabIndex, Icon orig) { SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(tab, tabIndex, ColorSchemeAssociationKind.TAB, ComponentState.DEFAULT); float brightnessFactor = colorScheme.isDark() ? 0.2f : 0.8f; return new ImageIcon(SubstanceImageCreator.getColorSchemeImage(tab, orig, colorScheme, brightnessFactor)); } /** * Returns the current icon for the specified button. * * @param b * Button. * @param defaultIcon * The default icon. * @param glowingIcon * The glowing icon. * @param ignoreRolloverSetting * If true, the rollover status of the specified * button is ignored. * @return Icon for the specified button. */ public static Icon getIcon(AbstractButton b, Icon defaultIcon, Icon glowingIcon, boolean ignoreRolloverSetting) { ButtonModel model = b.getModel(); Icon icon = getActiveIcon(b.getIcon() == null ? defaultIcon : b .getIcon(), b, glowingIcon, ignoreRolloverSetting); if (icon == null) return null; if (icon.getClass().isAnnotationPresent(TransitionAware.class)) return icon; Icon tmpIcon = null; if (icon != null) { if (!model.isEnabled()) { if (model.isSelected()) { tmpIcon = b.getDisabledSelectedIcon(); } else { tmpIcon = b.getDisabledIcon(); } } else if (model.isPressed() && model.isArmed()) { tmpIcon = b.getPressedIcon(); } else if (b.isRolloverEnabled() && model.isRollover()) { if (model.isSelected()) { tmpIcon = b.getRolloverSelectedIcon(); } else { tmpIcon = b.getRolloverIcon(); } } else if (model.isSelected()) { tmpIcon = b.getSelectedIcon(); } if (tmpIcon != null) { icon = tmpIcon; } } return icon; } /** * Returns the global menu gutter fill kind. * * @return The global menu gutter fill kind. * @see SubstanceLookAndFeel#MENU_GUTTER_FILL_KIND */ public static MenuGutterFillKind getMenuGutterFillKind() { Object globalSetting = UIManager .get(SubstanceLookAndFeel.MENU_GUTTER_FILL_KIND); if (globalSetting instanceof MenuGutterFillKind) return (MenuGutterFillKind) globalSetting; return MenuGutterFillKind.HARD; } /** * Given a component, returns the parent for computing the * {@link SubstanceDecorationPainter}. * * @param c * Component. * @return The parent for computing the {@link SubstanceDecorationPainter}. */ public static Container getHeaderParent(Component c) { Component comp = c.getParent(); Container result = null; while (comp != null) { // the second part fixes the incorrect alignments on // internal frames. if ((comp instanceof JLayeredPane) && (result == null)) result = (Container) comp; if ((result == null) && (comp instanceof Window)) result = (Container) comp; comp = comp.getParent(); } return result; } /** * Paints the focus ring on the specified component. * * @param g * Graphics context. * @param mainComp * The main component for the focus painting. * @param focusedComp * The actual component that has the focus. For example, the main * component can be a {@link JSpinner}, while the focused * component is a text field inside the the spinner editor. * @param focusShape * Focus shape. May be null - in this case, the * bounds of mainComp will be used. * @param textRect * Text rectangle (if relevant). * @param maxAlphaCoef * Maximum alhpa coefficient for painting the focus. Values lower * than 1.0 will result in a translucent focus ring (can be used * to paint a focus ring that doesn't draw too much attention * away from the content, for example on text components). * @param extraPadding * Extra padding between the component bounds and the focus ring * painting. */ public static void paintFocus(Graphics g, Component mainComp, Component focusedComp, Shape focusShape, Rectangle textRect, float maxAlphaCoef, int extraPadding) { FadeTracker fadeTracker = FadeTracker.getInstance(); FocusKind focusKind = SubstanceCoreUtilities.getFocusKind(mainComp); if ((focusKind == FocusKind.NONE) && (!fadeTracker.isTracked(focusedComp, FadeKind.FOCUS))) return; Graphics2D graphics = (Graphics2D) g.create(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); float alpha = 1.0f; if (fadeTracker.isTracked(focusedComp, FadeKind.FOCUS)) { alpha = fadeTracker.getFade(focusedComp, FadeKind.FOCUS); } alpha *= maxAlphaCoef; graphics.setComposite(TransitionLayout.getAlphaComposite(mainComp, alpha, g)); Color color = SubstanceColorUtilities.getFocusColor(mainComp); graphics.setColor(color); focusKind.paintFocus(mainComp, focusedComp, graphics, focusShape, textRect, extraPadding); graphics.dispose(); } /** * Paints the focus ring on the specified component. * * @param g * Graphics context. * @param mainComp * The main component for the focus painting. * @param focusedComp * The actual component that has the focus. For example, the main * component can be a {@link JSpinner}, while the focused * component is a text field inside the the spinner editor. * @param textRect * Text rectangle (if relevant). */ public static void paintFocus(Graphics g, Component mainComp, Component focusedComp, Rectangle textRect) { paintFocus(g, mainComp, focusedComp, null, textRect, 1.0f, 0); } /** * Returns indication whether the specified button is a close button on some * title pane. * * @param ab * Button. * @return true if the specified button is a close button on * some title pane, false otherwise. */ public static boolean isTitleCloseButton(JComponent ab) { if ((ab instanceof SubstanceTitleButton) && Boolean.TRUE .equals(ab .getClientProperty(SubstanceButtonUI.IS_TITLE_CLOSE_BUTTON))) return true; return false; } /** * Uninstalls the specified menu item. * * @param menuItem * Menu item. */ public static void uninstallMenu(JMenuItem menuItem) { if (menuItem instanceof JMenu) { JMenu menu = (JMenu) menuItem; for (Component comp : menu.getMenuComponents()) if (comp instanceof JMenuItem) SubstanceCoreUtilities.uninstallMenu((JMenuItem) comp); } ButtonUI menuItemUI = menuItem.getUI(); if (menuItemUI instanceof SubstanceMenu) { SubstanceMenu sMenu = (SubstanceMenu) menuItemUI; if (sMenu.getAssociatedMenuItem() != null) { menuItemUI.uninstallUI(menuItem); } } for (ActionListener actionListener : menuItem.getActionListeners()) menuItem.removeActionListener(actionListener); menuItem.removeAll(); } /** * Returns an icon pointed to by the specified string. * * @param iconResource * Resource location string. * @return Icon. */ public static Icon getIcon(String iconResource) { ClassLoader cl = getClassLoaderForResources(); URL iconUrl = cl.getResource(iconResource); if (iconUrl == null) return null; return new IconUIResource(new ImageIcon(iconUrl)); } /** * Returns the class loader for loading the resource files. It is a fix by * Dag Joar and Christian Schlichtherle for application running with * -Xbootclasspath VM flag. In this case, the using * MyClass.class.getClassLoader() would return null, but the context class * loader will function properly that classes will be properly loaded * regardless of whether the lib is added to the system class path, the * extension class path and regardless of the class loader architecture set * up by some frameworks. * * @return The class loader for loading the resource files. */ public static ClassLoader getClassLoaderForResources() { ClassLoader cl = (ClassLoader) UIManager.get("ClassLoader"); if (cl == null) cl = Thread.currentThread().getContextClassLoader(); return cl; } /** * Returns the fade callback for the specified button. * * @param button * Button. * @param toRepaintParent * if true, button's parent will be repainted on * each iteration cycle. Otherwise, the button itself will be * repainted. * @return Fade callback for the specified button. */ public static FadeTrackerCallback getFadeCallback( final AbstractButton button, boolean toRepaintParent) { return getFadeCallback(button, button.getModel(), false, toRepaintParent, button); } /** * Returns the fade callback for the specified component. * * @param component * Component. * @param model * Model for tracking the transitions. For button components, * pass the {@link AbstractButton#getModel()}, for other controls * pass a dummy (synthesized) model. * @param toIgnoreSelection * If true, the {@link ButtonModel#isSelected()} * will not be checked. This can be used for tracking transitions * on menu items that use armed state instead, when * we don't want to use different rollover color schemes for * selected and unselected checkbox and radio button menu items * (to preserve consistent visual appearence of highlights). * @param toRepaintParent * if true, component's parent will be repainted on * each iteration cycle. Otherwise, the * componentToRepaint will be repainted. * @param componentToRepaint * If toRepaintParent is false, this * component will be repainted. * @return Fade callback for the specified component. */ public static FadeTrackerCallback getFadeCallback( final JComponent component, final ButtonModel model, final boolean toIgnoreSelection, final boolean toRepaintParent, final Component componentToRepaint) { return getFadeCallback(component, model, null, toIgnoreSelection, toRepaintParent, componentToRepaint); } /** * Returns the fade callback for the specified component. * * @param component * Component. * @param model * Model for tracking the transitions. For button components, * pass the {@link AbstractButton#getModel()}, for other controls * pass a dummy (synthesized) model. * @param extraKey * Extra key. * @param toIgnoreSelection * If true, the {@link ButtonModel#isSelected()} * will not be checked. This can be used for tracking transitions * on menu items that use armed state instead, when * we don't want to use different rollover color schemes for * selected and unselected checkbox and radio button menu items * (to preserve consistent visual appearence of highlights). * @param toRepaintParent * if true, component's parent will be repainted on * each iteration cycle. Otherwise, the * componentToRepaint will be repainted. * @param componentToRepaint * If toRepaintParent is false, this * component will be repainted. * @return Fade callback for the specified component. */ public static FadeTrackerCallback getFadeCallback( final JComponent component, final ButtonModel model, String extraKey, final boolean toIgnoreSelection, final boolean toRepaintParent, final Component componentToRepaint) { final String prevComponentStateKey = (extraKey == null) ? SubstanceCoreUtilities.PREV_COMPONENT_STATE : SubstanceCoreUtilities.PREV_COMPONENT_STATE + ":" + extraKey; final String prevSelComponentStateKey = (extraKey == null) ? SubstanceCoreUtilities.PREV_SEL_COMPONENT_STATE : SubstanceCoreUtilities.PREV_SEL_COMPONENT_STATE + ":" + extraKey; final String nextComponentStateKey = (extraKey == null) ? SubstanceCoreUtilities.NEXT_COMPONENT_STATE : SubstanceCoreUtilities.NEXT_COMPONENT_STATE + ":" + extraKey; final String nextSelComponentStateKey = (extraKey == null) ? SubstanceCoreUtilities.NEXT_SEL_COMPONENT_STATE : SubstanceCoreUtilities.NEXT_SEL_COMPONENT_STATE + ":" + extraKey; // fix for issue 351 - ComponentState.getState may access // MenuSelectionManager APIs and as such it needs to run on EDT. FadeTrackerCallback callback = new UIThreadFadeTrackerAdapter() { @Override public void fadeReversed(FadeKind fadeKind, boolean isFadingIn, float fadeCycle10) { component.putClientProperty(prevComponentStateKey, component .getClientProperty(nextComponentStateKey)); component.putClientProperty(prevSelComponentStateKey, component .getClientProperty(nextSelComponentStateKey)); // String text = (component instanceof AbstractButton) ? // ((AbstractButton) // component) // .getText() // : ""; // System.out.println(component.getClass().getSimpleName() // + "[" // + text // + "]" // + " : " // + fadeKind.toString() // + " - tracking prev as " // + ((ComponentState) component // .getClientProperty(PREV_COMPONENT_STATE)) // .name()); if (!toRepaintParent) { componentToRepaint.repaint(); } else { Container parent = component.getParent(); if (parent != null) { parent.repaint(); } } } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.animation.FadeTrackerAdapter#fadeEnded(org * .jvnet.lafwidget.animation.FadeKind) */ @Override public void fadeEnded(final FadeKind fadeKind) { // System.out.println(toIgnoreSelection); component.putClientProperty(prevComponentStateKey, ComponentState.getState(model, component, toIgnoreSelection)); component.putClientProperty(prevSelComponentStateKey, ComponentState.getState(model, component, false)); component.putClientProperty(nextComponentStateKey, null); component.putClientProperty(nextSelComponentStateKey, null); // String text = (component instanceof AbstractButton) ? // ((AbstractButton) // component) // .getText() // : ""; // ComponentState prevState = (ComponentState) component // .getClientProperty(PREV_COMPONENT_STATE); // System.out.println(component.getClass().getSimpleName() + "[" // + text + "]" + " : " + fadeKind.toString() // + " - tracking prev as " + prevState.name()); if (!toRepaintParent) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (component instanceof JMenuItem) { if (isCoveredByLightweightPopups(component)) { component .putClientProperty( SubstanceCoreUtilities.IS_COVERED_BY_LIGHTWEIGHT_POPUPS, Boolean.TRUE); } else { component .putClientProperty( SubstanceCoreUtilities.IS_COVERED_BY_LIGHTWEIGHT_POPUPS, null); } } // System.out.println("Repainted " // + componentToRepaint.getClass() // .getSimpleName() + " on " // + fadeKind.toString() + " end"); componentToRepaint.repaint(); } }); } else { Container parent = component.getParent(); if (parent != null) { parent.repaint(); } } } @Override public void fadePerformed(FadeKind fadeKind, float fadeCycle10) { component.putClientProperty(nextComponentStateKey, ComponentState.getState(model, component, toIgnoreSelection)); component.putClientProperty(nextSelComponentStateKey, ComponentState.getState(model, component, false)); if (!toRepaintParent) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (component instanceof JMenuItem) { if (isCoveredByLightweightPopups(component)) { component .putClientProperty( SubstanceCoreUtilities.IS_COVERED_BY_LIGHTWEIGHT_POPUPS, Boolean.TRUE); } else { component .putClientProperty( SubstanceCoreUtilities.IS_COVERED_BY_LIGHTWEIGHT_POPUPS, null); } } componentToRepaint.repaint(); } }); } else { Container parent = component.getParent(); if (parent != null) { parent.repaint(); } } } private boolean isCoveredByLightweightPopups(final Component comp) { JRootPane rootPane = SwingUtilities.getRootPane(comp); if (rootPane == null) return false; Component[] popups = rootPane.getLayeredPane() .getComponentsInLayer(JLayeredPane.POPUP_LAYER); if (popups == null) return false; // System.out.println("Has " + popups.length + " popups"); // Convert the component bounds to the layered pane. // Can't use the SwingUtilities.convertRectangle() as that // eventually will try to acquire the lock on the container Rectangle compBoundsConverted = SwingUtilities .convertRectangle(comp.getParent(), comp.getBounds(), rootPane.getLayeredPane()); // System.out.println("Bounds : \n\torig : " + comp.getBounds() // + "\n\ttrans:" + compBoundsConverted); int popupIndexToStartWith = getPopupParentIndexOf(comp, popups) - 1; // String txt = (comp instanceof JMenuItem) ? ((JMenuItem) comp) // .getText() : ""; // System.out.println("Starting scan from popup " // + popupIndexToStartWith + " for " + txt); for (int i = popupIndexToStartWith; i >= 0; i--) { Component popup = popups[i]; // System.out.println("Popup " + // popup.getClass().getName()); // System.out.println("Popup bounds " + popup.getBounds()); if (compBoundsConverted.intersects(popup.getBounds())) { return true; } } return false; } }; return callback; } /** * Gets a component and a list of popups and returns the index of the popup * that is a parent of the specified component. Is used to track issue 297 * and prevent visual artifacts. * * @param comp * Component. * @param popups * List of popups. * @return Index of the popup which is component's parent if any, or the * popup list length otherwise. */ public static int getPopupParentIndexOf(Component comp, Component[] popups) { for (int i = 0; i < popups.length; i++) { Component popup = popups[i]; Component currComp = comp; while (currComp != null) { if (currComp == popup) { return i; } currComp = currComp.getParent(); } } return popups.length; } /** * Returns the previous state of the specified component. * * @param comp * Component. * @return The previous state of the specified component. */ public static ComponentState getPrevComponentState(JComponent comp) { ComponentState result = (ComponentState) comp .getClientProperty(PREV_COMPONENT_STATE); if (result == null) { result = ComponentState.DEFAULT; } return result; } /** * Returns the previous state of the specified component. * * @param comp * Component. * @param extraKey * Extra key. * @return The previous state of the specified component. */ public static ComponentState getPrevComponentState(JComponent comp, String extraKey) { String prevComponentStateKey = (extraKey == null) ? SubstanceCoreUtilities.PREV_COMPONENT_STATE : SubstanceCoreUtilities.PREV_COMPONENT_STATE + ":" + extraKey; ComponentState result = (ComponentState) comp .getClientProperty(prevComponentStateKey); if (result == null) { result = ComponentState.DEFAULT; } return result; } /** * Returns the previous state of the specified component. * * @param comp * Component. * @return The previous state of the specified component. */ public static ComponentState getPrevSelComponentState(JComponent comp) { ComponentState result = (ComponentState) comp .getClientProperty(PREV_SEL_COMPONENT_STATE); if (result == null) { result = ComponentState.DEFAULT; } return result; } /** * Checks whether a component has the specified client property set to the * specified value. * * @param comp * Component. * @param propertyName * Client property name. * @param expectedValue * Expected value. * @param checkHierarchy * if true, the entire component hierarchy is * traversed. * @return true if the component has the specified client * property set to the specified value, false * otherwise. */ public static boolean hasPropertySetTo(Component comp, String propertyName, boolean expectedValue, boolean checkHierarchy) { if (!checkHierarchy) { if (comp instanceof JComponent) { JComponent jcomp = (JComponent) comp; Object componentProp = jcomp.getClientProperty(propertyName); if (componentProp != null) { if (componentProp.equals(expectedValue)) return true; } } } else { Component c = comp; while (c != null) { if (c instanceof JComponent) { JComponent jcomp = (JComponent) c; Object componentProp = jcomp .getClientProperty(propertyName); if (componentProp != null) { if (componentProp.equals(expectedValue)) return true; } } c = c.getParent(); } } Object globalProp = UIManager.get(propertyName); if (globalProp != null) { return globalProp.equals(expectedValue); } return false; } /** * Returns the resource bundle for the specified component. * * @param jcomp * Component. * @return Resource bundle for the specified component. */ public static ResourceBundle getResourceBundle(JComponent jcomp) { if (LafWidgetUtilities.toIgnoreGlobalLocale(jcomp)) { return SubstanceLookAndFeel.getLabelBundle(jcomp.getLocale()); } else { return SubstanceLookAndFeel.getLabelBundle(); } } /** * Returns the border painter for the specified component. * * @param comp * Component. * @return Border painter for the specified component. * @see SubstanceSkin#getBorderPainter() */ public static SubstanceBorderPainter getBorderPainter(Component comp) { return SubstanceCoreUtilities.getSkin(comp).getBorderPainter(); } /** * Returns the highlight border painter for the specified component. * * @param comp * Component. * @return Highlight border painter for the specified component. * @see SubstanceSkin#getBorderPainter() * @see SubstanceSkin#getHighlightBorderPainter() */ public static SubstanceBorderPainter getHighlightBorderPainter( Component comp) { SubstanceBorderPainter result = SubstanceCoreUtilities.getSkin(comp) .getHighlightBorderPainter(); if (result != null) return result; return getBorderPainter(comp); } /** * Returns the component hierarchy. * * @param comp * Component. * @return Component hierarchy string. */ public static String getHierarchy(Component comp) { StringBuffer buffer = new StringBuffer(); getHierarchy(comp, buffer, 0); while (true) { if (comp instanceof Window) { Window w = (Window) comp; comp = w.getOwner(); if (comp != null) { buffer.append("Owner --->\n"); getHierarchy(comp, buffer, 0); } } else { break; } } return buffer.toString(); } /** * Computes the component hierarchy. * * @param comp * Component. * @param buffer * Hierarchy representation buffer. * @param level * Hierarchy level. */ public static void getHierarchy(Component comp, StringBuffer buffer, int level) { for (int i = 0; i < level; i++) buffer.append(" "); String name = comp.getName(); if (comp instanceof Dialog) name = ((Dialog) comp).getTitle(); if (comp instanceof Frame) name = ((Frame) comp).getTitle(); buffer.append(comp.getClass().getName() + "[" + name + "]\n"); if (comp instanceof Container) { Container cont = (Container) comp; for (int i = 0; i < cont.getComponentCount(); i++) getHierarchy(cont.getComponent(i), buffer, level + 1); } } /** * Returns the title pane of the specified root pane. * * @param rootPane * Root pane. * @return The title pane of the specified root pane. */ public static JComponent getTitlePane(JRootPane rootPane) { JInternalFrame jif = (JInternalFrame) SwingUtilities .getAncestorOfClass(JInternalFrame.class, rootPane); if (jif != null) { SubstanceInternalFrameUI ui = (SubstanceInternalFrameUI) jif .getUI(); return ui.getTitlePane(); } SubstanceRootPaneUI ui = (SubstanceRootPaneUI) rootPane.getUI(); if (ui == null) return null; return ui.getTitlePane(); } /** * Returns the arrow icon. * * @param comp * Component. * @param button * Button. * @param orientation * Arrow orientation. * @return Arrow icon. */ public static Icon getArrowIcon(final AbstractButton button, final int orientation) { Icon result = new ArrowButtonTransitionAwareIcon(button, orientation); return result; } /** * Returns the arrow icon. * * @param comp * Component. * @param button * Button. * @param orientation * Arrow orientation. * @return Arrow icon. */ public static Icon getDoubleArrowIcon(final Component comp, final AbstractButton button, final int orientation) { Icon result = new TransitionAwareIcon(button, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { int fontSize = SubstanceSizeUtils .getComponentFontSize(comp); return SubstanceImageCreator.getDoubleArrowIconDelta( fontSize, 0, 2, 0, orientation, scheme); } }, "substance.general.doubleArrow"); return result; } /** * Returns the colorization factor for the specified component. * * @param c * Component. * @return The colorization factor for the specified component. * @see SubstanceLookAndFeel#COLORIZATION_FACTOR */ public static double getColorizationFactor(Component c) { JPopupMenu popupMenu = null; while (c != null) { if (c instanceof JComponent) { JComponent jcomp = (JComponent) c; Object compProp = jcomp .getClientProperty(SubstanceLookAndFeel.COLORIZATION_FACTOR); if (compProp instanceof Double) return (Double) compProp; } if (c instanceof JPopupMenu) { popupMenu = (JPopupMenu) c; } c = c.getParent(); } if (popupMenu != null) { Component invoker = popupMenu.getInvoker(); if (popupMenu != invoker) return getColorizationFactor(popupMenu.getInvoker()); } Object globalProp = UIManager .get(SubstanceLookAndFeel.COLORIZATION_FACTOR); if (globalProp instanceof Double) { return (Double) globalProp; } return 0.5; } /** * Returns the skin of the specified component. * * @param c * Component. * @return The skin of the specified component. * @see SubstanceLookAndFeel#SKIN_PROPERTY */ public static SubstanceSkin getSkin(Component c) { if (!SubstanceLookAndFeel.isCurrentLookAndFeel()) return null; SubstanceComboPopup comboPopup = (SubstanceComboPopup) SwingUtilities .getAncestorOfClass(SubstanceComboPopup.class, c); if (comboPopup != null) { // special case for combobox popup - take the skin // of the combobox itself - issue 439 return getSkin(comboPopup.getCombobox()); } JRootPane rootPane = SwingUtilities.getRootPane(c); if (c instanceof SubstanceInternalFrameTitlePane) { // use correct root pane for painting the // title panes of internal frames Component frame = c.getParent(); if ((frame != null) && (frame instanceof JInternalFrame)) { rootPane = ((JInternalFrame) frame).getRootPane(); } } if ((c != null) && (c.getParent() instanceof SubstanceInternalFrameTitlePane)) { // use correct root pane for painting the // title buttons of internal frames Component frame = c.getParent().getParent(); if ((frame != null) && (frame instanceof JInternalFrame)) { rootPane = ((JInternalFrame) frame).getRootPane(); } } if (rootPane != null) { Object skinProp = rootPane .getClientProperty(SubstanceLookAndFeel.SKIN_PROPERTY); if (skinProp instanceof SubstanceSkin) return (SubstanceSkin) skinProp; } return SubstanceLookAndFeel.getCurrentSkin(); } /** * Returns a hash key for the specified parameters. * * @param objects * Key components. * @return Hash key. */ public static HashMapKey getHashKey(Object... objects) { return new HashMapKey(objects); } /** * Stops all Substance threads. Improper use may result in UI artifacts and * runtime exceptions. */ public static void stopThreads() { PulseTracker.stopAllTimers(); FadeTracker.getInstance().stopAllTimers(); TrackableThread.requestStopAllThreads(); } /** * Retrieves a single parameter from the VM flags. * * @param parameterName * Parameter name. * @return Parameter value. */ public static String getVmParameter(String parameterName) { String paramValue = null; try { paramValue = System.getProperty(parameterName); return paramValue; } catch (Exception exc) { // probably running in unsecure JNLP - ignore return null; } } /** * Checks whether the specified component uses highlights. * * @param comp * Component. * @return true if the specified component uses highlights, * false otherwise. */ public static boolean toUseHighlightColorScheme(Component comp) { return hasPropertySetTo(comp, USE_HIGHLIGHT, true, true); } /** * Tests UI threading violations on creating the specified component. * * @param comp * Component. * @throws UiThreadingViolationException * If the component is created off Event Dispatch Thread. */ public static void testComponentCreationThreadingViolation(Component comp) { if (!SwingUtilities.isEventDispatchThread()) { UiThreadingViolationException uiThreadingViolationError = new UiThreadingViolationException( "Component creation must be done on Event Dispatch Thread"); uiThreadingViolationError.printStackTrace(System.err); throw uiThreadingViolationError; } } /** * Tests UI threading violations on changing the state the specified * component. * * @param comp * Component. * @throws UiThreadingViolationException * If the component is changing state off Event Dispatch Thread. */ public static void testComponentStateChangeThreadingViolation(Component comp) { if (!SwingUtilities.isEventDispatchThread()) { UiThreadingViolationException uiThreadingViolationError = new UiThreadingViolationException( "Component state change must be done on Event Dispatch Thread"); uiThreadingViolationError.printStackTrace(System.err); throw uiThreadingViolationError; } } public static void traceSubstanceApiUsage(Component comp, String message) { Window w = SwingUtilities.getWindowAncestor(comp); String wTitle = null; if (w instanceof Frame) { wTitle = ((Frame) w).getTitle(); } if (w instanceof Dialog) { wTitle = ((Dialog) w).getTitle(); } throw new IllegalArgumentException(message + " [component " + comp.getClass().getSimpleName() + " in window " + w.getClass().getSimpleName() + ":'" + wTitle + "' under " + UIManager.getLookAndFeel().getName() + "]"); } /** * Scans {@code imageList} for best-looking image of specified dimensions. * Image can be scaled and/or padded with transparency. */ public static BufferedImage getScaledIconImage( java.util.List imageList, int width, int height) { if (width == 0 || height == 0) { return null; } Image bestImage = null; int bestWidth = 0; int bestHeight = 0; double bestSimilarity = 3; // Impossibly high value for (Iterator i = imageList.iterator(); i.hasNext();) { // Iterate imageList looking for best matching image. // 'Similarity' measure is defined as good scale factor and small // insets. // best possible similarity is 0 (no scale, no insets). // It's found while the experiments that good-looking result is // achieved // with scale factors x1, x3/4, x2/3, xN, x1/N. Image im = i.next(); if (im == null) { continue; } int iw; int ih; try { iw = im.getWidth(null); ih = im.getHeight(null); } catch (Exception e) { continue; } if (iw > 0 && ih > 0) { // Calc scale factor double scaleFactor = Math.min((double) width / (double) iw, (double) height / (double) ih); // Calculate scaled image dimensions // adjusting scale factor to nearest "good" value int adjw = 0; int adjh = 0; double scaleMeasure = 1; // 0 - best (no) scale, 1 - impossibly // bad if (scaleFactor >= 2) { // Need to enlarge image more than twice // Round down scale factor to multiply by integer value scaleFactor = Math.floor(scaleFactor); adjw = iw * (int) scaleFactor; adjh = ih * (int) scaleFactor; scaleMeasure = 1.0 - 0.5 / scaleFactor; } else if (scaleFactor >= 1) { // Don't scale scaleFactor = 1.0; adjw = iw; adjh = ih; scaleMeasure = 0; } else if (scaleFactor >= 0.75) { // Multiply by 3/4 scaleFactor = 0.75; adjw = iw * 3 / 4; adjh = ih * 3 / 4; scaleMeasure = 0.3; } else if (scaleFactor >= 0.6666) { // Multiply by 2/3 scaleFactor = 0.6666; adjw = iw * 2 / 3; adjh = ih * 2 / 3; scaleMeasure = 0.33; } else { // Multiply size by 1/scaleDivider // where scaleDivider is minimum possible integer // larger than 1/scaleFactor double scaleDivider = Math.ceil(1.0 / scaleFactor); scaleFactor = 1.0 / scaleDivider; adjw = (int) Math.round(iw / scaleDivider); adjh = (int) Math.round(ih / scaleDivider); scaleMeasure = 1.0 - 1.0 / scaleDivider; } double similarity = ((double) width - (double) adjw) / width + ((double) height - (double) adjh) / height + // Large // padding // is // bad scaleMeasure; // Large rescale is bad if (similarity < bestSimilarity) { bestSimilarity = similarity; bestImage = im; bestWidth = adjw; bestHeight = adjh; } if (similarity == 0) break; } } if (bestImage == null) { // No images were found, possibly all are broken return null; } BufferedImage bimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g = bimage.createGraphics(); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); // BufferedImage bestBuffered = getBlankImage(bestImage.getWidth(null), // bestImage.getHeight(null)); // bestBuffered.getGraphics().drawImage(bestImage, 0, 0, null); // BufferedImage scaled = // LafWidgetUtilities.createThumbnail(bestBuffered, // bestWidth); try { int x = (width - bestWidth) / 2; int y = (height - bestHeight) / 2; g.drawImage(bestImage, x, y, bestWidth, bestHeight, null); } finally { g.dispose(); } return bimage; } public static boolean canReplaceChildBackgroundColor(Color background) { return (background instanceof UIResource) || (background instanceof SubstanceColorResource); } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceTitleButton.java0000644000175000017500000000604211136475562027042 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import javax.accessibility.AccessibleContext; import javax.swing.JButton; import javax.swing.UIManager; import org.jvnet.lafwidget.animation.FadeConfigurationManager; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.substance.SubstanceLookAndFeel; /** * Title button in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceTitleButton extends JButton { static { FadeConfigurationManager.getInstance().disallowFades( FadeKind.GHOSTING_BUTTON_PRESS, SubstanceTitleButton.class); FadeConfigurationManager.getInstance().disallowFades( FadeKind.GHOSTING_ICON_ROLLOVER, SubstanceTitleButton.class); } private String uiKey; public SubstanceTitleButton(String uiKey) { this.uiKey = uiKey; this.setOpaque(false); this.putClientProperty(SubstanceLookAndFeel.USE_THEMED_DEFAULT_ICONS, Boolean.FALSE); } @Override public boolean isOpaque() { return false; } public SubstanceTitleButton() { this(""); } @Override public boolean isFocusTraversable() { return false; } @Override public void requestFocus() { }; @Override public AccessibleContext getAccessibleContext() { AccessibleContext ac = super.getAccessibleContext(); if (uiKey != null) { ac.setAccessibleName(UIManager.getString(uiKey)); uiKey = null; } return ac; } } substance-5.3.orig/src/org/jvnet/substance/utils/ButtonBackgroundDelegate.java0000644000175000017500000003745311172043020027611 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.*; import java.awt.image.BufferedImage; import java.util.Set; import javax.swing.*; import javax.swing.JInternalFrame.JDesktopIcon; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.*; import org.jvnet.substance.api.SubstanceConstants.Side; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; import org.jvnet.substance.shaper.*; /** * Delegate class for painting backgrounds of buttons in Substance look * and feel. This class is for internal use only. * * @author Kirill Grouchnikov */ public class ButtonBackgroundDelegate { /** * Cache for background images. Each time * {@link #getBackground(AbstractButton, SubstanceButtonShaper, SubstanceGradientPainter, int, int)} * is called, it checks this map to see if it already contains * such background. If so, the background from the map is returned. */ private static LazyResettableHashMap regularBackgrounds = new LazyResettableHashMap( "ButtonBackgroundDelegate"); /** * Retrieves the background for the specified button. * * @param button * Button. * @param model * Button model. * @param shaper * Button shaper. * @param painter * Button gradient painter. * @param borderPainter * Button border painter. * @param width * Button width. * @param height * Button height. * @return Button background. */ public static BufferedImage getFullAlphaBackground(AbstractButton button, ButtonModel model, SubstanceButtonShaper shaper, SubstanceGradientPainter painter, SubstanceBorderPainter borderPainter, int width, int height) { ComponentState state = ComponentState.getState(model, button); ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(button, null); // compute cycle count (for animation) float cyclePos = state.getCyclePosition(); boolean isPulsating = false; if (button instanceof JButton) { JButton jb = (JButton) button; if (PulseTracker.isPulsating(jb) && (state != ComponentState.PRESSED_SELECTED) && (state != ComponentState.PRESSED_UNSELECTED)) { isPulsating = true; cyclePos = (int) (PulseTracker.getCycles(jb) % 20); if (cyclePos > 10) { cyclePos = 19 - cyclePos; } cyclePos /= 10.0f; } } // compute color scheme SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, state); SubstanceColorScheme colorScheme2 = colorScheme; SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.BORDER, state); SubstanceColorScheme borderScheme2 = borderScheme; // see if need to use attention-drawing animation boolean isWindowModified = false; if (SubstanceCoreUtilities.isTitleCloseButton(button)) { // check if have windowModified property Component comp = button; while (comp != null) { if (comp instanceof JInternalFrame) { JInternalFrame jif = (JInternalFrame) comp; isWindowModified = Boolean.TRUE .equals(jif .getClientProperty(SubstanceLookAndFeel.WINDOW_MODIFIED)); break; } if (comp instanceof JRootPane) { JRootPane jrp = (JRootPane) comp; isWindowModified = Boolean.TRUE .equals(jrp .getClientProperty(SubstanceLookAndFeel.WINDOW_MODIFIED)); break; } if (comp instanceof JDesktopIcon) { JDesktopIcon jdi = (JDesktopIcon) comp; JInternalFrame jif = jdi.getInternalFrame(); isWindowModified = Boolean.TRUE .equals(jif .getClientProperty(SubstanceLookAndFeel.WINDOW_MODIFIED)); break; } comp = comp.getParent(); } if (isWindowModified) { colorScheme2 = SubstanceColorSchemeUtilities.YELLOW; colorScheme = SubstanceColorSchemeUtilities.ORANGE; } } // see if need to use fade animation. Important - don't do it // on pulsating buttons (such as default or close buttons // of modified frames). if (!isWindowModified && !isPulsating && model.isEnabled()) { FadeState fadeState = SubstanceFadeUtilities.getFadeState(button, FadeKind.ROLLOVER, FadeKind.SELECTION, FadeKind.PRESS); if (fadeState != null) { colorScheme = SubstanceColorSchemeUtilities.getColorScheme( button, state); colorScheme2 = SubstanceColorSchemeUtilities.getColorScheme( button, prevState); borderScheme = SubstanceColorSchemeUtilities.getColorScheme( button, ColorSchemeAssociationKind.BORDER, state); borderScheme2 = SubstanceColorSchemeUtilities.getColorScheme( button, ColorSchemeAssociationKind.BORDER, prevState); cyclePos = fadeState.getFadePosition(); // System.out.println(extraModelKey + ":" + cyclePos); if (fadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; } else { // System.out.println(extraModelKey + ":" + state.name()); } } // if (colorScheme == colorScheme2) { // System.out.println(extraModelKey + ":" + state.name() + ":" // + colorScheme.getDisplayName()); // } // compute the straight sides Set straightSides = SubstanceCoreUtilities .getSides(button, SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY); String straightKey = ""; for (Side sSide : straightSides) { straightKey += sSide.name() + "-"; } boolean isRoundButton = StandardButtonShaper.isRoundButton(button); float radius = 0.0f; if (shaper instanceof RectangularButtonShaper) { radius = ((RectangularButtonShaper) shaper).getCornerRadius(button, null); } Set openSides = SubstanceCoreUtilities.getSides(button, SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY); // String openKey = ""; // for (Side oSide : openSides) { // openKey += oSide.name() + "-"; // } // String extraModelKey = ""; // for (String modelKey : extraModelKeys) { // extraModelKey += (modelKey + "-"); // } boolean isContentAreaFilled = button.isContentAreaFilled(); boolean isBorderPainted = button.isBorderPainted(); HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height, prevState.name(), state.name(), cyclePos, colorScheme .getDisplayName(), colorScheme2.getDisplayName(), borderScheme.getDisplayName(), borderScheme2.getDisplayName(), shaper.getDisplayName(), painter.getDisplayName(), borderPainter.getDisplayName(), straightKey, openSides, button .getClass().getName(), isRoundButton, radius, isContentAreaFilled, isBorderPainted, SubstanceSizeUtils .getComponentFontSize(button)); // System.out.println(component.getClass().getSimpleName() + ":" // + extraModelKeys + " " // + /* button.getText() + ":" + */prevState.name() + "->" // + state.name() + " - " + cyclePos); // System.out.println("\t" + colorScheme2.getDisplayName() + ":" // + colorScheme.getDisplayName()); BufferedImage existing = regularBackgrounds.get(key); if (existing == null) { int openDelta = (int) (Math.ceil(3.0 * SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(button)))); int deltaLeft = openSides.contains(Side.LEFT) ? openDelta : 0; int deltaRight = openSides.contains(Side.RIGHT) ? openDelta : 0; int deltaTop = openSides.contains(Side.TOP) ? openDelta : 0; int deltaBottom = openSides.contains(Side.BOTTOM) ? openDelta : 0; // System.err.println(key); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(button)) / 2.0); Shape contour = shaper.getButtonOutline(button, new Insets( borderDelta, borderDelta, borderDelta, borderDelta), width + deltaLeft + deltaRight, height + deltaTop + deltaBottom, false); BufferedImage newBackground = SubstanceCoreUtilities.getBlankImage( width, height); Graphics2D finalGraphics = (Graphics2D) newBackground.getGraphics(); finalGraphics.translate(-deltaLeft, -deltaTop); if (isContentAreaFilled) { painter.paintContourBackground(finalGraphics, button, width + deltaLeft + deltaRight, height + deltaTop + deltaBottom, contour, false, colorScheme, colorScheme2, cyclePos, true, colorScheme != colorScheme2); } if (isBorderPainted) { int borderThickness = (int) SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(button)); Shape contourInner = borderPainter.isPaintingInnerContour() ? shaper .getButtonOutline(button, new Insets(borderDelta + borderThickness, borderDelta + borderThickness, borderDelta + borderThickness, borderDelta + borderThickness), width + deltaLeft + deltaRight, height + deltaTop + deltaBottom, true) : null; borderPainter.paintBorder(finalGraphics, button, width + deltaLeft + deltaRight, height + deltaTop + deltaBottom, contour, contourInner, borderScheme, borderScheme2, cyclePos, borderScheme != borderScheme2); } regularBackgrounds.put(key, newBackground); } existing = regularBackgrounds.get(key); // existing.validate(GraphicsEnvironment.getLocalGraphicsEnvironment() // .getDefaultScreenDevice().getDefaultConfiguration()); return existing; } /** * Simple constructor. */ public ButtonBackgroundDelegate() { super(); } /** * Updates background of the specified button. * * @param g * Graphic context. * @param button * Button to update. */ public void updateBackground(Graphics g, AbstractButton button) { // failsafe for LAF change if (!SubstanceLookAndFeel.isCurrentLookAndFeel()) return; if (SubstanceCoreUtilities.isButtonNeverPainted(button)) return; int width = button.getWidth(); int height = button.getHeight(); int y = 0; if (SubstanceCoreUtilities.isScrollButton(button) || SubstanceCoreUtilities.isSpinnerButton(button)) { Sideable sideable = (Sideable) button; PairwiseButtonBackgroundDelegate.updatePairwiseBackground(g, button, width, height, sideable.getSide(), false); return; } SubstanceGradientPainter painter = SubstanceCoreUtilities .getGradientPainter(button); SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(button); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(button); BufferedImage bgImage = getFullAlphaBackground(button, button .getModel(), shaper, painter, borderPainter, width, height); ComponentState state = ComponentState.getState(button); // Two special cases here: // 1. Button has flat appearance. // 2. Button is disabled. // For both cases, we need to set custom translucency. boolean isFlat = SubstanceCoreUtilities.hasFlatAppearance(button); boolean isSpecial = isFlat || !state.isKindActive(FadeKind.ENABLE); float extraAlpha = 1.0f; if (isSpecial) { if (isFlat) { // Special handling of flat buttons if (FadeTracker.getInstance().isTracked(button, FadeKind.ROLLOVER) && !state.isKindActive(FadeKind.SELECTION) && state.isKindActive(FadeKind.ENABLE)) { extraAlpha = FadeTracker.getInstance().getFade(button, FadeKind.ROLLOVER); } else { if (state == ComponentState.DEFAULT) { // flat button in default state and not // participating in rollover animation extraAlpha = 0.0f; } } if (state == ComponentState.DISABLED_UNSELECTED) extraAlpha = 0.0f; } else { if (!state.isKindActive(FadeKind.ENABLE)) { extraAlpha = SubstanceColorSchemeUtilities.getAlpha(button, state); } } } if (extraAlpha > 0.0f) { Graphics2D graphics = (Graphics2D) g.create(); graphics.setComposite(TransitionLayout.getAlphaComposite(button, extraAlpha, g)); graphics.drawImage(bgImage, 0, y, null); graphics.dispose(); } } /** * Checks whether the specified button has round corners. * * @param button * Button to check. * @return true if the specified button has round corners, * false otherwise. */ public static boolean isRoundButton(AbstractButton button) { return (!SubstanceCoreUtilities.isComboBoxButton(button)) && (!SubstanceCoreUtilities.isScrollButton(button)) && SubstanceCoreUtilities.hasText(button); } /** * Returns true if the specified x,y location is * contained within the look and feel's defined shape of the specified * component. x and y are defined to be relative * to the coordinate system of the specified component. * * @param button * the component where the x,y location is being queried; * @param x * the x coordinate of the point * @param y * the y coordinate of the point * @return true if the specified x,y location is * contained within the look and feel's defined shape of the * specified component, false otherwise. */ public static boolean contains(AbstractButton button, int x, int y) { // failsafe for LAF change if (!SubstanceLookAndFeel.isCurrentLookAndFeel()) { return false; } SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(button); if (shaper == null) return false; Shape contour = shaper.getButtonOutline(button, null, button.getWidth(), button.getHeight(), false); return contour.contains(x, y); } /** * Returns the memory usage string. * * @return Memory usage string. */ static String getMemoryUsage() { StringBuffer sb = new StringBuffer(); sb.append("SubstanceBackgroundDelegate: \n"); sb.append("\t" + regularBackgrounds.size() + " regular"); // + pairwiseBackgrounds.size() + " pairwise"); return sb.toString(); } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceImageCreator.java0000644000175000017500000022675311247126200027125 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.*; import java.awt.MultipleGradientPaint.CycleMethod; import java.awt.geom.*; import java.awt.image.*; import javax.swing.*; import javax.swing.text.JTextComponent; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.ComponentState.ColorSchemeKind; import org.jvnet.substance.api.SubstanceConstants.Side; import org.jvnet.substance.colorscheme.ShiftColorScheme; import org.jvnet.substance.painter.border.FlatBorderPainter; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.gradient.SimplisticGradientPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; import org.jvnet.substance.utils.filters.*; import org.jvnet.substance.watermark.SubstanceWatermark; /** * Provides utility functions for creating various images for Substance * look and feel. This class is for internal use only. * * @author Kirill Grouchnikov */ public final class SubstanceImageCreator { /** * Custom gradient painter for filling the checkmarks of checkboxes and * radio buttons. * * @author Kirill Grouchnikov */ public static class SimplisticSoftBorderReverseGradientPainter extends SimplisticGradientPainter { /** * Singleton instance. */ public static final SubstanceGradientPainter INSTANCE = new SimplisticSoftBorderReverseGradientPainter(); /** * Private constructor. */ private SimplisticSoftBorderReverseGradientPainter() { } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.SubstanceGradientPainter#getDisplayName() */ @Override public String getDisplayName() { return "Simplistic Soft Border Reverse"; } @Override public Color getTopFillColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return super .getBottomFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } @Override public Color getBottomFillColor( SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return super .getTopFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } } /** * Paints border instance of specified dimensions and status. * * @param c * Component. * @param graphics * Graphics context. * @param x * Component left X (in graphics context). * @param y * Component top Y (in graphics context). * @param width * Border width. * @param height * Border height. * @param radius * Border radius. * @param borderScheme1 * First border color scheme. * @param borderScheme2 * Second border color scheme. * @param cyclePos * Cycle position for interpolating the border color schemes. */ public static void paintBorder(Component c, Graphics2D graphics, int x, int y, int width, int height, float radius, SubstanceColorScheme borderScheme1, SubstanceColorScheme borderScheme2, float cyclePos) { SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(c); graphics.translate(x, y); int componentFontSize = SubstanceSizeUtils.getComponentFontSize(c); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(componentFontSize) / 2.0); Shape contour = SubstanceOutlineUtilities.getBaseOutline(width, height, radius, null, borderDelta); int borderThickness = (int) SubstanceSizeUtils .getBorderStrokeWidth(componentFontSize); GeneralPath contourInner = (c instanceof JTextComponent) ? null : SubstanceOutlineUtilities.getBaseOutline(width, height, radius - borderThickness, null, borderThickness + borderDelta); borderPainter.paintBorder(graphics, c, width, height, contour, contourInner, borderScheme1, borderScheme2, cyclePos, borderScheme1 != borderScheme2); graphics.translate(-x, -y); } /** * Retrieves check mark image. * * @param button * Button for the check mark. * @param dimension * Check mark dimension. * @param isEnabled * Enabled status. * @param scheme * Color scheme for the check mark. * @param checkMarkVisibility * Checkmark visibility in 0.0-1.0 range. * @return Check mark image. */ private static BufferedImage getCheckMark(AbstractButton button, int dimension, boolean isEnabled, SubstanceColorScheme scheme, float checkMarkVisibility) { BufferedImage result = SubstanceCoreUtilities.getBlankImage(dimension, dimension); // get graphics and set hints Graphics2D graphics = (Graphics2D) result.getGraphics(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // create curved checkbox path GeneralPath path = new GeneralPath(); path.moveTo(0.25f * dimension, 0.5f * dimension); path.quadTo(0.37f * dimension, 0.6f * dimension, 0.47f * dimension, 0.8f * dimension); path.quadTo(0.55f * dimension, 0.5f * dimension, 0.85f * dimension, 0f); // compute the x-based clip for the visibility float xClipStart = 0.15f * dimension; float xClipEnd = 0.95f * dimension; float xClipRealEnd = xClipStart + (xClipEnd - xClipStart) * checkMarkVisibility; graphics.setClip(0, 0, (int) Math.ceil(xClipRealEnd), dimension); graphics.setColor(SubstanceColorUtilities.getMarkColor(scheme, isEnabled)); Stroke stroke = new BasicStroke((float) 0.15 * dimension, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); graphics.setStroke(stroke); graphics.draw(path); return result; } /** * Returns arrow icon for the specified parameters. * * @param fontSize * Font size. * @param direction * Arrow direction. * @param colorScheme * Arrow icon color scheme. * @return Arrow icon. */ public static Icon getArrowIcon(int fontSize, int direction, SubstanceColorScheme colorScheme) { float width = SubstanceSizeUtils.getArrowIconWidth(fontSize); float height = SubstanceSizeUtils.getArrowIconHeight(fontSize); if (direction == SwingConstants.CENTER) height *= 2; float strokeWidth = SubstanceSizeUtils.getArrowStrokeWidth(fontSize); return new ImageIcon(getArrow(width, height, strokeWidth, direction, colorScheme)); } /** * Retrieves arrow icon. * * @param width * Arrow width. * @param height * Arrow height. * @param strokeWidth * Stroke width. * @param direction * Arrow direction. * @param scheme * Color scheme for the arrow. * @return Arrow image. * @see SwingConstants#NORTH * @see SwingConstants#WEST * @see SwingConstants#SOUTH * @see SwingConstants#EAST */ public static Icon getArrowIcon(float width, float height, float strokeWidth, int direction, SubstanceColorScheme scheme) { return new ImageIcon(getArrow(width, height, strokeWidth, direction, scheme)); } /** * Retrieves arrow image. * * @param width * Arrow width. * @param height * Arrow height. * @param strokeWidth * Stroke width. * @param direction * Arrow direction. * @param scheme * Color scheme for the arrow. * @return Arrow image. * @see SwingConstants#NORTH * @see SwingConstants#WEST * @see SwingConstants#SOUTH * @see SwingConstants#EAST * @see SwingConstants#CENTER */ public static BufferedImage getArrow(float width, float height, float strokeWidth, int direction, SubstanceColorScheme scheme) { BufferedImage arrowImage = SubstanceCoreUtilities.getBlankImage( (int) width, (int) height); // System.out.println(width + ":" + height + ":" + strokeWidth); // get graphics and set hints Graphics2D graphics = (Graphics2D) arrowImage.getGraphics(); // graphics.setColor(Color.red); // graphics.fillRect(0, 0, width, height); graphics.translate(1, 1); width -= 2; height -= 2; graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Color arrowColor = SubstanceColorUtilities.getMarkColor(scheme, true); graphics.setColor(arrowColor); int cap = (width < 15) ? BasicStroke.CAP_BUTT : BasicStroke.CAP_ROUND; Stroke stroke = new BasicStroke(strokeWidth, cap, BasicStroke.JOIN_MITER); graphics.setStroke(stroke); int cushion = (int) strokeWidth / 2; if (direction == SwingConstants.CENTER) { BufferedImage top = getArrow(width, height / 2, strokeWidth, SwingConstants.NORTH, scheme); BufferedImage bottom = getArrow(width, height / 2, strokeWidth, SwingConstants.SOUTH, scheme); graphics.drawImage(top, 0, 1, null); graphics.drawImage(bottom, 0, (int) height / 2 - 1, null); return arrowImage; } else { GeneralPath gp = new GeneralPath(); gp.moveTo(cushion, strokeWidth); gp.lineTo((float) 0.5 * (width - 1), height - 1 - cushion); gp.lineTo(width - 1 - cushion, strokeWidth); graphics.draw(gp); // graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // RenderingHints.VALUE_ANTIALIAS_OFF); // graphics.setStroke(new BasicStroke(1.0f, cap, // BasicStroke.JOIN_MITER)); // graphics.setColor(Color.red); // graphics.drawRect(0, 0, (int)width - 1, (int)height - 1); int quadrantCounterClockwise = 0; switch (direction) { case SwingConstants.NORTH: quadrantCounterClockwise = 2; break; case SwingConstants.WEST: quadrantCounterClockwise = 1; break; case SwingConstants.SOUTH: quadrantCounterClockwise = 0; break; case SwingConstants.EAST: quadrantCounterClockwise = 3; break; } BufferedImage rotatedImage = SubstanceImageCreator.getRotated( arrowImage, quadrantCounterClockwise); return rotatedImage; } } /** * Returns double arrow icon for the specified parameters. * * @param fontSize * Font size. * @param deltaWidth * Arrow width delta. * @param deltaHeight * Arrow height delta. * @param deltaStrokeWidth * Arrow stroke width delta. * @param direction * Arrow direction. * @param colorScheme * Color scheme for the arrow. * @return Double arrow icon. */ public static Icon getDoubleArrowIconDelta(int fontSize, float deltaWidth, float deltaHeight, float deltaStrokeWidth, int direction, SubstanceColorScheme colorScheme) { float arrowWidth = SubstanceSizeUtils.getArrowIconWidth(fontSize) + deltaWidth; float arrowHeight = SubstanceSizeUtils.getArrowIconHeight(fontSize) + deltaHeight; float arrowStrokeWidth = SubstanceSizeUtils .getDoubleArrowStrokeWidth(fontSize) + deltaStrokeWidth; return getDoubleArrowIcon(fontSize, arrowWidth, arrowHeight, arrowStrokeWidth, direction, colorScheme); } /** * Retrieves arrow icon. * * @param width * Arrow width. * @param height * Arrow height. * @param strokeWidth * Stroke width. * @param direction * Arrow direction. * @param colorScheme * Color scheme for the arrow. * @return Arrow image. * @see SwingConstants#NORTH * @see SwingConstants#WEST * @see SwingConstants#SOUTH * @see SwingConstants#EAST */ public static Icon getDoubleArrowIcon(int fontSize, float width, float height, float strokeWidth, int direction, SubstanceColorScheme colorScheme) { int delta = 3 + 2 * SubstanceSizeUtils.getExtraPadding(fontSize) / 3; BufferedImage downArrowImage = SubstanceCoreUtilities.getBlankImage( (int) width, (int) height); BufferedImage singleArrow = getArrow(width, Math.max(1, height - delta), strokeWidth, SwingConstants.SOUTH, colorScheme); // get graphics and set hints Graphics2D graphics = (Graphics2D) downArrowImage.getGraphics(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics.drawImage(singleArrow, 0, 0, null); graphics.drawImage(singleArrow, 0, delta, null); int quadrantCounterClockwise = 0; switch (direction) { case SwingConstants.NORTH: quadrantCounterClockwise = 2; break; case SwingConstants.WEST: quadrantCounterClockwise = 1; break; case SwingConstants.SOUTH: quadrantCounterClockwise = 0; break; case SwingConstants.EAST: quadrantCounterClockwise = 3; break; } BufferedImage arrowImage = SubstanceImageCreator.getRotated( downArrowImage, quadrantCounterClockwise); return new ImageIcon(arrowImage); } /** * Returns rotated image. * * @param bi * Image to rotate. * @param quadrantClockwise * Amount of quadrants to rotate in clockwise directio. The * rotation angle is 90 times this value. * @return Rotated image. */ public static BufferedImage getRotated(BufferedImage bi, int quadrantClockwise) { quadrantClockwise = quadrantClockwise % 4; int width = bi.getWidth(); int height = bi.getHeight(); if ((quadrantClockwise == 1) || (quadrantClockwise == 3)) { width = bi.getHeight(); height = bi.getWidth(); } BufferedImage biRot = SubstanceCoreUtilities.getBlankImage(width, height); AffineTransform at = null; switch (quadrantClockwise) { case 1: at = AffineTransform.getTranslateInstance(width, 0); at.rotate(Math.PI / 2); break; case 2: at = AffineTransform.getTranslateInstance(width, height); at.rotate(Math.PI); break; case 3: at = AffineTransform.getTranslateInstance(0, height); at.rotate(-Math.PI / 2); } Graphics2D rotg = biRot.createGraphics(); if (at != null) rotg.setTransform(at); rotg.drawImage(bi, 0, 0, null); rotg.dispose(); return biRot; } /** * Returns rotated image. * * @param bi * Image to rotate. * @param quadrantClockwise * Amount of quadrants to rotate in clockwise directio. The * rotation angle is 90 times this value. * @return Rotated image. */ public static VolatileImage getRotated(final VolatileImage bi, int quadrantClockwise) { quadrantClockwise = quadrantClockwise % 4; int width = bi.getWidth(); int height = bi.getHeight(); if ((quadrantClockwise == 1) || (quadrantClockwise == 3)) { width = bi.getHeight(); height = bi.getWidth(); } VolatileImage biRot = SubstanceCoreUtilities.getBlankVolatileImage( width, height); AffineTransform at = null; switch (quadrantClockwise) { case 1: at = AffineTransform.getTranslateInstance(width, 0); at.rotate(Math.PI / 2); break; case 2: at = AffineTransform.getTranslateInstance(width, height); at.rotate(Math.PI); break; case 3: at = AffineTransform.getTranslateInstance(0, height); at.rotate(-Math.PI / 2); } Graphics2D rotg = biRot.createGraphics(); if (at != null) rotg.setTransform(at); rotg.drawImage(bi, 0, 0, null); rotg.dispose(); return biRot; } /** * Translated the specified icon to grey scale. * * @param icon * Icon. * @return Greyscale version of the specified icon. */ public static Icon toGreyscale(Icon icon) { if (icon == null) { return null; } int width = icon.getIconWidth(); int height = icon.getIconHeight(); BufferedImage result = SubstanceCoreUtilities.getBlankImage(width, height); icon.paintIcon(null, result.getGraphics(), 0, 0); return new ImageIcon(new GrayscaleFilter().filter(result, null)); } /** * Makes the specified icon transparent. * * @param c * Component. * @param icon * Icon. * @param alpha * The alpha of the resulting image. The closer this value is to * 0.0, the more transparent resulting image will be. * @return Transparent version of the specified icon. */ public static Icon makeTransparent(Component c, Icon icon, double alpha) { if (icon == null) { return null; } int width = icon.getIconWidth(); int height = icon.getIconHeight(); BufferedImage result = SubstanceCoreUtilities.getBlankImage(width, height); icon.paintIcon(c, result.getGraphics(), 0, 0); return new ImageIcon(new TranslucentFilter(alpha).filter(result, null)); } /** * Retrieves radio button of the specified size that matches the specified * parameters. * * @param component * Component. * @param dimension * Radio button dimension. * @param componentState * Component state. * @param prevState * Previous component state. * @param offsetX * Offset on X axis - should be positive in order to see the * entire radio button. * @param scheme1 * First color scheme. * @param scheme2 * Second color scheme. * @param interpolationCyclePos * Interpolation cycle. * @param checkMarkVisibility * Checkmark visibility in 0.0-1.0 range. * @return Radio button of the specified size that matches the specified * parameters. */ public static BufferedImage getRadioButton(JComponent component, SubstanceGradientPainter fillPainter, SubstanceBorderPainter borderPainter, int dimension, ComponentState componentState, ComponentState prevState, int offsetX, SubstanceColorScheme currFillColorScheme, SubstanceColorScheme prevFillColorScheme, SubstanceColorScheme currMarkColorScheme, SubstanceColorScheme prevMarkColorScheme, SubstanceColorScheme currBorderColorScheme, SubstanceColorScheme prevBorderColorScheme, float interpolationCyclePos, float checkMarkVisibility) { // ComponentState.ColorSchemeKind kind = componentState // .getColorSchemeKind(); float cyclePos = (currFillColorScheme != prevFillColorScheme) ? interpolationCyclePos : componentState.getCyclePosition(); float borderCyclePos = (currBorderColorScheme != prevBorderColorScheme) ? interpolationCyclePos : componentState.getCyclePosition(); float markCyclePos = (currMarkColorScheme != prevMarkColorScheme) ? interpolationCyclePos : componentState.getCyclePosition(); if (componentState.getColorSchemeKind() != ColorSchemeKind.CURRENT) { fillPainter = SimplisticSoftBorderReverseGradientPainter.INSTANCE; } float borderThickness = SubstanceSizeUtils .getBorderStrokeWidth(dimension); int delta = (int) (borderThickness - 0.6); // System.out.println(dimension + ":" + borderThickness + ":" + delta); // float fDelta = borderThickness / 2.0f; Shape contourBorder = new Ellipse2D.Float(delta, delta, dimension - 2 * delta - 1, dimension - 2 * delta - 1); BufferedImage offBackground = SubstanceCoreUtilities.getBlankImage( dimension + offsetX, dimension); Graphics2D graphics = (Graphics2D) offBackground.getGraphics(); float alpha = SubstanceColorSchemeUtilities.getAlpha(component, componentState); graphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, alpha)); graphics.translate(offsetX, 0); fillPainter.paintContourBackground(graphics, component, dimension, dimension, contourBorder, false, currFillColorScheme, prevFillColorScheme, cyclePos, true, currFillColorScheme != prevFillColorScheme); Shape contourInner = new Ellipse2D.Float(delta + borderThickness, delta + borderThickness, dimension - 2 * delta - 2 * borderThickness, dimension - 2 * delta - 2 * borderThickness); borderPainter.paintBorder(graphics, component, dimension, dimension, contourBorder, contourInner, currBorderColorScheme, prevBorderColorScheme, borderCyclePos, currBorderColorScheme != prevBorderColorScheme); graphics.setComposite(AlphaComposite.SrcOver); // graphics.translate(-offsetX, 0); float rc = dimension / 2.0f; float radius = dimension / 4.5f; // graphics.translate(offsetX, 0); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); if (componentState.isKindActive(FadeKind.SELECTION) || (checkMarkVisibility > 0.0)) { // mark Shape markOval = new Ellipse2D.Double(rc - radius, rc - radius, 2 * radius, 2 * radius); graphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, alpha * checkMarkVisibility)); drawRadioMark(graphics, SubstanceColorUtilities .getMarkColor(currMarkColorScheme, componentState .getColorSchemeKind() != ColorSchemeKind.DISABLED), markOval); graphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, alpha * checkMarkVisibility * markCyclePos)); drawRadioMark(graphics, SubstanceColorUtilities .getMarkColor(prevMarkColorScheme, componentState .getColorSchemeKind() != ColorSchemeKind.DISABLED), markOval); } else { // draw ghost mark holder graphics.setPaint(new GradientPaint(rc + radius, rc - radius, currFillColorScheme.getDarkColor(), rc - radius, rc + radius, currFillColorScheme.getLightColor())); Shape markOval = new Ellipse2D.Double(rc - radius, rc - radius, 2 * radius, 2 * radius); graphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, alpha * 0.3f)); graphics.fill(markOval); } graphics.translate(-offsetX, 0); return offBackground; } /** * Draws radio mark. * * @param graphics * Graphics context. * @param color * Radio mark color. * @param markOval * Radio mark shape. */ private static void drawRadioMark(Graphics2D graphics, Color color, Shape markOval) { graphics.setColor(color); graphics.fill(markOval); } /** * Retrieves check box of the specified size that matches the specified * component state. * * @param button * Button for the check mark. * @param dimension * Check box size. * @param componentState * Component state. * @param prevState * Previous component state. * @param colorScheme1 * First color scheme. * @param colorScheme2 * Second color scheme. * @param interpolationCyclePos * Interpolation cycle in 0.0-1.0 range. * @param checkMarkVisibility * Checkmark visibility in 0.0-1.0 range. * @param isCheckMarkFadingOut * if true, the value of * interpolationCyclePos10 is used as the alpha * channel. * @return Check box of the specified size that matches the specified * component state. */ public static BufferedImage getCheckBox(AbstractButton button, SubstanceGradientPainter fillPainter, SubstanceBorderPainter borderPainter, int dimension, ComponentState componentState, ComponentState prevState, SubstanceColorScheme currFillColorScheme, SubstanceColorScheme prevFillColorScheme, SubstanceColorScheme currMarkColorScheme, SubstanceColorScheme prevMarkColorScheme, SubstanceColorScheme currBorderColorScheme, SubstanceColorScheme prevBorderColorScheme, float interpolationCyclePos, float checkMarkVisibility, boolean isCheckMarkFadingOut) { // int checkMarkSize = SubstanceSizeUtils // .getCheckBoxMarkSize(SubstanceSizeUtils // .getComponentFontSize(button)); int offset = SubstanceSizeUtils.getAdjustedSize(SubstanceSizeUtils .getComponentFontSize(button), 3, 9, 1, false); int delta = offset; float cornerRadius = SubstanceSizeUtils .getClassicButtonCornerRadius(SubstanceSizeUtils .getComponentFontSize(button)); if (dimension <= 10) { offset = 2; cornerRadius = 2; } float cyclePos = (currFillColorScheme != prevFillColorScheme) ? interpolationCyclePos : componentState.getCyclePosition(); float borderCyclePos = (currBorderColorScheme != prevBorderColorScheme) ? interpolationCyclePos : componentState.getCyclePosition(); float markCyclePos = (currMarkColorScheme != prevMarkColorScheme) ? interpolationCyclePos : componentState.getCyclePosition(); int contourDim = dimension - delta; int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(button)) / 2.0); GeneralPath contour = SubstanceOutlineUtilities.getBaseOutline( contourDim, contourDim, cornerRadius, null, borderDelta); if (componentState.getColorSchemeKind() != ColorSchemeKind.CURRENT) { fillPainter = SimplisticSoftBorderReverseGradientPainter.INSTANCE; } BufferedImage offBackground = SubstanceCoreUtilities.getBlankImage( dimension, dimension); Graphics2D graphics = (Graphics2D) offBackground.getGraphics(); float alpha = SubstanceColorSchemeUtilities.getAlpha(button, componentState); graphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, alpha)); graphics.translate(delta - 1, delta - 1); fillPainter.paintContourBackground(graphics, button, contourDim, contourDim, contour, false, currFillColorScheme, prevFillColorScheme, cyclePos, true, currFillColorScheme != prevFillColorScheme); // graphics.drawImage(background, 0, 0, null); int borderThickness = (int) SubstanceSizeUtils .getBorderStrokeWidth(dimension); GeneralPath contourInner = SubstanceOutlineUtilities.getBaseOutline( contourDim, contourDim, cornerRadius - borderThickness, null, borderThickness + borderDelta); borderPainter.paintBorder(graphics, button, contourDim, contourDim, contour, contourInner, currBorderColorScheme, prevBorderColorScheme, borderCyclePos, currBorderColorScheme != prevBorderColorScheme); graphics.translate(-delta, 1 - delta); if (componentState.isKindActive(FadeKind.SELECTION) || (checkMarkVisibility > 0.0)) { if (isCheckMarkFadingOut) { graphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, alpha * checkMarkVisibility)); checkMarkVisibility = 1.0f; } BufferedImage checkMark1 = SubstanceImageCreator.getCheckMark( button, dimension - 2 * offset / 3, componentState .isKindActive(FadeKind.ENABLE), currMarkColorScheme, checkMarkVisibility); graphics.drawImage(checkMark1, 1 + 2 * offset / 3, (dimension < 14) ? 0 : -1, null); BufferedImage checkMark2 = SubstanceImageCreator.getCheckMark( button, dimension - 2 * offset / 3, componentState .isKindActive(FadeKind.ENABLE), prevMarkColorScheme, checkMarkVisibility); graphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, alpha * markCyclePos)); graphics.drawImage(checkMark2, 1 + 2 * offset / 3, (dimension < 14) ? 0 : -1, null); } return offBackground; } /** * Retrieves composite background for the specified parameters. The * composite background consists of three layers: *
    *
  1. Layer that matches the increased state. *
  2. Layer that matches the decreased state. *
  3. Regular layer with rounded background. *
* The layers are drawn in the following order: *
    *
  1. The left half of the first layer *
  2. The right half of the second layer *
  3. The third layer *
* Combined together, the layers create the image for scrollbar track with * continuation of the arrow increase and decrease buttons. * * @param component * Component. * @param width * Image width. * @param height * Image height. * @param cornerRadius * Corner radius. * @param decrButton * The decrease button. * @param incrButton * The increase button. * @param flipSides * If true, the drawn halves of the first and the * second layers above will be swapped. * @return Composite background for the specified parameters. */ public static BufferedImage getCompositeRoundedBackground( JComponent component, int width, int height, int cornerRadius, AbstractButton decrButton, AbstractButton incrButton, boolean flipSides) { int delta = 3; BufferedImage result = SubstanceCoreUtilities.getBlankImage(width, height); if (decrButton != null) { Graphics2D graphics = (Graphics2D) result.getGraphics(); if (!flipSides) { graphics.setClip(-delta, 0, width / 2, height); graphics.translate(-delta, 0); } else { graphics.setClip(width / 2, 0, width / 2 + 1, height); } PairwiseButtonBackgroundDelegate.updatePairwiseBackground(graphics, decrButton, width + 2 * delta, height, flipSides ? Side.RIGHT : Side.LEFT, true); graphics.dispose(); } if (incrButton != null) { Graphics2D graphics = (Graphics2D) result.getGraphics(); if (!flipSides) { graphics.setClip(width / 2, 0, width / 2 + 1, height); } else { graphics.setClip(-delta, 0, width / 2, height); graphics.translate(-delta, 0); } PairwiseButtonBackgroundDelegate.updatePairwiseBackground(graphics, incrButton, width + 2 * delta, height, flipSides ? Side.LEFT : Side.RIGHT, true); graphics.dispose(); } return result; } /** * Overlays light-colored echo below the specified image. * * @param image * The input image. * @param echoAlpha * Alpha channel for the echo image. * @param offsetX * X offset of the echo. * @param offsetY * Y offset of the echo. * @return Image with overlayed echo. */ private static BufferedImage overlayEcho(BufferedImage image, float echoAlpha, int offsetX, int offsetY) { int width = image.getWidth(); int height = image.getHeight(); // blur the original image // ConvolveOp convolve = new ConvolveOp(new Kernel(3, 3, new float[] { // .4f, .4f, .4f, .4f, .0f, .4f, .4f, .4f, .4f }), // ConvolveOp.EDGE_NO_OP, null); offsetX = offsetY = 0; BufferedImage negated = getNegated(image); BufferedImage result = SubstanceCoreUtilities.getBlankImage(width, height); Graphics2D graphics = (Graphics2D) result.getGraphics().create(); graphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.2f * echoAlpha * echoAlpha * echoAlpha)); graphics.drawImage(negated, offsetX - 1, offsetY - 1, null); graphics.drawImage(negated, offsetX + 1, offsetY - 1, null); graphics.drawImage(negated, offsetX - 1, offsetY + 1, null); graphics.drawImage(negated, offsetX + 1, offsetY + 1, null); graphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.7f * echoAlpha * echoAlpha * echoAlpha)); graphics.drawImage(negated, offsetX, offsetY - 1, null); graphics.drawImage(negated, offsetX, offsetY + 1, null); graphics.drawImage(negated, offsetX - 1, offsetY, null); graphics.drawImage(negated, offsetX + 1, offsetY, null); graphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 1.0f)); graphics.drawImage(image, 0, 0, null); graphics.dispose(); return result; } /** * Returns minimize icon. * * @param scheme * Color scheme for the icon. * @return Minimize icon. */ public static Icon getMinimizeIcon(SubstanceColorScheme scheme, SubstanceColorScheme backgroundScheme) { int iSize = SubstanceSizeUtils.getTitlePaneIconSize(); return getMinimizeIcon(iSize, scheme, backgroundScheme); } /** * Returns minimize icon. * * @param iSize * Icon dimension. * @param scheme * Color scheme for the icon. * @return Minimize icon. */ public static Icon getMinimizeIcon(int iSize, SubstanceColorScheme scheme, SubstanceColorScheme backgroundScheme) { BufferedImage image = SubstanceCoreUtilities .getBlankImage(iSize, iSize); Graphics2D graphics = (Graphics2D) image.getGraphics(); int start = (iSize / 4) - 2; int end = (3 * iSize / 4);// - 1; int size = end - start - 3; Color color = SubstanceColorUtilities.getMarkColor(scheme, true); graphics.setColor(color); graphics.fillRect(start + 2, end - 2, size, 3); int fgStrength = SubstanceColorUtilities.getColorBrightness(color .getRGB()); int fgNegativeStrength = SubstanceColorUtilities .getColorBrightness(SubstanceColorUtilities .getNegativeColor(color.getRGB())); int bgStrength = SubstanceColorUtilities .getColorBrightness(backgroundScheme.getLightColor().getRGB()); boolean noEcho = (fgStrength > fgNegativeStrength) && (fgStrength < bgStrength); return new ImageIcon(SubstanceImageCreator.overlayEcho(image, noEcho ? 0 : SubstanceColorUtilities.getColorStrength(color), 1, 1)); } /** * Returns restore icon. * * @param scheme * Color scheme for the icon. * @return Restore icon. */ public static Icon getRestoreIcon(SubstanceColorScheme scheme, SubstanceColorScheme backgroundScheme) { int iSize = SubstanceSizeUtils.getTitlePaneIconSize(); BufferedImage image = SubstanceCoreUtilities .getBlankImage(iSize, iSize); Graphics2D graphics = (Graphics2D) image.getGraphics(); int start = (iSize / 4) - 2; int end = (3 * iSize / 4) - 1; int size = end - start - 3; Color color = SubstanceColorUtilities.getMarkColor(scheme, true); graphics.setColor(color); graphics.drawRect(start, end - size + 1, size, size); graphics.drawLine(start, end - size + 2, start + size, end - size + 2); graphics.fillRect(end - size, start + 1, size + 1, 2); graphics.drawLine(end, start + 1, end, start + size + 1); graphics.drawLine(start + size + 2, start + size + 1, end, start + size + 1); int fgStrength = SubstanceColorUtilities.getColorBrightness(color .getRGB()); int fgNegativeStrength = SubstanceColorUtilities .getColorBrightness(SubstanceColorUtilities .getNegativeColor(color.getRGB())); int bgStrength = SubstanceColorUtilities .getColorBrightness(backgroundScheme.getLightColor().getRGB()); boolean noEcho = (fgStrength > fgNegativeStrength) && (fgStrength < bgStrength); return new ImageIcon(SubstanceImageCreator.overlayEcho(image, noEcho ? 0 : SubstanceColorUtilities.getColorStrength(color), 1, 1)); } /** * Returns maximize icon. * * @param scheme * Color scheme for the icon. * @return Maximize icon. */ public static Icon getMaximizeIcon(SubstanceColorScheme scheme, SubstanceColorScheme backgroundScheme) { int iSize = SubstanceSizeUtils.getTitlePaneIconSize(); return getMaximizeIcon(iSize, scheme, backgroundScheme); } /** * Returns maximize icon. * * @param iSize * Icon dimension. * @param scheme * Color scheme for the icon. * @return Maximize icon. */ public static Icon getMaximizeIcon(int iSize, SubstanceColorScheme scheme, SubstanceColorScheme backgroundScheme) { BufferedImage image = SubstanceCoreUtilities .getBlankImage(iSize, iSize); Graphics2D graphics = (Graphics2D) image.getGraphics(); int start = (iSize / 4) - 1; int end = iSize - start - 1;// (3 * iSize / 4); Color color = SubstanceColorUtilities.getMarkColor(scheme, true); graphics.setColor(color); graphics.drawRect(start, start, end - start, end - start); graphics.drawLine(start, start + 1, end, start + 1); int fgStrength = SubstanceColorUtilities.getColorBrightness(color .getRGB()); int fgNegativeStrength = SubstanceColorUtilities .getColorBrightness(SubstanceColorUtilities .getNegativeColor(color.getRGB())); int bgStrength = SubstanceColorUtilities .getColorBrightness(backgroundScheme.getLightColor().getRGB()); boolean noEcho = (fgStrength > fgNegativeStrength) && (fgStrength < bgStrength); return new ImageIcon(SubstanceImageCreator.overlayEcho(image, noEcho ? 0 : SubstanceColorUtilities.getColorStrength(color), 1, 1)); } /** * Returns close icon. * * @param scheme * Color scheme for the icon. * @return Close icon. */ public static Icon getCloseIcon(SubstanceColorScheme scheme, SubstanceColorScheme backgroundScheme) { return SubstanceImageCreator.getCloseIcon(SubstanceSizeUtils .getTitlePaneIconSize(), scheme, backgroundScheme); } /** * Returns close icon. * * @param iSize * Icon dimension. * @param colorScheme * Color scheme for the icon. * @return Close icon. */ public static Icon getCloseIcon(int iSize, SubstanceColorScheme colorScheme, SubstanceColorScheme backgroundScheme) { BufferedImage image = SubstanceCoreUtilities .getBlankImage(iSize, iSize); Graphics2D graphics = (Graphics2D) image.getGraphics(); if (iSize < 15) { graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } else { graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } int start = (iSize / 4);// - 1; int end = (3 * iSize / 4); // System.out.println(iSize + ":" + start + ":" + end); Stroke stroke = new BasicStroke(SubstanceSizeUtils .getFocusStrokeWidth(iSize), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); graphics.setStroke(stroke); Color color = SubstanceColorUtilities.getMarkColor(colorScheme, true); graphics.setColor(color); graphics.drawLine(start, start, end, end); graphics.drawLine(start, end, end, start); int fgStrength = SubstanceColorUtilities.getColorBrightness(color .getRGB()); int fgNegativeStrength = SubstanceColorUtilities .getColorBrightness(SubstanceColorUtilities .getNegativeColor(color.getRGB())); int bgStrength = SubstanceColorUtilities .getColorBrightness(backgroundScheme.getLightColor().getRGB()); boolean noEcho = (fgStrength > fgNegativeStrength) && (fgStrength < bgStrength); // System.out.println(SubstanceColorUtilities.getColorBrightness(color // .getRGB()) // + ":" // + SubstanceColorUtilities // .getColorBrightness(SubstanceColorUtilities // .getNegativeColor(color.getRGB())) // + ":" // + SubstanceColorUtilities.getColorBrightness(backgroundScheme // .getLightColor().getRGB())); return new ImageIcon(SubstanceImageCreator.overlayEcho(image, noEcho ? 0 : SubstanceColorUtilities.getColorStrength(color), 1, 1)); } /** * Paints rectangular gradient background. * * @param g * Graphic context. * @param startX * Background starting X coord. * @param startY * Background starting Y coord. * @param width * Background width. * @param height * Background height. * @param colorScheme * Color scheme for the background. * @param borderAlpha * Border alpha. * @param isVertical * if true, the gradient will be vertical, if * false, the gradient will be horizontal. */ public static void paintRectangularBackground(Component c, Graphics g, int startX, int startY, int width, int height, SubstanceColorScheme colorScheme, float borderAlpha, boolean isVertical) { Graphics2D graphics = (Graphics2D) g.create(); graphics.translate(startX, startY); if (!isVertical) { LinearGradientPaint paint = new LinearGradientPaint(0, 0, 0, height, new float[] { 0.0f, 0.4f, 0.5f, 1.0f }, new Color[] { colorScheme.getUltraLightColor(), colorScheme.getLightColor(), colorScheme.getMidColor(), colorScheme.getUltraLightColor() }, CycleMethod.REPEAT); graphics.setPaint(paint); graphics.fillRect(0, 0, width, height); } else { LinearGradientPaint paint = new LinearGradientPaint(0, 0, width, 0, new float[] { 0.0f, 0.4f, 0.5f, 1.0f }, new Color[] { colorScheme.getUltraLightColor(), colorScheme.getLightColor(), colorScheme.getMidColor(), colorScheme.getUltraLightColor() }, CycleMethod.REPEAT); graphics.setPaint(paint); graphics.fillRect(0, 0, width, height); } if (borderAlpha > 0.0f) { Graphics2D g2d = (Graphics2D) graphics.create(); g2d.setComposite(TransitionLayout.getAlphaComposite(null, borderAlpha, graphics)); paintSimpleBorderAliased(c, g2d, width, height, colorScheme, colorScheme, 0.0f); g2d.dispose(); } graphics.dispose(); } /** * Paints simple border. * * @param g2d * Graphics context. * @param width * Border width. * @param height * Border height. * @param colorScheme * First color scheme. * @param colorScheme2 * Second color scheme. * @param cyclePos * Interpolation cycle. */ public static void paintSimpleBorder(Component c, Graphics2D g2d, int width, int height, SubstanceColorScheme colorScheme, SubstanceColorScheme colorScheme2, float cyclePos) { int componentFontSize = SubstanceSizeUtils.getComponentFontSize(c); // int borderDelta = (int) Math.floor(SubstanceSizeUtils // .getBorderStrokeWidth(componentFontSize) / 2.0); // int borderDelta2 = (int) Math.floor(SubstanceSizeUtils // .getBorderStrokeWidth(componentFontSize)); float borderThickness = (float) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(componentFontSize)); g2d.setColor(SubstanceColorUtilities.getMidBorderColor(colorScheme, colorScheme2, cyclePos)); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); int joinKind = BasicStroke.JOIN_ROUND; int capKind = BasicStroke.CAP_BUTT; g2d.setStroke(new BasicStroke(borderThickness, capKind, joinKind)); g2d.draw(new Rectangle2D.Float((borderThickness - 1.0f) / 2.0f, (borderThickness - 1.0f) / 2.0f, width - 1 - (borderThickness - 1.5f), height - 1 - (borderThickness - 1.5f))); // g2d.drawRect(borderDelta, borderDelta, width - 1 - borderDelta2, // height // - 1 - borderDelta2); } public static void paintSimpleBorderAliased(Component c, Graphics2D g2d, int width, int height, SubstanceColorScheme colorScheme, SubstanceColorScheme colorScheme2, float cyclePos) { int componentFontSize = SubstanceSizeUtils.getComponentFontSize(c); // int borderDelta = (int) Math.floor(SubstanceSizeUtils // .getBorderStrokeWidth(componentFontSize) / 2.0); // int borderDelta2 = (int) Math.floor(SubstanceSizeUtils // .getBorderStrokeWidth(componentFontSize)); float borderThickness = (float) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(componentFontSize)); g2d.setColor(SubstanceColorUtilities.getMidBorderColor(colorScheme, colorScheme2, cyclePos)); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); int joinKind = BasicStroke.JOIN_MITER; int capKind = BasicStroke.CAP_SQUARE; g2d.setStroke(new BasicStroke(borderThickness, capKind, joinKind)); g2d.draw(new Rectangle2D.Float(borderThickness / 2.0f, borderThickness / 2.0f, width - borderThickness, height - borderThickness)); } /** * Paints rectangular gradient background with spots and optional replicated * stripe image. * * @param g * Graphics context. * @param startX * X start coordinate. * @param startY * Y start coordinate. * @param width * Background width. * @param height * Background height. * @param colorScheme * Color scheme for the background. * @param stripeImage * Stripe image to replicate. * @param stripeOffset * Offset of the first stripe replication. * @param borderAlpha * Border alpha. * @param isVertical * Indication of horizontal / vertical orientation. */ public static void paintRectangularStripedBackground(Component c, Graphics g, int startX, int startY, int width, int height, SubstanceColorScheme colorScheme, BufferedImage stripeImage, int stripeOffset, float borderAlpha, boolean isVertical) { Graphics2D graphics = (Graphics2D) g.create(startX, startY, width, height); if (!isVertical) { LinearGradientPaint paint = new LinearGradientPaint(0, 0, 0, height, new float[] { 0.0f, 0.2f, 0.5f, 0.8f, 1.0f }, new Color[] { colorScheme.getDarkColor(), colorScheme.getLightColor(), colorScheme.getMidColor(), colorScheme.getLightColor(), colorScheme.getDarkColor() }, CycleMethod.REPEAT); graphics.setPaint(paint); graphics.fillRect(0, 0, width, height); if (stripeImage != null) { int stripeSize = stripeImage.getHeight(); int stripeCount = width / stripeSize; stripeOffset = stripeOffset % (2 * stripeSize); for (int stripe = -2; stripe <= stripeCount; stripe += 2) { int stripePos = stripe * stripeSize + stripeOffset; graphics.drawImage(stripeImage, stripePos, 0, null); } } } else { LinearGradientPaint paint = new LinearGradientPaint(0, 0, width, 0, new float[] { 0.0f, 0.2f, 0.5f, 0.8f, 1.0f }, new Color[] { colorScheme.getDarkColor(), colorScheme.getLightColor(), colorScheme.getMidColor(), colorScheme.getLightColor(), colorScheme.getDarkColor() }, CycleMethod.REPEAT); graphics.setPaint(paint); graphics.fillRect(0, 0, width, height); if (stripeImage != null) { int stripeSize = stripeImage.getWidth(); int stripeCount = height / stripeSize; stripeOffset = stripeOffset % (2 * stripeSize); for (int stripe = -2; stripe <= stripeCount; stripe += 2) { int stripePos = stripe * stripeSize + stripeOffset; graphics.drawImage(stripeImage, 0, stripePos, null); } } } if (borderAlpha > 0.0f) { Graphics2D g2d = (Graphics2D) graphics.create(); g2d.setComposite(TransitionLayout.getAlphaComposite(null, borderAlpha, graphics)); paintSimpleBorderAliased(c, g2d, width, height, colorScheme, colorScheme, 0.0f); g2d.dispose(); } graphics.dispose(); } /** * Returns diagonal stripe image. * * @param baseSize * Stripe base in pixels. * @param color * Stripe color. * @return Diagonal stripe image. */ public static BufferedImage getStripe(int baseSize, Color color) { int width = (int) (1.8 * baseSize); int height = baseSize; BufferedImage result = SubstanceCoreUtilities.getBlankImage(width, height); Graphics2D graphics = (Graphics2D) result.getGraphics(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Polygon polygon = new Polygon(); polygon.addPoint(0, 0); polygon.addPoint(width - 1 - baseSize, 0); polygon.addPoint(width - 1, height - 1); polygon.addPoint(baseSize, height - 1); graphics.setColor(color); graphics.fillPolygon(polygon); graphics.drawPolygon(polygon); float[] BLUR = { 0.10f, 0.10f, 0.10f, 0.10f, 0.30f, 0.10f, 0.10f, 0.10f, 0.10f }; ConvolveOp vBlurOp = new ConvolveOp(new Kernel(3, 3, BLUR)); BufferedImage blurred = vBlurOp.filter(result, null); return blurred; } /** * Returns drag bumps image. * * @param c * Component. * @param colorScheme * Color scheme. * @param alwaysUseActive * Indicates whether the active color scheme should always be * used. * @param width * Drag bumps width. * @param height * Drag bumps height. * @param maxNumberOfStripes * The maximum number of bump stripes (rows or columns). * @return Drag bumps image. */ public static BufferedImage getDragImage(Component c, SubstanceColorScheme colorScheme, int width, int height, int maxNumberOfStripes) { BufferedImage result = SubstanceCoreUtilities.getBlankImage(width, height); Graphics2D graphics = (Graphics2D) result.getGraphics(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); boolean isDark = colorScheme.isDark(); Color back1 = isDark ? colorScheme.getLightColor() : SubstanceColorUtilities.getInterpolatedColor(colorScheme .getLightColor(), colorScheme.getDarkColor(), 0.8); Color back2 = isDark ? colorScheme.getExtraLightColor() : SubstanceColorUtilities.getInterpolatedColor(colorScheme .getMidColor(), colorScheme.getDarkColor(), 0.4); Color fore = isDark ? colorScheme.getDarkColor() : colorScheme .getUltraLightColor(); int componentFontSize = SubstanceSizeUtils.getComponentFontSize(c); int bumpDotDiameter = SubstanceSizeUtils .getDragBumpDiameter(componentFontSize); int bumpCellSize = (int) (1.5 * bumpDotDiameter + 1); int bumpRows = Math.max(1, height / bumpCellSize - 1); int bumpColumns = Math.max(1, (width - 2) / bumpCellSize); if (maxNumberOfStripes > 0) { if (height > width) bumpColumns = Math.min(bumpColumns, maxNumberOfStripes); else bumpRows = Math.min(bumpRows, maxNumberOfStripes); } int bumpRowOffset = (height - bumpCellSize * bumpRows) / 2; int bumpColOffset = 1 + (width - bumpCellSize * bumpColumns) / 2; for (int col = 0; col < bumpColumns; col++) { int cx = bumpColOffset + col * bumpCellSize; boolean isEvenCol = (col % 2 == 0); int offsetY = isEvenCol ? 0 : bumpDotDiameter; for (int row = 0; row < bumpRows; row++) { int cy = offsetY + bumpRowOffset + row * bumpCellSize; graphics.setColor(fore); graphics.fillOval(cx + 1, cy + 1, bumpDotDiameter, bumpDotDiameter); // graphics.setColor(back1); graphics .setPaint(new GradientPaint(cx, cy, back1, cx + bumpDotDiameter - 1, cy + bumpDotDiameter - 1, back2)); graphics.fillOval(cx, cy, bumpDotDiameter, bumpDotDiameter); } } return result; } /** * Paints the bump dots on the split pane dividers. * * @param g * Graphics context. * @param divider * Split pane divider. * @param x * X coordinate of the bump dots. * @param y * Y coordinate of the bump dots. * @param width * Width of the bump dots area. * @param height * Height of the bump dots area. * @param isHorizontal * Indicates whether the dots are horizontal. * @param componentState * Split pane divider state. * @param colorScheme1 * First color scheme. * @param colorScheme2 * Second color scheme. * @param interpolationCyclePos * Interpolation cycle. */ public static void paintSplitDividerBumpImage(Graphics g, SubstanceSplitPaneDivider divider, int x, int y, int width, int height, boolean isHorizontal, ComponentState componentState, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float interpolationCyclePos) { Graphics2D graphics = (Graphics2D) g.create(); graphics.translate(x, y); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int componentFontSize = SubstanceSizeUtils .getComponentFontSize(divider); int bumpDotDiameter = SubstanceSizeUtils .getBigDragBumpDiameter(componentFontSize); int bumpCellSize = (int) (1.5 * bumpDotDiameter + 1); int bumpRows = isHorizontal ? 1 : Math .max(1, height / bumpCellSize - 1); int bumpColumns = isHorizontal ? Math .max(1, (width - 2) / bumpCellSize) : 1; int bumpRowOffset = (height - bumpCellSize * bumpRows) / 2; int bumpColOffset = 1 + (width - bumpCellSize * bumpColumns) / 2; BufferedImage singleDot = SubstanceCoreUtilities.getBlankImage( bumpDotDiameter, bumpDotDiameter); Graphics2D dotGraphics = (Graphics2D) singleDot.getGraphics(); dotGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); dotGraphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 1.0f - interpolationCyclePos)); Color markColor = SubstanceColorUtilities.getMarkColor(colorScheme1, divider.isEnabled()); dotGraphics.setColor(markColor); dotGraphics.fillOval(0, 0, bumpDotDiameter, bumpDotDiameter); dotGraphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, interpolationCyclePos)); Color markColor2 = SubstanceColorUtilities.getMarkColor(colorScheme2, divider.isEnabled()); dotGraphics.setColor(markColor2); dotGraphics.fillOval(0, 0, bumpDotDiameter, bumpDotDiameter); dotGraphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.4f)); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(divider); borderPainter.paintBorder(dotGraphics, divider, width, height, new Ellipse2D.Float(0, 0, bumpDotDiameter - 1, bumpDotDiameter - 1), null, colorScheme1, colorScheme2, interpolationCyclePos, colorScheme1 != colorScheme2); graphics.setComposite(TransitionLayout.getAlphaComposite(divider, 0.8f, g)); for (int col = 0; col < bumpColumns; col++) { int cx = bumpColOffset + col * bumpCellSize; for (int row = 0; row < bumpRows; row++) { int cy = bumpRowOffset + row * bumpCellSize + (bumpCellSize - bumpDotDiameter) / 2; graphics.drawImage(singleDot, cx, cy, null); } } graphics.dispose(); } /** * Returns resize grip image. * * @param c * Component. * @param colorScheme * Color scheme. * @param dimension * Resize grip width. * @param isCrowded * Indicates whether the grips should be painted closely. * @return Resize grip image. */ public static BufferedImage getResizeGripImage(Component c, SubstanceColorScheme colorScheme, int dimension, boolean isCrowded) { BufferedImage result = SubstanceCoreUtilities.getBlankImage(dimension, dimension); Graphics2D graphics = (Graphics2D) result.getGraphics(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); boolean isDark = colorScheme.isDark(); // SubstanceCoreUtilities // .getActiveScheme(null) : SubstanceCoreUtilities // .getDefaultScheme(null); Color back1 = isDark ? colorScheme.getLightColor() : SubstanceColorUtilities.getInterpolatedColor(colorScheme .getLightColor(), colorScheme.getDarkColor(), 0.8); Color back2 = isDark ? colorScheme.getExtraLightColor() : SubstanceColorUtilities.getInterpolatedColor(colorScheme .getMidColor(), colorScheme.getDarkColor(), 0.4); Color fore = isDark ? colorScheme.getDarkColor() : colorScheme .getUltraLightColor(); int bumpDotDiameter = SubstanceSizeUtils .getDragBumpDiameter(SubstanceSizeUtils.getComponentFontSize(c)); int bumpCellSize = (int) (1.5 * bumpDotDiameter + 1); if (isCrowded) bumpCellSize--; int bumpLines = dimension / bumpCellSize; int bumpOffset = (dimension - bumpCellSize * bumpLines) / 2; for (int col = 0; col < bumpLines; col++) { int cx = bumpOffset + col * bumpCellSize; for (int row = (bumpLines - col - 1); row < bumpLines; row++) { int cy = bumpOffset + row * bumpCellSize; graphics.setColor(fore); graphics.fillOval(cx + 1, cy + 1, bumpDotDiameter, bumpDotDiameter); // graphics.setColor(back1); graphics .setPaint(new GradientPaint(cx, cy, back1, cx + bumpDotDiameter - 1, cy + bumpDotDiameter - 1, back2)); graphics.fillOval(cx, cy, bumpDotDiameter, bumpDotDiameter); } } return result; } /** * Retrieves tree icon. * * @param tree * Tree. * @param fillScheme * Icon fill color scheme. * @param borderScheme * Icon border color scheme. * @param isCollapsed * Collapsed state. * @return Tree icon. */ public static BufferedImage getTreeIcon(JTree tree, SubstanceColorScheme fillScheme, SubstanceColorScheme borderScheme, boolean isCollapsed) { int fontSize = SubstanceSizeUtils.getComponentFontSize(tree); int dim = SubstanceSizeUtils.getTreeIconSize(fontSize); BufferedImage result = SubstanceCoreUtilities.getBlankImage(dim + 2, dim); Graphics2D graphics = (Graphics2D) result.getGraphics(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); Graphics2D g2 = (Graphics2D) graphics.create(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); SimplisticGradientPainter gradPainter = new SimplisticSoftBorderReverseGradientPainter(); FlatBorderPainter fbp = new FlatBorderPainter(); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(fontSize) / 2.0); Shape contour = SubstanceOutlineUtilities.getBaseOutline(dim - 1, dim - 1, SubstanceSizeUtils.getClassicButtonCornerRadius(dim), null, borderDelta); g2.translate(0, 1); boolean isDark = fillScheme.isDark(); fillScheme = new ShiftColorScheme(fillScheme, fillScheme .getExtraLightColor(), 0.7); gradPainter.paintContourBackground(g2, tree, dim - 1, dim - 1, contour, false, fillScheme, fillScheme, 0, false, false); borderScheme = new ShiftColorScheme(borderScheme, isDark ? borderScheme .getUltraLightColor() : borderScheme.getLightColor(), 0.5); fbp.paintBorder(g2, tree, dim - 1, dim - 1, contour, null, borderScheme, borderScheme, 0, false); g2.translate(-1, -1); Color signColor = isDark ? borderScheme.getUltraLightColor().brighter() .brighter() : borderScheme.getUltraDarkColor(); if ((tree != null) && !tree.isEnabled()) signColor = borderScheme.getForegroundColor(); g2.setColor(signColor); int mid = dim / 2; int length = 5 * dim / 12; g2.drawLine(mid - length / 2, dim / 2, mid + length / 2, dim / 2); if (isCollapsed) { g2.drawLine(dim / 2, mid - length / 2, dim / 2, mid + length / 2); } g2.dispose(); return result; } /** * Retrieves a single crayon of the specified color and dimensions for the * crayon panel in color chooser. * * @param mainColor * Crayon main color. * @param width * Crayon width. * @param height * Crayon height. * @return Crayon image. */ public static BufferedImage getSingleCrayon(Color mainColor, int width, int height) { BufferedImage image = SubstanceCoreUtilities.getBlankImage(width, height); int baseTop = (int) (0.2 * height); Graphics2D graphics = (Graphics2D) image.getGraphics().create(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int r = mainColor.getRed(); int g = mainColor.getGreen(); int b = mainColor.getBlue(); // light coefficient double lc = 0.8; int lr = (int) (r + (255 - r) * lc); int lg = (int) (g + (255 - g) * lc); int lb = (int) (b + (255 - b) * lc); // dark coefficient double dc = 0.05; int dr = (int) ((1.0 - dc) * r); int dg = (int) ((1.0 - dc) * g); int db = (int) ((1.0 - dc) * b); Color lightColor = new Color(lr, lg, lb); Color darkColor = new Color(dr, dg, db); LinearGradientPaint paint = new LinearGradientPaint(0, 0, width, 0, new float[] { 0.0f, 0.3f, 0.5f, 0.9f, 1.0f }, new Color[] { lightColor, darkColor, darkColor, lightColor, lightColor }, CycleMethod.REPEAT); graphics.setPaint(paint); graphics.fillRect(0, baseTop, width, height); int dbwr = lr; int dbwg = lg; int dbwb = lb; int lbwr = 128 + dr / 4; int lbwg = 128 + dg / 4; int lbwb = 128 + db / 4; Color lightStripeColor = new Color(lbwr, lbwg, lbwb); Color darkStripeColor = new Color(dbwr, dbwg, dbwb); int stripeTop = (int) (0.35 * height); int stripeHeight = (int) (0.04 * height); LinearGradientPaint stripePaint = new LinearGradientPaint(0, 0, width, 0, new float[] { 0.0f, 0.3f, 0.5f, 0.9f, 1.0f }, new Color[] { lightStripeColor, darkStripeColor, darkStripeColor, lightStripeColor, lightStripeColor }, CycleMethod.REPEAT); graphics.setPaint(stripePaint); graphics.fillRect(0, stripeTop, width, stripeHeight); graphics.setColor(lightStripeColor); graphics.drawRect(0, stripeTop, width - 1, stripeHeight); // create cap path GeneralPath capPath = new GeneralPath(); capPath.moveTo(0.5f * width - 3, 4); capPath.quadTo(0.5f * width, 0, 0.5f * width + 3, 4); capPath.lineTo(width - 3, baseTop); capPath.lineTo(2, baseTop); capPath.lineTo(0.5f * width - 3, 4); graphics.setClip(capPath); graphics.setPaint(new GradientPaint(0, baseTop / 2, lightColor, (int) (0.6 * width), baseTop, mainColor)); graphics.fillRect(0, 0, width / 2, baseTop); graphics.setPaint(new GradientPaint(width, baseTop / 2, lightColor, (int) (0.4 * width), baseTop, mainColor)); graphics.fillRect(width / 2, 0, width / 2, baseTop); graphics.setStroke(new BasicStroke((float) 1.3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); graphics.setClip(null); graphics .setColor(new Color(64 + dr / 2, 64 + dg / 2, 64 + db / 2, 200)); graphics.drawRect(0, baseTop, width - 1, height - baseTop - 1); graphics.draw(capPath); graphics.dispose(); return image; } /** * Crayon colors. */ private final static int[] crayonColors = { 0x800000, // Cayenne 0x808000, // Asparagus 0x008000, // Clover 0x008080, // Teal 0x000080, // Midnight 0x800080, // Plum 0x7f7f7f, // Tin 0x808080, // Nickel 0x804000, // Mocha 0x408000, // Fern 0x008040, // Moss 0x004080, // Ocean 0x400080, // Eggplant 0x800040, // Maroon 0x666666, // Steel 0x999999, // Aluminium 0xff0000, // Maraschino 0xffff00, // Lemon 0x00ff00, // Spring 0x00ffff, // Turquoise 0x0000ff, // Blueberry 0xff00ff, // Magenta 0x4c4c4c, // Iron 0xb3b3b3, // Magnesium 0xff8000, // Tangerine 0x80ff00, // Lime 0x00ff80, // Sea Foam 0x0080ff, // Aqua 0x8000ff, // Grape 0xff0080, // Strawberry 0x333333, // Tungsten 0xcccccc, // Silver 0xff6666, // Salmon 0xffff66, // Banana 0x66ff66, // Flora 0x66ffff, // Ice 0x6666ff, // Orchid 0xff66ff, // Bubblegum 0x191919, // Lead 0xe6e6e6, // Mercury 0xffcc66, // Cantaloupe 0xccff66, // Honeydew 0x66ffcc, // Spindrift 0x66ccff, // Sky 0xcc66ff, // Lavender 0xff6fcf, // Carnation 0x000000, // Licorice 0xffffff, // Snow }; /** * Retrieves crayon X offset. * * @param i * Crayon index. * @return Crayon X offset. */ private static int crayonX(int i) { return (i % 8) * 22 + 4 + ((i / 8) % 2) * 11; } /** * Retrieves crayon Y offset. * * @param i * Crayon index. * @return Crayon Y offset. */ private static int crayonY(int i) { return (i / 8) * 20 + 23; } /** * Retrieves crayons image for the crayon panel of color chooser. * * @return Crayons image. */ public static Image getCrayonsImage() { int iw = 195; int ih = 208; Image image = SubstanceCoreUtilities.getBlankImage(iw, ih); Graphics2D graphics = (Graphics2D) image.getGraphics().create(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics.setColor(new Color(240, 240, 240)); graphics.fillRect(0, 0, iw, ih); for (int i = 0; i < SubstanceImageCreator.crayonColors.length; i++) { Color crayonColor = new Color( 0xff000000 | SubstanceImageCreator.crayonColors[i]); Image crayonImage = SubstanceImageCreator.getSingleCrayon( crayonColor, 22, 120); graphics.drawImage(crayonImage, SubstanceImageCreator.crayonX(i), SubstanceImageCreator.crayonY(i), null); } graphics.setColor(new Color(190, 190, 190)); graphics.drawRoundRect(0, 1, iw - 1, ih - 2, 4, 4); graphics.dispose(); return image; } /** * Returns small icon representation of the specified integer value. The * remainder of dividing the integer by 16 is translated to four circles * arranged in 2*2 grid. * * @param value * Integer value to represent. * @param colorScheme * Icon color scheme. * @return Icon representation of the specified integer value. */ public static Icon getHexaMarker(int value, SubstanceColorScheme colorScheme) { BufferedImage result = SubstanceCoreUtilities.getBlankImage(9, 9); value %= 16; Color offColor = null; Color onColor = null; if (colorScheme == null) { return new ImageIcon(result); } boolean isDark = colorScheme.isDark(); offColor = isDark ? colorScheme.getMidColor() : colorScheme .getMidColor().darker(); onColor = isDark ? SubstanceColorUtilities.getInterpolatedColor( colorScheme.getUltraLightColor(), Color.white, 0.2) : colorScheme.getUltraDarkColor().darker(); boolean bit1 = ((value & 0x1) != 0); boolean bit2 = ((value & 0x2) != 0); boolean bit3 = ((value & 0x4) != 0); boolean bit4 = ((value & 0x8) != 0); Graphics2D graphics = (Graphics2D) result.getGraphics().create(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics.setColor(bit1 ? onColor : offColor); graphics.fillOval(5, 5, 4, 4); graphics.setColor(bit2 ? onColor : offColor); graphics.fillOval(5, 0, 4, 4); graphics.setColor(bit3 ? onColor : offColor); graphics.fillOval(0, 5, 4, 4); graphics.setColor(bit4 ? onColor : offColor); graphics.fillOval(0, 0, 4, 4); graphics.dispose(); return new ImageIcon(result); } /** * Returns big icon representation of the specified integer value. The * remainder of dividing the integer by 16 is translated to four circles * arranged in 2*2 grid. * * @param value * Integer value to represent. * @param colorScheme * Icon color scheme. * @return Icon representation of the specified integer value. */ public static Image getBigHexaMarker(int value, SubstanceColorScheme colorScheme) { int iSize = SubstanceSizeUtils.getTitlePaneIconSize(); BufferedImage result = SubstanceCoreUtilities.getBlankImage(iSize, iSize); value %= 16; Color offColor = null; Color onColor = null; if (colorScheme == null) return result; boolean isDark = colorScheme.isDark(); offColor = isDark ? colorScheme.getMidColor() : colorScheme .getMidColor().darker(); onColor = isDark ? SubstanceColorUtilities.getInterpolatedColor( colorScheme.getUltraLightColor(), Color.white, 0.2) : colorScheme.getUltraDarkColor().darker(); boolean bit1 = ((value & 0x1) != 0); boolean bit2 = ((value & 0x2) != 0); boolean bit3 = ((value & 0x4) != 0); boolean bit4 = ((value & 0x8) != 0); Graphics2D graphics = (Graphics2D) result.getGraphics().create(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics.setColor(bit1 ? onColor : offColor); graphics.fillOval(9, 9, 6, 6); graphics.setColor(bit2 ? onColor : offColor); graphics.fillOval(9, 2, 6, 6); graphics.setColor(bit3 ? onColor : offColor); graphics.fillOval(2, 9, 6, 6); graphics.setColor(bit4 ? onColor : offColor); graphics.fillOval(2, 2, 6, 6); graphics.dispose(); return result; } /** * Returns search icon. * * @param dimension * Icon dimension. * @param colorScheme * Icon color scheme. * @param leftToRight * LTR indication of the resulting icon. * @return Search icon. */ public static Icon getSearchIcon(int dimension, SubstanceColorScheme colorScheme, boolean leftToRight) { BufferedImage result = SubstanceCoreUtilities.getBlankImage(dimension, dimension); Graphics2D graphics = (Graphics2D) result.getGraphics().create(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Color color = SubstanceColorUtilities.getMarkColor(colorScheme, true); graphics.setColor(color); graphics.setStroke(new BasicStroke(1.5f)); if (leftToRight) { int xc = (int) (0.6 * dimension); int yc = (int) (0.45 * dimension); int r = (int) (0.3 * dimension); graphics.drawOval(xc - r, yc - r, 2 * r, 2 * r); graphics.setStroke(new BasicStroke(3.0f)); GeneralPath handle = new GeneralPath(); handle.moveTo((float) (xc - r / Math.sqrt(2.0)), (float) (yc + r / Math.sqrt(2.0))); handle.lineTo(1.8f, dimension - 2.2f); graphics.draw(handle); } else { int xc = (int) (0.4 * dimension); int yc = (int) (0.45 * dimension); int r = (int) (0.3 * dimension); graphics.drawOval(xc - r, yc - r, 2 * r, 2 * r); graphics.setStroke(new BasicStroke(3.0f)); GeneralPath handle = new GeneralPath(); handle.moveTo((float) (xc + r / Math.sqrt(2.0)), (float) (yc + r / Math.sqrt(2.0))); handle.lineTo(dimension - 2.5f, dimension - 2.2f); graphics.draw(handle); } graphics.dispose(); return new ImageIcon(result); } /** * Returns an icon that matches the specified watermark. * * @param watermark * Watermark instance. * @return Icon that matches the specified watermark. */ public static Icon getWatermarkIcon(SubstanceWatermark watermark) { int iSize = SubstanceSizeUtils.getTitlePaneIconSize(); BufferedImage result = SubstanceCoreUtilities.getBlankImage(iSize, iSize); Graphics2D graphics = (Graphics2D) result.getGraphics().create(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); watermark.previewWatermark(graphics, 0, 0, iSize, iSize); graphics.dispose(); return new ImageIcon(result); } /** * Returns a lock icon that matches the specified scheme. * * @param scheme * Scheme instance. * @return Lock icon that matches the specified scheme. */ public static Icon getSmallLockIcon(SubstanceColorScheme scheme) { int extraPadding = SubstanceSizeUtils .getExtraPadding(SubstanceSizeUtils.getControlFontSize()); BufferedImage result = SubstanceCoreUtilities.getBlankImage( 6 + 2 * extraPadding, 8 + 2 * extraPadding); Color fore = scheme.getForegroundColor(); Color fill = new Color(208, 208, 48); Graphics2D graphics = (Graphics2D) result.getGraphics().create(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); graphics.setColor(fill); // lock fill graphics.fillRect(1, 2 + extraPadding, 4 + 2 * extraPadding, 4 + 2 * extraPadding); graphics.setColor(fore); // lock left side graphics.drawLine(0, 3 + extraPadding, 0, 7 + 2 * extraPadding); // lock right side graphics.drawLine(5 + 2 * extraPadding, 3 + extraPadding, 5 + 2 * extraPadding, 7 + 2 * extraPadding); // lock bottom side graphics.drawLine(0, 7 + 2 * extraPadding, 5 + 2 * extraPadding, 7 + 2 * extraPadding); // lock top side graphics.drawLine(1, 2 + extraPadding, 4 + 2 * extraPadding, 2 + extraPadding); // lock left handle graphics.drawLine(1 + extraPadding, 1, 1 + extraPadding, 2 + extraPadding); // lock right handle graphics.drawLine(4 + extraPadding, 1, 4 + extraPadding, 2 + extraPadding); // lock top handle graphics.drawLine(2 + extraPadding, 0, 3 + extraPadding, 0); // lock keyhole graphics.fillRect(2 + extraPadding, 4 + extraPadding, 2, 2 + extraPadding); graphics.dispose(); return new ImageIcon(result); } /** * Returns the negative of the specified image. * * @param bi * Image. * @return The negative of the specified image. */ public static BufferedImage getNegated(BufferedImage bi) { return new NegatedFilter().filter(bi, null); } /** * Creates a new version of the specified icon that is rendered in the * colors of the specified color scheme. * * @param comp * Component. * @param original * The original icon. * @param colorScheme * Color scheme. * @return Scheme-based version of the original icon. */ public static BufferedImage getColorSchemeImage(Component comp, Icon original, SubstanceColorScheme colorScheme, float originalBrightnessFactor) { int w = original.getIconWidth(); int h = original.getIconHeight(); BufferedImage origImage = SubstanceCoreUtilities.getBlankImage(w, h); original.paintIcon(comp, origImage.getGraphics(), 0, 0); return getColorSchemeImage(origImage, colorScheme, originalBrightnessFactor); } /** * Creates a new version of the specified image that is rendered in the * colors of the specified color scheme. * * @param original * The original image. * @param colorScheme * Color scheme. * @param toSaturate * Indicates whether the resulting image should be saturated. * @return Scheme-based version of the original icon. */ public static BufferedImage getColorSchemeImage(BufferedImage original, SubstanceColorScheme colorScheme, float originalBrightnessFactor) { return ColorSchemeFilter.getColorSchemeFilter(colorScheme, originalBrightnessFactor).filter(original, null); } } substance-5.3.orig/src/org/jvnet/substance/utils/PulseTracker.java0000644000175000017500000002672211136475562025330 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.Component; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.lang.ref.WeakReference; import java.util.WeakHashMap; import javax.swing.*; import javax.swing.JInternalFrame.JDesktopIcon; import org.jvnet.substance.SubstanceLookAndFeel; /** * Tracker for pulsating (default and focused) JButtons. This class * is for internal use only. * * @author Kirill Grouchnikov */ public class PulseTracker implements ActionListener { /** * Map (with weakly-referenced keys) of all trackers. For each default * button which has not been claimed by GC, we have a tracker (with * associated Timer). */ private static WeakHashMap trackers = new WeakHashMap(); /** * Map (with weakly-referenced keys) of cycle counts. For each default * button which is shown and is in window that owns focus, * this map contains the cycle count (for animation purposes). * On each event of the associated Timer (see * {@link #actionPerformed(ActionEvent)}), the counter is incremented by 1. * For buttons that are in windows that lose focus, the counter is reverted * back to 0 (animation stops). */ private static WeakHashMap cycles = new WeakHashMap(); /** * Waek reference to the associated button. */ private WeakReference buttonRef; /** * The associated timer. */ private Timer timer; /** * Simple constructor. * * @param jbutton */ private PulseTracker(JButton jbutton) { // Create weak reference. this.buttonRef = new WeakReference(jbutton); // Create coalesced timer. this.timer = new Timer(50, this); this.timer.setCoalesce(true); // Store event handler and initial cycle count. PulseTracker.trackers.put(jbutton, this); PulseTracker.cycles.put(jbutton, (long) 0); } /** * Recursively checks whether the specified component or one of its inner * components has focus. * * @param component * Component to check. * @return true if the specified component or one of its inner * components has focus, false otherwise. */ private static boolean isInFocusedWindow(Component component) { if (component == null) { return false; } // check if the component itself is focus owner if (component.isFocusOwner()) { return true; } // recursively find if has focus owner component if (component instanceof Container) { for (Component comp : ((Container) component).getComponents()) { if (isInFocusedWindow(comp)) { return true; } } } return false; } /** * Recursively checks whether the specified component has visible glass * pane. * * @param component * Component to check. * @return true if the specified component has visible glass * pane, false otherwise. */ private static boolean hasGlassPane(Component component) { if (component == null) { return false; } // check if the component has visible glass pane Component glassPane = null; if (component instanceof JDialog) { glassPane = ((JDialog) component).getGlassPane(); } if (component instanceof JFrame) { glassPane = ((JFrame) component).getGlassPane(); } if ((glassPane != null) && (glassPane.isVisible())) { return true; } return false; } /* * (non-Javadoc) * * @see * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent event) { // get the button and check if it wasn't GC'd JButton jButton = this.buttonRef.get(); if (jButton == null) { return; } if (PulseTracker.hasGlassPane(jButton.getTopLevelAncestor())) return; if (!isPulsating(jButton)) { // has since lost its default status PulseTracker tracker = trackers.get(jButton); tracker.stopTimer(); tracker.buttonRef.clear(); trackers.remove(jButton); cycles.remove(jButton); } else { if ((!PulseTracker.isInFocusedWindow(jButton.getTopLevelAncestor())) && (!isAttentionDrawingCloseButton(jButton))) { // no focus in button window - will restore original (not // animated) painting PulseTracker.update(jButton); } else { // check if it's enabled if (jButton.isEnabled()) { // increment cycle count for pulsating buttons. long oldCycle = cycles.get(jButton); if (oldCycle == 20) { oldCycle = isAttentionDrawingCloseButton(jButton) ? -80 : 0; } cycles.put(jButton, oldCycle + 1); } else { // revert to 0 if it's not enabled if (cycles.get(jButton) != 0) { cycles.put(jButton, (long) 0); } } } } // maybe LAF has changed if (SubstanceLookAndFeel.isCurrentLookAndFeel()) jButton.repaint(); } /** * Starts the associated timer. */ private void startTimer() { if (!this.timer.isRunning()) { this.timer.start(); } } /** * Stops the associated timer. */ private void stopTimer() { if (this.timer.isRunning()) { this.timer.stop(); } } /** * Returns the status of the associated timer. * * @return true is the associated timer is running, * false otherwise. */ private boolean isRunning() { return this.timer.isRunning(); } /** * Updates the state of the specified button which must be a default button * in some window. The button state is determined based on focus ownership. * * @param jButton * Button. */ public static void update(JButton jButton) { boolean hasFocus = PulseTracker.isInFocusedWindow(jButton .getTopLevelAncestor()); PulseTracker tracker = trackers.get(jButton); if (!hasFocus) { // remove if (tracker == null) { return; } if (cycles.get(jButton) == 0) { return; } cycles.put(jButton, (long) 0); // System.out.println("r::" + trackers.size()); } else { // add if (tracker != null) { tracker.startTimer(); return; } tracker = new PulseTracker(jButton); tracker.startTimer(); trackers.put(jButton, tracker); long initialCycle = isAttentionDrawingCloseButton(jButton) ? -80 : 0; cycles.put(jButton, initialCycle); // System.out.println("a::" + trackers.size()); } } /** * Retrieves the current cycle count for the specified button. * * @param jButton * Button. * @return Current cycle count for the specified button. */ public static long getCycles(JButton jButton) { Long cycleCount = cycles.get(jButton); if (cycleCount == null) { return 0; } long result = cycleCount.longValue(); if (result < 0) result = 0; return result; } /** * Retrieves the animation state for the specified button. * * @param jButton * Button. * @return true if the specified button is being animated, * false otherwise. */ public static boolean isAnimating(JButton jButton) { PulseTracker tracker = trackers.get(jButton); if (tracker == null) { return false; } return tracker.isRunning(); } /** * Returns memory usage. * * @return Memory usage string. */ static String getMemoryUsage() { StringBuffer sb = new StringBuffer(); sb.append("PulseTracker: \n"); sb.append("\t" + trackers.size() + " trackers, " + cycles.size() + " cycles"); return sb.toString(); } /** * Checks whether the specified button is attention-drawing * close button of some internal frame, root pane or desktop * icon. * * @param jButton * Button. * @return true if the specified button is close * button of some internal frame, root pane or desktop icon, * false otherwise. */ public static boolean isAttentionDrawingCloseButton(JButton jButton) { if (SubstanceCoreUtilities.isTitleCloseButton(jButton)) { // check if have windowModified property Component comp = jButton; boolean isWindowModified = false; while (comp != null) { if (comp instanceof JInternalFrame) { JInternalFrame jif = (JInternalFrame) comp; isWindowModified = Boolean.TRUE .equals(jif .getClientProperty(SubstanceLookAndFeel.WINDOW_MODIFIED)); break; } if (comp instanceof JRootPane) { JRootPane jrp = (JRootPane) comp; isWindowModified = Boolean.TRUE .equals(jrp .getClientProperty(SubstanceLookAndFeel.WINDOW_MODIFIED)); break; } if (comp instanceof JDesktopIcon) { JDesktopIcon jdi = (JDesktopIcon) comp; JInternalFrame jif = jdi.getInternalFrame(); isWindowModified = Boolean.TRUE .equals(jif .getClientProperty(SubstanceLookAndFeel.WINDOW_MODIFIED)); break; } comp = comp.getParent(); } if (isWindowModified) { return true; } } return false; } /** * Checks whether the specified button is pulsating. * * @param jButton * Button. * @return true if the specified button is pulsating, * false otherwise. */ public static boolean isPulsating(JButton jButton) { // default button pulsates. boolean isDefault = jButton.isDefaultButton(); if (isDefault) { return true; } // attention-drawing close button pulsates. return isAttentionDrawingCloseButton(jButton); } /** * Stops all timers. */ public static void stopAllTimers() { for (PulseTracker tracker : trackers.values()) { tracker.stopTimer(); } } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceInternalFrameTitlePane.java0000644000175000017500000006363411246440072031122 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.JInternalFrame.JDesktopIcon; import javax.swing.plaf.MenuBarUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicInternalFrameTitlePane; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.*; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.ShiftColorScheme; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.utils.icon.SubstanceIconFactory; import org.jvnet.substance.utils.icon.TransitionAwareIcon; /** * UI for internal frame title pane in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceInternalFrameTitlePane extends BasicInternalFrameTitlePane { /** * Listens on the changes to the internal frame title. */ protected PropertyChangeListener substancePropertyListener; /** * Listens to the changes to the * {@link SubstanceLookAndFeel#WINDOW_MODIFIED * } property on the internal * frame and its root pane. */ protected PropertyChangeListener substanceWinModifiedListener; /** * Client property to mark an internal frame as being iconified. */ protected static final String ICONIFYING = "substance.internal.internalTitleFramePane.iconifying"; /** * Client property to mark a title pane as uninstalled. */ protected static final String UNINSTALLED = "substance.internal.internalTitleFramePane.uninstalled"; // protected boolean wasClosable; /** * Simple constructor. * * @param f * Associated internal frame. */ public SubstanceInternalFrameTitlePane(JInternalFrame f) { super(f); this.setToolTipText(f.getTitle()); SubstanceLookAndFeel.setDecorationType(this, DecorationAreaType.SECONDARY_TITLE_PANE); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicInternalFrameTitlePane#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); if (SubstanceLookAndFeel.isCurrentLookAndFeel()) { this.setForeground(SubstanceColorUtilities .getForegroundColor(SubstanceCoreUtilities.getSkin( this.frame).getMainActiveColorScheme( DecorationAreaType.SECONDARY_TITLE_PANE))); } // this.wasClosable = this.frame.isClosable(); } // /* // * (non-Javadoc) // * // * @see // * javax.swing.plaf.basic.BasicInternalFrameTitlePane#uninstallDefaults() // */ // @Override // protected void uninstallDefaults() { // super.uninstallDefaults(); // if (this.wasClosable != this.frame.isClosable()) { // this.frame.setClosable(this.wasClosable); // } // } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicInternalFrameTitlePane#installListeners() */ @Override protected void installListeners() { super.installListeners(); this.substancePropertyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (JInternalFrame.TITLE_PROPERTY.equals(evt.getPropertyName())) { SubstanceInternalFrameTitlePane.this .setToolTipText((String) evt.getNewValue()); } if ("JInternalFrame.messageType".equals(evt.getPropertyName())) { updateOptionPaneState(); frame.repaint(); } } }; this.frame.addPropertyChangeListener(this.substancePropertyListener); // Property change listener for pulsating close button // when window has been marked as changed. this.substanceWinModifiedListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (SubstanceLookAndFeel.WINDOW_MODIFIED.equals(evt .getPropertyName())) { syncCloseButtonTooltip(); // if (Boolean.TRUE.equals(evt.getNewValue())) { // SubstanceInternalFrameTitlePane.this.closeButton // .setToolTipText(SubstanceLookAndFeel // .getLabelBundle().getString( // "SystemMenu.close") // + " [" // + SubstanceLookAndFeel // .getLabelBundle() // .getString( // "Tooltip.contentsNotSaved") // + "]"); // } else { // SubstanceInternalFrameTitlePane.this.closeButton // .setToolTipText(SubstanceLookAndFeel // .getLabelBundle().getString( // "SystemMenu.close")); // } } } }; // Wire it on the frame itself and its root pane. this.frame.addPropertyChangeListener(this.substanceWinModifiedListener); this.frame.getRootPane().addPropertyChangeListener( this.substanceWinModifiedListener); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicInternalFrameTitlePane#uninstallListeners() */ @Override public void uninstallListeners() { this.frame.removePropertyChangeListener(this.substancePropertyListener); this.substancePropertyListener = null; this.frame .removePropertyChangeListener(this.substanceWinModifiedListener); this.frame.getRootPane().removePropertyChangeListener( this.substanceWinModifiedListener); this.substanceWinModifiedListener = null; // if ((this.menuBar != null) && (this.menuBar.getMenuCount() > 0)) { // if (this.getParent() instanceof JInternalFrame) // this.menuBar.getUI().uninstallUI(this.menuBar); // SubstanceTitlePane.uninstallMenu(this.menuBar.getMenu(0)); // } super.uninstallListeners(); } /** * Uninstalls this title pane. */ public void uninstall() { if ((this.menuBar != null) && (this.menuBar.getMenuCount() > 0)) { MenuBarUI menuBarUI = this.menuBar.getUI(); if (menuBarUI instanceof SubstanceMenuBarUI) { SubstanceMenuBarUI ui = (SubstanceMenuBarUI) menuBarUI; if (ui.getMenuBar() == this.menuBar) menuBarUI.uninstallUI(this.menuBar); } SubstanceCoreUtilities.uninstallMenu(this.menuBar.getMenu(0)); this.remove(menuBar); // fix for issue 362 - remove the buttons so that we don't // have duplicate buttons on internal frames in reparented // desktop panes this.remove(maxButton); this.remove(closeButton); this.remove(iconButton); } this.uninstallListeners(); this.putClientProperty(UNINSTALLED, Boolean.TRUE); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicInternalFrameTitlePane#enableActions() */ @Override protected void enableActions() { super.enableActions(); if (!this.frame.isIcon()) { if (this.maxButton != null) this.maxButton.setEnabled(this.maximizeAction.isEnabled() || this.restoreAction.isEnabled()); if (this.iconButton != null) this.iconButton.setEnabled(this.iconifyAction.isEnabled()); } } // protected static Map imageCache = new // LinkedHashMap() { // @Override // protected boolean removeEldestEntry(Entry eldest) // { // return this.size() > 50; // } // }; // /* * (non-Javadoc) * * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) */ @Override public void paintComponent(Graphics g) { // if (this.isPalette) { // this.paintPalette(g); // return; // } Graphics2D graphics = (Graphics2D) g.create(); // Desktop icon is translucent. final float coef = (this.getParent() instanceof JDesktopIcon) ? 0.6f : 1.0f; graphics.setComposite(TransitionLayout.getAlphaComposite(this.frame, coef, g)); boolean leftToRight = this.frame.getComponentOrientation() .isLeftToRight(); int width = this.getWidth(); int height = this.getHeight() + 2; SubstanceColorScheme scheme = SubstanceCoreUtilities .getSkin(this.frame).getMainDefaultColorScheme( DecorationAreaType.SECONDARY_TITLE_PANE); JInternalFrame hostFrame = (JInternalFrame) SwingUtilities .getAncestorOfClass(JInternalFrame.class, this); JComponent hostForColorization = hostFrame; if (hostFrame == null) { // try desktop icon JDesktopIcon desktopIcon = (JDesktopIcon) SwingUtilities .getAncestorOfClass(JDesktopIcon.class, this); if (desktopIcon != null) hostFrame = desktopIcon.getInternalFrame(); hostForColorization = desktopIcon; } // if ((hostFrame != null) && SubstanceCoreUtilities.hasColorization( // this)) { Color backgr = hostFrame.getBackground(); if (!(backgr instanceof UIResource)) { double colorization = SubstanceCoreUtilities .getColorizationFactor(hostForColorization); scheme = ShiftColorScheme.getShiftedScheme(scheme, backgr, colorization, null, 0.0); } // } String theTitle = this.frame.getTitle(); // offset of border int xOffset = 0; int leftEnd; int rightEnd; if (leftToRight) { xOffset = 5; Icon icon = this.frame.getFrameIcon(); if (icon != null) { xOffset += icon.getIconWidth() + 5; } leftEnd = (this.menuBar == null) ? 0 : (this.menuBar.getWidth() + 5); xOffset += leftEnd; if (icon != null) leftEnd += (icon.getIconWidth() + 5); rightEnd = width - 5; // find the leftmost button for the right end AbstractButton leftmostButton = null; if (this.frame.isIconifiable()) { leftmostButton = this.iconButton; } else { if (this.frame.isMaximizable()) { leftmostButton = this.maxButton; } else { if (this.frame.isClosable()) { leftmostButton = this.closeButton; } } } if (leftmostButton != null) { Rectangle rect = leftmostButton.getBounds(); rightEnd = rect.getBounds().x - 5; } if (theTitle != null) { FontMetrics fm = this.frame.getFontMetrics(graphics.getFont()); int titleWidth = rightEnd - leftEnd; String clippedTitle = SubstanceCoreUtilities.clipString(fm, titleWidth, theTitle); // show tooltip with full title only if necessary if (theTitle.equals(clippedTitle)) this.setToolTipText(null); else this.setToolTipText(theTitle); theTitle = clippedTitle; } } else { xOffset = width - 5; Icon icon = this.frame.getFrameIcon(); if (icon != null) { xOffset -= (icon.getIconWidth() + 5); } rightEnd = (this.menuBar == null) ? xOffset : xOffset - this.menuBar.getWidth() - 5; // find the rightmost button for the left end AbstractButton rightmostButton = null; if (this.frame.isIconifiable()) { rightmostButton = this.iconButton; } else { if (this.frame.isMaximizable()) { rightmostButton = this.maxButton; } else { if (this.frame.isClosable()) { rightmostButton = this.closeButton; } } } leftEnd = 5; if (rightmostButton != null) { Rectangle rect = rightmostButton.getBounds(); leftEnd = rect.getBounds().x + 5; } if (theTitle != null) { FontMetrics fm = this.frame.getFontMetrics(graphics.getFont()); int titleWidth = rightEnd - leftEnd; String clippedTitle = SubstanceCoreUtilities.clipString(fm, titleWidth, theTitle); // show tooltip with full title only if necessary if (theTitle.equals(clippedTitle)) { this.setToolTipText(null); } else { this.setToolTipText(theTitle); } theTitle = clippedTitle; xOffset = rightEnd - fm.stringWidth(theTitle); } } BackgroundPaintingUtils.update(graphics, SubstanceInternalFrameTitlePane.this, false); // DecorationPainterUtils.paintDecorationBackground(graphics, // SubstanceInternalFrameTitlePane.this, false); // draw the title (if needed) if (theTitle != null) { JRootPane rootPane = this.getRootPane(); FontMetrics fm = rootPane.getFontMetrics(graphics.getFont()); int yOffset = ((height - fm.getHeight()) / 2) + fm.getAscent(); SubstanceTextUtilities.paintTextWithDropShadow(this, graphics, SubstanceColorUtilities.getForegroundColor(scheme), theTitle, width, height, xOffset, yOffset); } Icon icon = this.frame.getFrameIcon(); if (icon != null) { if (leftToRight) { int iconY = ((height / 2) - (icon.getIconHeight() / 2)); icon.paintIcon(this.frame, graphics, 5, iconY); } else { int iconY = ((height / 2) - (icon.getIconHeight() / 2)); icon.paintIcon(this.frame, graphics, width - 5 - icon.getIconWidth(), iconY); } } graphics.dispose(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicInternalFrameTitlePane#setButtonIcons() */ @Override protected void setButtonIcons() { super.setButtonIcons(); if (!SubstanceLookAndFeel.isCurrentLookAndFeel()) return; Icon restoreIcon = new TransitionAwareIcon(this.maxButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { return SubstanceIconFactory .getTitlePaneIcon( SubstanceIconFactory.IconKind.RESTORE, scheme, SubstanceCoreUtilities .getSkin( SubstanceInternalFrameTitlePane.this) .getBackgroundColorScheme( DecorationAreaType.SECONDARY_TITLE_PANE)); } }, "substance.internalFrame.restoreIcon"); Icon maximizeIcon = new TransitionAwareIcon(this.maxButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { return SubstanceIconFactory .getTitlePaneIcon( SubstanceIconFactory.IconKind.MAXIMIZE, scheme, SubstanceCoreUtilities .getSkin( SubstanceInternalFrameTitlePane.this) .getBackgroundColorScheme( DecorationAreaType.SECONDARY_TITLE_PANE)); } }, "substance.internalFrame.maxIcon"); Icon minimizeIcon = new TransitionAwareIcon(this.iconButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { return SubstanceIconFactory .getTitlePaneIcon( SubstanceIconFactory.IconKind.MINIMIZE, scheme, SubstanceCoreUtilities .getSkin( SubstanceInternalFrameTitlePane.this) .getBackgroundColorScheme( DecorationAreaType.SECONDARY_TITLE_PANE)); } }, "substance.internalFrame.minIcon"); Icon closeIcon = new TransitionAwareIcon(this.closeButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { return SubstanceIconFactory .getTitlePaneIcon( SubstanceIconFactory.IconKind.CLOSE, scheme, SubstanceCoreUtilities .getSkin( SubstanceInternalFrameTitlePane.this) .getBackgroundColorScheme( DecorationAreaType.SECONDARY_TITLE_PANE)); } }, "substance.internalFrame.closeIcon"); if (this.frame.isIcon()) { this.iconButton.setIcon(restoreIcon); this.iconButton.setToolTipText(SubstanceCoreUtilities .getResourceBundle(frame).getString("SystemMenu.restore")); this.maxButton.setIcon(maximizeIcon); this.maxButton.setToolTipText(SubstanceCoreUtilities .getResourceBundle(frame).getString("SystemMenu.maximize")); } else { this.iconButton.setIcon(minimizeIcon); this.iconButton.setToolTipText(SubstanceCoreUtilities .getResourceBundle(frame).getString("SystemMenu.iconify")); if (this.frame.isMaximum()) { this.maxButton.setIcon(restoreIcon); this.maxButton.setToolTipText(SubstanceCoreUtilities .getResourceBundle(frame).getString( "SystemMenu.restore")); } else { this.maxButton.setIcon(maximizeIcon); this.maxButton.setToolTipText(SubstanceCoreUtilities .getResourceBundle(frame).getString( "SystemMenu.maximize")); } } if (closeIcon != null) { this.closeButton.setIcon(closeIcon); // this.closeButton.setToolTipText(SubstanceLookAndFeel // .getLabelBundle().getString("SystemMenu.close")); syncCloseButtonTooltip(); } } /** * Click correction listener that resets models of minimize and restore * buttons on click (so that the rollover behaviour will be preserved * correctly). * * @author Kirill Grouchnikov. */ public static class ClickListener implements ActionListener { /* * (non-Javadoc) * * @see * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent * ) */ public void actionPerformed(ActionEvent e) { AbstractButton src = (AbstractButton) e.getSource(); ButtonModel model = src.getModel(); model.setArmed(false); model.setPressed(false); model.setRollover(false); model.setSelected(false); } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicInternalFrameTitlePane#createActions() */ @Override protected void createActions() { super.createActions(); this.iconifyAction = new SubstanceIconifyAction(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicInternalFrameTitlePane#createButtons() */ @Override protected void createButtons() { iconButton = new SubstanceTitleButton( "InternalFrameTitlePane.iconifyButtonAccessibleName"); iconButton.addActionListener(iconifyAction); maxButton = new SubstanceTitleButton( "InternalFrameTitlePane.maximizeButtonAccessibleName"); maxButton.addActionListener(maximizeAction); closeButton = new SubstanceTitleButton( "InternalFrameTitlePane.closeButtonAccessibleName"); closeButton.addActionListener(closeAction); setButtonIcons(); for (ActionListener listener : this.iconButton.getActionListeners()) if (listener instanceof ClickListener) return; this.iconButton.addActionListener(new ClickListener()); for (ActionListener listener : this.maxButton.getActionListeners()) if (listener instanceof ClickListener) return; this.maxButton.addActionListener(new ClickListener()); this.iconButton.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); this.maxButton.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); this.closeButton.putClientProperty( SubstanceButtonUI.IS_TITLE_CLOSE_BUTTON, Boolean.TRUE); this.closeButton.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); this.enableActions(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicInternalFrameTitlePane#createLayout() */ @Override protected LayoutManager createLayout() { return new SubstanceTitlePaneLayout(); } /** * Synchronizes the tooltip of the close button. */ protected void syncCloseButtonTooltip() { if (SubstanceCoreUtilities.isInternalFrameModified(this.frame)) { this.closeButton.setToolTipText(SubstanceCoreUtilities .getResourceBundle(frame).getString("SystemMenu.close") + " [" + SubstanceCoreUtilities.getResourceBundle(frame) .getString("Tooltip.contentsNotSaved") + "]"); } else { this.closeButton.setToolTipText(SubstanceCoreUtilities .getResourceBundle(frame).getString("SystemMenu.close")); } this.closeButton.repaint(); } /* * (non-Javadoc) * * @see javax.swing.JComponent#removeNotify() */ @Override public void removeNotify() { super.removeNotify(); // fix for defect 211 - internal frames that are iconified // programmatically should not uninstall the title panes. boolean isAlive = ((this.frame.isIcon() && !this.frame.isClosed()) || Boolean.TRUE .equals(frame.getClientProperty(ICONIFYING))); if (!isAlive) { this.uninstall(); } } /* * (non-Javadoc) * * @see javax.swing.JComponent#addNotify() */ @Override public void addNotify() { super.addNotify(); if (Boolean.TRUE.equals(this.getClientProperty(UNINSTALLED))) { this.installTitlePane(); // this.installListeners(); this.putClientProperty(UNINSTALLED, null); } } /** * Layout manager for this title pane. * * @author Kirill Grouchnikov */ protected class SubstanceTitlePaneLayout extends TitlePaneLayout { @Override public void addLayoutComponent(String name, Component c) { } @Override public void removeLayoutComponent(Component c) { } @Override public Dimension preferredLayoutSize(Container c) { return minimumLayoutSize(c); } @Override public Dimension minimumLayoutSize(Container c) { // Compute width. int width = 30; if (frame.isClosable()) { width += 21; } if (frame.isMaximizable()) { width += 16 + (frame.isClosable() ? 10 : 4); } if (frame.isIconifiable()) { width += 16 + (frame.isMaximizable() ? 2 : (frame.isClosable() ? 10 : 4)); } FontMetrics fm = frame.getFontMetrics(getFont()); String frameTitle = frame.getTitle(); int title_w = frameTitle != null ? fm.stringWidth(frameTitle) : 0; int title_length = frameTitle != null ? frameTitle.length() : 0; if (title_length > 2) { int subtitle_w = fm.stringWidth(frame.getTitle() .substring(0, 2) + "..."); width += (title_w < subtitle_w) ? title_w : subtitle_w; } else { width += title_w; } // Compute height. int height = 0; // if (isPalette) { // height = paletteTitleHeight; // } else { int fontHeight = fm.getHeight(); fontHeight += 7; Icon icon = frame.getFrameIcon(); int iconHeight = 0; if (icon != null) { // SystemMenuBar forces the icon to be 16x16 or less. iconHeight = Math.min(icon.getIconHeight(), 16); } iconHeight += 5; height = Math.max(fontHeight, iconHeight); // } return new Dimension(width, height); } @Override public void layoutContainer(Container c) { boolean leftToRight = frame.getComponentOrientation() .isLeftToRight(); int w = getWidth(); int x = leftToRight ? w : 0; int y = 2; int spacing; // assumes all buttons have the same dimensions // these dimensions include the borders int buttonHeight = closeButton.getIcon().getIconHeight(); int buttonWidth = closeButton.getIcon().getIconWidth(); y = (getHeight() - buttonHeight) / 2; // Icon icon = frame.getFrameIcon(); // int iconHeight = 0; // if (icon != null) { // iconHeight = icon.getIconHeight(); // } // int xMenuBar = (leftToRight) ? 2 : w - 16 - 2; // menuBar.setBounds(xMenuBar, (getHeight() - iconHeight) / 2, 16, // 16); if (frame.isClosable()) { // if (isPalette) { // spacing = 3; // x += leftToRight ? -spacing - (buttonWidth + 2) : spacing; // closeButton.setBounds(x, y, buttonWidth + 2, // getHeight() - 4); // if (!leftToRight) // x += (buttonWidth + 2); // } else { spacing = 4; x += leftToRight ? -spacing - buttonWidth : spacing; closeButton.setBounds(x, y, buttonWidth, buttonHeight); if (!leftToRight) x += buttonWidth; // } } if (frame.isMaximizable()) {// && !isPalette) { spacing = frame.isClosable() ? 10 : 4; x += leftToRight ? -spacing - buttonWidth : spacing; maxButton.setBounds(x, y, buttonWidth, buttonHeight); if (!leftToRight) x += buttonWidth; } if (frame.isIconifiable()) {// && !isPalette) { spacing = frame.isMaximizable() ? 2 : (frame.isClosable() ? 10 : 4); x += leftToRight ? -spacing - buttonWidth : spacing; iconButton.setBounds(x, y, buttonWidth, buttonHeight); if (!leftToRight) x += buttonWidth; } // // buttonsWidth = leftToRight ? w - x : x; } } /** * Custom iconifying action. * * @author Kirill Grouchnikov */ public class SubstanceIconifyAction extends IconifyAction { /** * Creates an iconifying action. */ public SubstanceIconifyAction() { super(); } @Override public void actionPerformed(ActionEvent e) { frame.putClientProperty(ICONIFYING, Boolean.TRUE); super.actionPerformed(e); frame.putClientProperty(ICONIFYING, null); } } /** * Updates the state of internal frames used in {@link JOptionPane}s. */ private void updateOptionPaneState() { Object obj = frame.getClientProperty("JInternalFrame.messageType"); if (obj == null) { // Don't change the closable state unless in an JOptionPane. return; } if (frame.isClosable()) { frame.setClosable(false); } } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceColorSchemeUtilities.java0000644000175000017500000006662011244102502030651 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.Color; import java.awt.Component; import java.io.*; import java.net.URL; import java.util.ArrayList; import java.util.List; import javax.swing.*; import javax.swing.plaf.UIResource; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.utils.combo.SubstanceComboBoxButton; import org.jvnet.substance.utils.scroll.SubstanceScrollButton; /** * Utilities related to color schemes. This class is for internal use only. * * @author Kirill Grouchnikov */ public class SubstanceColorSchemeUtilities { private static enum ColorSchemeKind { LIGHT, DARK } /** * Metallic skin. */ public static final SubstanceSkin METALLIC_SKIN = getMetallicSkin(); /** * Returns a metallic skin. * * @return Metallic skin. */ private static SubstanceSkin getMetallicSkin() { SubstanceSkin res = new SubstanceSkin() { @Override public String getDisplayName() { return "Metallic Skin"; } }; res.registerDecorationAreaSchemeBundle(new SubstanceColorSchemeBundle( new MetallicColorScheme(), new MetallicColorScheme(), new LightGrayColorScheme()), DecorationAreaType.NONE); return res; } /** * Base interface for colorization support. * * @author Kirill Grouchnikov */ private static interface ColorizationSupport { /** * Returns the background color of the specified component. * * @param component * Component. * @return The background color of the specified component. */ public Color getBackground(Component component); /** * Returns the foreground color of the specified component. * * @param component * Component. * @return The foreground color of the specified component. */ public Color getForeground(Component component); } /** * Returns a colorized version of the specified color scheme. * * @param component * Component. * @param scheme * Color scheme. * @param isEnabled * Indicates whether the component is enabled. * @return Colorized version of the specified color scheme. */ private static SubstanceColorScheme getColorizedScheme(Component component, SubstanceColorScheme scheme, boolean isEnabled) { ColorizationSupport support = new ColorizationSupport() { private boolean toTakeFromParent(Component component) { return (component.getParent() != null) && ((component instanceof SubstanceScrollButton) || (component instanceof SubstanceSpinnerButton) || (component instanceof SubstanceComboBoxButton) || (component instanceof SubstanceTitleButton)); } public Color getBackground(Component component) { return toTakeFromParent(component) ? component.getParent() .getBackground() : component.getBackground(); } public Color getForeground(Component component) { return toTakeFromParent(component) ? component.getParent() .getForeground() : component.getForeground(); } }; return getColorizedScheme(component, scheme, support, isEnabled); } /** * Returns a colorized version of the specified color scheme. * * @param component * Component. * @param scheme * Color scheme. * @param support * Used to compute the colorized scheme. * @param isEnabled * Indicates whether the component is enabled. * @return Colorized version of the specified color scheme. */ private static SubstanceColorScheme getColorizedScheme(Component component, SubstanceColorScheme scheme, ColorizationSupport support, boolean isEnabled) { if (component != null) { // Support for enhancement 256 - colorizing // controls. Color bk = support.getBackground(component); Color fg = support.getForeground(component); // if (component instanceof SubstanceTitleButton) { // if ((fg != null) && (bk != null)) { // // guard for issue 322 - these are null when JavaHelp // // window is printed. // fg = SubstanceColorUtilities.getInterpolatedColor(fg, bk, // 0.5); // } // } if (bk instanceof UIResource) bk = null; if (fg instanceof UIResource) { fg = null; } if ((bk != null) || (fg != null)) { double colorization = SubstanceCoreUtilities .getColorizationFactor(component); if (!isEnabled) colorization /= 2.0; if (colorization > 0.0) { return ShiftColorScheme.getShiftedScheme(scheme, bk, colorization, fg, colorization); } } } return scheme; } /** * Returns the color scheme of the specified tabbed pane tab. * * @param jtp * Tabbed pane. * @param tabIndex * Tab index. * @param componentState * Tab component state. * @return The color scheme of the specified tabbed pane tab. */ public static SubstanceColorScheme getColorScheme(final JTabbedPane jtp, final int tabIndex, ColorSchemeAssociationKind associationKind, ComponentState componentState) { SubstanceSkin skin = SubstanceCoreUtilities.getSkin(jtp); if (skin == null) { SubstanceCoreUtilities .traceSubstanceApiUsage(jtp, "Substance delegate used when Substance is not the current LAF"); } SubstanceColorScheme nonColorized = skin.getColorScheme(jtp, associationKind, componentState); if (tabIndex >= 0) { Component component = jtp.getComponentAt(tabIndex); SubstanceColorScheme colorized = getColorizedScheme(component, nonColorized, new ColorizationSupport() { public Color getBackground(Component component) { return jtp.getBackgroundAt(tabIndex); } public Color getForeground(Component component) { return jtp.getForegroundAt(tabIndex); } }, componentState.isKindActive(FadeKind.ENABLE)); return colorized; } else { return getColorizedScheme(jtp, nonColorized, componentState .isKindActive(FadeKind.ENABLE)); } } // /** // * Returns the border color scheme of the specified tabbed pane tab. // * // * @param jtp // * Tabbed pane. // * @param tabIndex // * Tab index. // * @param componentState // * Tab component state. // * @return The border color scheme of the specified tabbed pane tab. // */ // public static SubstanceColorScheme getBorderColorScheme( // final JTabbedPane jtp, final int tabIndex, // ComponentState componentState) { // // SubstanceColorScheme nonColorized = SubstanceCoreUtilities.getSkin(jtp) // .getColorScheme(jtp, ColorSchemeAssociationKind.TAB_BORDER, // componentState); // if (tabIndex >= 0) { // Component component = jtp.getComponentAt(tabIndex); // SubstanceColorScheme colorized = getColorizedScheme(component, // nonColorized, new ColorizationSupport() { // public Color getBackground(Component component) { // return jtp.getBackgroundAt(tabIndex); // } // // public Color getForeground(Component component) { // return jtp.getForegroundAt(tabIndex); // } // }, componentState.isKindActive(FadeKind.ENABLE)); // return colorized; // } else { // return getColorizedScheme(jtp, nonColorized, componentState // .isKindActive(FadeKind.ENABLE)); // } // } /** * Returns the color scheme of the specified component. * * @param component * Component. * @param componentState * Component state. * @return Component color scheme. */ public static SubstanceColorScheme getColorScheme(Component component, ComponentState componentState) { Component orig = component; // special case - if the component is marked as flat and // it is in the default state, or it is a button // that is never painting its background - get the color scheme of the // parent boolean isButtonThatIsNeverPainted = ((component instanceof AbstractButton) && SubstanceCoreUtilities .isButtonNeverPainted((AbstractButton) component)); if (isButtonThatIsNeverPainted || (SubstanceCoreUtilities.hasFlatAppearance(component, false) && (componentState == ComponentState.DEFAULT))) { component = component.getParent(); } SubstanceSkin skin = SubstanceCoreUtilities.getSkin(component); if (skin == null) { SubstanceCoreUtilities .traceSubstanceApiUsage(component, "Substance delegate used when Substance is not the current LAF"); } SubstanceColorScheme nonColorized = skin.getColorScheme(component, componentState); return getColorizedScheme(orig, nonColorized, componentState .isKindActive(FadeKind.ENABLE)); } /** * Returns the color scheme of the component. * * @param component * Component. * @param componentState * Component state. * @return Component border color scheme. */ public static SubstanceColorScheme getColorScheme(Component component, ColorSchemeAssociationKind associationKind, ComponentState componentState) { // special case - if the component is marked as flat and // it is in the default state, get the color scheme of the parent. // However, flat toolbars should be ignored, since they are // the "top" level decoration area. if (!(component instanceof JToolBar) && SubstanceCoreUtilities.hasFlatAppearance(component, false) && (componentState == ComponentState.DEFAULT)) { component = component.getParent(); } SubstanceColorScheme nonColorized = SubstanceCoreUtilities.getSkin( component).getColorScheme(component, associationKind, componentState); return getColorizedScheme(component, nonColorized, componentState .isKindActive(FadeKind.ENABLE)); } // /** // * Returns the highlight color scheme of the component. // * // * @param component // * Component. // * @param componentState // * Component state. // * @return Component highlight color scheme. // */ // public static SubstanceColorScheme getHighlightColorScheme( // Component component, ComponentState componentState) { // return SubstanceCoreUtilities.getSkin(component) // .getColorScheme(component, // ColorSchemeAssociationKind.HIGHLIGHT, componentState); // // .getHighlightColorScheme(component, componentState); // } /** * Returns the alpha channel of the highlight color scheme of the component. * * @param component * Component. * @param componentState * Component state. * @return Highlight color scheme alpha channel. */ public static float getHighlightAlpha(Component component, ComponentState componentState) { return SubstanceCoreUtilities.getSkin(component).getHighlightAlpha( component, componentState); } /** * Returns the alpha channel of the color scheme of the component. * * @param component * Component. * @param componentState * Component state. * @return Color scheme alpha channel. */ public static float getAlpha(Component component, ComponentState componentState) { return SubstanceCoreUtilities.getSkin(component).getAlpha(component, componentState); } /** * Used as reference in attention-drawing animations. This field is for * internal use only. */ public final static SubstanceColorScheme YELLOW = new SunGlareColorScheme(); /** * Used as reference in attention-drawing animations. This field is for * internal use only. */ public final static SubstanceColorScheme ORANGE = new SunfireRedColorScheme(); /** * Used as reference to the green color scheme. This field is for * internal use only. */ public final static SubstanceColorScheme GREEN = new BottleGreenColorScheme(); public static SubstanceColorScheme getColorScheme(URL url) { BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(url.openStream())); String name = null; ColorSchemeKind kind = null; Color ultraLight = null; Color extraLight = null; Color light = null; Color mid = null; Color dark = null; Color ultraDark = null; Color foreground = null; SchemeBaseColors base = null; while (true) { String line = reader.readLine(); if (line == null) break; String[] split = line.split("="); if (split.length != 2) { throw new IllegalArgumentException( "Unsupported format in line " + line); } String key = split[0]; String value = split[1]; if ("name".equals(key)) { if (name == null) { name = value; continue; } throw new IllegalArgumentException( "'name' should only be defined once"); } if ("extends".equals(key)) { if (base == null) { base = getBaseColorScheme(new URL(url, value) .openStream()); continue; } throw new IllegalArgumentException( "'extends' should only be defined once"); } if ("kind".equals(key)) { if (kind == null) { if ("Light".equals(value)) { kind = ColorSchemeKind.LIGHT; continue; } if ("Dark".equals(value)) { kind = ColorSchemeKind.DARK; continue; } throw new IllegalArgumentException( "Unsupported format in line " + line); } throw new IllegalArgumentException( "'name' should only be defined once"); } if ("colorUltraLight".equals(key)) { if (ultraLight == null) { ultraLight = Color.decode(value); continue; } throw new IllegalArgumentException( "'ultraLight' should only be defined once"); } if ("colorExtraLight".equals(key)) { if (extraLight == null) { extraLight = Color.decode(value); continue; } throw new IllegalArgumentException( "'extraLight' should only be defined once"); } if ("colorLight".equals(key)) { if (light == null) { light = Color.decode(value); continue; } throw new IllegalArgumentException( "'light' should only be defined once"); } if ("colorMid".equals(key)) { if (mid == null) { mid = Color.decode(value); continue; } throw new IllegalArgumentException( "'mid' should only be defined once"); } if ("colorDark".equals(key)) { if (dark == null) { dark = Color.decode(value); continue; } throw new IllegalArgumentException( "'dark' should only be defined once"); } if ("colorUltraDark".equals(key)) { if (ultraDark == null) { ultraDark = Color.decode(value); continue; } throw new IllegalArgumentException( "'ultraDark' should only be defined once"); } if ("colorForeground".equals(key)) { if (foreground == null) { foreground = Color.decode(value); continue; } throw new IllegalArgumentException( "'foreground' should only be defined once"); } throw new IllegalArgumentException( "Unsupported format in line " + line); } if (base != null) { // merge with base if (ultraLight == null) ultraLight = base.getUltraLightColor(); if (extraLight == null) extraLight = base.getExtraLightColor(); if (light == null) light = base.getLightColor(); if (mid == null) mid = base.getMidColor(); if (dark == null) dark = base.getDarkColor(); if (ultraDark == null) ultraDark = base.getUltraDarkColor(); if (foreground == null) foreground = base.getForegroundColor(); } if ((name == null) || (kind == null) || (ultraLight == null) || (extraLight == null) || (light == null) || (mid == null) || (dark == null) || (ultraDark == null) || (foreground == null)) { throw new IllegalArgumentException("Incomplete specification"); } Color[] colors = new Color[] { ultraLight, extraLight, light, mid, dark, ultraDark, foreground }; switch (kind) { case LIGHT: return getLightColorScheme(name, colors); default: return getDarkColorScheme(name, colors); } } catch (IOException ioe) { throw new IllegalArgumentException(ioe); } finally { if (reader != null) { try { reader.close(); } catch (IOException ioe) { } } } } public static SchemeBaseColors getBaseColorScheme(InputStream is) { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); Color ultraLight = null; Color extraLight = null; Color light = null; Color mid = null; Color dark = null; Color ultraDark = null; Color foreground = null; try { while (true) { String line = reader.readLine(); if (line == null) break; String[] split = line.split("="); if (split.length != 2) { throw new IllegalArgumentException( "Unsupported format in line " + line); } String key = split[0]; String value = split[1]; if ("colorUltraLight".equals(key)) { if (ultraLight == null) { ultraLight = Color.decode(value); continue; } throw new IllegalArgumentException( "'ultraLight' should only be defined once"); } if ("colorExtraLight".equals(key)) { if (extraLight == null) { extraLight = Color.decode(value); continue; } throw new IllegalArgumentException( "'extraLight' should only be defined once"); } if ("colorLight".equals(key)) { if (light == null) { light = Color.decode(value); continue; } throw new IllegalArgumentException( "'light' should only be defined once"); } if ("colorMid".equals(key)) { if (mid == null) { mid = Color.decode(value); continue; } throw new IllegalArgumentException( "'mid' should only be defined once"); } if ("colorDark".equals(key)) { if (dark == null) { dark = Color.decode(value); continue; } throw new IllegalArgumentException( "'dark' should only be defined once"); } if ("colorUltraDark".equals(key)) { if (ultraDark == null) { ultraDark = Color.decode(value); continue; } throw new IllegalArgumentException( "'ultraDark' should only be defined once"); } if ("colorForeground".equals(key)) { if (foreground == null) { foreground = Color.decode(value); continue; } throw new IllegalArgumentException( "'foreground' should only be defined once"); } throw new IllegalArgumentException( "Unsupported format in line " + line); } final Color[] colors = new Color[] { ultraLight, extraLight, light, mid, dark, ultraDark, foreground }; return new SchemeBaseColors() { @Override public String getDisplayName() { return null; } @Override public Color getUltraLightColor() { return colors[0]; } @Override public Color getExtraLightColor() { return colors[1]; } @Override public Color getLightColor() { return colors[2]; } @Override public Color getMidColor() { return colors[3]; } @Override public Color getDarkColor() { return colors[4]; } @Override public Color getUltraDarkColor() { return colors[5]; } @Override public Color getForegroundColor() { return colors[6]; } }; } catch (IOException ioe) { throw new IllegalArgumentException(ioe); } finally { if (reader != null) { try { reader.close(); } catch (IOException ioe) { } } } } public static SubstanceColorScheme getLightColorScheme(String name, final Color[] colors) { if (colors == null) throw new IllegalArgumentException("Color encoding cannot be null"); if (colors.length != 7) throw new IllegalArgumentException( "Color encoding must have 7 components"); return new BaseLightColorScheme(name) { public Color getUltraLightColor() { return colors[0]; } public Color getExtraLightColor() { return colors[1]; } public Color getLightColor() { return colors[2]; } public Color getMidColor() { return colors[3]; } public Color getDarkColor() { return colors[4]; } public Color getUltraDarkColor() { return colors[5]; } public Color getForegroundColor() { return colors[6]; } }; } public static SubstanceColorScheme getDarkColorScheme(String name, final Color[] colors) { if (colors == null) throw new IllegalArgumentException("Color encoding cannot be null"); if (colors.length != 7) throw new IllegalArgumentException( "Color encoding must have 7 components"); return new BaseDarkColorScheme(name) { public Color getUltraLightColor() { return colors[0]; } public Color getExtraLightColor() { return colors[1]; } public Color getLightColor() { return colors[2]; } public Color getMidColor() { return colors[3]; } public Color getDarkColor() { return colors[4]; } public Color getUltraDarkColor() { return colors[5]; } public Color getForegroundColor() { return colors[6]; } }; } public static SubstanceSkin.ColorSchemes getColorSchemes(URL url) { List schemes = new ArrayList(); BufferedReader reader = null; Color ultraLight = null; Color extraLight = null; Color light = null; Color mid = null; Color dark = null; Color ultraDark = null; Color foreground = null; String name = null; ColorSchemeKind kind = null; boolean inColorSchemeBlock = false; try { reader = new BufferedReader(new InputStreamReader(url.openStream())); while (true) { String line = reader.readLine(); if (line == null) break; if (line.trim().length() == 0) continue; if (line.indexOf("{") >= 0) { if (inColorSchemeBlock) { throw new IllegalArgumentException( "Already in color scheme definition"); } inColorSchemeBlock = true; name = line.substring(0, line.indexOf("{")).trim(); continue; } if (line.indexOf("}") >= 0) { if (!inColorSchemeBlock) { throw new IllegalArgumentException( "Not in color scheme definition"); } inColorSchemeBlock = false; if ((name == null) || (kind == null) || (ultraLight == null) || (extraLight == null) || (light == null) || (mid == null) || (dark == null) || (ultraDark == null) || (foreground == null)) { throw new IllegalArgumentException( "Incomplete specification"); } Color[] colors = new Color[] { ultraLight, extraLight, light, mid, dark, ultraDark, foreground }; if (kind == ColorSchemeKind.LIGHT) { schemes.add(getLightColorScheme(name, colors)); } else { schemes.add(getDarkColorScheme(name, colors)); } name = null; kind = null; ultraLight = null; extraLight = null; light = null; mid = null; dark = null; ultraDark = null; foreground = null; continue; } String[] split = line.split("="); if (split.length != 2) { throw new IllegalArgumentException( "Unsupported format in line " + line); } String key = split[0].trim(); String value = split[1].trim(); if ("kind".equals(key)) { if (kind == null) { if ("Light".equals(value)) { kind = ColorSchemeKind.LIGHT; continue; } if ("Dark".equals(value)) { kind = ColorSchemeKind.DARK; continue; } throw new IllegalArgumentException( "Unsupported format in line " + line); } throw new IllegalArgumentException( "'kind' should only be defined once"); } if ("colorUltraLight".equals(key)) { if (ultraLight == null) { ultraLight = Color.decode(value); continue; } throw new IllegalArgumentException( "'ultraLight' should only be defined once"); } if ("colorExtraLight".equals(key)) { if (extraLight == null) { extraLight = Color.decode(value); continue; } throw new IllegalArgumentException( "'extraLight' should only be defined once"); } if ("colorLight".equals(key)) { if (light == null) { light = Color.decode(value); continue; } throw new IllegalArgumentException( "'light' should only be defined once"); } if ("colorMid".equals(key)) { if (mid == null) { mid = Color.decode(value); continue; } throw new IllegalArgumentException( "'mid' should only be defined once"); } if ("colorDark".equals(key)) { if (dark == null) { dark = Color.decode(value); continue; } throw new IllegalArgumentException( "'dark' should only be defined once"); } if ("colorUltraDark".equals(key)) { if (ultraDark == null) { ultraDark = Color.decode(value); continue; } throw new IllegalArgumentException( "'ultraDark' should only be defined once"); } if ("colorForeground".equals(key)) { if (foreground == null) { foreground = Color.decode(value); continue; } throw new IllegalArgumentException( "'foreground' should only be defined once"); } throw new IllegalArgumentException( "Unsupported format in line " + line); } ; } catch (IOException ioe) { throw new IllegalArgumentException(ioe); } finally { if (reader != null) { try { reader.close(); } catch (IOException ioe) { } } } return new SubstanceSkin.ColorSchemes(schemes); } } substance-5.3.orig/src/org/jvnet/substance/utils/MemoryAnalyzer.java0000644000175000017500000002174111136475562025676 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.*; import java.io.*; import java.text.SimpleDateFormat; import java.util.*; import java.util.List; import javax.swing.*; import org.jvnet.lafwidget.utils.TrackableThread; /** * Tracer for memory usage patterns of Substance look-and-feel. The * tracer is started when VM has -Dsubstancelaf.traceFile flag. The * value of this flag specifies the location of trace log file. When activated, * the tracer runs a thread that collects information on memory usage and * appends it to the trace log file every X seconds. The * X (delay) is specified in the constructor. This class is for * internal use only. * * @author Kirill Grouchnikov */ public class MemoryAnalyzer extends TrackableThread { /** * Sleep delay between trace log iterations. */ private long delay; /** * Trace logfile name. */ private String filename; /** * Singleton instance. */ private static MemoryAnalyzer instance; /** * If true, this tracer has received a request to * stop. */ private static boolean isStopRequest = false; /** * Usage strings collected during the sleep time. */ private static ArrayList usages; /** * Formatting object. */ private static SimpleDateFormat sdf; /** * Simple constructor. * * @param delay * Sleep delay between trace log iterations. * @param filename * Trace logfile name. */ private MemoryAnalyzer(long delay, String filename) { super(); this.delay = delay; this.filename = filename; this.setName("Substance memory analyzer"); } /** * Starts the memory tracing. * * @param delay * Sleep delay between trace log iterations. * @param filename * Trace logfile name. */ public static synchronized void commence(long delay, String filename) { if (instance == null) { instance = new MemoryAnalyzer(delay, filename); usages = new ArrayList(); // yeah, yeah, it's not multi-thread safe. sdf = new SimpleDateFormat("HH:mm:ss.SSS"); instance.start(); } } /** * Issues request to stop tracing. */ @Override public synchronized void requestStop() { isStopRequest = true; } /** * Checks whether a request to stop tracing has been issued. * * @return true if a request to stop tracing has been issued, * false otherwise. */ private static synchronized boolean hasStopRequest() { return isStopRequest; } /** * Checks whether tracer is running. * * @return true if tracer is running, false * otherwise. */ public static boolean isRunning() { return (instance != null); } /** * Adds usage string. * * @param usage * Usage string. Will be output to the trace file at next * iteration of the tracer. */ public static synchronized void enqueueUsage(String usage) { if (instance != null) { usages.add(sdf.format(new Date()) + ": " + usage); } } /** * Returns all queued usages. * * @return All queued usages. */ public static synchronized ArrayList getUsages() { ArrayList copy = new ArrayList(); for (String usage : usages) copy.add(usage); usages.clear(); return copy; } /* * (non-Javadoc) * * @see java.lang.Runnable#run() */ @Override public void run() { // output all settings from UIManager // Need to run on EDT - issue 392 try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { BufferedWriter bw = null; try { bw = new BufferedWriter(new FileWriter(new File( filename), true)); bw.write(sdf.format(new Date()) + "\n"); UIDefaults uidefs = UIManager.getLookAndFeel() .getDefaults(); // Retrieve the keys. Can't use an iterator since the // map may be modified during the iteration. So retrieve // all at once. Set keySet = uidefs.keySet(); List keyList = new LinkedList(); for (Object key : keySet) { keyList.add((String) key); } Collections.sort(keyList); for (String key : keyList) { Object v = uidefs.get(key); if (v instanceof Integer) { int intVal = uidefs.getInt(key); bw.write(key + " (int) : " + intVal); } else if (v instanceof Boolean) { boolean boolVal = uidefs.getBoolean(key); bw.write(key + " (bool) : " + boolVal); } else if (v instanceof String) { String strVal = uidefs.getString(key); bw.write(key + " (string) : " + strVal); } else if (v instanceof Dimension) { Dimension dimVal = uidefs.getDimension(key); bw.write(key + " (Dimension) : " + dimVal.width + "*" + dimVal.height); } else if (v instanceof Insets) { Insets insetsVal = uidefs.getInsets(key); bw.write(key + " (Insets) : " + insetsVal.top + "*" + insetsVal.left + "*" + insetsVal.bottom + "*" + insetsVal.right); } else if (v instanceof Color) { Color colorVal = uidefs.getColor(key); bw.write(key + " (int) : " + colorVal.getRed() + "," + colorVal.getGreen() + "," + colorVal.getBlue()); } else if (v instanceof Font) { Font fontVal = uidefs.getFont(key); bw.write(key + " (Font) : " + fontVal.getFontName() + "*" + fontVal.getSize()); } else { bw .write(key + " (Object) : " + uidefs.get(key)); } bw.write("\n"); } } catch (IOException ioe) { requestStop(); } catch (Throwable t) { } finally { if (bw != null) { try { bw.close(); } catch (Exception exc) { } } } } }); } catch (Exception exc) { requestStop(); } BufferedWriter bw = null; while (!hasStopRequest()) { // gather statistics and print them to file bw = null; try { bw = new BufferedWriter(new FileWriter(new File(this.filename), true)); bw.write(sdf.format(new Date()) + "\n"); java.util.List stats = LazyResettableHashMap.getStats(); if (stats != null) { for (String stat : stats) { bw.write(stat + "\n"); } } bw.write(PulseTracker.getMemoryUsage() + "\n"); ArrayList usages = getUsages(); for (String usage : usages) { bw.write(usage + "\n"); } bw.write("UIManager has " + UIManager.getDefaults().size() + " entries\n"); long heapSize = Runtime.getRuntime().totalMemory(); long heapFreeSize = Runtime.getRuntime().freeMemory(); int heapSizeKB = (int) (heapSize / 1024); int takenHeapSizeKB = (int) ((heapSize - heapFreeSize) / 1024); bw.write("Heap : " + takenHeapSizeKB + " / " + heapSizeKB); bw.write("\n"); } catch (IOException ioe) { this.requestStop(); } finally { if (bw != null) { try { bw.close(); } catch (Exception exc) { } } } // sleep try { sleep(this.delay); } catch (InterruptedException ie) { } } } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceSizeUtils.java0000644000175000017500000007070411246723152026517 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.*; import javax.swing.border.Border; import javax.swing.plaf.BorderUIResource; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants; import org.jvnet.substance.fonts.*; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * This class is responsible for computing DPI-aware insets, stroke widths, * paddings, icon sizes etc. This class if for internal use only. * * @author Kirill Grouchnikov */ public class SubstanceSizeUtils { /** * Cached control font size. */ private static int controlFontSize = -1; /** * The points to pixels ratio of the current font policy. */ private static double pointsToPixelsRatio = 1.0; /** * Gets the current control font size. * * @return Control font size. */ public static int getControlFontSize() { if (controlFontSize > 0) return controlFontSize; FontPolicy fPolicy = SubstanceLookAndFeel.getFontPolicy(); FontSet fSet = fPolicy.getFontSet("Substance", null); controlFontSize = fSet.getControlFont().getSize(); return controlFontSize; } /** * Sets the new value for the control font size. * * @param size * Control font size. */ public static void setControlFontSize(int size) { controlFontSize = size; } /** * Computes the font size for the specified component. If the component is * null or doesn't have font set ({@link Component#getFont()} * returns null), this method returns the default control font * size from {@link #getControlFontSize()}. * * @param c * Component. * @return Font size for the specified component */ public static int getComponentFontSize(Component c) { return ((c == null) || (c.getFont() == null)) ? getControlFontSize() : c.getFont().getSize(); } /** * Gets the adjusted size. The basic functionality of this method is as * follows: * *
    *
  • The baseSize parameter specifies the base value
  • *
  • The forEachBase and toAdjustBy specify how * to adjust the resulting value based on the passed fontSize.
  • *
* * For example, if you want base value to be 1.2 pixels, and have it grow by * 0.1 pixel for every additional pixel in the font size, call this method * with the following values: * *
    *
  • baseSize = 1.2
  • *
  • forEachBase = 1
  • *
  • toAdjustBy = 0.1
  • *
* * @param fontSize * Font size. * @param baseSize * The base value. * @param forEachBase * Base units for computing the adjustment. * @param toAdjustBy * Adjustment amount for computing the adjustment. * @return Adjusted size. */ public static float getAdjustedSize(int fontSize, float baseSize, int forEachBase, float toAdjustBy) { int delta = fontSize - 11; if (delta <= 0) return baseSize; float result = baseSize + delta * toAdjustBy / forEachBase; return result; } /** * Gets the adjusted size. The basic functionality of this method is as * follows: * *
    *
  • The baseSize parameter specifies the base value
  • *
  • The forEachBase and toAdjustBy specify how * to adjust the resulting value based on the passed fontSize.
  • *
* * For example, if you want base value to be 4 pixels, and have it grow by 1 * pixel for every 3 additional pixels in the font size, call this method * with the following values: * *
    *
  • baseSize = 4
  • *
  • forEachBase = 3
  • *
  • toAdjustBy = 1
  • *
* * @param fontSize * Font size. * @param baseSize * The base value. * @param forEachBase * Base units for computing the adjustment. * @param toAdjustBy * Adjustment amount for computing the adjustment. * @param toRoundAsEven * If true, the final value will be rounded down to * the closest even value. * @return Adjusted size. */ public static int getAdjustedSize(int fontSize, int baseSize, int forEachBase, int toAdjustBy, boolean toRoundAsEven) { int delta = fontSize - 11; if (delta <= 0) return baseSize; int result = baseSize + delta * toAdjustBy / forEachBase; if (toRoundAsEven && (result % 2 != 0)) result--; return result; } /** * Returns the height of arrow icons under the specified font size. * * @param fontSize * Font size. * @return Height of arrow icons under the specified font size. */ public static float getArrowIconHeight(int fontSize) { if (fontSize < 12) return 2.5f + fontSize * 0.5f; return 3.0f + fontSize * 0.6f; } /** * Returns the width of arrow icons under the specified font size. * * @param fontSize * Font size. * @return Width of arrow icons under the specified font size. */ public static float getArrowIconWidth(int fontSize) { int result = 2 * fontSize / 3; if (result % 2 == 0) result++; return result + 4; } /** * Returns the stroke width of arrow icons under the specified font size. * * @param fontSize * Font size. * @return Stroke width of arrow icons under the specified font size. */ public static float getArrowStrokeWidth(int fontSize) { return fontSize / 6.0f; } /** * Returns the stroke width of borders under the specified font size. * * @param fontSize * Font size. * @return Stroke width of borders under the specified font size. */ public static float getBorderStrokeWidth(int fontSize) { return fontSize / 10.0f; } /** * Returns the border for check boxes under the specified font size. * * @param fontSize * Font size. * @return Border for check boxes under the specified font size. */ public static Border getCheckBoxBorder(int fontSize) { int focusRingWidth = (int) Math.ceil(2.0 * SubstanceSizeUtils .getFocusStrokeWidth(fontSize)); int tbInset = 1 + focusRingWidth; int lrInset = focusRingWidth; return new BorderUIResource.EmptyBorderUIResource(tbInset, lrInset, tbInset, 2 + lrInset); } /** * Returns the check mark size for check boxes under the specified font * size. * * @param fontSize * Font size. * @return Check mark size for check boxes under the specified font size. */ public static int getCheckBoxMarkSize(int fontSize) { return 5 + fontSize; } /** * Returns the corner radius for {@link ClassicButtonShaper} under the * specified font size. * * @param fontSize * Font size. * @return Corner radius for {@link ClassicButtonShaper} under the specified * font size. */ public static float getClassicButtonCornerRadius(int fontSize) { return getAdjustedSize(fontSize, 2, 6, 1, false); } /** * Returns the combo box border insets under the specified font size. * * @param fontSize * Font size. * @return Combo box border insets under the specified font size. */ public static Insets getComboBorderInsets(int fontSize) { // The base insets are 1,2,1,2. We add one pixel for // each 4 extra points in base control size. int tbInset = getAdjustedSize(fontSize, 1, 4, 1, false); int lrInset = getAdjustedSize(fontSize, 2, 4, 1, false); return new Insets(tbInset, lrInset, tbInset, lrInset); } /** * Returns the combo box text border insets under the specified font size. * * @param fontSize * Font size. * @return Combo box text border insets under the specified font size. */ public static Insets getComboTextBorderInsets(int fontSize) { // the following makes sure that the text components // and combos have the same height and text alignment // under all font sizes. Insets textInsets = getTextBorderInsets(fontSize); Insets comboInsets = getComboBorderInsets(fontSize); int topDelta = textInsets.top - comboInsets.top; int bottomDelta = textInsets.bottom - comboInsets.bottom; int lrInset = getAdjustedSize(fontSize, 1, 4, 1, false); return new Insets(topDelta, lrInset, bottomDelta, lrInset); } /** * Returns the default border insets under the specified font size. * * @param fontSize * Font size. * @return Default border insets under the specified font size. */ public static Insets getDefaultBorderInsets(int fontSize) { // The base insets are 2,2,2,2. We add one pixel for // each 3 extra points in base control size. int inset = getAdjustedSize(fontSize, 2, 3, 1, false); return new Insets(inset, inset, inset, inset); } /** * Returns the stroke width of double arrow icons under the specified font * size. * * @param fontSize * Font size. * @return Stroke width of double arrow icons under the specified font size. */ public static float getDoubleArrowStrokeWidth(int fontSize) { return fontSize / 8.0f; } /** * Returns the diameter of a drag bump dot under the specified font size. * * @param fontSize * Font size. * @return Diameter of a drag bump dot under the specified font size. */ public static int getDragBumpDiameter(int fontSize) { return getAdjustedSize(fontSize, 2, 4, 1, false); } /** * Returns the diameter of a big drag bump dot under the specified font * size. * * @param fontSize * Font size. * @return Diameter of a big drag bump dot under the specified font size. */ public static int getBigDragBumpDiameter(int fontSize) { int result = getAdjustedSize(fontSize, 3, 3, 1, false); if (result % 2 != 0) result++; return result; } /** * Returns the extra padding amount under the specified font size. * * @param fontSize * Font size. * @return Extra padding amount under the specified font size. */ public static int getExtraPadding(int fontSize) { if (fontSize < 14) return 0; return (int) SubstanceSizeUtils.getAdjustedSize(fontSize, 0, 3, 1.2f); } /** * Returns the focus ring padding amount under the specified font size. * * @param fontSize * Font size. * @return Focus ring padding amount under the specified font size. */ public static int getFocusRingPadding(int fontSize) { if (fontSize < 14) return 2; return 3 + (int) SubstanceSizeUtils.getAdjustedSize(fontSize, 0, 3, 0.8f); } /** * Returns the stroke width of focus rings under the specified font size. * * @param fontSize * Font size. * @return Stroke width of focus rings under the specified font size. */ public static float getFocusStrokeWidth(int fontSize) { return Math.max(1.0f, fontSize / 10.0f); } /** * Returns the list cell renderer insets under the specified font size. * * @param fontSize * Font size. * @return List cell renderer insets under the specified font size. */ public static Insets getListCellRendererInsets(int fontSize) { // Special handling to make non-editable combo boxes // have the same height as text components. The combo box // uses list cell renderer, so to compute the top and // bottom insets of a list cell renderer, we subtract the // insets of combo box from the insets of text component. Insets textInsets = getTextBorderInsets(fontSize); Insets comboInsets = getComboBorderInsets(fontSize); int topDelta = textInsets.top - comboInsets.top; int bottomDelta = textInsets.bottom - comboInsets.bottom; int lrInset = SubstanceSizeUtils.getAdjustedSize(fontSize, 4, 4, 1, false); return new Insets(topDelta, lrInset, bottomDelta, lrInset); } /** * Returns the check mark size of check box menu items and radio button menu * items under the specified font size. * * @param fontSize * Font size. * @return Check mark size of check box menu items and radio button menu * items under the specified font size. */ public static int getMenuCheckMarkSize(int fontSize) { int result = fontSize - 2; if (result % 2 == 0) result--; return result; } /** * Returns the margin for menu items under the specified font size. * * @param fontSize * Font size. * @return Margin for menu items under the specified font size. */ public static int getMenuItemMargin(int fontSize) { return getAdjustedSize(fontSize, 2, 4, 1, false); } /** * Returns the gap between text and icon in buttons and menu items under the * specified font size. * * @param fontSize * Font size. * @return Gap between text and icon in button menu items under the * specified font size. */ public static int getTextIconGap(int fontSize) { return getAdjustedSize(fontSize, 4, 3, 1, false); } /** * Returns the minimum button height under the specified font size. * * @param fontSize * Font size. * @return Minimum button height under the specified font size. */ public static int getMinButtonHeight(int fontSize) { return 11 + (fontSize - 5) * 3 / 2; } /** * Returns the maximum button height under the specified font size. * * @param fontSize * Font size. * @return Maximum button height under the specified font size. */ public static int getMinButtonWidth(int fontSize) { return (int) (3.5 * getMinButtonHeight(fontSize)); } /** * Returns the password dot diameter for password fields under the specified * font size. * * @param fontSize * Font size. * @return Password dot diameter for password fields under the specified * font size. */ public static int getPasswordDotDiameter(int fontSize) { return getAdjustedSize(fontSize, 7, 2, 1, false); } /** * Returns the password dot gap for password fields under the specified font * size. * * @param fontSize * Font size. * @return Password dot gap for password fields under the specified font * size. */ public static int getPasswordDotGap(int fontSize) { return (fontSize - 6) / 3; } /** * Returns the border for radio buttons under the specified font size. * * @param fontSize * Font size. * @return Border for radio buttons under the specified font size. */ public static Border getRadioButtonBorder(int fontSize) { int focusRingWidth = (int) Math.ceil(2.0 * SubstanceSizeUtils .getFocusStrokeWidth(fontSize)); int tbInset = 1 + focusRingWidth; int lrInset = focusRingWidth; return new BorderUIResource.EmptyBorderUIResource(tbInset, 3 + lrInset, tbInset, 2 + lrInset); } /** * Returns the check mark size for radio buttons under the specified font * size. * * @param fontSize * Font size. * @return Check mark size for radio buttons under the specified font size. */ public static int getRadioButtonMarkSize(int fontSize) { int result = fontSize; if (result % 2 == 0) result--; return result; } /** * Returns the width of scroll bars under the specified font size. * * @param fontSize * Font size. * @return Width of scroll bars under the specified font size. */ public static int getScrollBarWidth(int fontSize) { int result = (int) (getArrowIconWidth(fontSize) * 3 / 2); if (result % 2 == 0) result++; return result; } /** * Returns the slider thumb icon size under the specified font size. * * @param fontSize * Font size. * @return Slider thumb icon size under the specified font size. */ public static int getSliderIconSize(int fontSize) { int result = fontSize + 5; if (result % 2 != 0) result--; return result; } /** * Returns the slider tick size under the specified font size. * * @param fontSize * Font size. * @return Slider tick size under the specified font size. */ public static int getSliderTickSize(int fontSize) { return Math.max(7, fontSize - 3); } /** * Returns the slider track size under the specified font size. * * @param fontSize * Font size. * @return Slider track size under the specified font size. */ public static int getSliderTrackSize(int fontSize) { return Math.max(4, 5 + (fontSize - 11) / 2); } /** * Returns the height of small arrow icons under the specified font size. * * @param fontSize * Font size. * @return Height of small arrow icons under the specified font size. */ public static float getSmallArrowIconHeight(int fontSize) { return getArrowIconHeight(fontSize) - 1; } /** * Returns the width of small arrow icons under the specified font size. * * @param fontSize * Font size. * @return Width of small arrow icons under the specified font size. */ public static float getSmallArrowIconWidth(int fontSize) { return getArrowIconWidth(fontSize) - 2; } /** * Returns the height of spinner arrow icons under the specified font size. * * @param fontSize * Font size. * @return Height of spinner arrow icons under the specified font size. */ public static float getSpinnerArrowIconHeight(int fontSize) { float result = SubstanceSizeUtils.getArrowIconHeight(fontSize) + SubstanceSizeUtils .getAdjustedSize(fontSize + 1, 0, 1, -0.25f); return result; } /** * Returns the width of spinner arrow icons under the specified font size. * * @param fontSize * Font size. * @return Width of spinner arrow icons under the specified font size. */ public static float getSpinnerArrowIconWidth(int fontSize) { int result = (int) (SubstanceSizeUtils.getArrowIconWidth(fontSize) + SubstanceSizeUtils .getAdjustedSize(fontSize, 1, 1, -0.15f)); if (result % 2 == 0) result--; return result; } /** * Returns the spinner border insets under the specified font size. * * @param fontSize * Font size. * @return Spinner border insets under the specified font size. */ public static Insets getSpinnerBorderInsets(int fontSize) { // make sure that spinners and combos have the same height and text // alignment under all font sizes. Insets comboInsets = getComboBorderInsets(fontSize); return new Insets(comboInsets.top + 1, comboInsets.left, comboInsets.bottom + 1, comboInsets.right); } /** * Returns the spinner arrow button insets under the specified font size. * * @param fontSize * Font size. * @return Spinner arrow button insets under the specified font size. */ public static Insets getSpinnerArrowButtonInsets(int fontSize) { int borderStrokeWidth = (int) Math .floor(getBorderStrokeWidth(fontSize)); return new Insets(borderStrokeWidth, borderStrokeWidth, borderStrokeWidth, borderStrokeWidth); } // /** // * Returns the spinner button width under the specified font size. // * // * @param fontSize // * Font size. // * @return Spinner button width under the specified font size. // */ // public static int getSpinnerButtonWidth(int fontSize) { // return (int)(getArrowIconWidth(fontSize) * 3 / 2); // } /** * Returns the spinner text border insets under the specified font size. * * @param fontSize * Font size. * @return Spinner text border insets under the specified font size. */ public static Insets getSpinnerTextBorderInsets(int fontSize) { Insets textInsets = getComboTextBorderInsets(fontSize); return new Insets(textInsets.top - 1, textInsets.left, textInsets.bottom - 1, textInsets.right); } /** * Returns the height of split pane divider arrow icons under the specified * font size. * * @param fontSize * Font size. * @return Height of split pane divider arrow icons under the specified font * size. */ public static float getSplitPaneArrowIconHeight(int fontSize) { float result = SubstanceSizeUtils.getArrowIconHeight(fontSize) + SubstanceSizeUtils.getAdjustedSize(fontSize, -1, 1, -0.3f); return result; } /** * Returns the width of split pane divider arrow icons under the specified * font size. * * @param fontSize * Font size. * @return Width of split pane divider arrow icons under the specified font * size. */ public static float getSplitPaneArrowIconWidth(int fontSize) { float result = SubstanceSizeUtils.getArrowIconWidth(fontSize) + SubstanceSizeUtils.getAdjustedSize(fontSize, -2, 1, -0.25f); // if (result % 2 == 0) // result--; return result; } /** * Returns the offset of the first split pane divider button under the * specified font size. * * @param fontSize * Font size. * @return Offset of the first split pane divider button under the specified * font size. */ public static int getSplitPaneButtonOffset(int fontSize) { return getAdjustedSize(fontSize, 2, 3, 1, false); } /** * Returns the tabbed pane content insets under the specified size. The * {@link SubstanceConstants.TabContentPaneBorderKind#SINGLE_FULL} is * assumed. * * @param fontSize * Font size. * @return Tabbed pane content insets under the specified size. */ public static Insets getTabbedPaneContentInsets(int fontSize) { float borderStrokeWidth = getBorderStrokeWidth(fontSize); int tbIns = (int) (Math.ceil(2.5 * borderStrokeWidth)); int lrIns = (int) (Math.ceil(3.0 * borderStrokeWidth)); return new Insets(tbIns, lrIns, tbIns, lrIns); } /** * Returns the stroke width of tab close buttons under the specified size. * * @param fontSize * Font size. * @return Stroke width of tab close buttons under the specified size. */ public static float getTabCloseButtonStrokeWidth(int fontSize) { return fontSize / 10.0f; } /** * Returns the icon size of tab close buttons under the specified size. * * @param fontSize * Font size. * @return Icon size of tab close buttons under the specified size. */ public static int getTabCloseIconSize(int fontSize) { return fontSize - 2; } /** * Returns the table cell renderer insets under the specified font size. * * @param fontSize * Font size. * @return Table cell renderer insets under the specified font size. */ public static Insets getTableCellRendererInsets(int fontSize) { Insets listCellInsets = getListCellRendererInsets(fontSize); return new Insets(listCellInsets.top - 1, listCellInsets.left - 2, listCellInsets.bottom - 1, listCellInsets.right - 2); } /** * Returns the text border insets under the specified font size. * * @param fontSize * Font size. * @return Text border insets under the specified font size. */ public static Insets getTextBorderInsets(int fontSize) { // The base insets are 3,4,3,4. We add one pixel for // each 3 extra points in base control size. int tbInset = getAdjustedSize(fontSize, 3, 3, 1, false); int lrInset = getAdjustedSize(fontSize, 4, 3, 1, false); return new Insets(tbInset, lrInset, tbInset, lrInset); } /** * Returns the text button padding amount on left and right sides under the * specified font size. * * @param fontSize * Font size. * @return Text button padding amount on left and right sides under the * specified font size. */ public static int getTextButtonLRPadding(int fontSize) { return SubstanceSizeUtils.getAdjustedSize(fontSize, 3, 2, 1, false); } /** * Returns the icon size of title pane buttons under the specified size. * * @param fontSize * Font size. * @return Icon size of title pane buttons under the specified size. */ public static int getTitlePaneIconSize() { return 5 + getControlFontSize(); } /** * Returns the tool bar drag inset under the specified font size. * * @param fontSize * Font size. * @return Tool bar drag inset under the specified font size. */ public static int getToolBarDragInset(int fontSize) { return fontSize + 5; } /** * Returns the tool bar insets under the specified font size. * * @param fontSize * Font size. * @return Tool bar insets under the specified font size. */ public static Insets getToolBarInsets(int fontSize) { int lbrInset = getAdjustedSize(fontSize, 2, 3, 1, false); int tInset = getAdjustedSize(fontSize, 1, 3, 1, false); return new Insets(tInset, lbrInset, lbrInset, lbrInset); } /** * Returns the tooltip border insets under the specified font size. * * @param fontSize * Font size. * @return Tooltip border insets under the specified font size. */ public static Insets getToolTipBorderInsets(int fontSize) { // The base insets are 1,1,1,1. We add one pixel for // each 3 extra points in base control size. int inset = getAdjustedSize(fontSize, 1, 3, 1, false); return new Insets(inset, inset, inset, inset); } /** * Returns the tree cell renderer insets under the specified font size. * * @param fontSize * Font size. * @return Tree cell renderer insets under the specified font size. */ public static Insets getTreeCellRendererInsets(int fontSize) { Insets listCellInsets = getListCellRendererInsets(fontSize); return new Insets(listCellInsets.top - 1, listCellInsets.left - 2, listCellInsets.bottom - 1, listCellInsets.right - 2); } /** * Returns the icon size of tree expand / collapse icons under the specified * size. * * @param fontSize * Font size. * @return Icon size of tree expand / collapse icons under the specified * size. */ public static int getTreeIconSize(int fontSize) { int extraPadding = SubstanceSizeUtils.getExtraPadding(fontSize); int extraPadding2 = 2 * extraPadding; return 10 + extraPadding2; } /** * Returns the points to pixels ratio of the current font policy. * * @return The points to pixels ratio of the current font policy. */ public static double getPointsToPixelsRatio() { return pointsToPixelsRatio; } /** * Resets the points to pixels ratio based on the specified font policy. * * @param fontPolicy * Font policy. */ public static void resetPointsToPixelsRatio(FontPolicy fontPolicy) { if (fontPolicy instanceof DefaultGnomeFontPolicy) { pointsToPixelsRatio = DefaultGnomeFontPolicy .getPointsToPixelsRatio(); } else { pointsToPixelsRatio = Toolkit.getDefaultToolkit() .getScreenResolution() / 72.0; } } } substance-5.3.orig/src/org/jvnet/substance/utils/ModifiedFadeStep.java0000644000175000017500000000522311136475562026051 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.animation.FadeStep; /** * Non-linear fade step implementation for animating modified components. * * @author Kirill Grouchnikov */ public class ModifiedFadeStep implements FadeStep { /** * Custom fade kind for animating modified components. */ public static final FadeKind MARKED_MODIFIED_FADE_KIND = new FadeKind( "substancelaf.markedModified"); // static { //FadeConfigurationManager.getInstance().allowFades(MARKED_MODIFIED_FADE_KIND // ); // } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.utils.FadeStep#getNextStep(org.jvnet.lafwidget.utils * .FadeTracker.FadeKind, float, boolean, boolean) */ public float getNextStep(FadeKind fadeKind, float currFadePosition, boolean isFadeIn, boolean isLooping) { if (isFadeIn) { if (currFadePosition < 2.0) return 0.0025f; else return 0.07f; } else { return 0.08f; } } } substance-5.3.orig/src/org/jvnet/substance/utils/SubstanceSpinnerButton.java0000644000175000017500000001146211136475562027401 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.Component; import java.awt.Insets; import javax.swing.*; import org.jvnet.lafwidget.animation.FadeConfigurationManager; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants; import org.jvnet.substance.shaper.ClassicButtonShaper; import org.jvnet.substance.utils.border.SubstanceButtonBorder; /** * Spinner button in Substance look and feel. * * @author Kirill Grouchnikov */ @SubstanceArrowButton public class SubstanceSpinnerButton extends JButton implements Sideable { static { FadeConfigurationManager.getInstance().disallowFades( FadeKind.GHOSTING_BUTTON_PRESS, SubstanceSpinnerButton.class); FadeConfigurationManager.getInstance().disallowFades( FadeKind.GHOSTING_ICON_ROLLOVER, SubstanceSpinnerButton.class); } /** * Button orientation. */ private int orientation; /** * Simple constructor. * * @param spinner * The owner spinner. * @param orientation * The orientation of the spinner icon arrow. */ public SubstanceSpinnerButton(JSpinner spinner, final int orientation) { // super(0, 0, false); super(); // setModel(new DefaultButtonModel() { // @Override // public void setArmed(boolean armed) { // super.setArmed(isPressed() || armed); // } // }); this.setEnabled(spinner.isEnabled()); this.setFocusable(false); this.setRequestFocusEnabled(false); this.setMargin(new Insets(0, 0, 0, 2)); this.setBorder(new SubstanceButtonBorder(ClassicButtonShaper.class) { public Insets getBorderInsets(Component c) { int extraPadding = SubstanceSizeUtils .getExtraPadding(SubstanceSizeUtils .getComponentFontSize(c)); // Bring the icons closer together instead of // having them centered in the spinner buttons int deltaTop = (orientation == SwingConstants.NORTH) ? 2 : 0; int deltaBottom = (orientation == SwingConstants.NORTH) ? 0 : 2; return new Insets(extraPadding + deltaTop, extraPadding, extraPadding + deltaBottom, extraPadding); } }); this.orientation = orientation; this.putClientProperty(SubstanceLookAndFeel.USE_THEMED_DEFAULT_ICONS, Boolean.FALSE); } /* * (non-Javadoc) * * @see java.awt.Component#isFocusable() */ @Override public boolean isFocusable() { return false; } /* * (non-Javadoc) * * @see org.jvnet.substance.utils.Sideable#getSide() */ public SubstanceConstants.Side getSide() { switch (this.orientation) { case SwingConstants.NORTH: return SubstanceConstants.Side.BOTTOM; case SwingConstants.WEST: return SubstanceConstants.Side.RIGHT; case SwingConstants.SOUTH: return SubstanceConstants.Side.TOP; case SwingConstants.EAST: return SubstanceConstants.Side.LEFT; default: return null; } } // // @Override // public void paint(Graphics g) { // super.paint(g); // Color c = "Spinner.nextButton".equals(this.getName()) ? Color.red // : Color.green.darker(); // g.setColor(c); // g.drawRect(0, 0, getWidth() - 1, getHeight() - 1); // } } substance-5.3.orig/src/org/jvnet/substance/utils/HashMapKey.java0000644000175000017500000000502111136475562024703 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.util.Arrays; /** * Implementation of a key for the {@link LazyResettableHashMap}. * * @author Kirill Grouchnikov */ public class HashMapKey { /** * Fields that represent this key object. */ private Object[] keyFields; /** * Creates a new key object. * * @param fields * Fields of the key object. */ public HashMapKey(Object... fields) { this.keyFields = fields; } /* * (non-Javadoc) * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { return Arrays.deepHashCode(this.keyFields); } /* * (non-Javadoc) * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (!(obj instanceof HashMapKey)) return false; HashMapKey key2 = (HashMapKey) obj; return Arrays.equals(this.keyFields, key2.keyFields); } } substance-5.3.orig/src/org/jvnet/substance/utils/PairwiseButtonBackgroundDelegate.java0000644000175000017500000003265411136475562031337 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.utils; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.AffineTransform; import java.awt.geom.GeneralPath; import java.awt.image.BufferedImage; import java.util.EnumSet; import java.util.Set; import javax.swing.AbstractButton; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.*; import org.jvnet.substance.api.SubstanceConstants.Side; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; /** * Delegate class for painting backgrounds of buttons in Substance look * and feel. This class is for internal use only. * * @author Kirill Grouchnikov */ public class PairwiseButtonBackgroundDelegate { /** * Cache for background images for pairwise backgrounds. Each time * {@link #getPairwiseBackground(AbstractButton, int, int, Side)} is called, * it checks this map to see if it already contains such * background. If so, the background from the map is returned. */ private static LazyResettableHashMap pairwiseBackgrounds = new LazyResettableHashMap( "PairwiseButtonBackgroundDelegate"); /** * Paints background image for the specified button in button pair (such as * scrollbar arrows, for example). * * @param g * Graphics context. * @param button * Button. * @param painter * Gradient painter. * @param width * Button width. * @param height * Button height. * @param side * Button orientation. * @param toIgnoreOpenSides * If true, the open side setting (controlled by the * {@link SubstanceLookAndFeel#BUTTON_OPEN_SIDE_PROPERTY} is * ignored. */ public static void updatePairwiseBackground(Graphics g, AbstractButton button, int width, int height, SubstanceConstants.Side side, boolean toIgnoreOpenSides) { if (SubstanceCoreUtilities.isButtonNeverPainted(button)) return; BufferedImage resultNonFlat = null; ComponentState state = ComponentState.getState(button); ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(button); float cyclePos = state.getCyclePosition(); SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, state); SubstanceColorScheme colorScheme2 = colorScheme; SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.BORDER, state); SubstanceColorScheme borderScheme2 = borderScheme; FadeTracker fadeTracker = FadeTracker.getInstance(); FadeState fadeState = fadeTracker.getFadeState(button, FadeKind.ROLLOVER); if (fadeState != null) { colorScheme = SubstanceColorSchemeUtilities.getColorScheme(button, prevState); colorScheme2 = SubstanceColorSchemeUtilities.getColorScheme(button, state); borderScheme = SubstanceColorSchemeUtilities.getColorScheme(button, ColorSchemeAssociationKind.BORDER, prevState); borderScheme2 = SubstanceColorSchemeUtilities.getColorScheme( button, ColorSchemeAssociationKind.BORDER, state); cyclePos = fadeState.getFadePosition(); if (!fadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; BufferedImage imageDefault = getPairwiseFullAlphaBackground( button, SubstanceImageCreator.SimplisticSoftBorderReverseGradientPainter.INSTANCE, width, height, side, cyclePos, colorScheme, colorScheme2, borderScheme, borderScheme2, toIgnoreOpenSides); if (imageDefault == null) return; resultNonFlat = imageDefault; } else { resultNonFlat = getPairwiseFullAlphaBackground( button, SubstanceImageCreator.SimplisticSoftBorderReverseGradientPainter.INSTANCE, width, height, side, 0, colorScheme, colorScheme2, borderScheme, borderScheme2, toIgnoreOpenSides); } boolean isFlat = SubstanceCoreUtilities.hasFlatAppearance(button); boolean isSpecial = isFlat || !state.isKindActive(FadeKind.ENABLE); float extraAlpha = 1.0f; if (isSpecial) { if (isFlat) { // Special handling of flat buttons if (FadeTracker.getInstance().isTracked(button, FadeKind.ROLLOVER) && !state.isKindActive(FadeKind.SELECTION) && state.isKindActive(FadeKind.ENABLE)) { extraAlpha = FadeTracker.getInstance().getFade(button, FadeKind.ROLLOVER); } else { if (state == ComponentState.DEFAULT) { // flat button in default state and not // participating in rollover animation extraAlpha = 0.0f; } } if (state == ComponentState.DISABLED_UNSELECTED) extraAlpha = 0.0f; } else { if (!state.isKindActive(FadeKind.ENABLE)) { extraAlpha = SubstanceColorSchemeUtilities.getAlpha(button, state); } } } if (extraAlpha > 0.0f) { Graphics2D graphics = (Graphics2D) g.create(); graphics.setComposite(TransitionLayout.getAlphaComposite(button, extraAlpha, g)); graphics.drawImage(resultNonFlat, 0, 0, null); graphics.dispose(); } } /** * Retrieves background image for the specified button in button pair (such * as scrollbar arrows, for example). * * @param button * Button. * @param kind * Color scheme kind. * @param painter * Gradient painter. * @param width * Button width. * @param height * Button height. * @param side * Button orientation. * @param cyclePos * Cycle position. * @param colorScheme * The first color scheme. * @param colorScheme2 * The second color scheme. * @param borderScheme * The first border color scheme. * @param borderScheme2 * The second border color scheme. * @param graphicsComposite * Composite to apply before painting the button. * @param toIgnoreOpenSides * If true, the open side setting (controlled by the * {@link SubstanceLookAndFeel#BUTTON_OPEN_SIDE_PROPERTY} is * ignored. * @return Button background image. */ private static BufferedImage getPairwiseFullAlphaBackground( AbstractButton button, SubstanceGradientPainter painter, int width, int height, SubstanceConstants.Side side, float cyclePos, SubstanceColorScheme colorScheme, SubstanceColorScheme colorScheme2, SubstanceColorScheme borderScheme, SubstanceColorScheme borderScheme2, boolean toIgnoreOpenSides) { if (SubstanceCoreUtilities.isButtonNeverPainted(button)) return null; Set openSides = toIgnoreOpenSides ? EnumSet.noneOf(Side.class) : SubstanceCoreUtilities.getSides(button, SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY); String openKey = ""; for (Side oSide : openSides) { openKey += oSide.name() + "-"; } boolean noBorder = SubstanceCoreUtilities.isSpinnerButton(button); // && !button.getParent().isEnabled(); String sideKey = (side == null) ? "null" : side.toString(); HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height, sideKey, cyclePos, openKey, colorScheme.getDisplayName(), colorScheme2.getDisplayName(), borderScheme.getDisplayName(), borderScheme2.getDisplayName(), button.getClass().getName(), painter.getDisplayName(), noBorder); // System.out.println("\tKey " + key); if (!pairwiseBackgrounds.containsKey(key)) { // System.out.println("\tNot found"); // buttons will be rectangular to make two scrolls (horizontal // and vertical) touch the corners. int radius = 0; int deltaLeft = openSides.contains(Side.LEFT) ? 3 : 0; int deltaRight = openSides.contains(Side.RIGHT) ? 3 : 0; int deltaTop = openSides.contains(Side.TOP) ? 3 : 0; int deltaBottom = openSides.contains(Side.BOTTOM) ? 3 : 0; // if ((side == Side.TOP) || (side == Side.BOTTOM)) { // int temp = deltaLeft; // deltaLeft = deltaBottom; // deltaBottom = deltaRight; // deltaRight = deltaTop; // deltaTop = temp; // } // System.out.println(button.getName() + ":" + deltaLeft + ":" + // deltaRight + ":" + deltaTop + ":" + deltaBottom); GeneralPath contour = null; // SubstanceGradientPainter painter = new StandardGradientPainter(); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(button); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(button)) / 2.0); BufferedImage finalBackground = SubstanceCoreUtilities .getBlankImage(width, height); Graphics2D finalGraphics = (Graphics2D) finalBackground .getGraphics(); // finalGraphics.setColor(Color.red); // finalGraphics.fillRect(0, 0, width, height); finalGraphics.translate(-deltaLeft, -deltaTop); if (side != null) { switch (side) { case TOP: case BOTTOM: // rotate by 90% for better visuals contour = SubstanceOutlineUtilities.getBaseOutline(height + deltaTop + deltaBottom, width + deltaLeft + deltaRight, radius, null, borderDelta); int translateY = height; if (SubstanceCoreUtilities.isScrollButton(button)) { translateY += (1 + ((side == SubstanceConstants.Side.BOTTOM) ? 1 : -2)); } AffineTransform at = AffineTransform.getTranslateInstance( 0, translateY); at.rotate(-Math.PI / 2); finalGraphics.setTransform(at); painter.paintContourBackground(finalGraphics, button, height + deltaTop + deltaBottom, width + deltaLeft + deltaRight, contour, false, colorScheme, colorScheme2, cyclePos, true, colorScheme != colorScheme2); if (!noBorder) { borderPainter.paintBorder(finalGraphics, button, height + deltaTop + deltaBottom, width + deltaLeft + deltaRight, contour, null, borderScheme, borderScheme2, cyclePos, borderScheme != borderScheme2); } break; case RIGHT: case LEFT: // arrow in horizontal bar contour = SubstanceOutlineUtilities.getBaseOutline(width + deltaLeft + deltaRight, height + deltaTop + deltaBottom, radius, null, borderDelta); painter.paintContourBackground(finalGraphics, button, width + deltaLeft + deltaRight, height + deltaTop + deltaBottom, contour, false, colorScheme, colorScheme2, cyclePos, true, colorScheme != colorScheme2); if (!noBorder) { borderPainter.paintBorder(finalGraphics, button, width + deltaLeft + deltaRight, height + deltaTop + deltaBottom, contour, null, borderScheme, borderScheme2, cyclePos, borderScheme != borderScheme2); } break; } } else { contour = SubstanceOutlineUtilities.getBaseOutline(width + deltaLeft + deltaRight, height + deltaTop + deltaBottom, radius, null, borderDelta); painter.paintContourBackground(finalGraphics, button, width + deltaLeft + deltaRight, height + deltaTop + deltaBottom, contour, false, colorScheme, colorScheme2, cyclePos, true, colorScheme != colorScheme2); if (!noBorder) { borderPainter.paintBorder(finalGraphics, button, width + deltaLeft + deltaRight, height + deltaTop + deltaBottom, contour, null, borderScheme, borderScheme2, cyclePos, borderScheme != borderScheme2); } } // System.out.println("\tCreated new background " + width + ":" + // height); pairwiseBackgrounds.put(key, finalBackground); } BufferedImage opaque = pairwiseBackgrounds.get(key); return opaque; } } substance-5.3.orig/src/org/jvnet/substance/SubstanceOptionPaneUI.java0000644000175000017500000001335311245202246025726 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import javax.swing.*; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicOptionPaneUI; import org.jvnet.lafwidget.LafWidgetUtilities; import org.jvnet.lafwidget.animation.*; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.icon.GlowingIcon; /** * UI for option panes in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceOptionPaneUI extends BasicOptionPaneUI { static { FadeConfigurationManager.getInstance().allowFades(FadeKind.ICON_GLOW, OptionPaneLabel.class); } /** * Label extension class. Due to defect 250, the option pane icon animation * (glowing icon) should repaint only the icon itself and not the entire * option pane. While the FadeConfigurationManager API provides an option to * enable animations on the specific component, it's better to enable it on * the component class (to make the lookups faster). So, when the option * pane icon label is created (in addIcon method), we use this class. * * @author Kirill Grouchnikov */ protected static class OptionPaneLabel extends JLabel { } /** * Icon label. */ private OptionPaneLabel substanceIconLabel; /** * Creates a new SubstanceOptionPaneUI instance. */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceOptionPaneUI(); } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#paint(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void paint(Graphics g, JComponent c) { BackgroundPaintingUtils.updateIfOpaque(g, c); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicOptionPaneUI#addIcon(java.awt.Container) */ @Override protected void addIcon(Container top) { Icon sideIcon = (optionPane == null ? null : optionPane.getIcon()); if (sideIcon == null && optionPane != null) sideIcon = super.getIconForType(optionPane.getMessageType()); if (sideIcon != null) { if (!SubstanceLookAndFeel.isToUseConstantThemesOnDialogs()) { sideIcon = SubstanceCoreUtilities.getThemedIcon(null, sideIcon); } substanceIconLabel = new OptionPaneLabel(); substanceIconLabel.setIcon(new GlowingIcon(sideIcon, substanceIconLabel)); substanceIconLabel.setName("OptionPane.iconLabel"); substanceIconLabel.setVerticalAlignment(SwingConstants.TOP); top.add(substanceIconLabel, BorderLayout.BEFORE_LINE_BEGINS); } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicOptionPaneUI#getIconForType(int) */ @Override protected Icon getIconForType(int messageType) { switch (messageType) { case JOptionPane.ERROR_MESSAGE: return SubstanceCoreUtilities .getIcon("resource/32/dialog-error.png"); case JOptionPane.INFORMATION_MESSAGE: return SubstanceCoreUtilities .getIcon("resource/32/dialog-information.png"); case JOptionPane.WARNING_MESSAGE: return SubstanceCoreUtilities .getIcon("resource/32/dialog-warning.png"); case JOptionPane.QUESTION_MESSAGE: return SubstanceCoreUtilities .getIcon("resource/32/help-browser.png"); } return null; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicOptionPaneUI#installComponents() */ @Override protected void installComponents() { super.installComponents(); // fix for defect 265 - check that the label is not null // before activating the loop. if (this.substanceIconLabel != null) { // Make the icon glow for three cycles. There's no need to // explicitly cancel the animation when the option pane is closed // before the animation is over - when the three cycles are up, // the animation will be removed by the tracker. FadeTracker.getInstance().trackFadeLooping( FadeKind.ICON_GLOW, LafWidgetUtilities.getAnimationKind(this.optionPane) .derive(0.1f), this.substanceIconLabel, null, false, null, 3, true); } } } substance-5.3.orig/src/org/jvnet/substance/SubstanceToggleButtonUI.java0000644000175000017500000004016511162715420026271 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.*; import javax.swing.text.View; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.shaper.SubstanceButtonShaper; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.border.SubstanceButtonBorder; import org.jvnet.substance.utils.icon.GlowingIcon; /** * UI for toggle buttons in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceToggleButtonUI extends BasicToggleButtonUI { /** * Painting delegate. */ private ButtonBackgroundDelegate delegate; /** * The matching glowing icon. Is used only when * {@link FadeConfigurationManager#fadeAllowed(FadeKind, Component)} returns * true on {@link FadeKind#ICON_GLOW}. */ protected GlowingIcon glowingIcon; /** * Property change listener. Listens on changes to the * {@link SubstanceLookAndFeel#BUTTON_SHAPER_PROPERTY} property and * {@link AbstractButton#MODEL_CHANGED_PROPERTY} property. */ protected PropertyChangeListener substancePropertyListener; /** * Tracker for visual state transitions. */ protected ButtonVisualStateTracker substanceVisualStateTracker; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceToggleButtonUI(); } /** * Simple constructor. */ public SubstanceToggleButtonUI() { this.delegate = new ButtonBackgroundDelegate(); } /* * (non-Javadoc) * * @seejavax.swing.plaf.basic.BasicButtonUI#installDefaults(javax.swing. * AbstractButton) */ @Override public void installDefaults(AbstractButton b) { super.installDefaults(b); if (b.getClientProperty(SubstanceButtonUI.BORDER_ORIGINAL) == null) b.putClientProperty(SubstanceButtonUI.BORDER_ORIGINAL, b .getBorder()); if (b.getClientProperty(SubstanceButtonUI.BORDER_ORIGINAL) == null) b.putClientProperty(SubstanceButtonUI.BORDER_ORIGINAL, b .getBorder()); trackGlowingIcon(b); SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(b); if (b.getClientProperty(SubstanceButtonUI.BORDER_COMPUTED) == null) { b.setBorder(shaper.getButtonBorder(b)); } else { Border currBorder = b.getBorder(); if (!(currBorder instanceof SubstanceButtonBorder)) { b.setBorder(shaper.getButtonBorder(b)); } else { SubstanceButtonBorder sbCurrBorder = (SubstanceButtonBorder) currBorder; if (shaper.getClass() != sbCurrBorder.getButtonShaperClass()) b.setBorder(shaper.getButtonBorder(b)); } } b.putClientProperty(SubstanceButtonUI.OPACITY_ORIGINAL, b.isOpaque()); // fix for defect 140 b.setOpaque(false); b.setRolloverEnabled(true); LookAndFeel.installProperty(b, "iconTextGap", SubstanceSizeUtils .getTextIconGap(SubstanceSizeUtils.getComponentFontSize(b))); } /* * (non-Javadoc) * * @seejavax.swing.plaf.basic.BasicButtonUI#uninstallDefaults(javax.swing. * AbstractButton) */ @Override public void uninstallDefaults(AbstractButton b) { super.uninstallDefaults(b); b.setBorder((Border) b .getClientProperty(SubstanceButtonUI.BORDER_ORIGINAL)); b.setOpaque((Boolean) b .getClientProperty(SubstanceButtonUI.OPACITY_ORIGINAL)); b.putClientProperty(SubstanceButtonUI.OPACITY_ORIGINAL, null); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicButtonUI#createButtonListener(javax.swing * .AbstractButton) */ @Override protected BasicButtonListener createButtonListener(AbstractButton b) { return null; } /* * (non-Javadoc) * * @seejavax.swing.plaf.basic.BasicButtonUI#installListeners(javax.swing. * AbstractButton) */ @Override protected void installListeners(final AbstractButton b) { super.installListeners(b); this.substanceVisualStateTracker = new ButtonVisualStateTracker(); this.substanceVisualStateTracker.installListeners(b, true); // ButtonVisualStateTracker.track(b, true); // this.substanceButtonListener = new RolloverButtonListener(b); // b.addMouseListener(this.substanceButtonListener); // b.addMouseMotionListener(this.substanceButtonListener); // b.addFocusListener(this.substanceButtonListener); // b.addPropertyChangeListener(this.substanceButtonListener); // b.addChangeListener(this.substanceButtonListener); this.substancePropertyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { // if (AbstractButton.MODEL_CHANGED_PROPERTY.equals(evt // .getPropertyName())) { // if (substanceFadeStateListener != null) // substanceFadeStateListener.unregisterListeners(); // substanceFadeStateListener = new FadeStateListener(b, b // .getModel(), SubstanceCoreUtilities // .getFadeCallback(b, false)); // substanceFadeStateListener.registerListeners(); // } if (AbstractButton.ICON_CHANGED_PROPERTY.equals(evt .getPropertyName())) { trackGlowingIcon(b); } } }; b.addPropertyChangeListener(this.substancePropertyListener); // this.substanceFadeStateListener = new FadeStateListener(b, // b.getModel(), SubstanceCoreUtilities.getFadeCallback(b, false)); // this.substanceFadeStateListener.registerListeners(); } /* * (non-Javadoc) * * @seejavax.swing.plaf.basic.BasicButtonUI#uninstallListeners(javax.swing. * AbstractButton) */ @Override protected void uninstallListeners(AbstractButton b) { this.substanceVisualStateTracker.uninstallListeners(b); this.substanceVisualStateTracker = null; // ButtonVisualStateTracker.untrack(b); // b.removeMouseListener(this.substanceButtonListener); // b.removeMouseMotionListener(this.substanceButtonListener); // b.removeFocusListener(this.substanceButtonListener); // b.removePropertyChangeListener(this.substanceButtonListener); // b.removeChangeListener(this.substanceButtonListener); // this.substanceButtonListener = null; b.removePropertyChangeListener(this.substancePropertyListener); this.substancePropertyListener = null; // this.substanceFadeStateListener.unregisterListeners(); // this.substanceFadeStateListener = null; super.uninstallListeners(b); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicToggleButtonUI#paint(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void paint(Graphics g, JComponent c) { // final AbstractButton b = (AbstractButton) c; // // SubstanceTextPainter textPainter = SubstanceLookAndFeel // .getCurrentTextPainter(); // textPainter.init(b, null, false); // if (textPainter.needsBackgroundImage()) { // textPainter.setBackgroundFill(b, b.getParent().getBackground(), // true, 0, 0); // textPainter // .attachCallback(new SubstanceTextPainter.BackgroundPaintingCallback() // { // public void paintBackground(Graphics g) { // delegate.updateBackground(g, b); // }; // }); // } else { // this.delegate.updateBackground(g, b); // } // // FontMetrics fm = g.getFontMetrics(); // // Insets i = c.getInsets(); // // Rectangle viewRect = new Rectangle(); // Rectangle iconRect = new Rectangle(); // Rectangle textRect = new Rectangle(); // // viewRect.x = i.left; // viewRect.y = i.top; // viewRect.width = b.getWidth() - (i.right + viewRect.x); // viewRect.height = b.getHeight() - (i.bottom + viewRect.y); // // textRect.x = textRect.y = textRect.width = textRect.height = 0; // iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0; // // Font f = c.getFont(); // g.setFont(f); // // // layout the text and icon // String text = SwingUtilities.layoutCompoundLabel(c, fm, b.getText(), // b // .getIcon(), b.getVerticalAlignment(), b // .getHorizontalAlignment(), b.getVerticalTextPosition(), b // .getHorizontalTextPosition(), viewRect, iconRect, textRect, b // .getText() == null ? 0 : b.getIconTextGap()); // // View v = (View) c.getClientProperty(BasicHTML.propertyKey); // if (v != null) { // v.paint(g, textRect); // } else { // float alpha = this.paintButtonText(g, b, textRect, text); // Graphics2D g2d = (Graphics2D) g.create(); // g2d.setComposite(TransitionLayout.getAlphaComposite(b, alpha, g)); // textPainter.renderSurface(g2d); // g2d.dispose(); // } // // // Paint the Icon // if (b.getIcon() != null) { // paintIcon(g, c, iconRect); // } // // if (b.isFocusPainted()) { // if (b.hasFocus() // || FadeTracker.getInstance().isTracked(c, FadeKind.FOCUS)) { // this.paintFocus(g, b, viewRect, textRect, iconRect); // } // } final AbstractButton b = (AbstractButton) c; if (b instanceof JButton) { JButton jb = (JButton) b; if (PulseTracker.isPulsating(jb)) { PulseTracker.update(jb); } else { } } FontMetrics fm = g.getFontMetrics(); Insets i = c.getInsets(); Rectangle viewRect = new Rectangle(); Rectangle iconRect = new Rectangle(); final Rectangle textRect = new Rectangle(); viewRect.x = i.left; viewRect.y = i.top; viewRect.width = b.getWidth() - (i.right + viewRect.x); viewRect.height = b.getHeight() - (i.bottom + viewRect.y); textRect.x = textRect.y = textRect.width = textRect.height = 0; iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0; Font f = c.getFont(); // layout the text and icon String text = SwingUtilities.layoutCompoundLabel(c, fm, b.getText(), b .getIcon(), b.getVerticalAlignment(), b .getHorizontalAlignment(), b.getVerticalTextPosition(), b .getHorizontalTextPosition(), viewRect, iconRect, textRect, b .getText() == null ? 0 : b.getIconTextGap()); Graphics2D g2d = (Graphics2D) g.create(); View v = (View) c.getClientProperty(BasicHTML.propertyKey); g2d.setFont(f); this.delegate.updateBackground(g2d, b); if (v != null) { v.paint(g2d, textRect); } else { this.paintButtonText(g2d, b, textRect, text); } // Paint the Icon if (b.getIcon() != null) { paintIcon(g2d, b, iconRect); } if (b.isFocusPainted()) { if (b.hasFocus() || FadeTracker.getInstance().isTracked(c, FadeKind.FOCUS)) { this.paintFocus(g2d, b, viewRect, textRect, iconRect); } } } /* * (non-Javadoc) * * @see * javax.swing.plaf.ComponentUI#getPreferredSize(javax.swing.JComponent) */ @Override public Dimension getPreferredSize(JComponent c) { AbstractButton button = (AbstractButton) c; SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(button); // fix for defect 263 Dimension superPref = super.getPreferredSize(button); if (superPref == null) return null; if (shaper == null) return superPref; return shaper.getPreferredSize(button, superPref); } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#contains(javax.swing.JComponent, int, * int) */ @Override public boolean contains(JComponent c, int x, int y) { return ButtonBackgroundDelegate.contains((JToggleButton) c, x, y); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicButtonUI#paintFocus(java.awt.Graphics, * javax.swing.AbstractButton, java.awt.Rectangle, java.awt.Rectangle, * java.awt.Rectangle) */ @Override protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) { if (!b.isFocusPainted()) return; SubstanceCoreUtilities.paintFocus(g, b, b, null, textRect, 1.0f, SubstanceSizeUtils.getFocusRingPadding(SubstanceSizeUtils .getComponentFontSize(b))); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicToggleButtonUI#paintIcon(java.awt.Graphics, * javax.swing.AbstractButton, java.awt.Rectangle) */ @Override protected void paintIcon(Graphics g, AbstractButton b, Rectangle iconRect) { Graphics2D graphics = (Graphics2D) g.create(); FadeTracker fadeTracker = FadeTracker.getInstance(); Icon icon = SubstanceCoreUtilities.getIcon(b, null, this.glowingIcon, false); graphics.setComposite(TransitionLayout.getAlphaComposite(b, g)); if (fadeTracker.isTracked(b, FadeKind.ROLLOVER)) { ComponentState state = ComponentState.getState(b); // System.out.println(state.name() + ":" + state.isRollover()); if (state.isKindActive(FadeKind.ROLLOVER)) {// == // ComponentState.ROLLOVER_UNSELECTED) { // Came from default state SubstanceCoreUtilities.getIcon(b, null, this.glowingIcon, true) .paintIcon(b, graphics, iconRect.x, iconRect.y); graphics.setComposite(TransitionLayout.getAlphaComposite(b, fadeTracker.getFade(b, FadeKind.ROLLOVER), g)); icon.paintIcon(b, graphics, iconRect.x, iconRect.y); } else { // if (state == ComponentState.DEFAULT) { // Came from rollover state icon.paintIcon(b, graphics, iconRect.x, iconRect.y); graphics.setComposite(TransitionLayout.getAlphaComposite(b, fadeTracker.getFade(b, FadeKind.ROLLOVER), g)); b.getIcon().paintIcon(b, graphics, iconRect.x, iconRect.y); } } else { icon.paintIcon(b, graphics, iconRect.x, iconRect.y); } graphics.dispose(); } /** * Paints the text. * * @param g * Graphic context * @param button * Button * @param textRect * Text rectangle * @param text * Text to paint */ protected void paintButtonText(Graphics g, AbstractButton button, Rectangle textRect, String text) { SubstanceTextUtilities.paintText(g, button, textRect, text, (button) .getDisplayedMnemonicIndex()); } /** * Tracks possible usage of glowing icon. * * @param b * Button. */ protected void trackGlowingIcon(AbstractButton b) { Icon currIcon = b.getIcon(); if (currIcon instanceof GlowingIcon) return; if (currIcon == null) return; this.glowingIcon = new GlowingIcon(currIcon, b); } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void update(Graphics g, JComponent c) { this.paint(g, c); } }substance-5.3.orig/src/org/jvnet/substance/fonts/0000755000175000017500000000000011256731150022030 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/fonts/DefaultKDEFontPolicy.java0000644000175000017500000002440111136475562026624 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.fonts; import java.awt.Font; import java.io.*; import java.util.regex.Pattern; import javax.swing.UIDefaults; /** * The default font policy for KDE desktops. * * @author Paranoid */ public class DefaultKDEFontPolicy implements FontPolicy { /** * method to check if current user session is KDE * * @return {@Code true} if KDE session is currently running. */ public static boolean isKDERunning() { // KDE_FULL_SESSION=true return "true".equals(System.getenv("KDE_FULL_SESSION")); } /** * Checks for KDE4 flags in current env. There are few possible flags:
* {@code KDE_SESSION_VERSION=4
DESKTOP_SESSION=kde4
} If distro * for some readon don't set this flags - KDE3 is possibli * running.

* * There is one more way to determine current KDE version. We can run * {@code "konsole --version"} command and parse output, but KDE3 don't have * own env flags, so this command will run every time we using KDE3. * * @return {@code true} if KDE4 env flags found, {@code false} otherwise. */ private static boolean isKDE4Running() { if (!isKDERunning()) { throw new IllegalStateException("KDE is not running"); } return "4".equals(System.getenv("KDE_SESSION_VERSION")) || "kde4".equals(System.getenv("DESKTOP_SESSION")); } private static final String SANS_SERIF = "SansSerif"; private static FontSet fontSet = null; public synchronized FontSet getFontSet(String lafName, UIDefaults table) { if (fontSet == null) { fontSet = getInternalFontSet(lafName, table); } return fontSet; } private FontSet getInternalFontSet(String lafName, UIDefaults table) { // size is the most important, then family and then style int commonSize = 10; int menuSize = 10; int titleSize = 10; int commonStyle = Font.PLAIN; int menuStyle = Font.PLAIN; int titleStyle = Font.BOLD; String commonFamily = SANS_SERIF; String menuFamily = SANS_SERIF; String titleFamily = SANS_SERIF; // size is the most important, then family and then style /* * KDE4 can set common, menu, small and window title, while KDE3 can set * only common, menu and window title. But in KDE4 config files small * font is named "smallestReadableFont" */ // try { String kdeglobals = getFileContent("kdeglobals"); Pattern pattern = Pattern.compile(","); try { String fontParam = getIniParam(kdeglobals, "[General]", "font"); String[] fontParams = pattern.split(fontParam); commonFamily = fontParams[0]; commonSize = Integer.parseInt(fontParams[1]); boolean bold = "75".equals(fontParams[4]); boolean italic = "1".equals(fontParams[5]); if (bold && italic) { commonStyle = Font.BOLD + Font.ITALIC; } else if (italic) { commonStyle = Font.ITALIC; } else if (bold) { commonStyle = Font.BOLD; } else { commonStyle = Font.PLAIN; } } catch (Exception commonReadException) { commonFamily = SANS_SERIF; commonSize = 10; commonStyle = Font.PLAIN; } try { String menuFontParam = getIniParam(kdeglobals, "[General]", "menuFont"); String[] menuFontParams = pattern.split(menuFontParam); menuFamily = menuFontParams[0]; menuSize = Integer.parseInt(menuFontParams[1]); boolean bold = "75".equals(menuFontParams[4]); boolean italic = "1".equals(menuFontParams[5]); if (bold && italic) { menuStyle = Font.BOLD + Font.ITALIC; } else if (italic) { menuStyle = Font.ITALIC; } else if (bold) { menuStyle = Font.BOLD; } else { menuStyle = Font.PLAIN; } } catch (Exception menuReadException) { menuFamily = SANS_SERIF; menuSize = 10; menuStyle = Font.PLAIN; } try { String activeFontParam = getIniParam(kdeglobals, "[WM]", "activeFont"); String[] activeFontParams = pattern.split(activeFontParam); titleFamily = activeFontParams[0]; titleSize = Integer.parseInt(activeFontParams[1]); boolean bold = "75".equals(activeFontParams[4]); boolean italic = "1".equals(activeFontParams[5]); if (bold && italic) { titleStyle = Font.BOLD + Font.ITALIC; } else if (italic) { titleStyle = Font.ITALIC; } else if (bold) { titleStyle = Font.BOLD; } else { titleStyle = Font.PLAIN; } } catch (Exception titleReadException) { titleFamily = SANS_SERIF; titleSize = 10; titleStyle = Font.BOLD; } } catch (Exception kdeglobalsReadException) { commonFamily = SANS_SERIF; commonSize = 10; commonStyle = Font.PLAIN; menuFamily = SANS_SERIF; menuSize = 10; menuStyle = Font.PLAIN; titleFamily = SANS_SERIF; titleSize = 10; titleStyle = Font.BOLD; } // // double dcommonSize = commonSize; double dmenuSize = menuSize; double dtitleSize = titleSize; int dpi; try { String dpiParam = getIniParam(getFileContent("kcmfonts"), "[General]", "forceFontDPI"); dpi = Integer.parseInt(dpiParam); } catch (Exception dpiReadException) { dpi = 96; } // kcmfonts common for both KDE3 and KDE4 if (dpi <= 0) { dpi = 96; } if (dpi < 50) { dpi = 50; } dcommonSize = ((commonSize * dpi) / 72.0); dmenuSize = ((menuSize * dpi) / 72.0); dtitleSize = ((titleSize * dpi) / 72.0); commonSize = (int) (dcommonSize + 0.5); if (commonSize < 1) { commonSize = 1; } menuSize = (int) (dmenuSize + 0.5); if (menuSize < 1) { menuSize = 1; } titleSize = (int) (dtitleSize + 0.5); if (titleSize < 1) { titleSize = 1; } // Font commonFont = new Font(commonFamily, commonStyle, commonSize); Font menuFont = new Font(menuFamily, menuStyle, menuSize); Font titleFont = new Font(titleFamily, titleStyle, titleSize); return FontSets.createDefaultFontSet(commonFont, menuFont, commonFont, commonFont, commonFont, titleFont); } private String getIniParam(String content, String category, String param) throws Exception { // checking if our param in our category - we don't need same params // from other categories int categoryIndex = content.indexOf(category); int nextCategoryIndex = content.indexOf('[', categoryIndex + 1); if (nextCategoryIndex < 0) { nextCategoryIndex = content.length(); } int paramIndex = content.indexOf(param, categoryIndex); if (paramIndex >= 0 && paramIndex < nextCategoryIndex) { // now paramString contains full string of our parameter int lineEnd = content.indexOf(System.getProperty("line.separator"), paramIndex); if (lineEnd <= 0) { lineEnd = content.length(); } String paramString = content.substring(paramIndex, lineEnd); // getting just our value, we don't need other symbols int equalityIndex = paramString.indexOf('='); /* * paramString.indexOf('#'); paramString.indexOf(';'); * * don't know do we need to remove trailing comments after this * symbols? have nothing similar in my system... */ String result = paramString.substring(equalityIndex + 1).trim(); if (result.length() > 0) { return result; } } throw new Exception("No such param in current category"); } private String getFileContent(String fileName) throws IOException { /* * preparing KDE home folder. KDE4 may be stored in .kde4 folder, and * may be in .kde. * * we check for .kde4 folder, if it exists - we will use it. Otherwise * we will left kdeHome empty, and it will be set to .kde in both cases * of KDE3 and KDE4 with .kde folder. */ String userHome = System.getProperty("user.home"); String kdeHome = null; if (isKDE4Running()) { File kdeHomeFolder = new File(userHome, ".kde4"); if (kdeHomeFolder.exists()) { kdeHome = ".kde4"; } } if (kdeHome == null) { kdeHome = ".kde"; } char fs = File.separatorChar; fileName = userHome + fs + kdeHome + "/share/config/" + fileName; if (fs != '/') { fileName = fileName.replace('/', fs); } // creating file from user home, using system's file separator: BufferedReader in = new BufferedReader(new FileReader(fileName)); StringBuilder sb = new StringBuilder(); // size same as inside BufferedReader code char[] buffer = new char[8192]; int read = 0; while ((read = in.read(buffer)) >= 0) { sb.append(buffer, 0, read); } in.close(); return sb.toString(); } } substance-5.3.orig/src/org/jvnet/substance/fonts/FontPolicy.java0000644000175000017500000000544711126425524024774 0ustar drazzibdrazzib/* * Copyright (c) 2001-2006 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.fonts; import javax.swing.UIDefaults; /** * Looks up and returns a FontSet. * * @author Karsten Lentzsch * @version $Revision: 1.2 $ * * @see FontSet * @see FontPolicies * * @since 2.0 */ public interface FontPolicy { /** * Looks up and returns a set of fonts that will be used by a Look&Feel * to set the default fonts for its components. *

* * This method is invoked during the L&F component initialization. And * the invoker hands over the UIDefaults object used to define the component * settings. Hence, the UIDefaults object may be used to look up a font as * initialized by a super Look&Feel. For example the JGoodies Windows * L&F could use the defaults set by the super L&F, the Sun Windows * L&F. * * @param lafName * the name of the Look&Feel that requests the fonts * @param table * the UIDefaults table that can be used to look up fonts of a * super L&F * * @return a set of fonts used as default for the component. */ FontSet getFontSet(String lafName, UIDefaults table); } substance-5.3.orig/src/org/jvnet/substance/fonts/SubstanceFontUtilities.java0000644000175000017500000001731011146543652027355 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.fonts; import java.awt.Font; import java.security.AccessController; import java.security.PrivilegedAction; import javax.swing.UIDefaults; import javax.swing.plaf.FontUIResource; import org.jvnet.lafwidget.utils.LookUtils; import org.jvnet.substance.utils.SubstanceSizeUtils; /** * Font-related utilities. * * @author Kirill Grouchnikov */ public class SubstanceFontUtilities { /** * Font set implementation for Substance. This is used to make the window * title font bold. * * @author Kirill Grouchnikov */ private static class SubstanceFontSet implements FontSet { /** * The default system font set. */ private FontSet systemFontSet; /** * Creates a new font set for Substance. * * @param systemFontSet * The default system font set. */ public SubstanceFontSet(FontSet systemFontSet) { this.systemFontSet = systemFontSet; } /** * Returns Substance-specific font resource. * * @param systemFont * The default system font. * @return Substance-specific font resource. */ private FontUIResource getSubstanceFont(FontUIResource systemFont) { return systemFont; } /** * Returns Substance-specific font resource. * * @param systemFont * The default system font. * @param toBoldify * If true, the original font (the first * parameter) is boldified. * @param extraFontSize * Extra font size in pixels. * @return Substance-specific font resource. */ private FontUIResource getSubstanceFont(FontUIResource systemFont, boolean toBoldify, int extraFontSize) { boolean isOrigItalic = systemFont.isItalic(); int newStyle = systemFont.getStyle(); if (toBoldify) { if (isOrigItalic) newStyle = Font.ITALIC + Font.BOLD; else newStyle = Font.BOLD; } return new FontUIResource(systemFont.deriveFont( (float) (systemFont.getSize() + extraFontSize)).deriveFont( newStyle)); // return new FontUIResource(systemFont.getFontName(), newStyle, // systemFont.getSize() + extraFontSize); } /* * (non-Javadoc) * * @see contrib.com.jgoodies.looks.common.FontSet#getControlFont() */ public FontUIResource getControlFont() { return this.getSubstanceFont(this.systemFontSet.getControlFont()); } /* * (non-Javadoc) * * @see contrib.com.jgoodies.looks.common.FontSet#getMenuFont() */ public FontUIResource getMenuFont() { return this.getSubstanceFont(this.systemFontSet.getMenuFont()); } /* * (non-Javadoc) * * @see contrib.com.jgoodies.looks.common.FontSet#getMessageFont() */ public FontUIResource getMessageFont() { return this.getSubstanceFont(this.systemFontSet.getMessageFont()); } /* * (non-Javadoc) * * @see contrib.com.jgoodies.looks.common.FontSet#getSmallFont() */ public FontUIResource getSmallFont() { return this.getSubstanceFont(this.systemFontSet.getSmallFont(), false, 1); } /* * (non-Javadoc) * * @see contrib.com.jgoodies.looks.common.FontSet#getTitleFont() */ public FontUIResource getTitleFont() { return this.getSubstanceFont(this.systemFontSet.getTitleFont()); } /* * (non-Javadoc) * * @see contrib.com.jgoodies.looks.common.FontSet#getWindowTitleFont() */ public FontUIResource getWindowTitleFont() { return this.getSubstanceFont(this.systemFontSet .getWindowTitleFont(), true, 1); } } /** * Returns the default platform-specific font policy. * * @return Default platform-specific font policy. */ public static FontPolicy getDefaultFontPolicy() { // boolean toWrapPolicy = !LookUtils.IS_OS_MAC; FontPolicy defaultPolicy = FontPolicies.getDefaultPlasticPolicy(); boolean isKDE = false; // boolean isGnome = false; try { isKDE = DefaultKDEFontPolicy.isKDERunning(); } catch (Throwable t) { // security access - too bad for KDE desktops. } if (LookUtils.IS_OS_WINDOWS) { defaultPolicy = FontPolicies.getDefaultWindowsPolicy(); } else { if (LookUtils.IS_OS_MAC) { defaultPolicy = new DefaultMacFontPolicy(); } else { if (isKDE) { // new in version 4.2 defaultPolicy = new DefaultKDEFontPolicy(); } else { try { String desktop = AccessController .doPrivileged(new PrivilegedAction() { public String run() { return System .getProperty("sun.desktop"); } }); if ("gnome".equals(desktop)) { // new in version 4.1 defaultPolicy = new DefaultGnomeFontPolicy(); // isGnome = true; } } catch (Throwable t) { // security access - too bad for Gnome desktops. } } } } // System.out.println("System " + System.getProperty("os.name") // + ", policy " + defaultPolicy.getClass().getName()); // SubstanceSizeUtils.resetPointsToPixelsRatio(defaultPolicy); final FontPolicy fontPolicy = FontPolicies .customSettingsPolicy(defaultPolicy); if (LookUtils.IS_OS_MAC || isKDE)// || isGnome) return fontPolicy; return new FontPolicy() { public FontSet getFontSet(String lafName, UIDefaults table) { FontSet baseResult = fontPolicy.getFontSet(lafName, table); FontSet substanceFontSet = new SubstanceFontSet(baseResult); return substanceFontSet; } }; } /** * Returns scaled platform-specific font policy. * * @param scaleFactor * Scale factor. Should be positive. * @return Scaled platform-specific font policy. */ public static FontPolicy getScaledFontPolicy(final float scaleFactor) { final FontSet substanceCoreFontSet = SubstanceFontUtilities .getDefaultFontPolicy().getFontSet("Substance", null); // Create the scaled font set FontPolicy newFontPolicy = new FontPolicy() { public FontSet getFontSet(String lafName, UIDefaults table) { return new ScaledFontSet(substanceCoreFontSet, scaleFactor); } }; return newFontPolicy; } } substance-5.3.orig/src/org/jvnet/substance/fonts/FontPolicies.java0000644000175000017500000003272711126425524025305 0ustar drazzibdrazzib/* * Copyright (c) 2001-2006 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.fonts; import java.awt.Font; import javax.swing.UIDefaults; import org.jvnet.lafwidget.utils.LookUtils; /** * Provides predefined FontPolicy implementations. *

* * Note: The available policies work well on Windows. On other * platforms the fonts specified by the runtime environment are chosen. I plan * to provide more logic or options for other platforms, for example that a * Linux system checks for a Tahoma or Segoe UI. *

* * TODO: Add a check for a custom font policy set in the System properties. *

* * TODO: Add policies that emulate different Windows setups: default XP on 96dpi * with normal fonts ("XP-normal-96"), Vista on 120dpi with large fonts * ("Vista-large-120"), etc. * * @author Karsten Lentzsch * @version $Revision: 1.3 $ * * @see FontPolicy * @see FontSet * @see FontSets * @see Fonts * * @since 2.0 */ public final class FontPolicies { private FontPolicies() { // Override default constructor; prevents instantation. } // Getting a FontPolicy ********************************************* /** * Returns a font policy that in turn always returns the specified FontSet. * The FontSet will be fixed, but the FontSet itself may return different * fonts in different environments. * * @param fontSet * the FontSet to be return by this policy * @return a font policy that returns the specified FontSet. */ public static FontPolicy createFixedPolicy(FontSet fontSet) { return new FixedPolicy(fontSet); } /** * Returns a font policy that checks for a custom FontPolicy and a custom * FontSet specified in the System settings or UIManager. If no custom * settings are available, the given default policy will be used to look up * the FontSet. * * @param defaultPolicy * the policy used if there are no custom settings * @return a FontPolicy that checks for custom settings before the default * policy is returned. */ public static FontPolicy customSettingsPolicy(FontPolicy defaultPolicy) { return new CustomSettingsPolicy(defaultPolicy); } // /** // * Returns the default platform independent font choice policy.

// * // * The current implementation just returns the logical fonts. // * A future version shall check for available good fonts // * and shall use them before it falls back to the logical fonts. // * // * @return the default platform independent font choice policy. // */ // public static FontPolicy getDefaultCrossPlatformPolicy() { // return new DefaultCrossPlatformPolicy(); // } /** * Returns the default font policy for Plastic on the Windows platform. It * differs from the default Windows policy in that it uses a bold font for * TitledBorders, titles, and titled separators. * * @return the default font policy for Plastic on the Windows platform. */ public static FontPolicy getDefaultPlasticOnWindowsPolicy() { return new DefaultPlasticOnWindowsPolicy(); } /** * Returns the default Plastic FontPolicy that may vary with the platform * and environment. On Windows, the PlasticOnWindowsPolicy is returned that * is much like the defualt WindowsPolicy but uses a bold title font. On * other Platforms, the logical fonts policy is returned that uses the * logical fonts as specified by the Java runtime environment. * * @return a Windows-like policy on Windows, a logical fonts policy on all * other platforms */ public static FontPolicy getDefaultPlasticPolicy() { if (LookUtils.IS_OS_WINDOWS) { return getDefaultPlasticOnWindowsPolicy(); } return getLogicalFontsPolicy(); // return getDefaultCrossPlatformPolicy(); } /** * Returns the default font policy for the Windows platform. It aims to * return a FontSet that is close to the native guidelines and useful for * the current Java environment. *

* * The control font scales with the platform screen resolution * (96dpi/101dpi/120dpi/144dpi/...) and honors the desktop font settings * (normal/large/extra large). * * @return the default font policy for the Windows platform. */ public static FontPolicy getDefaultWindowsPolicy() { return new DefaultWindowsPolicy(); } /** * Returns a font policy that returns the logical fonts as specified by the * Java runtime environment. * * @return a font policy that returns logical fonts. */ public static FontPolicy getLogicalFontsPolicy() { return createFixedPolicy(FontSets.getLogicalFontSet()); } /** * Returns a font policy for getting a Plastic appearance that aims to be * visual backward compatible with the JGoodies Looks version 1.x. It uses a * font choice similar to the choice implemented by the Plastic L&fs in * the JGoodies Looks version 1.x. * * @return a font policy that aims to reproduce the Plastic font choice in * the JGoodies Looks 1.x. */ public static FontPolicy getLooks1xPlasticPolicy() { Font controlFont = Fonts.getDefaultGUIFontWesternModernWindowsNormal(); Font menuFont = controlFont; Font titleFont = controlFont.deriveFont(Font.BOLD); FontSet fontSet = FontSets.createDefaultFontSet(controlFont, menuFont, titleFont); return createFixedPolicy(fontSet); } /** * Returns a font policy for getting a Windows appearance that aims to be * visual backward compatible with the JGoodies Looks version 1.x. It uses a * font choice similar to the choice implemented by the Windows L&f in * the JGoodies Looks version 1.x. * * @return a font policy that aims to reproduce the Windows font choice in * the JGoodies Looks 1.x. */ public static FontPolicy getLooks1xWindowsPolicy() { return new Looks1xWindowsPolicy(); } /** * Returns a font policy intended for API users that want to move Plastic * code from the Looks 1.x to the Looks 2.0. On Windows, it uses the Looks * 2.0 Plastic fonts, on other platforms it uses the Looks 1.x Plastic * fonts. * * @return the recent Plastic font policy on Windows, the JGoodies Looks 1.x * on other Platforms. */ public static FontPolicy getTransitionalPlasticPolicy() { return LookUtils.IS_OS_WINDOWS ? getDefaultPlasticOnWindowsPolicy() : getLooks1xPlasticPolicy(); } // Utility Methods ******************************************************** /** * Looks up and returns a custom FontSet for the given Look&Feel name, * or null if no custom font set has been defined for this * Look&Feel. * * @param the * name of the Look&Feel, one of "Plastic" or * "Windows" * @return a custom FontPolicy - if any - or otherwise null */ private static FontSet getCustomFontSet(String lafName) { String controlFontKey = lafName + ".controlFont"; String menuFontKey = lafName + ".menuFont"; String decodedControlFont = LookUtils.getSystemProperty(controlFontKey); if (decodedControlFont == null) return null; Font controlFont = Font.decode(decodedControlFont); String decodedMenuFont = LookUtils.getSystemProperty(menuFontKey); Font menuFont = decodedMenuFont != null ? Font.decode(decodedMenuFont) : null; Font titleFont = "Plastic".equals(lafName) ? controlFont .deriveFont(Font.BOLD) : controlFont; return FontSets.createDefaultFontSet(controlFont, menuFont, titleFont); } /** * Looks up and returns a custom FontPolicy for the given Look&Feel * name, or null if no custom policy has been defined for this * Look&Feel. * * @param the * name of the Look&Feel, one of "Plastic" or * "Windows" * @return a custom FontPolicy - if any - or otherwise null */ private static FontPolicy getCustomPolicy(String lafName) { // TODO: Look up predefined font choice policies return null; } private static final class CustomSettingsPolicy implements FontPolicy { private final FontPolicy wrappedPolicy; CustomSettingsPolicy(FontPolicy wrappedPolicy) { this.wrappedPolicy = wrappedPolicy; } public FontSet getFontSet(String lafName, UIDefaults table) { FontPolicy customPolicy = getCustomPolicy(lafName); if (customPolicy != null) { return customPolicy.getFontSet(null, table); } FontSet customFontSet = getCustomFontSet(lafName); if (customFontSet != null) { return customFontSet; } return wrappedPolicy.getFontSet(lafName, table); } } // private static final class DefaultCrossPlatformPolicy implements // FontPolicy { // // public FontSet getFontSet(String lafName, UIDefaults table) { // // TODO: If Tahoma or Segoe UI is available, return them // // in a size appropriate for the screen resolution. // // Otherwise return the logical font set. // return FontSets.getLogicalFontSet(); // } // } /** * Implements the default font lookup for the Plastic L&f family when * running in a Windows environment. */ private static final class DefaultPlasticOnWindowsPolicy implements FontPolicy { public FontSet getFontSet(String lafName, UIDefaults table) { Font windowsControlFont = Fonts.getWindowsControlFont(); Font controlFont; if (windowsControlFont != null) { controlFont = windowsControlFont; } else if (table != null) { controlFont = table.getFont("Button.font"); } else { controlFont = new Font("Dialog", Font.PLAIN, 12); } Font menuFont = table == null ? controlFont : table .getFont("Menu.font"); Font titleFont = controlFont.deriveFont(Font.BOLD); return FontSets.createDefaultFontSet(controlFont, menuFont, titleFont); } } /** * Implements the default font lookup on the Windows platform. */ private static final class DefaultWindowsPolicy implements FontPolicy { public FontSet getFontSet(String lafName, UIDefaults table) { Font windowsControlFont = Fonts.getWindowsControlFont(); Font controlFont; if (windowsControlFont != null) { controlFont = windowsControlFont; } else if (table != null) { controlFont = table.getFont("Button.font"); } else { controlFont = new Font("Dialog", Font.PLAIN, 12); } Font menuFont = table == null ? controlFont : table .getFont("Menu.font"); Font titleFont = controlFont; Font messageFont = table == null ? controlFont : table .getFont("OptionPane.font"); Font smallFont = table == null ? controlFont.deriveFont(controlFont .getSize2D() - 2f) : table.getFont("ToolTip.font"); Font windowTitleFont = table == null ? controlFont : table .getFont("InternalFrame.titleFont"); return FontSets.createDefaultFontSet(controlFont, menuFont, titleFont, messageFont, smallFont, windowTitleFont); } } /** * A FontPolicy that returns a fixed FontSet and that ignores the laf name * and UIDefaults table. */ private static final class FixedPolicy implements FontPolicy { private final FontSet fontSet; FixedPolicy(FontSet fontSet) { this.fontSet = fontSet; } public FontSet getFontSet(String lafName, UIDefaults table) { return fontSet; } } /** * Aims to mimic the font choice as used in the JGoodies Looks 1.x. */ private static final class Looks1xWindowsPolicy implements FontPolicy { public FontSet getFontSet(String lafName, UIDefaults table) { Font windowsControlFont = Fonts.getLooks1xWindowsControlFont(); Font controlFont; if (windowsControlFont != null) { controlFont = windowsControlFont; } else if (table != null) { controlFont = table.getFont("Button.font"); } else { controlFont = new Font("Dialog", Font.PLAIN, 12); } return FontSets.createDefaultFontSet(controlFont); } } } substance-5.3.orig/src/org/jvnet/substance/fonts/FontSets.java0000644000175000017500000002346611126425524024454 0ustar drazzibdrazzib/* * Copyright (c) 2001-2006 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.fonts; import java.awt.Font; import javax.swing.plaf.FontUIResource; import org.jvnet.substance.fonts.*; /** * Provides predefined FontSet implementations. * * @author Karsten Lentzsch * @version $Revision: 1.2 $ * * @see FontSet * @see FontPolicy * @see FontPolicies * * @since 2.0 */ public final class FontSets { private static FontSet logicalFontSet; private FontSets() { // Override default constructor; prevents instantation. } // Default FontSets ******************************************************* /** * Creates and returns a FontSet that is based only on the given control * font. The small font will be derived from the control font; all other * fonts returned are the control font. * * @param controlFont * the font used for all controls * * @return a FontSet based on the given fonts * * @throws NullPointerException * if the control font is null */ public static FontSet createDefaultFontSet(Font controlFont) { return createDefaultFontSet(controlFont, null); } /** * Creates and returns a FontSet that is based on the given control font and * menu font. The small font will be derived from the control font; all * other fonts return, except the menu font, are the control font. * * @param controlFont * the font used for all controls * @param menuFont * the font used for the menu bar and menu items * * @return a FontSet based on the given fonts * * @throws NullPointerException * if the control font is null */ public static FontSet createDefaultFontSet(Font controlFont, Font menuFont) { return createDefaultFontSet(controlFont, menuFont, null, null, null, null); } /** * Creates and returns a FontSet that is based on the given control font and * menu font. The small font will be derived from the control font; all * other fonts return, except the menu font, are the control font. * * @param controlFont * the font used for all controls * @param menuFont * the font used for the menu bar and menu items * @param titleFont * used for TitledBorder, titles and titled separators * * @return a FontSet based on the given fonts * * @throws NullPointerException * if the control font is null */ public static FontSet createDefaultFontSet(Font controlFont, Font menuFont, Font titleFont) { return createDefaultFontSet(controlFont, menuFont, titleFont, null, null, null); } /** * Creates and returns a FontSet for the given fonts. If a font is * null, it uses the control font as fallback. If the small * font is null it will be derived from the control font. * * @param controlFont * used for all controls * @param menuFont * used for the menu bar and menu items * @param titleFont * used for TitledBorder, titles and titled separators * @param messageFont * used for OptionPanes * @param smallFont * used for tool tips and similar components * @param windowTitleFont * used for internal frame window titles * * @return a FontSet based on the given fonts * * @throws NullPointerException * if the control font is null */ public static FontSet createDefaultFontSet(Font controlFont, Font menuFont, Font titleFont, Font messageFont, Font smallFont, Font windowTitleFont) { return new DefaultFontSet(controlFont, menuFont, titleFont, messageFont, smallFont, windowTitleFont); } // Logical FontSet ******************************************************** /** * Lazily creates and returns the FontSet that returns the logical fonts * specified by the Java runtime environment. * * @return a FontSets that uses the logical fonts specified by the Java * environment */ public static FontSet getLogicalFontSet() { if (logicalFontSet == null) { logicalFontSet = new LogicalFontSet(); } return logicalFontSet; } // Helper Code ************************************************************ private static final class DefaultFontSet implements FontSet { private final FontUIResource controlFont; private final FontUIResource menuFont; private final FontUIResource titleFont; private final FontUIResource messageFont; private final FontUIResource smallFont; private final FontUIResource windowTitleFont; // Instance Creation -------------------------------------------------- /** * Constructs a DefaultFontSet for the given fonts. If a font is * null, it uses the control font as fallback. If the small * font is null it will be derived from the control font. * * @param controlFont * used for all controls * @param menuFont * used for the menu bar and menu items * @param titleFont * used for TitledBorder, titles and titled separators * @param messageFont * used for OptionPanes * @param smallFont * used for tool tips and similar components * @param windowTitleFont * used for internal frame window titles * * @throws NullPointerException * if the control font is null */ public DefaultFontSet(Font controlFont, Font menuFont, Font titleFont, Font messageFont, Font smallFont, Font windowTitleFont) { this.controlFont = new FontUIResource(controlFont); this.menuFont = menuFont != null ? new FontUIResource(menuFont) : this.controlFont; this.titleFont = titleFont != null ? new FontUIResource(titleFont) : this.controlFont; // new // FontUIResource(controlFont.deriveFont // (Font.BOLD)) this.messageFont = messageFont != null ? new FontUIResource( messageFont) : this.controlFont; this.smallFont = new FontUIResource(smallFont != null ? smallFont : controlFont.deriveFont(controlFont.getSize2D() - 2f)); this.windowTitleFont = windowTitleFont != null ? new FontUIResource( windowTitleFont) : this.titleFont; } // FontSet API -------------------------------------------------------- public FontUIResource getControlFont() { return controlFont; } public FontUIResource getMenuFont() { return menuFont; } public FontUIResource getTitleFont() { return titleFont; } public FontUIResource getWindowTitleFont() { return windowTitleFont; } public FontUIResource getSmallFont() { return smallFont; } public FontUIResource getMessageFont() { return messageFont; } } /** * Looks up and returns the logical fonts as specified by the Java runtime * environment. */ private static final class LogicalFontSet implements FontSet { private FontUIResource controlFont; private FontUIResource titleFont; private FontUIResource systemFont; private FontUIResource smallFont; public FontUIResource getControlFont() { if (controlFont == null) { controlFont = new FontUIResource(Font.getFont( "swing.plaf.metal.controlFont", new Font("Dialog", Font.PLAIN, 12))); } return controlFont; } public FontUIResource getMenuFont() { return getControlFont(); } public FontUIResource getTitleFont() { if (titleFont == null) { titleFont = new FontUIResource(getControlFont().deriveFont( Font.BOLD)); } return titleFont; } public FontUIResource getSmallFont() { if (smallFont == null) { smallFont = new FontUIResource(Font.getFont( "swing.plaf.metal.smallFont", new Font("Dialog", Font.PLAIN, 10))); } return smallFont; } public FontUIResource getMessageFont() { if (systemFont == null) { systemFont = new FontUIResource(Font.getFont( "swing.plaf.metal.systemFont", new Font("Dialog", Font.PLAIN, 12))); } return systemFont; } public FontUIResource getWindowTitleFont() { return getTitleFont(); } } } substance-5.3.orig/src/org/jvnet/substance/fonts/DefaultMacFontPolicy.java0000644000175000017500000000527411136475562026730 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.fonts; import java.awt.Font; import javax.swing.UIDefaults; /** * The default font policy for Mac desktops. * * @author Kirill Grouchnikov */ public class DefaultMacFontPolicy implements FontPolicy { /* * (non-Javadoc) * * @see org.jvnet.substance.fonts.FontPolicy#getFontSet(java.lang.String, * javax.swing.UIDefaults) */ public FontSet getFontSet(String lafName, UIDefaults table) { Font controlFont = new Font("Lucida Grande", Font.PLAIN, 13); Font menuFont = table == null ? new Font("Lucida Grande", Font.PLAIN, 14) : table.getFont("Menu.font"); Font titleFont = menuFont; Font messageFont = table == null ? controlFont : table .getFont("OptionPane.font"); Font smallFont = table == null ? controlFont.deriveFont(controlFont .getSize2D() - 2f) : table.getFont("ToolTip.font"); Font windowTitleFont = table == null ? titleFont : table .getFont("InternalFrame.titleFont"); return FontSets.createDefaultFontSet(controlFont, menuFont, titleFont, messageFont, smallFont, windowTitleFont); } } substance-5.3.orig/src/org/jvnet/substance/fonts/ScaledFontSet.java0000644000175000017500000000656711136475562025420 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.fonts; import javax.swing.plaf.FontUIResource; /** * Wrapper around the base Substance font set. Is used to create larger / * smaller font sets. * * @author Kirill Grouchnikov */ public class ScaledFontSet implements FontSet { /** * Scale factor. Should be positive. */ private float scaleFactor; /** * The base Substance font set. */ private FontSet delegate; /** * Creates a wrapper font set. * * @param delegate * The base Substance font set. * @param scaleFactor * Scale factor. Should be positive. */ public ScaledFontSet(FontSet delegate, float scaleFactor) { super(); this.delegate = delegate; this.scaleFactor = scaleFactor; } /** * Returns the wrapped font. * * @param systemFont * Original font. * @return Wrapped font. */ private FontUIResource getWrappedFont(FontUIResource systemFont) { return new FontUIResource(systemFont.getFontName(), systemFont .getStyle(), (int) (systemFont.getSize() * this.scaleFactor)); } public FontUIResource getControlFont() { return this.getWrappedFont(this.delegate.getControlFont()); } public FontUIResource getMenuFont() { return this.getWrappedFont(this.delegate.getMenuFont()); } public FontUIResource getMessageFont() { return this.getWrappedFont(this.delegate.getMessageFont()); } public FontUIResource getSmallFont() { return this.getWrappedFont(this.delegate.getSmallFont()); } public FontUIResource getTitleFont() { return this.getWrappedFont(this.delegate.getTitleFont()); } public FontUIResource getWindowTitleFont() { return this.getWrappedFont(this.delegate.getWindowTitleFont()); } } substance-5.3.orig/src/org/jvnet/substance/fonts/DefaultGnomeFontPolicy.java0000644000175000017500000001262711136475562027275 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.fonts; import java.awt.*; import java.awt.geom.AffineTransform; import java.lang.reflect.Method; import java.util.StringTokenizer; import javax.swing.UIDefaults; import javax.swing.plaf.FontUIResource; /** * The default font policy for Gnome desktops. * * @author Kirill Grouchnikov */ public class DefaultGnomeFontPolicy implements FontPolicy { /** * Font scale. */ private static double fontScale; static { GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsConfiguration gc = ge.getDefaultScreenDevice() .getDefaultConfiguration(); AffineTransform at = gc.getNormalizingTransform(); fontScale = at.getScaleY(); } /* * (non-Javadoc) * * @see org.jvnet.substance.fonts.FontPolicy#getFontSet(java.lang.String, * javax.swing.UIDefaults) */ public FontSet getFontSet(String lafName, UIDefaults table) { Object defaultGtkFontName = Toolkit.getDefaultToolkit() .getDesktopProperty("gnome.Gtk/FontName"); String family = ""; int style = Font.PLAIN; int size = 10; if (defaultGtkFontName instanceof String) { String pangoName = (String) defaultGtkFontName; StringTokenizer tok = new StringTokenizer(pangoName); while (tok.hasMoreTokens()) { String word = tok.nextToken(); boolean allDigits = true; for (int i = 0; i < word.length(); i++) { if (!Character.isDigit(word.charAt(i))) { allDigits = false; break; } } if (word.equalsIgnoreCase("italic")) { style |= Font.ITALIC; } else if (word.equalsIgnoreCase("bold")) { style |= Font.BOLD; } else if (allDigits) { try { size = Integer.parseInt(word); } catch (NumberFormatException nfe) { size = 10; } } else { if (family.length() > 0) { family += " "; } family += word; } } } double dsize = size * getPointsToPixelsRatio(); size = (int) (dsize + 0.5); if (size < 1) { size = 1; } if (family.length() == 0) family = "sans"; // Font controlFont = new Font(family, style, size); Font controlFont = null; // make some black magic with sun-private classes // to better map the logical font name (such as sans) // to an actual font (such as DejaVu Sans). String fcFamilyLC = family.toLowerCase(); try { Class fontManagerClass = Class.forName("sun.font.FontManager"); Method mapFcMethod = fontManagerClass.getMethod("mapFcName", new Class[] { String.class }); Object mapFcMethodResult = mapFcMethod.invoke(null, fcFamilyLC); if (mapFcMethodResult != null) { Method getFontConfigFUIRMethod = fontManagerClass.getMethod( "getFontConfigFUIR", new Class[] { String.class, int.class, int.class }); controlFont = (Font) getFontConfigFUIRMethod.invoke(null, fcFamilyLC, style, size); } else { Font font = new FontUIResource(family, style, size); Method getCompositeFontUIResourceMethod = fontManagerClass .getMethod("getCompositeFontUIResource", new Class[] { Font.class }); controlFont = (Font) getCompositeFontUIResourceMethod.invoke( null, font); } } catch (Throwable t) { controlFont = new Font(family, style, size); } return FontSets.createDefaultFontSet(controlFont); } public static double getPointsToPixelsRatio() { // for details behind the computations, look in // com.sun.java.swing.plaf.gtk.PangoFonts int dpi = 96; Object value = Toolkit.getDefaultToolkit().getDesktopProperty( "gnome.Xft/DPI"); if (value instanceof Integer) { dpi = ((Integer) value).intValue() / 1024; if (dpi == -1) { dpi = 96; } if (dpi < 50) { dpi = 50; } return dpi / 72.0; } else { return fontScale; } } } substance-5.3.orig/src/org/jvnet/substance/fonts/FontSet.java0000644000175000017500000000565311126425524024267 0ustar drazzibdrazzib/* * Copyright (c) 2001-2006 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.fonts; import javax.swing.plaf.FontUIResource; /** * Returns the Fonts used by a Look&Feel or theme. These Fonts must * implement the UIResource marker interface. * * @author Karsten Lentzsch * @version $Revision: 1.2 $ * * @since 2.0 */ public interface FontSet { /** * Returns the font used for all dialog components. * * @return the font used for all dialog components. */ FontUIResource getControlFont(); /** * Returns the font used for the menu. * * @return the font used for the menu. */ FontUIResource getMenuFont(); /** * Returns the font used for the title label in TitledBorders. This font is * also used by JGoodies Forms titles, and titled separators. * * @return the font used for TitledBorder titles. */ FontUIResource getTitleFont(); /** * Returns the font used for internal frame titles. * * @return the font used for internal frame titles. */ FontUIResource getWindowTitleFont(); /** * Returns the font used for tool tips. * * @return the tool tip font. */ FontUIResource getSmallFont(); /** * Returns the font used for message dialogs. * * @return the font used for message dialogs. */ FontUIResource getMessageFont(); } substance-5.3.orig/src/org/jvnet/substance/fonts/Fonts.java0000644000175000017500000003467111126425526024002 0ustar drazzibdrazzib/* * Copyright (c) 2001-2006 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.fonts; import java.awt.Font; import java.awt.Toolkit; import java.util.Locale; import org.jvnet.lafwidget.utils.LookUtils; /** * Provides static access to popular Windows fonts. The sizes of the font * constants are specified in typographic points, approximately 1/72 of * an inch. *

* * TODO: Consider changing the visibility of the package private methods to * public. As an alternative we may provide a FontPolicy that can emulate the * font choice on Windows XP/2000 and Windows Vista for different software * resolutions (96dpi/120dpi) and desktop font size settings (Normal/Large/Extra * Large). * * @author Karsten Lentzsch * @version $Revision: 1.6 $ * * @see FontSet * @see FontSets * @see FontPolicy * @see FontPolicies * * @since 2.0 */ public final class Fonts { /** * The name of the default dialog font on western Windows XP. */ public static final String TAHOMA_NAME = "Tahoma"; /** * The name of the default dialog font on western Windows Vista. */ public static final String SEGOE_UI_NAME = "Segoe UI"; // Physical Fonts ********************************************************* /** * This is the default font on western XP with 96dpi and normal fonts. * Ascent=11, descent=3, height=14, dbuX=6, dbuY=12, 14dluY=21px. */ public static final Font TAHOMA_11PT = new Font(TAHOMA_NAME, Font.PLAIN, 11); /** * Ascent=13, descent=3, height=16, dbuX=8, dbuY=13, 14dluY=22.75px. */ public static final Font TAHOMA_13PT = new Font(TAHOMA_NAME, Font.PLAIN, 13); /** * Ascent=14, descent=3, height=17, dbuX=8, dbuY=14, 14dluY=24.5px. */ public static final Font TAHOMA_14PT = new Font(TAHOMA_NAME, Font.PLAIN, 14); /** * This is Segoe UI 9pt, the default font on western Vista with 96dpi. * Ascent=13, descent=4, height=17, dbuX=7, dbuY=13, 13dluY=21.125px. */ public static final Font SEGOE_UI_12PT = new Font(SEGOE_UI_NAME, Font.PLAIN, 12); /** * Ascent=14, descent=4, height=18, dbuX=8, dbuY=14, 13dluY=22.75px. */ public static final Font SEGOE_UI_13PT = new Font(SEGOE_UI_NAME, Font.PLAIN, 13); /** * Ascent=16, descent=5, height=21, dbuX=9, dbuY=16, 13dluY=26px. */ public static final Font SEGOE_UI_15PT = new Font(SEGOE_UI_NAME, Font.PLAIN, 15); // Default Windows Fonts ************************************************** /** * The default icon font on western Windows XP with 96dpi and the dialog * font desktop setting "Normal". */ public static final Font WINDOWS_XP_96DPI_NORMAL = TAHOMA_11PT; /** * The default GUI font on western Windows XP with 96dpi and the dialog font * desktop setting "Normal". */ public static final Font WINDOWS_XP_96DPI_DEFAULT_GUI = TAHOMA_11PT; /** * The default icon font on western Windows XP with 96dpi and the dialog * font desktop setting "Large". */ public static final Font WINDOWS_XP_96DPI_LARGE = TAHOMA_13PT; /** * The default icon font on western Windows XP with 120dpi and the dialog * font desktop setting "Normal". */ public static final Font WINDOWS_XP_120DPI_NORMAL = TAHOMA_14PT; /** * The default GUI font on western Windows XP with 120dpi and the dialog * font desktop setting "Normal". */ public static final Font WINDOWS_XP_120DPI_DEFAULT_GUI = TAHOMA_13PT; /** * The default icon font on western Windows Vista with 96dpi and the dialog * font desktop setting "Normal". */ public static final Font WINDOWS_VISTA_96DPI_NORMAL = SEGOE_UI_12PT; /** * The default icon font on western Windows Vista with 96dpi and the dialog * font desktop setting "Large". */ public static final Font WINDOWS_VISTA_96DPI_LARGE = SEGOE_UI_15PT; /** * The default icon font on western Windows Vista with 101dpi and the dialog * font desktop setting "Normal". *

* * TODO: Check if this shall be removed or not. */ static final Font WINDOWS_VISTA_101DPI_NORMAL = SEGOE_UI_13PT; /** * The default icon font on western Windows Vista with 120dpi and the dialog * font desktop setting "Normal". */ public static final Font WINDOWS_VISTA_120DPI_NORMAL = SEGOE_UI_15PT; // Desktop Property Font Keys ********************************************* /** * The desktop property key used to lookup the DEFAULTGUI font. This font * scales with the software resolution only but works in western and * non-western Windows environments. * * @see #getWindowsControlFont() */ static final String WINDOWS_DEFAULT_GUI_FONT_KEY = "win.defaultGUI.font"; /** * The desktop property key used to lookup Windows' icon font. This font * scales with the software resolution and the desktop font size setting * (Normal/Large/Extra Large). However, in some non-western Windows * environments this font cannot display the locale's glyphs. *

* * Implementation Note: Windows uses the icon font to label icons in the * Windows Explorer and other places. It seems to me that this works in * non-western environments due to font chaining. * * @see #getWindowsControlFont() */ static final String WINDOWS_ICON_FONT_KEY = "win.icon.font"; // Instance Creation ****************************************************** private Fonts() { // Override default constructor; prevents instantation. } // Font Lookup ************************************************************ static Font getDefaultGUIFontWesternModernWindowsNormal() { return LookUtils.IS_LOW_RESOLUTION ? WINDOWS_XP_96DPI_DEFAULT_GUI : WINDOWS_XP_120DPI_DEFAULT_GUI; } static Font getDefaultIconFontWesternModernWindowsNormal() { return LookUtils.IS_LOW_RESOLUTION ? WINDOWS_XP_96DPI_NORMAL : WINDOWS_XP_120DPI_NORMAL; } static Font getDefaultIconFontWesternWindowsVistaNormal() { return LookUtils.IS_LOW_RESOLUTION ? WINDOWS_VISTA_96DPI_NORMAL : WINDOWS_VISTA_120DPI_NORMAL; } /** * Returns the Windows control font used by the JGoodies Looks version 1.x. * It is intended for visual backward compatibility only. The font returned * is the default GUI font that scales with the resolution (96dpi, 120dpi, * etc) but not with the desktop font size settings (normal, large, extra * large). *

* * On Windows Vista, the font may be completely wrong. * * @return the Windows default GUI font that scales with the resolution, but * not the desktop font size setting * * @throws UnsupportedOperationException * on non-Windows platforms */ static Font getLooks1xWindowsControlFont() { if (!LookUtils.IS_OS_WINDOWS) throw new UnsupportedOperationException(); return getDesktopFont(WINDOWS_DEFAULT_GUI_FONT_KEY); } /** * Looks up and returns the Windows control font. Returns the Windows icon * title font unless it is inappropriate for the Windows version, Java * renderer, or locale. *

* * The icon title font scales with the resolution (96dpi, 101dpi, 120dpi, * etc) and the desktop font size settings (normal, large, extra large). * Older versions may return a poor font. Also, since Java 1.4 and Java 5 * render the Windows Vista icon font Segoe UI poorly, we return the default * GUI font in these environments. *

* * The last check is, if the icon font can display text in the default * locale. Therefore we test if the locale's localized display name can be * displayed by the icon font. For example, Tahoma can display "English", * "Deutsch", but not the display name for "Chinese" in Chinese. * * @return the Windows control font * * @throws UnsupportedOperationException * on non-Windows platforms */ public static Font getWindowsControlFont() { if (!LookUtils.IS_OS_WINDOWS) throw new UnsupportedOperationException(); Font defaultGUIFont = getDefaultGUIFont(); // Return the default GUI font on older Windows versions. if (LookUtils.IS_OS_WINDOWS_95 || LookUtils.IS_OS_WINDOWS_98 || LookUtils.IS_OS_WINDOWS_NT || LookUtils.IS_OS_WINDOWS_ME) return defaultGUIFont; // Java 1.4 and Java 5 raster the Segoe UI poorly, // so we use the older Tahoma, if it can display the localized text. if (LookUtils.IS_OS_WINDOWS_VISTA) { if (LookUtils.IS_JAVA_1_4_OR_5) { Font tahoma = getDefaultGUIFontWesternModernWindowsNormal(); return Boolean.TRUE.equals(canDisplayLocalizedText(tahoma, Locale.getDefault())) ? tahoma : defaultGUIFont; } } Font iconFont = getDesktopFont(WINDOWS_ICON_FONT_KEY); return Boolean.TRUE.equals(canDisplayLocalizedText(iconFont, Locale .getDefault())) ? iconFont : defaultGUIFont; } /** * Looks up and returns the Windows defaultGUI font. Works around a bug with * Java 1.4.2_11, 1.5.0_07, and 1.6 b89 in the Vista Beta2, where the * win.defaultGUI.font desktop property returns null. In this case a logical * "Dialog" font is used as fallback. * * @return the Windows defaultGUI font, or a dialog font as fallback. */ private static Font getDefaultGUIFont() { Font font = getDesktopFont(WINDOWS_DEFAULT_GUI_FONT_KEY); if (font != null) return font; return new Font("Dialog", Font.PLAIN, 12); } /** * Checks and answers whether the given font can display text that is * localized for the specified locale. Returns null if we can't * test it. *

* * First checks, if the locale's display language is available in localized * form, for example "Deutsch" for the German locale. If so, we check if the * given font can display the localized display language. *

* * Otherwise we check some known combinations of fonts and locales and * return the associated results. For all other combinations, * null is returned to indicate that we don't know whether the * font can display text in the given locale. * * @param font * the font to be tested * @param locale * the locale to be used * @return Boolean.TRUE if the font can display the locale's * text, Boolean.FALSE if not, null if we * don't know * * @since 2.0.4 */ public static Boolean canDisplayLocalizedText(Font font, Locale locale) { if (localeHasLocalizedDisplayLanguage(locale)) { return Boolean.valueOf(canDisplayLocalizedDisplayLanguage(font, locale)); } String fontName = font.getName(); String language = locale.getLanguage(); if ("Tahoma".equals(fontName)) { if ("hi".equals(language)) return Boolean.FALSE; else if ("ja".equals(language)) return Boolean.FALSE; else if ("ko".equals(language)) return Boolean.FALSE; else if ("zh".equals(language)) return Boolean.FALSE; } if ("Microsoft Sans Serif".equals(fontName)) { if ("ja".equals(language)) return Boolean.FALSE; else if ("ko".equals(language)) return Boolean.FALSE; else if ("zh".equals(language)) return Boolean.FALSE; } return null; } /** * Checks and answers if the given font can display the locale's localized * display language, for example "English" for English, "Deutsch" for * German, etc. The test invokes Font#canDisplayUpTo on the * localized display language. In a Chinese locale this test will check if * the font can display Chinese glyphs. * * @param font * the font to be tested * @param locale * the locale to be used * @return true if the font can display the locale's localized display * language, false otherwise */ private static boolean canDisplayLocalizedDisplayLanguage(Font font, Locale locale) { String testString = locale.getDisplayLanguage(locale); int index = font.canDisplayUpTo(testString); return index == -1; } /** * Checks and answers whether the locale's display language is available in * a localized form, for example "Deutsch" for the German locale. * * @param locale * the Locale to test * @return true if the display language is localized, false if not */ private static boolean localeHasLocalizedDisplayLanguage(Locale locale) { if (locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) return true; String englishDisplayLanguage = locale .getDisplayLanguage(Locale.ENGLISH); String localizedDisplayLanguage = locale.getDisplayLanguage(locale); return !(englishDisplayLanguage.equals(localizedDisplayLanguage)); } /** * Looks up and returns a font using the default toolkit's desktop * properties. * * @param fontName * the name of the font to return * @return the font */ private static Font getDesktopFont(String fontName) { Toolkit toolkit = Toolkit.getDefaultToolkit(); return (Font) toolkit.getDesktopProperty(fontName); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceLookAndFeel.java0000644000175000017500000023532511246717232025553 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.*; import javax.swing.*; import javax.swing.plaf.IconUIResource; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicLookAndFeel; import org.jvnet.lafplugin.*; import org.jvnet.lafwidget.LafWidgetRepository; import org.jvnet.lafwidget.animation.FadeConfigurationManager; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.substance.api.*; import org.jvnet.substance.api.SubstanceConstants.MenuGutterFillKind; import org.jvnet.substance.api.SubstanceConstants.SubstanceWidgetType; import org.jvnet.substance.api.combo.ComboPopupPrototypeCallback; import org.jvnet.substance.api.tabbed.BaseTabCloseListener; import org.jvnet.substance.api.tabbed.TabCloseCallback; import org.jvnet.substance.fonts.*; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.utils.DecorationPainterUtils; import org.jvnet.substance.plugin.SubstanceSkinPlugin; import org.jvnet.substance.shaper.*; import org.jvnet.substance.skin.SkinChangeListener; import org.jvnet.substance.skin.SkinInfo; import org.jvnet.substance.utils.*; import contrib.com.jgoodies.looks.common.ShadowPopupFactory; /** *

* Main class for Substance look and feel. All static methods in * this class should be called when Substance is the currently set look and feel * unless explicitly stated otherwise. *

* *

* Since version 5.0 this class is abstract. There are three options to use * Substance: *

* *
    *
  • Use one of the core skin-based look-and-feels in the * org.jvnet.substance.skin package.
  • *
  • Extend this class and pass a skin instance to the * {@link SubstanceLookAndFeel#SubstanceLookAndFeel(SubstanceSkin)} constructor. *
  • *
  • Call {@link SubstanceLookAndFeel#setSkin(String)} or * {@link SubstanceLookAndFeel#setSkin(SubstanceSkin)} static methods. These * methods do not require Substance to be the current look-and-feel.
  • *
* * @author Kirill Grouchnikov */ public abstract class SubstanceLookAndFeel extends BasicLookAndFeel { /** * The name of plugin configuration XML resource name. This is used for the * laf-plugin support layer of * third-party components. */ public static final String PLUGIN_XML = "META-INF/substance-plugin.xml"; /** * Plugin manager for component plugins. */ private static ComponentPluginManager componentPlugins; /** * Plugin manager for skin plugins. */ private static PluginManager skinPlugins; /** * List of all listeners on skin changes. */ protected final static Set skinChangeListeners = new HashSet(); /** * List of all listeners on closing tabs. */ protected final static Set localeChangeListeners = new HashSet(); /** * Indicates whether option dialogs (error, question, warning, info) should * use constant color schemes for icon coloring. Note that since version * 4.0, the default setting is true (use constant color * scheme). To use color scheme-consistent coloring, call * {@link #setToUseConstantThemesOnDialogs(boolean)} and pass * false. * * @see #isToUseConstantThemesOnDialogs() * @see #setToUseConstantThemesOnDialogs(boolean) */ private static boolean toUseConstantThemesOnDialogs = true; /** * Change listener on keyboard focus manager - fix for defect 208. */ protected PropertyChangeListener focusOwnerChangeListener; /** * The current keyboard focus manager - fix for defect 208. */ protected KeyboardFocusManager currentKeyboardFocusManager; /** * Fade kind for smart tree scroll. Disabled by default, use * {@link FadeConfigurationManager#allowFades(FadeKind)} to enable.

* *

* Smart tree scroll is relevant for scroll panes containing a tree. When * enabled, it automatically scrolls the tree horizontally when the viewport * shows mainly empty area (especially relevant for multi-level trees with * narrow viewports). *

* * @since 4.0 */ @SubstanceApi public final static FadeKind TREE_SMART_SCROLL_ANIMATION_KIND = new FadeKind( "substancelaf.treeSmartScrollAnimationKind", false); /** * Client property name for requesting that watermark should be painted on * the component and its descendants. This property can be set either as * client property on some component or as global property on * {@link UIManager}. The value should be either {@link Boolean#TRUE} or * {@link Boolean#FALSE}. * *

* In order to compute whether the current watermark should be painted on a * given component, its hierarchy is traversed bottom up. The first * component that has this property set defines the watermark visibility. If * neither component nor its ancestors define this property, the global * setting on {@link UIManager} is checked. If there is no global setting, * the watermark is not ignored (it is painted). *

* *

* There is special default setting for trees, tables, lists and text * components. These show watermark only when this property is explicitly * set to {@link Boolean#TRUE} on the component itself, one of its ancestors * or the {@link UIManager}. *

* * @since version 5.0 */ @SubstanceApi public static final String WATERMARK_VISIBLE = "substancelaf.watermark.visible"; /** * Client property name for ignoring the default (minimum) dimension for a * single button. This property can be set either on the specific button or * as a global setting on {@link UIManager}. The value should be either * {@link Boolean#TRUE} or {@link Boolean#FALSE}. *

* Note that {@link SubstanceButtonShaper} implementations are not required * to respect this property. The current implementations of the default * {@link StandardButtonShaper} and {@link ClassicButtonShaper} respect this * property. *

* *

* Example of marking a button to ignore minimum dimension settings: *

* * JButton button = new JButton("text");
* button.putClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY,
*   Boolean.TRUE); *
*

* Example of marking all application buttons to ignore minimum dimension * settings: *

* * UIManager.put(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY,
*   Boolean.TRUE); *
* * @since version 2.1 */ @SubstanceApi public static final String BUTTON_NO_MIN_SIZE_PROPERTY = "substancelaf.buttonnominsize"; /** * Client property name for specifying that a single button / all * application buttons should not paint the background. This property can be * set either on the specific button or as a global setting on * {@link UIManager}. The value should be either {@link Boolean#TRUE} or * {@link Boolean#FALSE}. Note that unlike the {@link #FLAT_PROPERTY}, a * button marked with this property will never show the background * (will always be painted flat). * *

* Example of marking a button to never paint background: *

* * JButton button = new JButton("text");
* button.putClientProperty(SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY,
*   Boolean.TRUE); *
* *

* Example of marking all application buttons to never paint background: *

* * UIManager.put(SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY,
*   Boolean.TRUE); *
* * @since version 2.3 * @see #FLAT_PROPERTY */ @SubstanceApi public static final String BUTTON_PAINT_NEVER_PROPERTY = "substancelaf.buttonpaintnever"; /** * Client property name for specifying a straight side for a single button. * This property must be set on the specific button. The value can be: * *

*

    *
  • A value in {@link SubstanceConstants.Side} enum. *
  • Set of values in {@link SubstanceConstants.Side} enum. *
* *

* Note that not the {@link SubstanceButtonShaper} implementations are * required to respect this property. The default * {@link StandardButtonShaper} and {@link ClassicButtonShaper} respect this * property. *

* *

* Example of marking a button to have straight north side: *

* * JButton button = new JButton("text");
* button.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY,
*   SubstanceConstants.Side.RIGHT); *
* * @since version 2.1 * @see #BUTTON_OPEN_SIDE_PROPERTY */ @SubstanceApi public static final String BUTTON_SIDE_PROPERTY = "substancelaf.buttonside"; /** * Client property name for specifying an open side for a single button. * This property must be set on the specific button. The value can be: * *

*

    *
  • A value in {@link SubstanceConstants.Side} enum. *
  • Set of values in {@link SubstanceConstants.Side} enum. *
*

*

* Example of marking a button to have open top and west sides: *

* * JButton button = new JButton("text");
* Set openSides = EnumSet.of(Side.TOP, Side.WEST);
* button.putClientProperty(SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY,
*   openSides); *
* * @since version 3.1 * @see #BUTTON_SIDE_PROPERTY */ @SubstanceApi public static final String BUTTON_OPEN_SIDE_PROPERTY = "substancelaf.buttonopenSide"; /** * Client property name for specifying the corner radius for buttons. * Currently, this property is respected only on toolbar buttons. This * property can be set on the specific toolbar button, on the specific * toolbar (will hold for all buttons in the toolbar) or as a global setting * on {@link UIManager}. The value should be a positive {@link Float}. * *

* Example of specifying a (toolbar) button to have corner radius of 5 * pixels: *

* * JButton button = new JButton("text");
* button.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS,
*   Float.valueOf(5.0f)); *
* *

* Example of specifying all buttons of a toolbar to have corner radius of 3 * pixels: *

* * JToolBar toolbar = new JToolBar("toolbar");
* toolbar.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS,
*   Float.valueOf(3.0f)); *
* *

* Example of specifying all toolbar buttons to have corner radius of 0 * pixels: *

* * UIManager.put(SubstanceLookAndFeel.CORNER_RADIUS, Float.valueOf(0.0f)); * * * @since version 3.0 */ @SubstanceApi public static final String CORNER_RADIUS = "substancelaf.cornerRadius"; /** * Property name for specifying that the component should be painted flat * (no background / border) when it's inactive. This property should be * specified on a specific component or its parent and must have either * {@link Boolean#TRUE} or {@link Boolean#FALSE} value. * *

* Example how to mark a button to appear flat: *

* * * JButton button = new JButton("text");
* button.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY,
*   Boolean.TRUE); *
* * @since version 3.0 * @see #BUTTON_PAINT_NEVER_PROPERTY */ @SubstanceApi public static final String FLAT_PROPERTY = "substancelaf.componentFlat"; /** * VM property name for specifying the heap status trace file. The trace * file will contain information on the status of heap. The property value * is used as a filename for tracing the heap status. Example for specifying * the trace file name: * *

* * -Dsubstancelaf.heapStatusTraceFile=C:/temp/myApp.heap.log * *

* * @since version 5.0 */ @SubstanceApi public static final String HEAP_STATUS_TRACE_FILE = "substancelaf.heapStatusTraceFile"; /** * Client property name for specifying that contents of a frame, dialog, * internal frame, desktop icon or tab have been modified and not saved. The * property can be set on: *

*

    *
  • {@link JInternalFrame} - the close button of the specific * internal frame will be animated (in case that the internal frame has * decorated title pane). In addition, once such internal frame is iconified * (to a {@link JInternalFrame.JDesktopIcon}), the close button of the its * desktop icon is animated as well.
  • *
  • {@link JRootPane} - the close button of the title pane of the * matching frame / dialog will be animated (in case that the frame / dialog * have decorated title pane).
  • *
  • {@link JComponent} in a {@link JTabbedPane}. Based on the * {@link #TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION} property presence, * either the entire tab or its close button area is animated. In this case, * this property must be set on the tab component itself, not on one * of its child components.
  • *
*

*

* The animation cycles between red, orange and yellow color schemes. In * most cases (all but tabs not marked with * {@link #TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION} property), the * animation will be visible only when the mouse hovers over the close * button of the matching container (frame, dialog, internal frame, desktop * icon, tab). The tooltip of the close button is changed as well to reflect * that the container contents are marked as modified. *

* *

* Here is a sample text editing application that illustrates the use of * this property. Once the contents of the text pane are changed, the frame * is marked as modified. The Save button marks the frame as * not-modified. In the real application, the listener on this button will * need to persist the changes as well. *

* * * public class Changer extends JFrame {
*   public Changer() {
*     super("Changer");
*
*     this.setLayout(new BorderLayout());
*     JTextPane textArea = new JTextPane();
*     this.add(textArea, BorderLayout.CENTER);
*     textArea.getDocument().addDocumentListener(new * DocumentListener() {
*       private void handleChange() {
*         getRootPane().putClientProperty(
*             SubstanceLookAndFeel.WINDOW_MODIFIED, * Boolean.TRUE);
*       }
*
*       public void * changedUpdate(DocumentEvent e) {
*         handleChange();
*       }
*
*       public void * insertUpdate(DocumentEvent e) {
*         handleChange();
*       }
*
*       public void * removeUpdate(DocumentEvent e) {
*         handleChange();
*       }
*     });
*     
*     JPanel buttons = new JPanel(new * FlowLayout(FlowLayout.RIGHT));
*     JButton saveButton = new JButton("Save");
*     saveButton.addActionListener(new ActionListener() {
*       public void * actionPerformed(ActionEvent e) {
*         getRootPane().putClientProperty(
*             SubstanceLookAndFeel.WINDOW_MODIFIED, * Boolean.FALSE);
*       }
*     });
*     
*     buttons.add(saveButton);
*     this.add(buttons, BorderLayout.SOUTH);
*     
*     this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
*   }
*
*   public static void main(String ... args) {
*     try {
*       UIManager.setLookAndFeel(new * SubstanceLookAndFeel());
*     }
*     catch (Exception exc) {}
*     JFrame.setDefaultLookAndFeelDecorated(true);
*     Changer ch = new Changer();
*     ch.setPreferredSize(new Dimension(200, 200));
*     ch.setSize(ch.getPreferredSize());
*     ch.setLocationRelativeTo(null);
*     ch.setVisible(true);
*   }
} *
* * @since version 2.1 */ @SubstanceApi public final static String WINDOW_MODIFIED = "windowModified"; /** * Client property name for adding close buttons on tabs. This property can * be specified on a single tab component, on a {@link JTabbedPane} itself * (will hold for all tab components that don't define this property) or on * {@link UIManager}. The value should be either {@link Boolean#TRUE} or * {@link Boolean#FALSE}. By default, the close buttons are not displayed. * *

* Example of setting that all tabs in the application will have close * buttons: *

* * UIManager.put(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY,
*   Boolean.TRUE); *
* *

* A more complex example: *

* * UIManager.put(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY,
*   Boolean.TRUE);
* JTabbedPane jtpMain = new JTabbedPane();
* JTabbedPane jtpSecondary = new JTabbedPane();
* jtpSecondary.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY,
*   Boolean.FALSE);
* JPanel panelSecondary = new JPanel();
* jtpMain.addTab(jtpSecondary);
* jtpMain.addTab(panelSecondary);
* JPanel tab1 = new JPanel();
* JPanel tab2 = new JPanel();
* tab2.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY,
*   Boolean.TRUE);
* jtpSecondary.addTab(tab1);
* jtpSecondary.addTab(tab2); *
* *

* In the example above, the first first-level child (jtpSecondary) * doesn't have the close button (since it overrides the global setting). * The second first-level child tab (panelSecondary) has close button * (from the global UIManager setting). The first second-level tab * doesn't have the close button (setting inherited from the parent * jtpSecondary tab that overrides the global setting). The second * second-level tab has the close button (since its setting overrides the * parent setting). *

* * @since version 2.1 * @see #TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION * @see #TABBED_PANE_CLOSE_CALLBACK */ @SubstanceApi public final static String TABBED_PANE_CLOSE_BUTTONS_PROPERTY = "substancelaf.tabbedpanehasclosebuttons"; /** * Client property name for specifying that only the close button of a * marked-as-modified tab component should pulsate. This property can be * specified on a single tab component, on a {@link JTabbedPane} itself * (will hold for all tab components that don't define this property) or on * {@link UIManager}. The value should be either {@link Boolean#TRUE} or * {@link Boolean#FALSE}. By default, the animation on modified tabs is on * the entire tab rectangle. Note that this setting is only relevant for * tabs marked with {@link #WINDOW_MODIFIED} property. * *

* Example of setting that all tabs in the application will have modified * animation on close button: *

* * UIManager.put(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION,
*   Boolean.TRUE); *
* *

* A more complex example: *

* * UIManager.put(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION,
*   Boolean.TRUE);
* JTabbedPane jtpMain = new JTabbedPane();
* JTabbedPane jtpSecondary = new JTabbedPane();
* jtpSecondary.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION,
*   Boolean.FALSE);
* JPanel panelSecondary = new JPanel();
* jtpMain.addTab(jtpSecondary);
* jtpMain.addTab(panelSecondary);
* JPanel tab1 = new JPanel();
* JPanel tab2 = new JPanel();
* tab2.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION,
*   Boolean.TRUE);
* jtpSecondary.addTab(tab1);
* jtpSecondary.addTab(tab2); *
* *

* In the example above, the first first-level child (jtpSecondary) * has the animation on the entire tab (since it overrides the global * setting). The second first-level child tab (panelSecondary) has * animation on the close button (from the global UIManager setting). * The first second-level tab has the animation on the entire tab (setting * inherited from the parent jtpSecondary tab that overrides the * global setting). The second second-level tab has animation on the close * button (since its setting overrides the parent setting). *

* * @since version 2.2 * @see #TABBED_PANE_CLOSE_BUTTONS_PROPERTY * @see #TABBED_PANE_CLOSE_CALLBACK */ @SubstanceApi public final static String TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION = "substancelaf.tabbedpaneclosebuttonsmodifiedanimation"; /** * Client property name for specifying the callback for deciding on the tab * close type. This property can be specified on a single tab component, on * a {@link JTabbedPane} itself (will hold for all tab components that don't * define this property) or on {@link UIManager}. The value should be an * instance of {@link TabCloseCallback}. Note that this setting is only * relevant for tabs marked with {@link #TABBED_PANE_CLOSE_BUTTONS_PROPERTY} * property. * *

* Example of custom tab close callback set on a tabbed pane: *

* * TabCloseCallback closeCallback = new TabCloseCallback() {
*   public TabCloseKind onAreaClick(JTabbedPane tabbedPane,
*       int tabIndex, MouseEvent mouseEvent) {
*     if (mouseEvent.getButton() != MouseEvent.BUTTON3)
*       return TabCloseKind.NONE;
*     if (mouseEvent.isShiftDown()) {
*       return TabCloseKind.ALL;
*     }
*     return TabCloseKind.THIS;
*   }
*
*   public TabCloseKind onCloseButtonClick(JTabbedPane tabbedPane,
*       int tabIndex, MouseEvent mouseEvent) {
*     if (mouseEvent.isAltDown()) {
*       return TabCloseKind.ALL_BUT_THIS;
*     }
*     if (mouseEvent.isShiftDown()) {
*       return TabCloseKind.ALL;
*     }
*     return TabCloseKind.THIS;
*   }
*
*   public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) {
*     return null;
*   }
*
*   public String getCloseButtonTooltip(JTabbedPane tabbedPane,
*       int tabIndex) {
*     StringBuffer result = new StringBuffer();
*     result.append("<html><body>");
*     result.append("Mouse click closes <b>"
*         + tabbedPane.getTitleAt(tabIndex) + "</b> tab");
*     result.append("<br><b>Alt</b>-Mouse click closes all tabs but <b>"
*         + tabbedPane.getTitleAt(tabIndex) + "</b> tab");
*     result.append("<br><b>Shift</b>-Mouse click closes all tabs");
*     result.append("</body></html>");
*     return result.toString();
*   }
* };
* * JTabbedPane jtp = new JTabbedPane();
* jtp.putClientProperty(
*     SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK,
*     closeCallback); *
* * @since version 2.3 */ @SubstanceApi public final static String TABBED_PANE_CLOSE_CALLBACK = "substancelaf.tabbedpanecloseCallback"; /** * Client property name for specifying the content pane border kind. This * property can be specified either on a single {@link JTabbedPane} or on * {@link UIManager}. The value should be one of * {@link SubstanceConstants.TabContentPaneBorderKind} enum. By default, the * border kind is * {@link SubstanceConstants.TabContentPaneBorderKind#DOUBLE_FULL}. * *

* Example of setting that all tabbed panes in the application have single * full border (default setting prior to version 4.1): *

* * UIManager.put(SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND,
*   TabContentPaneBorderKind.SINGLE_FULL); *
* *

* Example of specifying that the specific tabbed pane has single full * border (default setting prior to version 4.1): *

* * JTabbedPane jtpMain = new JTabbedPane();
* jtpMain.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND,
*   TabContentPaneBorderKind.SINGLE_FULL); *
* * @since version 4.1 */ @SubstanceApi public final static String TABBED_PANE_CONTENT_BORDER_KIND = "substancelaf.tabbedPaneContentBorderKind"; /** * Client property name for specifying combo popup flyout orientation. This * property can be set on either a specific {@link JComboBox} or globally on * {@link UIManager}. The value should be one of the {@link Integer}s below: * *

*

    *
  • The default {@link SwingConstants#SOUTH} - the popup is displayed * directly below the combo aligned to the left. *
  • {@link SwingConstants#NORTH} - the popup is displayed directly above * the combo aligned to the left. *
  • {@link SwingConstants#EAST} - the popup is displayed to the left of * the combo aligned to the top. *
  • {@link SwingConstants#WEST} - the popup is displayed to the right of * the combo aligned to the top. *
  • {@link SwingConstants#CENTER} - the popup is displayed centered * vertically over the combo aligned to the left. *
*

* *

* Note that the combo arrow changes in accordance with the combo popup * flyout orientation. Example of setting a combobox with a custom flyout * orientation: *

* * JComboBox cb = new JComboBox(
*   new Object[] { "Ester", "Jordi", "Jordina", "Jorge", "Sergi" });
* cb.putClientProperty(SubstanceLookAndFeel.COMBO_BOX_POPUP_FLYOUT_ORIENTATION,
*   SwingConstants.CENTER); *
* * @since version 2.3 * @see #COMBO_POPUP_PROTOTYPE */ public final static String COMBO_BOX_POPUP_FLYOUT_ORIENTATION = "substancelaf.comboboxpopupFlyoutOrientation"; /** * Client property name for specifying scroll pane button policy. This * property can be set on either a specific {@link JScrollPane} or globally * on {@link UIManager}. The value should be one of the * {@link SubstanceConstants.ScrollPaneButtonPolicyKind} enum. Example of * setting a scroll pane with a custom button policy: * *

* * JScrollPane jsp = new JScrollPane(new JPanel());
* jsp.putClientProperty(SubstanceLookAndFeel.SCROLL_PANE_BUTTONS_POLICY,
*   ScrollPaneButtonPolicyKind.MULTIPLE); *
* * @since version 3.1 */ @SubstanceApi public final static String SCROLL_PANE_BUTTONS_POLICY = "substancelaf.scrollPaneButtonsPolicy"; /** * Property name for specifying that extra UI elements (such as menu items * in system menu or lock borders) should be shown. This property can be set * as a global setting on {@link UIManager} or as a client property on a * specific component. The value should be either {@link Boolean#TRUE} or * {@link Boolean#FALSE}. * *

* Example of setting this property on {@link UIManager}: *

* * UIManager.put(SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS, Boolean.TRUE); * SwingUtilities.updateComponentTree(myFrame); * * * @since version 5.0 */ @SubstanceApi public final static String SHOW_EXTRA_WIDGETS = "substancelaf.addWidgets"; /** * Property name for specifying menu gutter fill kind. Menu gutter is the * part of the menu where checkmarks and icons are painted. The value should * be one of {@link MenuGutterFillKind} enum. This property can be set * globally on the {@link UIManager}. The default value is * {@link MenuGutterFillKind#HARD}. * *

* Example of setting soft fill kind: *

* * UIManager.put(SubstanceLookAndFeel.MENU_GUTTER_FILL_KIND, MenuGutterFillKind.SOFT); * * * @since version 3.2 */ public final static String MENU_GUTTER_FILL_KIND = "substancelaf.menuGutterFillKind"; /** * Client property name for specifying the kind of focus indication on * buttons, check boxes and radio buttons. The value should be one of * {@link SubstanceConstants.FocusKind} enum. This property can be set * either on the specific component or as global property on * {@link UIManager}. * *

* In order to compute the kind of focus indication for some component, the * component's hierarchy is traversed bottom up. The first component that * has this property set, defines the focus indication kind. If neither * component nor its ancestors define this property, the global setting on * {@link UIManager} is checked. If there is no global setting, the default * {@link SubstanceConstants.FocusKind#ALL_INNER} is used. Here is an * example to illustrate the above: *

* * *   JPanel topPanel = new JPanel();
*   topPanel.putClientProperty(SubstanceLookAndFeel.FOCUS_KIND, FocusKind.UNDERLINE);
*   JPanel panel1 = new JPanel();
*   JButton b1 = new JButton("button1");
*   b1.putClientProperty(SubstanceLookAndFeel.FOCUS_KIND, FocusKind.TEXT);
*   JButton b2 = new JButton("button2");
*   JButton b3 = new JButton("button3");
*   b3.putClientProperty(SubstanceLookAndFeel.FOCUS_KIND, FocusKind.ALL_INNER);
*   panel1.add(b1);
*   panel1.add(b2);
*   topPanel.add(panel1);
*   topPanel.add(b3);
*
* *

* In the code above: *

*
    *
  • Button b1 will have {@link SubstanceConstants.FocusKind#NONE} * focus kind which is set directly on the button. *
  • Button b2 will have * {@link SubstanceConstants.FocusKind#UNDERLINE} focus kind which is * inherited from its topPanel parent. *
  • Button b3 will have * {@link SubstanceConstants.FocusKind#ALL_INNER} focus kind which is set * directly on the button. *
* * @since 2.2 * @see SubstanceConstants.FocusKind */ public final static String FOCUS_KIND = "substancelaf.focusKind"; /** * Property name for specifying the combobox popup prototype display value * which is used to compute the width of the popup at runtime. The property * value should be one of: * *

*

    *
  • {@link ComboPopupPrototypeCallback} - will provide * application-specific logic at runtime. *
  • {@link Object} - will point to the prototype entry itself. *
*

* *

* This property can be set either on a specific {@link JComboBox} or * globally on {@link UIManager}. *

* *

* Here is an example of combo popup prototype set to a model element: *

* * JComboBox comboProto1 = new JComboBox(new Object[] { "aa", "aaaaa",
*   "aaaaaaaaaa", "this one is the one", "aaaaaaaaaaaaaaaaaaaaa" });
* comboProto1.setPrototypeDisplayValue("aaaaa");
* comboProto1.putClientProperty(SubstanceLookAndFeel.COMBO_POPUP_PROTOTYPE,
*   "this one is the one"); *
* *

* Here is an example of combo popup prototype set to a dynamic callback. * This callback always returns the last model element: *

* * JComboBox comboProto3 = new JComboBox(new Object[] { "aa", "aaaaa",
*   "this is not", "this one is not it",
*   "this one is it that is for the popup" });
* comboProto3.setPrototypeDisplayValue("aaaaa");
* comboProto3.putClientProperty(SubstanceLookAndFeel.COMBO_POPUP_PROTOTYPE,
*   new ComboPopupPrototypeCallback() {
*     public Object getPopupPrototypeDisplayValue(JComboBox jc) {
*       return jc.getModel().getElementAt(
*         jc.getModel().getSize() - 1);
*     }
*   }); *
* * @since version 3.0 * @see #COMBO_BOX_POPUP_FLYOUT_ORIENTATION */ @SubstanceApi public final static String COMBO_POPUP_PROTOTYPE = "substancelaf.comboPopupPrototype"; /** * VM property name for specifying the trace file. The trace file will * contain output of the memory analyser which can be used to pinpoint the * memory leaks. The property value is used as a filename for tracing the * memory allocations. Example for specifying the trace file name: * *

* * -Dsubstancelaf.traceFile=C:/temp/myApp.substance.log * *

* * @since version 2.0 */ @SubstanceApi public final static String TRACE_FILE = "substancelaf.traceFile"; /** * Client property name for specifying the number of echo characters for * each password character. The value should be an instance of * {@link Integer}, otherwise will be ignored. This property can be set * either on a specific {@link JPasswordField} or globally on * {@link UIManager}. * *

* Example of having all password fields echo 3 characters per each typed * user character: *

* * UIManager.put(SubstanceLookAndFeel.PASSWORD_ECHO_PER_CHAR,
*   new Integer(3)); *
* *

* Example of having a specific password field echo 2 characters per each * typed user character: *

* * JPasswordField jpf = new JPasswordField();
* jpf.putClientProperty(SubstanceLookAndFeel.PASSWORD_ECHO_PER_CHAR,
*   new Integer(2)); *
* * @since version 2.2 */ @SubstanceApi public final static String PASSWORD_ECHO_PER_CHAR = "substancelaf.passwordEchoPerChar"; /** *

* Client property name for specifying that icons on controls sch as * buttons, toggle buttons, labels, tabs and menu items should match the * color of the current color scheme when they are in default state. The * control is in default state when it's not pressed, not selected, not * armed and not rolled over. The value should be an instance of * {@link Boolean}. By default, all controls show regular (full-color * original) icons. The value can be set globally on {@link UIManager}. *

* * @since version 3.3 */ @SubstanceApi public final static String USE_THEMED_DEFAULT_ICONS = "substancelaf.useThemedDefaultIcons"; /** *

* Client property name for specifying the colorization amount applied to * the background and foreground of the current color scheme and the * specific control. By default, when the application does not use any * custom colors, all the controls are painted with the colors of the * current color scheme / skin. The colors coming from the look-and-feel * implement the marker {@link UIResource} interface which allows the UI * delegates to differentiate between application-specific colors which are * not changed, and the LAF-provide colors that are changed on LAF switch. *

* *

* This new client property installs the "smart colorization" mode which * uses the colors of the current color scheme and the custom background / * foreground colors (when installed by application) to colorize the * relevant portions of the control. For example, on checkbox the custom * background color will be used to colorize the check box itself, while the * custom foreground color will be applied to the check box text and the * check mark. *

* *

* The value of this property specifies the actual colorization amount. * Value of 0.0 results in Substance completely ignoring * the custom application background and foreground colors set on the * components - no colorization. Values closer to 1.0 result in almost full * usage of the custom application background and foreground colors set on * the components. Note that in order to maintain the gradients (fill, * border, etc), even value of 1.0 does not result in full custom color * being applied to the relevant visuals of the control. *

* *

* This property can be specified globally on {@link UIManager}, applying on * all controls, or on the specific component / container. In the later * case, the value will be applied to the component / container itself and * all its children that do not specify a custom value for this property. *

* *

* The default colorization amount (when this property is not set at all) is * 0.5. This means that applications that install custom background / * foreground colors on their UI controls will see them colorized with 50% * "strength", even without setting this property. *

* *

* The value should be an instance of {@link Double} in 0.0-1.0 range. *

* *

* Example of marking a button to have a custom background color and * colorizing it with 40%: *

* * JButton jb = new JButton("sample", myIcon);
* jb.setBackground(Color.red);
* jb.putClientProperty(SubstanceLookAndFeel.COLORIZATION_FACTOR,
*   new Double(0.4)); *
* *

* Note that components in decoration areas registered on the current skin * will ignore the colorization on custom background color. The background * of such components is always painted by the skin's decoration painter to * ensure consistent background painting of the relevant decoration area. *

* * @since version 4.2 * @see Component#setBackground(Color) * @see Component#setForeground(Color) */ @SubstanceApi public final static String COLORIZATION_FACTOR = "substancelaf.colorizationFactor"; /** * Internal client property name for storing application-specific font * policy. * * @since version 3.3 * @see #setFontPolicy(FontPolicy) * @see #getFontPolicy() */ protected final static String SUBSTANCE_FONT_POLICY_KEY = "substancelaf.fontPolicyKey"; /** * Property name for specifying outline shaper. This property is used a * client property that can be set on a specific control. * *

* The value must be a {@link SubstanceButtonShaper} object. *

* *

* Example of using a {@link SubstanceButtonShaper} object as client * property value: *

* * JButton b = new JButton("text");
* b.putClientProperty(SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY,
*   new ClassicButtonShaper()); *
* * @since version 2.1 */ @SubstanceApi public static final String BUTTON_SHAPER_PROPERTY = "substancelaf.buttonShaper"; /** * Property name for specifying a skin to be used on the specific root pane. * This property can only be installed on a {@link JRootPane} and will * affect all the controls in that root pane. The value must be an instance * of {@link SubstanceSkin}. After setting this property, call * {@link SwingUtilities#updateComponentTreeUI(Component)} on the matching * window. * * @since version 5.0 * @see #getCurrentSkin(Component) */ @SubstanceApi public static final String SKIN_PROPERTY = "substancelaf.skin"; /** * Resource bundle for Substance labels. */ private static ResourceBundle LABEL_BUNDLE = null; /** * Class loader for {@link #LABEL_BUNDLE}. */ private static ClassLoader labelBundleClassLoader; /** * The skin of this look-and-feel instance. */ protected SubstanceSkin skin; /** * The name of this look-and-feel instance. */ protected String name; /** * Creates a new skin-based Substance look-and-feel. This is the only way to * create an instance of {@link SubstanceLookAndFeel} class. * * @param skin * Skin. */ protected SubstanceLookAndFeel(SubstanceSkin skin) { this.skin = skin; this.name = "Substance " + skin.getDisplayName(); initPluginsIfNecessary(); } /** * Initializes the plugins if necessary. */ protected static void initPluginsIfNecessary() { if (SubstanceLookAndFeel.skinPlugins != null) return; SubstanceLookAndFeel.skinPlugins = new PluginManager( SubstanceLookAndFeel.PLUGIN_XML, LafPlugin.TAG_MAIN, SubstanceSkinPlugin.TAG_SKIN_PLUGIN_CLASS); SubstanceLookAndFeel.componentPlugins = new ComponentPluginManager( SubstanceLookAndFeel.PLUGIN_XML); } /** * Retrieves the current label bundle. * * @return The current label bundle. * @see #resetLabelBundle() */ public static synchronized ResourceBundle getLabelBundle() { if (SubstanceLookAndFeel.LABEL_BUNDLE == null) { // fix for RFE 157 (allowing custom class loader for // resource bundles which can remove server calls // in applets) if (SubstanceLookAndFeel.labelBundleClassLoader == null) { SubstanceLookAndFeel.LABEL_BUNDLE = ResourceBundle.getBundle( "org.jvnet.substance.resources.Labels", Locale .getDefault()); } else { SubstanceLookAndFeel.LABEL_BUNDLE = ResourceBundle.getBundle( "org.jvnet.substance.resources.Labels", Locale .getDefault(), SubstanceLookAndFeel.labelBundleClassLoader); } for (LocaleChangeListener lcl : SubstanceLookAndFeel.localeChangeListeners) lcl.localeChanged(); } return SubstanceLookAndFeel.LABEL_BUNDLE; } /** * Retrieves the label bundle for the specified locale. * * @param locale * Locale. * @return The label bundle for the specified locale. */ public static synchronized ResourceBundle getLabelBundle(Locale locale) { // fix for RFE 157 (allowing custom class loader for // resource bundles which can remove server calls // in applets) if (SubstanceLookAndFeel.labelBundleClassLoader == null) { return ResourceBundle.getBundle( "org.jvnet.substance.resources.Labels", locale); } else { return ResourceBundle.getBundle( "org.jvnet.substance.resources.Labels", locale, SubstanceLookAndFeel.labelBundleClassLoader); } } /** * Resets the current label bundle. Useful when the application changes * Locale at runtime. * * @see #getLabelBundle() */ public static synchronized void resetLabelBundle() { SubstanceLookAndFeel.LABEL_BUNDLE = null; LafWidgetRepository.resetLabelBundle(); } /** * Returns the current global skin. If the current look-and-feel is not * Substance, this method returns null. This method is for * internal use only. Applications should use the * {@link #getCurrentSkin(Component)}. * * @return Current global skin. * @see #getCurrentSkin(Component) */ public static SubstanceSkin getCurrentSkin() { LookAndFeel current = UIManager.getLookAndFeel(); if (current instanceof SubstanceLookAndFeel) { return currentSkin; } return null; } /** * Returns the current skin for the specified component. If the current * look-and-feel is not Substance, this method returns null. * * @param c * Component. May be null - in this case the global * current Substance skin will be returned. * @return Current skin for the specified component. * @see #SKIN_PROPERTY * @see #getCurrentSkin() */ @SubstanceApi public static SubstanceSkin getCurrentSkin(Component c) { return SubstanceCoreUtilities.getSkin(c); } /* * (non-Javadoc) * * @see javax.swing.LookAndFeel#getDescription() */ @Override public String getDescription() { return "Substance Look and Feel by Kirill Grouchnikov"; } /* * (non-Javadoc) * * @see javax.swing.LookAndFeel#getID() */ @Override public String getID() { return this.name; } /* * (non-Javadoc) * * @see javax.swing.LookAndFeel#getName() */ @Override public String getName() { return this.name; } /* * (non-Javadoc) * * @see javax.swing.LookAndFeel#isNativeLookAndFeel() */ @Override public boolean isNativeLookAndFeel() { return false; } /* * (non-Javadoc) * * @see javax.swing.LookAndFeel#isSupportedLookAndFeel() */ @Override public boolean isSupportedLookAndFeel() { return true; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicLookAndFeel#initClassDefaults(javax.swing * .UIDefaults) */ @Override protected void initClassDefaults(UIDefaults table) { super.initClassDefaults(table); String UI_CLASSNAME_PREFIX = "org.jvnet.substance.Substance"; Object[] uiDefaults = { "ButtonUI", UI_CLASSNAME_PREFIX + "ButtonUI", "CheckBoxUI", UI_CLASSNAME_PREFIX + "CheckBoxUI", "ComboBoxUI", UI_CLASSNAME_PREFIX + "ComboBoxUI", "CheckBoxMenuItemUI", UI_CLASSNAME_PREFIX + "CheckBoxMenuItemUI", "DesktopIconUI", UI_CLASSNAME_PREFIX + "DesktopIconUI", "DesktopPaneUI", UI_CLASSNAME_PREFIX + "DesktopPaneUI", "EditorPaneUI", UI_CLASSNAME_PREFIX + "EditorPaneUI", "FileChooserUI", UI_CLASSNAME_PREFIX + "FileChooserUI", // "FileChooserUI", "javax.swing.plaf.metal.MetalFileChooserUI", "FormattedTextFieldUI", UI_CLASSNAME_PREFIX + "FormattedTextFieldUI", "InternalFrameUI", UI_CLASSNAME_PREFIX + "InternalFrameUI", "LabelUI", UI_CLASSNAME_PREFIX + "LabelUI", "ListUI", UI_CLASSNAME_PREFIX + "ListUI", "MenuUI", UI_CLASSNAME_PREFIX + "MenuUI", "MenuBarUI", UI_CLASSNAME_PREFIX + "MenuBarUI", "MenuItemUI", UI_CLASSNAME_PREFIX + "MenuItemUI", "OptionPaneUI", UI_CLASSNAME_PREFIX + "OptionPaneUI", "PanelUI", UI_CLASSNAME_PREFIX + "PanelUI", "PasswordFieldUI", UI_CLASSNAME_PREFIX + "PasswordFieldUI", "PopupMenuUI", UI_CLASSNAME_PREFIX + "PopupMenuUI", "PopupMenuSeparatorUI", UI_CLASSNAME_PREFIX + "PopupMenuSeparatorUI", "ProgressBarUI", UI_CLASSNAME_PREFIX + "ProgressBarUI", "RadioButtonUI", UI_CLASSNAME_PREFIX + "RadioButtonUI", "RadioButtonMenuItemUI", UI_CLASSNAME_PREFIX + "RadioButtonMenuItemUI", "RootPaneUI", UI_CLASSNAME_PREFIX + "RootPaneUI", "ScrollBarUI", UI_CLASSNAME_PREFIX + "ScrollBarUI", "ScrollPaneUI", UI_CLASSNAME_PREFIX + "ScrollPaneUI", "SeparatorUI", UI_CLASSNAME_PREFIX + "SeparatorUI", "SliderUI", UI_CLASSNAME_PREFIX + "SliderUI", "SpinnerUI", UI_CLASSNAME_PREFIX + "SpinnerUI", "SplitPaneUI", UI_CLASSNAME_PREFIX + "SplitPaneUI", "TabbedPaneUI", UI_CLASSNAME_PREFIX + "TabbedPaneUI", "TableUI", UI_CLASSNAME_PREFIX + "TableUI", "TableHeaderUI", UI_CLASSNAME_PREFIX + "TableHeaderUI", "TextAreaUI", UI_CLASSNAME_PREFIX + "TextAreaUI", "TextFieldUI", UI_CLASSNAME_PREFIX + "TextFieldUI", "TextPaneUI", UI_CLASSNAME_PREFIX + "TextPaneUI", "ToggleButtonUI", UI_CLASSNAME_PREFIX + "ToggleButtonUI", "ToolBarUI", UI_CLASSNAME_PREFIX + "ToolBarUI", "ToolBarSeparatorUI", UI_CLASSNAME_PREFIX + "ToolBarSeparatorUI", "ToolTipUI", UI_CLASSNAME_PREFIX + "ToolTipUI", "TreeUI", UI_CLASSNAME_PREFIX + "TreeUI", }; table.putDefaults(uiDefaults); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicLookAndFeel#initComponentDefaults(javax.swing * .UIDefaults) */ @Override protected void initComponentDefaults(UIDefaults table) { super.initComponentDefaults(table); initFontDefaults(table); this.skin.addCustomEntriesToTable(table); } /** * Sets the {@link FontPolicy} to be used with Substance family. If the * specified policy is null, the default will be reset. This * method does not require Substance to be the current look-and-feel, and * will cause Substance to be set as the current application look-and-feel. * * @param fontPolicy * The {@link FontPolicy} to be used with Substance family, or * null to reset to the default * * @see #getFontPolicy() * @see SubstanceLookAndFeel#SUBSTANCE_FONT_POLICY_KEY */ @SubstanceApi public static void setFontPolicy(FontPolicy fontPolicy) { UIManager.put(SUBSTANCE_FONT_POLICY_KEY, fontPolicy); SubstanceSizeUtils.setControlFontSize(-1); SubstanceSizeUtils.resetPointsToPixelsRatio(fontPolicy); SubstanceLookAndFeel.setSkin(SubstanceLookAndFeel.getCurrentSkin()); } /** * Looks up and retrieves the {@link FontPolicy} used by the Substance * family. If a {@link FontPolicy} has been set, it'll be returned. * Otherwise, this method checks if a {@link FontPolicy} or {@link FontSet} * is defined in the system properties or UIDefaults. If so, it is returned. * If no {@link FontPolicy} has been set for this look, in the system * properties or {@link UIDefaults}, the default Substance font policy will * be returned. * * @return the {@link FontPolicy} set for this Look&feel - if any, the * {@link FontPolicy} specified in the system properties or * {@link UIDefaults} - if any, or the default Substance font * policy. * * @see #setFontPolicy * @see FontPolicies * @see FontPolicies#customSettingsPolicy(FontPolicy) */ @SubstanceApi public static FontPolicy getFontPolicy() { FontPolicy policy = (FontPolicy) UIManager .get(SUBSTANCE_FONT_POLICY_KEY); if (policy != null) return policy; // return default policy return SubstanceFontUtilities.getDefaultFontPolicy(); } /** * Looks up the correct control font and sets it for all controls. * * @param table * The UI defaults table. */ private void initFontDefaults(UIDefaults table) { FontSet substanceFontSet = getFontPolicy() .getFontSet("Substance", null); initFontDefaults(table, substanceFontSet); } /** * Sets Fonts in the given FontSet as defaults for all known component types * in the given UIDefaults table. * * @param table * the UIDefaults table used to set fonts * @param fontSet * describes the set of Fonts to be installed */ private static void initFontDefaults(UIDefaults table, FontSet fontSet) { Font controlFont = fontSet.getControlFont(); Font menuFont = fontSet.getMenuFont(); Font messageFont = fontSet.getMessageFont(); Font toolTipFont = fontSet.getSmallFont(); Font titleFont = fontSet.getTitleFont(); Font windowFont = fontSet.getWindowTitleFont(); // System.out.println("Control: " + fontSet.getControlFont()); // System.out.println("Menu: " + fontSet.getMenuFont()); // System.out.println("Message: " + fontSet.getMessageFont()); // System.out.println("Small: " + fontSet.getSmallFont()); // System.out.println("Title: " + fontSet.getTitleFont()); // System.out.println("Window title: " + fontSet.getWindowTitleFont()); Object[] defaults = { "Button.font", controlFont, "CheckBox.font", controlFont, "ColorChooser.font", controlFont, "ComboBox.font", controlFont, "EditorPane.font", controlFont, "FormattedTextField.font", controlFont, "Label.font", controlFont, "List.font", controlFont, "Panel.font", controlFont, "PasswordField.font", controlFont, "ProgressBar.font", controlFont, "RadioButton.font", controlFont, "ScrollPane.font", controlFont, "Spinner.font", controlFont, "TabbedPane.font", controlFont, "Table.font", controlFont, "TableHeader.font", controlFont, "TextArea.font", controlFont, "TextField.font", controlFont, "TextPane.font", controlFont, "ToolBar.font", controlFont, "ToggleButton.font", controlFont, "Tree.font", controlFont, "Viewport.font", controlFont, "InternalFrame.titleFont", windowFont, "DesktopIcon.titleFont", windowFont, "OptionPane.font", messageFont, "OptionPane.messageFont", messageFont, "OptionPane.buttonFont", messageFont, "TitledBorder.font", titleFont, "ToolTip.font", toolTipFont, "CheckBoxMenuItem.font", menuFont, "CheckBoxMenuItem.acceleratorFont", menuFont, "Menu.font", menuFont, "Menu.acceleratorFont", menuFont, "MenuBar.font", menuFont, "MenuItem.font", menuFont, "MenuItem.acceleratorFont", menuFont, "PopupMenu.font", menuFont, "RadioButtonMenuItem.font", menuFont, "RadioButtonMenuItem.acceleratorFont", menuFont, // ? }; table.putDefaults(defaults); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicLookAndFeel#getDefaults() */ @Override public UIDefaults getDefaults() { UIDefaults table = super.getDefaults(); SubstanceLookAndFeel.componentPlugins.processAllDefaultsEntries(table, this.skin); return table; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicLookAndFeel#initialize() */ @Override public void initialize() { super.initialize(); ShadowPopupFactory.install(); setSkin(this.skin, false); // tracer for memory analysis String paramTraceFile = SubstanceCoreUtilities .getVmParameter(SubstanceLookAndFeel.TRACE_FILE); if (paramTraceFile != null) { MemoryAnalyzer.commence(1000, paramTraceFile); for (Object plugin : SubstanceLookAndFeel.componentPlugins .getAvailablePlugins(true)) MemoryAnalyzer.enqueueUsage("Has plugin '" + plugin.getClass().getName() + "'"); } // to show heap status panel in title pane? String heapStatusPanelParam = SubstanceCoreUtilities .getVmParameter(SubstanceLookAndFeel.HEAP_STATUS_TRACE_FILE); SubstanceTitlePane.setHeapStatusLogfileName(heapStatusPanelParam); // initialize component plugins SubstanceLookAndFeel.componentPlugins.initializeAll(); // initialize widget support LafWidgetRepository.getRepository().setLafSupport( new SubstanceWidgetSupport()); // fix for defect 208 - tracking changes to focus owner // and repainting the default button this.focusOwnerChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("focusOwner".equals(evt.getPropertyName())) { Component newFocusOwner = (Component) evt.getNewValue(); if (newFocusOwner != null) { JRootPane rootPane = SwingUtilities .getRootPane(newFocusOwner); if (rootPane == null) return; JButton defaultButton = rootPane.getDefaultButton(); if (defaultButton == null) return; defaultButton.repaint(); } } if ("managingFocus".equals(evt.getPropertyName())) { if (Boolean.FALSE.equals(evt.getNewValue())) { // new keyboard focus manager has been installed currentKeyboardFocusManager .removePropertyChangeListener(focusOwnerChangeListener); currentKeyboardFocusManager = KeyboardFocusManager .getCurrentKeyboardFocusManager(); currentKeyboardFocusManager .addPropertyChangeListener(focusOwnerChangeListener); } } } }; this.currentKeyboardFocusManager = KeyboardFocusManager .getCurrentKeyboardFocusManager(); this.currentKeyboardFocusManager .addPropertyChangeListener(this.focusOwnerChangeListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicLookAndFeel#uninitialize() */ @Override public void uninitialize() { super.uninitialize(); SubstanceLookAndFeel.currentSkin = null; ShadowPopupFactory.uninstall(); SubstanceCoreUtilities.stopThreads(); // fix for defect 109 - memory leak on watermarks if (this.skin.getWatermark() != null) this.skin.getWatermark().dispose(); // uninitialize component plugins SubstanceLookAndFeel.componentPlugins.uninitializeAll(); // reset widget support LafWidgetRepository.getRepository().unsetLafSupport(); // clear caches LazyResettableHashMap.reset(); this.currentKeyboardFocusManager .removePropertyChangeListener(this.focusOwnerChangeListener); this.focusOwnerChangeListener = null; this.currentKeyboardFocusManager = null; } /** * Registers a new listener on skin change. * * @param skinChangeListener * New listener on skin change. * @see #setSkin(String) * @see #setSkin(SubstanceSkin) * @see #unregisterSkinChangeListener(SkinChangeListener) */ @SubstanceApi public static void registerSkinChangeListener( SkinChangeListener skinChangeListener) { SubstanceLookAndFeel.skinChangeListeners.add(skinChangeListener); } /** * Unregisters a listener on skin change. * * @param skinChangeListener * The listener to unregister. * @see #setSkin(String) * @see #setSkin(SubstanceSkin) * @see #registerSkinChangeListener(SkinChangeListener) */ @SubstanceApi public static void unregisterSkinChangeListener( SkinChangeListener skinChangeListener) { SubstanceLookAndFeel.skinChangeListeners.remove(skinChangeListener); } /** * Registers the specified listener on tab-close events on all tabbed * panes. * * @param tabCloseListener * Listener to register. * @see #registerTabCloseChangeListener(JTabbedPane, BaseTabCloseListener) * @see #unregisterTabCloseChangeListener(BaseTabCloseListener) * @see #unregisterTabCloseChangeListener(JTabbedPane, BaseTabCloseListener) */ @SubstanceApi public static void registerTabCloseChangeListener( BaseTabCloseListener tabCloseListener) { TabCloseListenerManager.getInstance() .registerListener(tabCloseListener); } /** * Registers the specified listener on tab-close events on the * specified tabbed pane. * * @param tabbedPane * Tabbed pane. If null, the tab close listener is * registered globally (for all tabbed panes). * @param tabCloseListener * Listener to register. * @see #registerTabCloseChangeListener(BaseTabCloseListener) * @see #unregisterTabCloseChangeListener(BaseTabCloseListener) * @see #unregisterTabCloseChangeListener(JTabbedPane, BaseTabCloseListener) */ @SubstanceApi public static void registerTabCloseChangeListener(JTabbedPane tabbedPane, BaseTabCloseListener tabCloseListener) { TabCloseListenerManager.getInstance().registerListener(tabbedPane, tabCloseListener); } /** * Unregisters the specified listener on tab-close events on all * tabbed panes. * * @param tabCloseListener * Listener to unregister. * @see #registerTabCloseChangeListener(BaseTabCloseListener) * @see #registerTabCloseChangeListener(JTabbedPane, BaseTabCloseListener) * @see #unregisterTabCloseChangeListener(JTabbedPane, BaseTabCloseListener) */ @SubstanceApi public static void unregisterTabCloseChangeListener( BaseTabCloseListener tabCloseListener) { TabCloseListenerManager.getInstance().unregisterListener( tabCloseListener); } /** * Unregisters the specified listener on tab-close events on the * specified tabbed pane. * * @param tabbedPane * Tabbed pane. If null, the tab close listener is * unregistered globally (for all tabbed panes). * @param tabCloseListener * Listener to unregister. * @see #registerTabCloseChangeListener(BaseTabCloseListener) * @see #registerTabCloseChangeListener(JTabbedPane, BaseTabCloseListener) * @see #unregisterTabCloseChangeListener(BaseTabCloseListener) */ @SubstanceApi public static void unregisterTabCloseChangeListener(JTabbedPane tabbedPane, BaseTabCloseListener tabCloseListener) { TabCloseListenerManager.getInstance().unregisterListener(tabbedPane, tabCloseListener); } /** * Returns the set of all listeners registered on tab-close events on * all tabbed panes. * * @return Set of all listeners registered on tab-close events on all * tabbed panes. */ @SubstanceApi public static Set getAllTabCloseListeners() { return TabCloseListenerManager.getInstance().getListeners(); } /** * Returns all listeners registered on tab closing of the specified tabbed * pane. * * @param tabbedPane * A tabbed pane. If null, all globally registered * tab close listeners are returned. * @return All listeners registered on tab closing of the specified tabbed * pane. */ @SubstanceApi public static Set getAllTabCloseListeners( JTabbedPane tabbedPane) { return TabCloseListenerManager.getInstance().getListeners(tabbedPane); } /** * Registers a new listener on locale change. * * @param localeListener * New listener on locale change. */ @SubstanceApi public static void registerLocaleChangeListener( LocaleChangeListener localeListener) { SubstanceLookAndFeel.localeChangeListeners.add(localeListener); } /** * Unregisters a listener on locale change. * * @param localeListener * The listener to unregister. */ @SubstanceApi public static void unregisterLocaleChangeListener( LocaleChangeListener localeListener) { SubstanceLookAndFeel.localeChangeListeners.remove(localeListener); } /** * Returns all listeners registered on locale change. * * @return All listeners registered on locale change. */ @SubstanceApi public static Set getLocaleListeners() { return Collections .unmodifiableSet(SubstanceLookAndFeel.localeChangeListeners); } /** * Sets the visibility of the specified widget kind(s). If the first * rootPane parameter is null, this call applies * to all root panes. * * @param rootPane * Root pane. May be null. * @param visible * Visibility indication. * @param substanceWidgets * Widget types. * @since version 5.0 */ @SubstanceApi public static void setWidgetVisible(JRootPane rootPane, boolean visible, SubstanceWidgetType... substanceWidgets) { SubstanceWidgetManager.getInstance().register(rootPane, visible, substanceWidgets); if (rootPane != null) { SwingUtilities.updateComponentTreeUI(rootPane); } else { for (Window window : Window.getWindows()) { JRootPane root = SwingUtilities.getRootPane(window); SwingUtilities.updateComponentTreeUI(root); } } } /** * Checks whether the JOptionPanes created with predefined * message types should use constant color schemes for the icons. * * @return true if the JOptionPanes created with * predefined message types should use constant color schemes for * the icons, false otherwise. * @see #setToUseConstantThemesOnDialogs(boolean) */ @SubstanceApi public static boolean isToUseConstantThemesOnDialogs() { return SubstanceLookAndFeel.toUseConstantThemesOnDialogs; } /** * Sets the new setting for the icons of the JOptionPanes * created with predefined message types. * * @param toUseConstantThemesOnDialogs * if true, the JOptionPanes created * with predefined message types should use constant color * schemes for the icons. * @see #isToUseConstantThemesOnDialogs() */ @SubstanceApi public static void setToUseConstantThemesOnDialogs( boolean toUseConstantThemesOnDialogs) { SubstanceLookAndFeel.toUseConstantThemesOnDialogs = toUseConstantThemesOnDialogs; SwingUtilities.invokeLater(new Runnable() { public void run() { for (Window window : Window.getWindows()) { SwingUtilities.updateComponentTreeUI(window); } } }); } /** * The current Substance skin. */ private static SubstanceSkin currentSkin = null; /** * Sets the specified skin. If the current look-and-feel is not Substance, * this method will create a new Substance look-and-feel based on the * specified skin and set it on {@link UIManager}. This method does not * require Substance to be the current look-and-feel. * * @param newSkin * Skin to set. * @param toUpdateWindows * if true, the * {@link SwingUtilities#updateComponentTreeUI(Component)} is * called on all windows returned by {@link Window#getWindows()} * API. * @return true if the specified skin has been set * successfully, false otherwise. * @see #setSkin(SubstanceSkin) */ @SubstanceApi private static boolean setSkin(SubstanceSkin newSkin, boolean toUpdateWindows) { if (!SwingUtilities.isEventDispatchThread()) { throw new IllegalStateException( "This method must be called on the Event Dispatch Thread"); } if (!newSkin.isValid()) return false; boolean isSubstance = (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel); if (!isSubstance) { class SkinDerivedLookAndFeel extends SubstanceLookAndFeel { public SkinDerivedLookAndFeel(SubstanceSkin newSkin) { super(newSkin); } } LookAndFeel derived = new SkinDerivedLookAndFeel(newSkin); try { UIManager.setLookAndFeel(derived); } catch (UnsupportedLookAndFeelException ulafe) { return false; } if (!(UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel)) { return false; } for (Window window : Window.getWindows()) { SwingUtilities.updateComponentTreeUI(window); } return true; } try { // Required skin settings must be non-null if (!newSkin.isValid()) { return false; } // fix for defect 109 - memory leak on watermark switch if ((currentSkin != null) && (currentSkin.getWatermark() != null)) { currentSkin.getWatermark().dispose(); } if (newSkin.getWatermark() != null) { if (!newSkin.getWatermark().updateWatermarkImage(newSkin)) { return false; } } UIDefaults defaults = UIManager.getLookAndFeelDefaults(); // The table will be null when the skin is set using a custom // LAF if (defaults != null) { initFontDefaults(UIManager.getLookAndFeelDefaults(), SubstanceLookAndFeel.getFontPolicy().getFontSet( "Substance", null)); newSkin.addCustomEntriesToTable(UIManager .getLookAndFeelDefaults()); SubstanceLookAndFeel.componentPlugins .processAllDefaultsEntries(UIManager .getLookAndFeelDefaults(), newSkin); } if (isSubstance) LazyResettableHashMap.reset(); currentSkin = newSkin; if (toUpdateWindows) { for (Window window : Window.getWindows()) { SwingUtilities.updateComponentTreeUI(window); } } // SwingUtilities.invokeLater(new Runnable() { // public void run() { for (SkinChangeListener skinChangeListener : SubstanceLookAndFeel.skinChangeListeners) skinChangeListener.skinChanged(); // } // }); return true; } catch (NoClassDefFoundError ncdfe) { // this may happen when a skin references some class // that can't be found in the classpath. return false; } catch (Exception e) { return false; } } /** * Sets the specified skin. If the current look-and-feel is not Substance, * this method will create a new Substance look-and-feel based on the * specified skin and set it on {@link UIManager}. This method does not * require Substance to be the current look-and-feel. Calling this method * will call {@link SwingUtilities#updateComponentTreeUI(Component)} on all * open top-level windows. * * @param newSkin * Skin to set. * @return true if the specified skin has been set * successfully, false otherwise. * @throws IllegalStateException * When called outside the Event Dispatch Thread. * @see #registerSkinChangeListener(SkinChangeListener) * @see #unregisterSkinChangeListener(SkinChangeListener) * @see SubstanceSkin#isValid() */ public static boolean setSkin(SubstanceSkin newSkin) { return setSkin(newSkin, true); } /** * Sets the specified skin. If the current look-and-feel is not Substance, * this method will create a new Substance look-and-feel based on the * specified skin and set it on {@link UIManager}. This method does not * require Substance to be the current look-and-feel. Calling this method * will call {@link SwingUtilities#updateComponentTreeUI(Component)} on all * open top-level windows. * * @param skinClassName * Skin to set. * @return true if the specified skin has been set * successfully, false otherwise. * @throws IllegalStateException * When called outside the Event Dispatch Thread. * @since version 3.1 * @see #setSkin(SubstanceSkin) * @see #registerSkinChangeListener(SkinChangeListener) * @see #unregisterSkinChangeListener(SkinChangeListener) * @see SubstanceSkin#isValid() */ @SubstanceApi public static boolean setSkin(String skinClassName) { try { Class skinClass = Class.forName(skinClassName); if (skinClass == null) { return false; } Object obj = skinClass.newInstance(); if (obj == null) { return false; } if (!(obj instanceof SubstanceSkin)) { return false; } return SubstanceLookAndFeel.setSkin((SubstanceSkin) obj); } catch (Exception exc) { exc.printStackTrace(); return false; } } /** * Returns all available skins. * * @return All available skins. Key - skin display name, value - skin * information. */ @SubstanceApi public static Map getAllSkins() { initPluginsIfNecessary(); Map result = new TreeMap(); for (Object skinPlugin : SubstanceLookAndFeel.skinPlugins .getAvailablePlugins(true)) { for (SkinInfo skinInfo : ((SubstanceSkinPlugin) skinPlugin) .getSkins()) { result.put(skinInfo.getDisplayName(), skinInfo); } } return result; } /* * (non-Javadoc) * * @see javax.swing.LookAndFeel#getSupportsWindowDecorations() */ @Override public boolean getSupportsWindowDecorations() { return true; } /** * Sets the class loader for {@link #LABEL_BUNDLE}. * * @param labelBundleClassLoader * Class loader for {@link #LABEL_BUNDLE}. * @since version 3.1 */ public static void setLabelBundleClassLoader( ClassLoader labelBundleClassLoader) { SubstanceLookAndFeel.labelBundleClassLoader = labelBundleClassLoader; LafWidgetRepository.setLabelBundleClassLoader(labelBundleClassLoader); } /** * Returns the title pane of the specified top-level window. * * @param window * Top-level window. * @return If the parameter is either {@link JFrame} or {@link JDialog} and * has custom decorations, the result is the title pane, * null otherwise. * @since version 3.1 */ @SubstanceApi public static JComponent getTitlePaneComponent(Window window) { JRootPane rootPane = null; if (window instanceof JFrame) { JFrame f = (JFrame) window; rootPane = f.getRootPane(); } if (window instanceof JDialog) { JDialog d = (JDialog) window; rootPane = d.getRootPane(); } if (rootPane != null) { SubstanceRootPaneUI ui = (SubstanceRootPaneUI) rootPane.getUI(); return ui.getTitlePane(); } return null; } /** * Sets the decoration type of the specified component and all its children. * * @param comp * Component. * @param type * Decoration type of the component and all its children. */ @SubstanceApi public static void setDecorationType(JComponent comp, DecorationAreaType type) { DecorationPainterUtils.setDecorationType(comp, type); } // /** // * Sets the decoration type of the specified component. // * // * @param comp // * Component. // * @param type // * Decoration type of the component and its children if // * isPropagatingToChildren is true. // * @param isPropagatingToChildren // * If true, the decoration type will be applied to // * the component children. // */ // @SubstanceApi // public static void setDecorationType(JComponent comp, // DecorationAreaType type, boolean isPropagatingToChildren) { // SubstanceDecorationUtilities.setDecorationType(comp, type, // isPropagatingToChildren); // } /** * Returns the decoration area type of the specified component. The * component and its ancestor hierarchy are scanned for the registered * decoration area type. The farthest ancestor that was passed to * {@link #setDecorationType(JComponent, DecorationAreaType, boolean)} with * the isPropagatingToChildren not set to false * (the second part is not checked for the component itself) defines the * result. * * @param comp * Component. * @return Decoration area type of the component. */ public static DecorationAreaType getDecorationType(Component comp) { return DecorationPainterUtils.getDecorationType(comp); } /** * Returns the immediate decoration area type of the specified component. * The component is checked for the registered decoration area type. If * {@link #setDecorationType(JComponent, DecorationAreaType, boolean)} was * not called on this component, this method returns null. * * @param comp * Component. * @return Immediate decoration area type of the component. */ public static DecorationAreaType getImmediateDecorationType(Component comp) { return DecorationPainterUtils.getImmediateDecorationType(comp); } /** * Checks whether Substance is the current look-and-feel. This method is for * internal use only. * * @return true if Substance is the current look-and-feel, * false otherwise. */ public static boolean isCurrentLookAndFeel() { return ((UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) && (currentSkin != null)); } /* * (non-Javadoc) * * @see javax.swing.LookAndFeel#getDisabledIcon(javax.swing.JComponent, * javax.swing.Icon) */ @Override public Icon getDisabledIcon(JComponent component, Icon icon) { if (icon == null) return null; SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(component, ComponentState.DISABLED_UNSELECTED); BufferedImage result = SubstanceImageCreator.getColorSchemeImage( component, icon, colorScheme, 0.5f); float alpha = SubstanceColorSchemeUtilities.getAlpha(component, ComponentState.DISABLED_UNSELECTED); if (alpha < 1.0f) { BufferedImage intermediate = SubstanceCoreUtilities.getBlankImage( result.getWidth(), result.getHeight()); Graphics2D g2d = intermediate.createGraphics(); g2d.setComposite(AlphaComposite.SrcOver.derive(alpha)); g2d.drawImage(result, 0, 0, null); g2d.dispose(); result = intermediate; } return new IconUIResource(new ImageIcon(result)); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceMenuUI.java0000644000175000017500000002633011247214700024555 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.awt.event.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.HashSet; import java.util.Set; import javax.swing.*; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicMenuUI; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.animation.FadeStateListener; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.SubstanceSizeUtils; import org.jvnet.substance.utils.icon.MenuArrowIcon; import org.jvnet.substance.utils.menu.MenuUtilities; import org.jvnet.substance.utils.menu.SubstanceMenu; import org.jvnet.substance.utils.menu.MenuUtilities.MenuPropertyListener; /** * UI for menus in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceMenuUI extends BasicMenuUI implements SubstanceMenu { /** * For rollover effects - enhancement 93. */ protected MouseListener substanceMouseListener; /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /** * Listens on all changes to the underlying menu item. */ protected MenuPropertyListener substanceMenuPropertyListener; /** * Property change listener. Listens on changes to * {@link AbstractButton#MODEL_CHANGED_PROPERTY} property. */ protected PropertyChangeListener substancePropertyListener; /** * For rollover effects - enhancement 93. */ protected FocusListener substanceFocusListener; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceMenuUI(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicMenuUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); this.menuItem.setRolloverEnabled(true); // this.menuItem.setOpaque(false); this.arrowIcon = new MenuArrowIcon((JMenu) this.menuItem); this.defaultTextIconGap = SubstanceSizeUtils .getTextIconGap(SubstanceSizeUtils .getComponentFontSize(this.menuItem)); this.menuItem.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); this.menuItem.putClientProperty(SubstanceCoreUtilities.USE_HIGHLIGHT, Boolean.TRUE); LookAndFeel.installProperty(menuItem, "opaque", Boolean.FALSE); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicMenuUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); // Improving performance on big menus. this.substanceMenuPropertyListener = new MenuPropertyListener( this.menuItem); this.substanceMenuPropertyListener.install(); // fix for enhancement 93 - rollover effects on menu items this.substanceMouseListener = new MouseAdapter() { // fix for defect 93 - no rollover effects on menu // items that are not in the selected path private boolean toRepaint() { MenuElement[] selectedMenuPath = MenuSelectionManager .defaultManager().getSelectedPath(); for (MenuElement elem : selectedMenuPath) { if (elem == SubstanceMenuUI.this.menuItem) { return true; } } return (selectedMenuPath.length == 0); } @Override public void mouseEntered(MouseEvent e) { if (this.toRepaint()) { menuItem.getModel().setRollover(true); // fix for issue 371 - repaint the menu bar since the // menu is marked as flat Rectangle bounds = menuItem.getBounds(); menuItem.getParent().repaint(bounds.x, bounds.y, bounds.width, bounds.height); } } @Override public void mouseExited(MouseEvent e) { if (this.toRepaint()) { menuItem.getModel().setRollover(false); // fix for issue 371 - repaint the menu bar since the // menu is marked as flat Rectangle bounds = menuItem.getBounds(); menuItem.getParent().repaint(bounds.x, bounds.y, bounds.width, bounds.height); } } }; this.menuItem.addMouseListener(this.substanceMouseListener); this.substanceFocusListener = new FocusAdapter() { // fix for defect 93 - no rollover effects on menu // items that are not in the selected path private boolean toRepaint() { MenuElement[] selectedMenuPath = MenuSelectionManager .defaultManager().getSelectedPath(); for (MenuElement elem : selectedMenuPath) { if (elem == SubstanceMenuUI.this.menuItem) { return true; } } return (selectedMenuPath.length == 0); } @Override public void focusLost(FocusEvent e) { if (toRepaint()) { menuItem.getModel().setRollover(false); // fix for issue 371 - repaint the menu bar since the // menu is marked as flat Rectangle bounds = menuItem.getBounds(); menuItem.getParent().repaint(bounds.x, bounds.y, bounds.width, bounds.height); } } }; this.menuItem.addFocusListener(this.substanceFocusListener); final Set toIgnore = new HashSet(); // fix for issue 371 - repaint the menu bar since the // menu is marked as flat this.substanceFadeStateListener = new FadeStateListener(this.menuItem, null, this.menuItem.getModel(), SubstanceCoreUtilities .getFadeCallback(this.menuItem, this.menuItem .getModel(), false, true, this.menuItem), toIgnore); this.substanceFadeStateListener.registerListeners(); // this.menuItem.getModel().addChangeListener(new ChangeListener() { // public void stateChanged(ChangeEvent e) { // ButtonModel bm = menuItem.getModel(); // System.out.println(menuItem.getText() + " e:" + bm.isEnabled() // + ":a:" + bm.isArmed() + ":r:" + bm.isRollover() // + ":p:" + bm.isPressed() + ":s:" + bm.isSelected()); // } // }); this.substancePropertyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (AbstractButton.MODEL_CHANGED_PROPERTY.equals(evt .getPropertyName())) { if (substanceFadeStateListener != null) substanceFadeStateListener.unregisterListeners(); substanceFadeStateListener = new FadeStateListener( menuItem, null, menuItem.getModel(), SubstanceCoreUtilities .getFadeCallback(menuItem, menuItem .getModel(), false, false, menuItem), toIgnore); substanceFadeStateListener.registerListeners(); } if ("font".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (menuItem != null) { menuItem.updateUI(); } } }); } } }; this.menuItem.addPropertyChangeListener(this.substancePropertyListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicMenuUI#uninstallListeners() */ @Override protected void uninstallListeners() { super.uninstallListeners(); // Improving performance on big menus. this.substanceMenuPropertyListener.uninstall(); this.substanceMenuPropertyListener = null; // fix for enhancement 93 - rollover effects on menu items this.menuItem.removeMouseListener(this.substanceMouseListener); this.substanceMouseListener = null; this.menuItem.removeFocusListener(this.substanceFocusListener); this.substanceFocusListener = null; this.menuItem .removePropertyChangeListener(this.substancePropertyListener); this.substancePropertyListener = null; this.substanceFadeStateListener.unregisterListeners(); this.substanceFadeStateListener = null; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getAssociatedMenuItem() */ public JMenuItem getAssociatedMenuItem() { return this.menuItem; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getAcceleratorFont() */ public Font getAcceleratorFont() { return this.acceleratorFont; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getArrowIcon() */ public Icon getArrowIcon() { return this.arrowIcon; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getCheckIcon() */ public Icon getCheckIcon() { return null; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getDefaultTextIconGap() */ public int getDefaultTextIconGap() { return this.defaultTextIconGap; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicMenuItemUI#getPreferredMenuItemSize(javax * .swing.JComponent, javax.swing.Icon, javax.swing.Icon, int) */ @Override protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { Dimension superDim = super.getPreferredMenuItemSize(c, checkIcon, arrowIcon, defaultTextIconGap); if (MenuUtilities.getPopupLayoutMetrics(menuItem, false) != null) { return new Dimension(MenuUtilities.getPreferredWidth(menuItem), superDim.height); } return superDim; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicMenuItemUI#paintMenuItem(java.awt.Graphics, * javax.swing.JComponent, javax.swing.Icon, javax.swing.Icon, * java.awt.Color, java.awt.Color, int) */ @Override protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { MenuUtilities.paintMenuItem(g, menuItem, checkIcon, arrowIcon, defaultTextIconGap); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceDesktopPaneUI.java0000644000175000017500000000757411245202246026077 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import javax.swing.JComponent; import javax.swing.UIManager; import javax.swing.border.Border; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicDesktopPaneUI; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.border.SubstanceBorder; /** * UI for desktop panes in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceDesktopPaneUI extends BasicDesktopPaneUI { /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceDesktopPaneUI(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicDesktopPaneUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); Border curr = this.desktop.getBorder(); if ((curr == null) || (curr instanceof UIResource)) { this.desktop.setBorder(new SubstanceBorder()); } } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void update(Graphics g, JComponent c) { if (!c.isShowing()) { return; } Graphics2D graphics = (Graphics2D) g.create(); graphics.setComposite(TransitionLayout.getAlphaComposite(c, g)); if (TransitionLayout.isOpaque(c)) { // hack for JLayeredPane.paint() and JDesktopPane.isOpaque() Color back = c.getBackground(); if (back instanceof UIResource) { graphics.setColor(UIManager.getColor("Panel.background")); graphics.fillRect(0, 0, c.getWidth(), c.getHeight()); } BackgroundPaintingUtils.updateIfOpaque(graphics, c); super.paint(graphics, c); } else { super.paint(graphics, c); } // graphics.setColor(UIManager.getColor("Desktop.foreground")); // graphics.drawRect(0, 0, c.getWidth() - 1, c.getHeight() - 1); graphics.dispose(); // GhostPaintingUtils.paintGhostImages(c, g); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceButtonUI.java0000644000175000017500000003740111242467054025134 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.*; import javax.swing.text.View; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.shaper.SubstanceButtonShaper; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.border.SubstanceButtonBorder; import org.jvnet.substance.utils.icon.GlowingIcon; /** * UI for buttons in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceButtonUI extends BasicButtonUI { /** * Property used during the button shaper switch. */ public static final String BORDER_COMPUTED = "substancelaf.buttonbordercomputed"; /** * Property used during the button shaper switch. */ public static final String BORDER_COMPUTING = "substancelaf.buttonbordercomputing"; /** * Property used to store the original (pre-Substance) button border. */ public static final String BORDER_ORIGINAL = "substancelaf.buttonborderoriginal"; /** * Property used to store the original button icon. */ public static final String ICON_ORIGINAL = "substancelaf.buttoniconoriginal"; /** * Property used to store the original (pre-Substance) button * opacity. */ public static final String OPACITY_ORIGINAL = "substancelaf.buttonopacityoriginal"; /** * Property used to lock the original (pre-Substance) button opacity. */ public static final String LOCK_OPACITY = "substancelaf.lockopacity"; /** * Internal property used to mark close buttons on title panes. */ public static final String IS_TITLE_CLOSE_BUTTON = "substancelaf.internal.isTitleCloseButton"; /** * Painting delegate. */ private ButtonBackgroundDelegate delegate; /** * The matching glowing icon. Is used only when * {@link FadeConfigurationManager#fadeAllowed(FadeKind, Component)} returns * true on {@link FadeKind#ICON_GLOW}. */ protected GlowingIcon glowingIcon; /** * Property change listener. Listens on changes to the * {@link SubstanceLookAndFeel#BUTTON_SHAPER_PROPERTY} property and * {@link AbstractButton#MODEL_CHANGED_PROPERTY} property. */ protected PropertyChangeListener substancePropertyListener; /** * Tracker for visual state transitions. */ protected ButtonVisualStateTracker substanceVisualStateTracker; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceButtonUI(); } /** * Simple constructor. */ public SubstanceButtonUI() { this.delegate = new ButtonBackgroundDelegate(); } /* * (non-Javadoc) * * @seejavax.swing.plaf.basic.BasicButtonUI#installDefaults(javax.swing. * AbstractButton) */ @Override protected void installDefaults(AbstractButton b) { super.installDefaults(b); if (b.getClientProperty(SubstanceButtonUI.BORDER_ORIGINAL) == null) b.putClientProperty(SubstanceButtonUI.BORDER_ORIGINAL, b .getBorder()); trackGlowingIcon(b); SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(b); if (b.getClientProperty(SubstanceButtonUI.BORDER_COMPUTED) == null) { b.setBorder(shaper.getButtonBorder(b)); } else { Border currBorder = b.getBorder(); if (!(currBorder instanceof SubstanceButtonBorder)) { b.setBorder(shaper.getButtonBorder(b)); } else { SubstanceButtonBorder sbCurrBorder = (SubstanceButtonBorder) currBorder; if (shaper.getClass() != sbCurrBorder.getButtonShaperClass()) b.setBorder(shaper.getButtonBorder(b)); } } b.putClientProperty(SubstanceButtonUI.OPACITY_ORIGINAL, b.isOpaque()); b.setOpaque(false); b.setRolloverEnabled(true); LookAndFeel.installProperty(b, "iconTextGap", SubstanceSizeUtils .getTextIconGap(SubstanceSizeUtils.getComponentFontSize(b))); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicButtonUI#uninstallDefaults(javax.swing. * AbstractButton) */ @Override protected void uninstallDefaults(AbstractButton b) { super.uninstallDefaults(b); b.setBorder((Border) b .getClientProperty(SubstanceButtonUI.BORDER_ORIGINAL)); b.setOpaque((Boolean) b .getClientProperty(SubstanceButtonUI.OPACITY_ORIGINAL)); Icon origIcon = (Icon) b .getClientProperty(SubstanceButtonUI.ICON_ORIGINAL); if (origIcon != null) b.setIcon(origIcon); b.putClientProperty(SubstanceButtonUI.OPACITY_ORIGINAL, null); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicButtonUI#createButtonListener(javax.swing * .AbstractButton) */ @Override protected BasicButtonListener createButtonListener(AbstractButton b) { return null; } /* * (non-Javadoc) * * @seejavax.swing.plaf.basic.BasicButtonUI#installListeners(javax.swing. * AbstractButton) */ @Override protected void installListeners(final AbstractButton b) { super.installListeners(b); this.substanceVisualStateTracker = new ButtonVisualStateTracker(); this.substanceVisualStateTracker.installListeners(b, true); // this.substanceButtonListener = new RolloverButtonListener(b); // b.addMouseListener(this.substanceButtonListener); // b.addMouseMotionListener(this.substanceButtonListener); // b.addFocusListener(this.substanceButtonListener); // b.addPropertyChangeListener(this.substanceButtonListener); // b.addChangeListener(this.substanceButtonListener); this.substancePropertyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { // if (AbstractButton.MODEL_CHANGED_PROPERTY.equals(evt // .getPropertyName())) { // if (substanceFadeStateListener != null) // substanceFadeStateListener.unregisterListeners(); // boolean toRepaintParent = (b instanceof // SubstanceScrollButton) // || (b instanceof SubstanceSpinnerButton) // || (b instanceof SubstanceComboBoxButton); // substanceFadeStateListener = new FadeStateListener(b, b // .getModel(), SubstanceCoreUtilities // .getFadeCallback(b, toRepaintParent)); // substanceFadeStateListener // .registerListeners(toRepaintParent); // } if (AbstractButton.ICON_CHANGED_PROPERTY.equals(evt .getPropertyName())) { trackGlowingIcon(b); } } }; b.addPropertyChangeListener(this.substancePropertyListener); // boolean toRepaintParent = (b instanceof SubstanceScrollButton) // || (b instanceof SubstanceSpinnerButton) // || (b instanceof SubstanceComboBoxButton); // this.substanceFadeStateListener = new FadeStateListener(b, // b.getModel(), SubstanceCoreUtilities.getFadeCallback(b, // toRepaintParent)); // this.substanceFadeStateListener.registerListeners(toRepaintParent); } /* * (non-Javadoc) * * @seejavax.swing.plaf.basic.BasicButtonUI#uninstallListeners(javax.swing. * AbstractButton) */ @Override protected void uninstallListeners(AbstractButton b) { this.substanceVisualStateTracker.uninstallListeners(b); this.substanceVisualStateTracker = null; // ButtonVisualStateTracker.untrack(b); // this.substanceVisualStateTracker.uninstallListeners(b); // this.substanceVisualStateTracker = null; // b.removeMouseListener(this.substanceButtonListener); // b.removeMouseMotionListener(this.substanceButtonListener); // b.removeFocusListener(this.substanceButtonListener); // b.removePropertyChangeListener(this.substanceButtonListener); // b.removeChangeListener(this.substanceButtonListener); // this.substanceButtonListener = null; b.removePropertyChangeListener(this.substancePropertyListener); this.substancePropertyListener = null; // this.substanceFadeStateListener.unregisterListeners(); // this.substanceFadeStateListener = null; super.uninstallListeners(b); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicButtonUI#paint(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void paint(Graphics g, JComponent c) { if (!SubstanceLookAndFeel.isCurrentLookAndFeel()) return; final AbstractButton b = (AbstractButton) c; if (b instanceof JButton) { JButton jb = (JButton) b; if (PulseTracker.isPulsating(jb)) { PulseTracker.update(jb); } else { } } FontMetrics fm = g.getFontMetrics(); Insets i = c.getInsets(); Rectangle viewRect = new Rectangle(); Rectangle iconRect = new Rectangle(); final Rectangle textRect = new Rectangle(); viewRect.x = i.left; viewRect.y = i.top; viewRect.width = b.getWidth() - (i.right + viewRect.x); viewRect.height = b.getHeight() - (i.bottom + viewRect.y); textRect.x = textRect.y = textRect.width = textRect.height = 0; iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0; Font f = c.getFont(); // layout the text and icon String text = SwingUtilities.layoutCompoundLabel(c, fm, b.getText(), b .getIcon(), b.getVerticalAlignment(), b .getHorizontalAlignment(), b.getVerticalTextPosition(), b .getHorizontalTextPosition(), viewRect, iconRect, textRect, b .getText() == null ? 0 : b.getIconTextGap()); Graphics2D g2d = (Graphics2D) g.create(); View v = (View) c.getClientProperty(BasicHTML.propertyKey); g2d.setFont(f); this.delegate.updateBackground(g2d, b); if (v != null) { v.paint(g2d, textRect); } else { this.paintButtonText(g2d, b, textRect, text); } // Paint the Icon if (b.getIcon() != null) { paintIcon(g2d, c, iconRect); } if (b.isFocusPainted()) { if (b.hasFocus() || FadeTracker.getInstance().isTracked(c, FadeKind.FOCUS)) { this.paintFocus(g2d, b, viewRect, textRect, iconRect); } } // g2d.setColor(Color.red); // g2d.draw(iconRect); // g2d.draw(viewRect); // g2d.draw(textRect); // if (isPartOfCompositeControl) { // g.drawImage(offscreen, 0, 0, null); // } } /* * (non-Javadoc) * * @see * javax.swing.plaf.ComponentUI#getPreferredSize(javax.swing.JComponent) */ @Override public Dimension getPreferredSize(JComponent c) { AbstractButton button = (AbstractButton) c; SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(button); // fix for defect 263 Dimension superPref = super.getPreferredSize(button); if (superPref == null) return null; if (shaper == null) return superPref; Dimension result = shaper.getPreferredSize(button, superPref); return result; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicButtonUI#paintFocus(java.awt.Graphics, * javax.swing.AbstractButton, java.awt.Rectangle, java.awt.Rectangle, * java.awt.Rectangle) */ @Override protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) { if (!b.isFocusPainted()) return; SubstanceCoreUtilities.paintFocus(g, b, b, null, textRect, 1.0f, SubstanceSizeUtils.getFocusRingPadding(SubstanceSizeUtils .getComponentFontSize(b))); } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#contains(javax.swing.JComponent, int, * int) */ @Override public boolean contains(JComponent c, int x, int y) { return ButtonBackgroundDelegate.contains((JButton) c, x, y); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicButtonUI#paintIcon(java.awt.Graphics, * javax.swing.JComponent, java.awt.Rectangle) */ @Override protected void paintIcon(Graphics g, JComponent c, Rectangle iconRect) { Graphics2D graphics = (Graphics2D) g.create(); // graphics.setColor(Color.red); // graphics.fill(iconRect); FadeTracker fadeTracker = FadeTracker.getInstance(); AbstractButton b = (AbstractButton) c; Icon icon = SubstanceCoreUtilities.getIcon(b, null, this.glowingIcon, false); graphics.setComposite(TransitionLayout.getAlphaComposite(b, g)); if (fadeTracker.isTracked(b, FadeKind.ROLLOVER)) { ComponentState state = ComponentState.getState(b); // System.out.println(state.name() + ":" + state.isRollover()); if (state.isKindActive(FadeKind.ROLLOVER)) { // Came from default state SubstanceCoreUtilities.getIcon(b, null, this.glowingIcon, true) .paintIcon(b, graphics, iconRect.x, iconRect.y); graphics.setComposite(TransitionLayout.getAlphaComposite(b, fadeTracker.getFade(b, FadeKind.ROLLOVER), g)); icon.paintIcon(b, graphics, iconRect.x, iconRect.y); } else { // if (state == ComponentState.DEFAULT) { // Came from rollover state icon.paintIcon(b, graphics, iconRect.x, iconRect.y); graphics.setComposite(TransitionLayout.getAlphaComposite(b, fadeTracker.getFade(b, FadeKind.ROLLOVER), g)); b.getIcon().paintIcon(b, graphics, iconRect.x, iconRect.y); } } else { icon.paintIcon(b, graphics, iconRect.x, iconRect.y); } graphics.dispose(); } /** * Paints the text. * * @param g * Graphic context * @param button * Button * @param textRect * Text rectangle * @param text * Text to paint */ protected void paintButtonText(Graphics g, AbstractButton button, Rectangle textRect, String text) { SubstanceTextUtilities.paintText(g, button, textRect, text, button .getDisplayedMnemonicIndex()); } /** * Tracks possible usage of glowing icon. * * @param b * Button. */ protected void trackGlowingIcon(AbstractButton b) { Icon currIcon = b.getIcon(); if (currIcon instanceof GlowingIcon) return; if (currIcon == null) return; this.glowingIcon = new GlowingIcon(currIcon, b); } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void update(Graphics g, JComponent c) { this.paint(g, c); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceLabelUI.java0000644000175000017500000001444211245202246024671 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicHTML; import javax.swing.plaf.basic.BasicLabelUI; import javax.swing.text.View; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.utils.*; /** * UI for labels in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceLabelUI extends BasicLabelUI { /** * Property change listener. */ protected PropertyChangeListener substancePropertyChangeListener; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceLabelUI(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicLabelUI#installListeners(javax.swing.JLabel) */ @Override protected void installListeners(final JLabel c) { super.installListeners(c); this.substancePropertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("opaque".equals(evt.getPropertyName())) { if (!Boolean.TRUE.equals(c .getClientProperty(SubstanceButtonUI.LOCK_OPACITY))) { c.putClientProperty(SubstanceButtonUI.OPACITY_ORIGINAL, evt.getNewValue()); // System.out // .println("PCL: " // + b.getText() // + "->" // + b // .getClientProperty(SubstanceButtonUI.OPACITY_ORIGINAL) // ); } } } }; c.addPropertyChangeListener(this.substancePropertyChangeListener); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicLabelUI#uninstallListeners(javax.swing.JLabel * ) */ @Override protected void uninstallListeners(JLabel c) { c.removePropertyChangeListener(this.substancePropertyChangeListener); this.substancePropertyChangeListener = null; super.uninstallListeners(c); } @Override public void paint(Graphics g, JComponent c) { JLabel label = (JLabel) c; String text = label.getText(); Icon icon = null; if (label.isEnabled()) { icon = label.getIcon(); if ((icon != null) && SubstanceCoreUtilities.useThemedDefaultIcon()) icon = SubstanceCoreUtilities.getThemedIcon(label, icon); } else { icon = label.getDisabledIcon(); } if ((icon == null) && (text == null)) { return; } final Rectangle paintIconR = new Rectangle(); final Rectangle paintTextR = new Rectangle(); Rectangle paintViewR = new Rectangle(); Insets paintViewInsets = new Insets(0, 0, 0, 0); Insets insets = label.getInsets(paintViewInsets); paintViewR.x = insets.left; paintViewR.y = insets.top; paintViewR.width = c.getWidth() - (insets.left + insets.right); paintViewR.height = c.getHeight() - (insets.top + insets.bottom); paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0; paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0; String clippedText = SwingUtilities.layoutCompoundLabel(label, g .getFontMetrics(), text, icon, label.getVerticalAlignment(), label.getHorizontalAlignment(), label.getVerticalTextPosition(), label .getHorizontalTextPosition(), paintViewR, paintIconR, paintTextR, label.getIconTextGap()); Graphics2D g2d = (Graphics2D) g.create(); BackgroundPaintingUtils.updateIfOpaque(g2d, c); if (icon != null) { icon.paintIcon(c, g2d, paintIconR.x, paintIconR.y); } ComponentState labelState = label.isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED; float labelAlpha = SubstanceColorSchemeUtilities.getAlpha(label, labelState); if (text != null) { final View v = (View) c.getClientProperty(BasicHTML.propertyKey); if (v != null) { v.paint(g2d, paintTextR); } else { // fix for issue 406 - use the same FG computation // color as for other controls SubstanceTextUtilities.paintText(g, label, paintTextR, clippedText, label.getDisplayedMnemonicIndex(), labelState, labelState, labelAlpha); } } g2d.dispose(); } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void update(Graphics g, JComponent c) { // failsafe for LAF change if (!SubstanceLookAndFeel.isCurrentLookAndFeel()) return; this.paint(g, c); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceTextFieldUI.java0000644000175000017500000001271311136475560025553 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.Color; import java.awt.Graphics; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.*; import javax.swing.plaf.basic.BasicBorders; import javax.swing.plaf.basic.BasicTextFieldUI; import org.jvnet.lafwidget.animation.FadeStateListener; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.border.SubstanceBorder; /** * UI for text fields in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceTextFieldUI extends BasicTextFieldUI { /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /** * The associated text field. */ protected JTextField textField; /** * Property change listener. */ protected PropertyChangeListener substancePropertyChangeListener; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceTextFieldUI(comp); } /** * Simple constructor. * * @param c * Component (text field). */ public SubstanceTextFieldUI(JComponent c) { super(); this.textField = (JTextField) c; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTextUI#paintBackground(java.awt.Graphics) */ @Override protected void paintBackground(Graphics g) { SubstanceTextUtilities.paintTextCompBackground(g, this.textField); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTextUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); this.substanceFadeStateListener = new FadeStateListener(this.textField, null, null); this.substanceFadeStateListener.registerListeners(false); this.substancePropertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("font".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { // remember the caret location - issue 404 int caretPos = textField.getCaretPosition(); textField.updateUI(); textField.setCaretPosition(caretPos); } }); } } }; this.textField .addPropertyChangeListener(this.substancePropertyChangeListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTextUI#uninstallListeners() */ @Override protected void uninstallListeners() { this.substanceFadeStateListener.unregisterListeners(); this.substanceFadeStateListener = null; this.textField .removePropertyChangeListener(this.substancePropertyChangeListener); this.substancePropertyChangeListener = null; super.uninstallListeners(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTextUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); Border b = this.textField.getBorder(); if (b == null || b instanceof UIResource) { Border newB = new BorderUIResource.CompoundBorderUIResource( new SubstanceBorder(SubstanceSizeUtils .getTextBorderInsets(SubstanceSizeUtils .getComponentFontSize(this.textField))), new BasicBorders.MarginBorder()); this.textField.setBorder(newB); } // support for per-window skins Color foregr = this.textField.getForeground(); if ((foregr == null) || (foregr instanceof UIResource)) { this.textField.setForeground(SubstanceColorUtilities .getForegroundColor(SubstanceLookAndFeel.getCurrentSkin( this.textField).getMainDefaultColorScheme())); } } } substance-5.3.orig/src/org/jvnet/substance/skin/0000755000175000017500000000000011256731150021643 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/skin/CremeSkin.java0000644000175000017500000001005611245410542024365 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.painter.border.*; import org.jvnet.substance.painter.decoration.ArcDecorationPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.gradient.ClassicGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * Creme skin. This class is part of officially supported API. * * @author Kirill Grouchnikov * @since version 3.1 */ public class CremeSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Creme"; /** * Creates a new Creme skin. */ public CremeSkin() { SubstanceColorScheme activeScheme = new LightAquaColorScheme() .tint(0.3).named("Creme Active"); SubstanceColorScheme defaultScheme = new CremeColorScheme(); SubstanceColorScheme disabledScheme = new LightGrayColorScheme().tint( 0.35).named("Creme Disabled"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.registerAsDecorationArea(defaultScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER, DecorationAreaType.FOOTER, DecorationAreaType.GENERAL, DecorationAreaType.TOOLBAR); setSelectedTabFadeStart(0.2); setSelectedTabFadeEnd(0.4); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new ClassicGradientPainter(); this.decorationPainter = new ArcDecorationPainter(); this.highlightPainter = new ClassicHighlightPainter(); this.borderPainter = new CompositeBorderPainter("Creme", new ClassicBorderPainter(), new DelegateBorderPainter( "Creme Inner", new ClassicBorderPainter(), new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.tint(0.9f); } })); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/MistSilverSkin.java0000644000175000017500000001035111245410572025434 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.painter.border.ClassicBorderPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.decoration.MatteDecorationPainter; import org.jvnet.substance.painter.gradient.MatteGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.StandardButtonShaper; /** * Mist Silver skin. This class is experimental. * * @author Kirill Grouchnikov * @since version 4.0 */ public class MistSilverSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Mist Silver"; /** * Creates a new Silver skin. */ public MistSilverSkin() { SubstanceColorScheme activeScheme = new MetallicColorScheme().tint(0.1) .named("Mist Silver Active"); SubstanceColorScheme defaultScheme = new MetallicColorScheme().shade( 0.05).named("Mist Silver Default"); SubstanceColorScheme disabledScheme = new LightGrayColorScheme().tone( 0.2).named("Mist Silver Disabled"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); defaultSchemeBundle.registerColorScheme(defaultScheme.tone(0.4), ColorSchemeAssociationKind.TEXT_HIGHLIGHT, ComponentState.SELECTED, ComponentState.ROLLOVER_SELECTED); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.registerDecorationAreaSchemeBundle(new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme), new SteelBlueColorScheme().saturate(-0.3).tint(0.5).named( "Mist Silver Background"), DecorationAreaType.GENERAL); this.registerAsDecorationArea(defaultScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER, DecorationAreaType.FOOTER, DecorationAreaType.TOOLBAR); this.setSelectedTabFadeStart(0.6); this.setSelectedTabFadeEnd(1.0); this.buttonShaper = new StandardButtonShaper(); this.gradientPainter = new MatteGradientPainter(); this.borderPainter = new ClassicBorderPainter(); this.decorationPainter = new MatteDecorationPainter(); this.highlightPainter = new ClassicHighlightPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/coffee-active.colorscheme0000644000175000017500000000027411162452526026576 0ustar drazzibdrazzibname=Coffee Active kind=Light colorUltraLight=#F4E5C0 colorExtraLight=#F0DEB3 colorLight=#EBD7A6 colorMid=#C7A67B colorDark=#AA8363 colorUltraDark=#946F4A colorForeground=#32220F substance-5.3.orig/src/org/jvnet/substance/skin/ravengraphite.colorschemes0000644000175000017500000000427111246165040027114 0ustar drazzibdrazzibRaven Graphite Default { kind=Dark colorUltraLight=#4A4A4A colorExtraLight=#464646 colorLight=#424242 colorMid=#3F3F3F colorDark=#353535 colorUltraDark=#313131 colorForeground=#B4B4B4 } Raven Graphite Border { kind=Dark colorUltraLight=#616161 colorExtraLight=#5A5A5A colorLight=#4F4F4F colorMid=#414141 colorDark=#323232 colorUltraDark=#2B2B2B colorForeground=#EDEDED } Raven Graphite Background { kind=Dark colorUltraLight=#5F5F5F colorExtraLight=#595959 colorLight=#4F4F4F colorMid=#424242 colorDark=#363636 colorUltraDark=#2F2F2F colorForeground=#B4B4B4 } Raven Graphite Active { kind=Dark colorUltraLight=#777777 colorExtraLight=#6F6F6F colorLight=#636363 colorMid=#535353 colorDark=#434343 colorUltraDark=#3B3B3B colorForeground=#C8C8C8 } Raven Graphite Selected Disabled { kind=Dark colorUltraLight=#777777 colorExtraLight=#6F6F6F colorLight=#636363 colorMid=#535353 colorDark=#434343 colorUltraDark=#3B3B3B colorForeground=#202020 } Raven Graphite Disabled { kind=Dark colorUltraLight=#646464 colorExtraLight=#5E5E5E colorLight=#545454 colorMid=#474747 colorDark=#3A3A3A colorUltraDark=#333333 colorForeground=#202020 } Raven Graphite Highlight { kind=Light colorUltraLight=#FBFCFF colorExtraLight=#F2F6FB colorLight=#CED7E0 colorMid=#BCC0C5 colorDark=#62666B colorUltraDark=#363B3F colorForeground=#1B2025 } Raven Graphite Text Highlight { kind=Light colorUltraLight=#BDBEC0 colorExtraLight=#B8BBBD colorLight=#A4A9AE colorMid=#9A9D9F colorDark=#686B6D colorUltraDark=#505355 colorForeground=#2B2F33 } Raven Graphite Separator { kind=Dark colorUltraLight=#565656 colorExtraLight=#525252 colorLight=#4F4F4F colorMid=#383838 colorDark=#353535 colorUltraDark=#333333 colorForeground=#B4B4B4 } Raven Graphite Aqua { kind=Light colorUltraLight=#6383FF colorExtraLight=#577EFF colorLight=#4A6FFF colorMid=#355FFB colorDark=#1A3DE6 colorUltraDark=#153BE1 colorForeground=#FFFFFF } substance-5.3.orig/src/org/jvnet/substance/skin/twilight.colorschemes0000644000175000017500000000471611175130150026107 0ustar drazzibdrazzibTwilight Default { kind=Dark colorUltraLight=#3E3C35 colorExtraLight=#3D3B34 colorLight=#3B3A33 colorMid=#393731 colorDark=#35342E colorUltraDark=#35332D colorForeground=#B9B49E } Twilight Active { kind=Light colorUltraLight=#969280 colorExtraLight=#95917F colorLight=#8F8B7A colorMid=#8C8877 colorDark=#35342E colorUltraDark=#35332D colorForeground=#000000 } Twilight Selected Disabled Border { kind=Dark colorUltraLight=#3B3932 colorExtraLight=#3B3932 colorLight=#3B3932 colorMid=#3B3932 colorDark=#3B3932 colorUltraDark=#3B3932 colorForeground=#B9B49E } Twilight Border { kind=Dark colorUltraLight=#292823 colorExtraLight=#292823 colorLight=#292823 colorMid=#292823 colorDark=#292823 colorUltraDark=#292823 colorForeground=#B9B49E } Twilight Mark Active { kind=Dark colorUltraLight=#292823 colorExtraLight=#292823 colorLight=#292823 colorMid=#292823 colorDark=#292823 colorUltraDark=#292823 colorForeground=#292823 } Twilight Highlight { kind=Light colorUltraLight=#C7AD81 colorExtraLight=#C7AE81 colorLight=#C7AE82 colorMid=#C7AE81 colorDark=#C7AE82 colorUltraDark=#C7AE81 colorForeground=#28201B } Twilight Watermark { kind=Light colorUltraLight=#4C4A41 colorExtraLight=#4C4A41 colorLight=#4C4A41 colorMid=#4C4A41 colorDark=#4C4A41 colorUltraDark=#4C4A41 colorForeground=#24231F } Twilight Decorations Watermark { kind=Light colorUltraLight=#4B4940 colorExtraLight=#4A483F colorLight=#46443C colorMid=#44423A colorDark=#414038 colorUltraDark=#413F37 colorForeground=#F1F1F2 } Twilight Separator { kind=Dark colorUltraLight=#5B5952 colorExtraLight=#58564F colorLight=#545249 colorMid=#3B3A33 colorDark=#36352E colorUltraDark=#35342D colorForeground=#F1F1F2 } Twilight Decorations Separator { kind=Dark colorUltraLight=#4F4E4A colorExtraLight=#4B4A47 colorLight=#494842 colorMid=#35342D colorDark=#302F29 colorUltraDark=#2F2D28 colorForeground=#F1F1F2 } Twilight Header Watermark { kind=Dark colorUltraLight=#141414 colorExtraLight=#121212 colorLight=#101010 colorMid=#0B0B0B colorDark=#030303 colorUltraDark=#000000 colorForeground=#FFFFFF } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceRavenGraphiteGlassLookAndFeel.java0000644000175000017500000000501511136475562032165 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Raven Graphite Glass skin * from {@link RavenGraphiteGlassSkin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin. * SubstanceRavenGraphiteGlassLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceRavenGraphiteGlassLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceRavenGraphiteGlassLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 3.3 */ public class SubstanceRavenGraphiteGlassLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Raven Graphite Glass look-and-feel. */ public SubstanceRavenGraphiteGlassLookAndFeel() { super(new RavenGraphiteGlassSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/lightgray-general-watermark.colorscheme0000644000175000017500000000031211131573542031465 0ustar drazzibdrazzibname=LightGray General Watermark kind=Light colorUltraLight=#E9EEF7 colorExtraLight=#E5E8ED colorLight=#DADCDF colorMid=#CACDD1 colorDark=#BCC4CC colorUltraDark=#BAC1CA colorForeground=#4C535C substance-5.3.orig/src/org/jvnet/substance/skin/DustCoffeeSkin.java0000644000175000017500000001131511244104222025352 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.api.*; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.gradient.MatteGradientPainter; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; /** * Dust Coffee skin. This class is part of officially supported * API. * * @author Kirill Grouchnikov * @since version 5.2 */ public class DustCoffeeSkin extends DustSkin { /** * Display name for this skin. */ public static final String NAME = "Dust Coffee"; /** * Creates a new Dust Coffee skin. */ public DustCoffeeSkin() { SubstanceColorScheme activeScheme = SubstanceColorSchemeUtilities .getColorScheme(DustCoffeeSkin.class .getClassLoader() .getResource( "org/jvnet/substance/skin/coffee-active.colorscheme")); SubstanceSkin.ColorSchemes schemes = SubstanceSkin .getColorSchemes(DustCoffeeSkin.class.getClassLoader() .getResource( "org/jvnet/substance/skin/dust.colorschemes")); SubstanceColorScheme defaultScheme = schemes.get("Dust Coffee Default"); SubstanceColorScheme watermarkScheme = schemes .get("Dust Coffee Watermark"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, defaultScheme); defaultSchemeBundle.registerColorScheme(defaultScheme, 0.5f, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(activeScheme, 0.5f, ComponentState.DISABLED_SELECTED); // borders and marks SubstanceColorScheme borderDefaultScheme = schemes .get("Dust Border Default"); defaultSchemeBundle.registerColorScheme(borderDefaultScheme, ColorSchemeAssociationKind.BORDER, ComponentState.DEFAULT, ComponentState.DISABLED_SELECTED, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(activeScheme, ColorSchemeAssociationKind.BORDER, ComponentState .getActiveStates()); defaultSchemeBundle.registerColorScheme(borderDefaultScheme, ColorSchemeAssociationKind.MARK); // text highlight SubstanceColorScheme textHighlightScheme = schemes .get("Dust Coffee Text Highlight"); defaultSchemeBundle.registerColorScheme(textHighlightScheme, ColorSchemeAssociationKind.TEXT_HIGHLIGHT, ComponentState.SELECTED, ComponentState.ROLLOVER_SELECTED); // custom highlight alphas defaultSchemeBundle.registerHighlightColorScheme(activeScheme, 0.6f, ComponentState.ROLLOVER_UNSELECTED, ComponentState.ARMED); defaultSchemeBundle.registerHighlightColorScheme(activeScheme, 0.8f, ComponentState.SELECTED); defaultSchemeBundle .registerHighlightColorScheme(activeScheme, 1.0f, ComponentState.ROLLOVER_SELECTED, ComponentState.ROLLOVER_ARMED); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, watermarkScheme, DecorationAreaType.NONE); this.gradientPainter = new MatteGradientPainter(); } @Override public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceMagmaLookAndFeel.java0000644000175000017500000000461411136475562027462 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Magma skin from * {@link MagmaSkin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin.SubstanceMagmaLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceMagmaLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceMagmaLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 3.1 */ public class SubstanceMagmaLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Magma look-and-feel. */ public SubstanceMagmaLookAndFeel() { super(new MagmaSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/office2007.colorschemes0000644000175000017500000001725211246660466026040 0ustar drazzibdrazzibOffice Blue Watermark { kind=Light colorUltraLight=#DEE8F5 colorExtraLight=#D2DFF0 colorLight=#D0E0F0 colorMid=#CAD9ED colorDark=#BACAD9 colorUltraDark=#AEC2D5 colorForeground=#15428B } Office Blue Header Watermark { kind=Light colorUltraLight=#BFDBFF colorExtraLight=#BFDBFF colorLight=#BFDBFF colorMid=#BDD8FC colorDark=#B9D3F4 colorUltraDark=#ADC7E7 colorForeground=#15428B } Office Blue Active { kind=Light colorUltraLight=#9DBDE7 colorExtraLight=#BBD5F8 colorLight=#ABCCF6 colorMid=#AACBF6 colorDark=#8CB8F3 colorUltraDark=#79ADF1 colorForeground=#15428B } Office Blue Title Watermark { kind=Light colorUltraLight=#E3EEFD colorExtraLight=#DBE9FB colorLight=#D7E6FA colorMid=#D3E4F9 colorDark=#CCDFF8 colorUltraDark=#CADEF7 colorForeground=#15428B } Office Blue Border Active { kind=Light colorUltraLight=#7F96BA colorExtraLight=#63779E colorLight=#576890 colorMid=#596991 colorDark=#576890 colorUltraDark=#566890 colorForeground=#15428B } Office Blue Default { kind=Light colorUltraLight=#D0E1F7 colorExtraLight=#C8DBEE colorLight=#C5D7F0 colorMid=#C1D3EC colorDark=#C0D4ED colorUltraDark=#BCD0E9 colorForeground=#15428B } Office Blue Border Default { kind=Light colorUltraLight=#9EBAE1 colorExtraLight=#8AADDB colorLight=#84A8D7 colorMid=#81A3D0 colorDark=#6E90B8 colorUltraDark=#537BAE colorForeground=#15428B } Office Blue Pressed { kind=Light colorUltraLight=#FDA661 colorExtraLight=#FC963C colorLight=#FD9D3E colorMid=#FC923C colorDark=#FC8F3C colorUltraDark=#FC923D colorForeground=#15428B } Office Blue Pressed Selected { kind=Light colorUltraLight=#FEB96C colorExtraLight=#FC963C colorLight=#FDA962 colorMid=#FD953C colorDark=#FC923D colorUltraDark=#FC8F3D colorForeground=#15428B } Office Blue Rollover { kind=Light colorUltraLight=#FEF7D5 colorExtraLight=#FCEFC3 colorLight=#FFE59F colorMid=#FFD560 colorDark=#FFD14E colorUltraDark=#FFD048 colorForeground=#15428B } Office Blue Rollover Selected { kind=Light colorUltraLight=#FDBD79 colorExtraLight=#FEE069 colorLight=#FFBD79 colorMid=#FFC64C colorDark=#FEAA38 colorUltraDark=#FEA335 colorForeground=#15428B } Office Blue Selected { kind=Light colorUltraLight=#FBDBB5 colorExtraLight=#FDEB9F colorLight=#FEC778 colorMid=#FDD07C colorDark=#FDB759 colorUltraDark=#FEB456 colorForeground=#15428B } Office Blue Separator { kind=Light colorUltraLight=#D5E3F1 colorExtraLight=#D0E1F7 colorLight=#C2D5ED colorMid=#C1D3EC colorDark=#8DACD3 colorUltraDark=#7797C1 colorForeground=#F8FAFC } Office Blue Tab Rollover { kind=Light colorUltraLight=#E0E3DC colorExtraLight=#E4E6E0 colorLight=#D8DBD0 colorMid=#E0D4A8 colorDark=#E2D19E colorUltraDark=#E3D198 colorForeground=#15428B } Office Blue Tab Selected { kind=Light colorUltraLight=#F5FAFF colorExtraLight=#EBF3FE colorLight=#EAF2FD colorMid=#E9F1FA colorDark=#E8F0F9 colorUltraDark=#E1EAF6 colorForeground=#15428B } Office Silver Watermark { kind=Light colorUltraLight=#EEF4F4 colorExtraLight=#EBF1F1 colorLight=#E9EEEE colorMid=#E5E8EA colorDark=#E1E5E9 colorUltraDark=#DFE3E9 colorForeground=#4C535C } Office Silver Header Watermark { kind=Light colorUltraLight=#D0D4DD colorExtraLight=#D0D4DD colorLight=#D0D4DD colorMid=#D0D4DD colorDark=#D0D4DD colorUltraDark=#D0D4DD colorForeground=#4C535C } Office Silver Title Watermark { kind=Light colorUltraLight=#E3E7ED colorExtraLight=#E5E6E9 colorLight=#DEE0E3 colorMid=#CFCFD0 colorDark=#C7CBD1 colorUltraDark=#BCC1CA colorForeground=#4C535C } Office Silver Active { kind=Light colorUltraLight=#DFE2E8 colorExtraLight=#DBDFE4 colorLight=#CED3D9 colorMid=#C6CACF colorDark=#C2C6CC colorUltraDark=#BBC1C9 colorForeground=#4C535C } Office Silver Border Active { kind=Light colorUltraLight=#A9B1B8 colorExtraLight=#A9B1B8 colorLight=#A9B1B8 colorMid=#A9B1B8 colorDark=#A9B0B9 colorUltraDark=#A9B1B8 colorForeground=#15428B } Office Silver Default { kind=Light colorUltraLight=#F0F2F2 colorExtraLight=#F3F5F5 colorLight=#F1F3F3 colorMid=#EFF1F3 colorDark=#E9ECEF colorUltraDark=#E7EAEE colorForeground=#4C535C } Office Silver Border Default { kind=Light colorUltraLight=#C6C7CA colorExtraLight=#B8C4C8 colorLight=#A0ACB3 colorMid=#B1BBC1 colorDark=#949FA4 colorUltraDark=#939FA4 colorForeground=#7C7C7C } Office Silver Mark Default { kind=Light colorUltraLight=#7C7C7C colorExtraLight=#7C7C7C colorLight=#7C7C7C colorMid=#7C7C7C colorDark=#7C7C7C colorUltraDark=#7C7C7C colorForeground=#7C7C7C } Office Silver Pressed { kind=Light colorUltraLight=#FDA661 colorExtraLight=#FC963C colorLight=#FD9D3E colorMid=#FC923C colorDark=#FC8F3C colorUltraDark=#FC923D colorForeground=#4C535C } Office Silver Pressed Selected { kind=Light colorUltraLight=#FEB96C colorExtraLight=#FC963C colorLight=#FDA962 colorMid=#FD953C colorDark=#FC923D colorUltraDark=#FC8F3D colorForeground=#4C535C } Office Silver Rollover { kind=Light colorUltraLight=#FEF7D5 colorExtraLight=#FCEFC3 colorLight=#FFE59F colorMid=#FFD560 colorDark=#FFD14E colorUltraDark=#FFD048 colorForeground=#4C535C } Office Silver Rollover Selected { kind=Light colorUltraLight=#FDBD79 colorExtraLight=#FEE069 colorLight=#FFBD79 colorMid=#FFC64C colorDark=#FEAA38 colorUltraDark=#FEA335 colorForeground=#4C535C } Office Silver Selected { kind=Light colorUltraLight=#FBDBB5 colorExtraLight=#FDEB9F colorLight=#FEC778 colorMid=#FDD07C colorDark=#FDB759 colorUltraDark=#FEB456 colorForeground=#4C535C } Office Silver Separator { kind=Light colorUltraLight=#EAECEF colorExtraLight=#D5DBE7 colorLight=#B3B7BA colorMid=#AFB4B8 colorDark=#ADB1B5 colorUltraDark=#ADB1B5 colorForeground=#7C7C7C } Office Silver Tab Rollover { kind=Light colorUltraLight=#E0E3DC colorExtraLight=#E4E6E0 colorLight=#D8DBD0 colorMid=#E0D4A8 colorDark=#E2D19E colorUltraDark=#E3D198 colorForeground=#15428B } Office Silver Tab Selected { kind=Light colorUltraLight=#F7F8FA colorExtraLight=#F5F5F6 colorLight=#EFF1F5 colorMid=#EEF1F5 colorDark=#E8ECF2 colorUltraDark=#E5EAF1 colorForeground=#4C535C } Office Border Selected { kind=Light colorUltraLight=#C6C0B1 colorExtraLight=#AEA590 colorLight=#8E8165 colorMid=#8E8064 colorDark=#9A7057 colorUltraDark=#9F7559 colorForeground=#FCE59C } Office Border Pressed { kind=Light colorUltraLight=#C8BAA4 colorExtraLight=#BDB19E colorLight=#A6957B colorMid=#8B7654 colorDark=#8B7654 colorUltraDark=#8B7654 colorForeground=#FEBE64 } Office Border Rollover { kind=Light colorUltraLight=#DAC378 colorExtraLight=#D9C176 colorLight=#D8BB6D colorMid=#D6B664 colorDark=#D7B867 colorUltraDark=#CFBA73 colorForeground=#FFE798 } Office Border Rollover Selected { kind=Light colorUltraLight=#B1A389 colorExtraLight=#AE9F7D colorLight=#A19476 colorMid=#9C8F73 colorDark=#9C8864 colorUltraDark=#8E8165 colorForeground=#F7C05B } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceBusinessBlackSteelLookAndFeel.java0000644000175000017500000000501511136475562032161 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Business Black Steel skin * from {@link BusinessBlackSteelSkin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin. * SubstanceBusinessBlackSteelLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 3.3 */ public class SubstanceBusinessBlackSteelLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Business Black Steel look-and-feel. */ public SubstanceBusinessBlackSteelLookAndFeel() { super(new BusinessBlackSteelSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/BusinessSkin.java0000644000175000017500000001163611245410522025130 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.painter.border.*; import org.jvnet.substance.painter.decoration.*; import org.jvnet.substance.painter.gradient.ClassicGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; /** * Business skin. This class is part of officially supported API. * * @author Kirill Grouchnikov * @since version 3.1 */ public class BusinessSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Business"; /** * Creates a new Business skin. */ public BusinessSkin() { SubstanceColorScheme activeScheme = new MetallicColorScheme() .tint(0.15).named("Business Active"); SubstanceColorScheme defaultScheme = new MetallicColorScheme().shade( 0.1).named("Business Default"); SubstanceColorScheme disabledScheme = defaultScheme; SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); defaultSchemeBundle .registerHighlightColorScheme(new BlendBiColorScheme( new TerracottaColorScheme(), new SunGlareColorScheme(), 0.5).tint(0.2).named("Business Highlight")); defaultSchemeBundle.registerColorScheme(disabledScheme, 0.4f, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(activeScheme, 0.4f, ComponentState.DISABLED_SELECTED); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.registerAsDecorationArea(defaultScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER, DecorationAreaType.FOOTER); SubstanceColorScheme generalBgScheme = SubstanceColorSchemeUtilities .getColorScheme(BusinessSkin.class .getClassLoader() .getResource( "org/jvnet/substance/skin/lightgray-general-watermark.colorscheme")); this.registerAsDecorationArea(generalBgScheme, DecorationAreaType.GENERAL); this.setSelectedTabFadeStart(0.6); this.setSelectedTabFadeEnd(1.0); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new ClassicGradientPainter(); this.borderPainter = new CompositeBorderPainter("Business", new ClassicBorderPainter(), new DelegateBorderPainter( "Business Inner", new ClassicBorderPainter(), new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.tint(0.9f); } })); BrushedMetalDecorationPainter decorationPainter = new BrushedMetalDecorationPainter(); decorationPainter.setBaseDecorationPainter(new ArcDecorationPainter()); decorationPainter.setTextureAlpha(0.2f); this.decorationPainter = decorationPainter; this.highlightPainter = new ClassicHighlightPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/dust.colorschemes0000644000175000017500000000524311243711164025235 0ustar drazzibdrazzibDust Active { kind=Light colorUltraLight=#B4ADA1 colorExtraLight=#B4ADA1 colorLight=#AEA79A colorMid=#A8A094 colorDark=#A29B8E colorUltraDark=#9E978A colorForeground=#222629 } Dust Border Active { kind=Dark colorUltraLight=#625B4E colorExtraLight=#615A4D colorLight=#5E574A colorMid=#5E574A colorDark=#5E574A colorUltraDark=#5E574A colorForeground=#B4ADA1 } Dust Border Default { kind=Light colorUltraLight=#A29C8F colorExtraLight=#8F887A colorLight=#827A6C colorMid=#756D5E colorDark=#6F6859 colorUltraDark=#6F6858 colorForeground=#5E574A } Dust Header Border { kind=Dark colorUltraLight=#2D251E colorExtraLight=#2D241E colorLight=#2C241E colorMid=#2C231D colorDark=#271F1A colorUltraDark=#271F1A colorForeground=#C1C2AA } Dust Default { kind=Light colorUltraLight=#EEECE8 colorExtraLight=#EAE7E2 colorLight=#E8E5DF colorMid=#DCD7CE colorDark=#CFC9BC colorUltraDark=#CDC7B9 colorForeground=#3B3639 } Dust Header Active { kind=Dark colorUltraLight=#604539 colorExtraLight=#604539 colorLight=#5E4438 colorMid=#594235 colorDark=#513D30 colorUltraDark=#4F3C2F colorForeground=#C1C2AA } Dust Header Default { kind=Dark colorUltraLight=#3C3B37 colorExtraLight=#3B3A36 colorLight=#393834 colorMid=#3B3A36 colorDark=#33322E colorUltraDark=#2F2E2C colorForeground=#C1C2C2 } Dust Header Separator { kind=Dark colorUltraLight=#3F3D3A colorExtraLight=#3D3B38 colorLight=#3B3936 colorMid=#363532 colorDark=#32302D colorUltraDark=#31302D colorForeground=#C1C2C2 } Dust Header Watermark { kind=Dark colorUltraLight=#2C2B29 colorExtraLight=#2C2B29 colorLight=#2B2A28 colorMid=#292827 colorDark=#292827 colorUltraDark=#292827 colorForeground=#999999 } Dust Coffee Default { kind=Light colorUltraLight=#E0D3B3 colorExtraLight=#DDD4B3 colorLight=#DCD7C1 colorMid=#D3CAA9 colorDark=#C9BF9B colorUltraDark=#C5BB97 colorForeground=#433C32 } Dust Coffee Watermark { kind=Light colorUltraLight=#E8D9B9 colorExtraLight=#E8D9B9 colorLight=#E8D9B9 colorMid=#E8D9B9 colorDark=#E8D9B9 colorUltraDark=#E8D9B9 colorForeground=#433C32 } Dust Coffee Text Highlight { kind=Light colorUltraLight=#E2C39D colorExtraLight=#DFBE95 colorLight=#DBBA8E colorMid=#C09A73 colorDark=#AA8363 colorUltraDark=#9A7554 colorForeground=#32220F } substance-5.3.orig/src/org/jvnet/substance/skin/ModerateSkin.java0000644000175000017500000001011611162644504025074 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.painter.border.ClassicBorderPainter; import org.jvnet.substance.painter.decoration.ClassicDecorationPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.gradient.GlassGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; /** * Moderate skin. This class is part of officially supported API. * * @author Kirill Grouchnikov * @since version 3.1 */ public class ModerateSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Moderate"; /** * Creates a new Moderate skin. */ public ModerateSkin() { SubstanceColorScheme activeScheme = new SteelBlueColorScheme(); SubstanceColorScheme defaultScheme = new MetallicColorScheme(); SubstanceColorScheme disabledScheme = new LightGrayColorScheme(); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); defaultSchemeBundle .registerHighlightColorScheme(new BlendBiColorScheme( new TerracottaColorScheme(), new SunGlareColorScheme(), 0.5)); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.registerAsDecorationArea(activeScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE); SubstanceColorScheme generalBgScheme = SubstanceColorSchemeUtilities .getColorScheme(ModerateSkin.class .getClassLoader() .getResource( "org/jvnet/substance/skin/lightgray-general-watermark.colorscheme")); this.registerAsDecorationArea(generalBgScheme, DecorationAreaType.GENERAL, DecorationAreaType.HEADER); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new GlassGradientPainter(); this.decorationPainter = new ClassicDecorationPainter(); this.borderPainter = new ClassicBorderPainter(); this.highlightPainter = new ClassicHighlightPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/ChallengerDeepSkin.java0000644000175000017500000000776211245410526026210 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import java.awt.Color; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.ToneColorScheme; import org.jvnet.substance.colorscheme.UltramarineColorScheme; import org.jvnet.substance.painter.border.GlassBorderPainter; import org.jvnet.substance.painter.decoration.ArcDecorationPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.gradient.GlassGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * Challenger Deep skin. This class is part of officially supported * API. * * @author Kirill Grouchnikov * @since version 3.2 */ public class ChallengerDeepSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Challenger Deep"; /** * Creates a new Challenger Deep skin. */ public ChallengerDeepSkin() { SubstanceColorScheme activeScheme = new UltramarineColorScheme(); SubstanceColorScheme defaultScheme = activeScheme.tone(0.1f).named( "Challenger Deep Default"); SubstanceColorScheme disabledScheme = new ToneColorScheme(activeScheme, 0.3) { Color foreColor = new Color(123, 118, 137); @Override public Color getForegroundColor() { return foreColor; } }.named("Challenger Deep Disabled"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.registerAsDecorationArea(defaultScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER, DecorationAreaType.FOOTER, DecorationAreaType.GENERAL, DecorationAreaType.TOOLBAR); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new GlassGradientPainter(); this.decorationPainter = new ArcDecorationPainter(); this.highlightPainter = new ClassicHighlightPainter(); this.borderPainter = new GlassBorderPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/MistAquaSkin.java0000644000175000017500000000765711245410566025101 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.painter.border.ClassicBorderPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.decoration.MatteDecorationPainter; import org.jvnet.substance.painter.gradient.MatteGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.StandardButtonShaper; /** * Mist Aqua skin. This class is experimental. * * @author Kirill Grouchnikov * @since version 4.0 */ public class MistAquaSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Mist Aqua"; /** * Creates a new Silver Aqua skin. */ public MistAquaSkin() { SubstanceColorScheme activeScheme = new AquaColorScheme(); SubstanceColorScheme defaultScheme = new MetallicColorScheme().shade( 0.05).named("Mist Aqua Default"); SubstanceColorScheme disabledScheme = new LightGrayColorScheme().tone( 0.2).named("Mist Aqua Disabled"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.registerDecorationAreaSchemeBundle(new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme), new SteelBlueColorScheme().saturate(-0.3).tint(0.5).named( "Mist Aqua Background"), DecorationAreaType.GENERAL); this.registerAsDecorationArea(defaultScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER, DecorationAreaType.FOOTER, DecorationAreaType.TOOLBAR); this.buttonShaper = new StandardButtonShaper(); this.gradientPainter = new MatteGradientPainter(); this.borderPainter = new ClassicBorderPainter(); this.decorationPainter = new MatteDecorationPainter(); this.highlightPainter = new ClassicHighlightPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceBusinessLookAndFeel.java0000644000175000017500000000464711136475562030241 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Business skin from * {@link BusinessSkin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin.SubstanceBusinessLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceBusinessLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceBusinessLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 3.1 */ public class SubstanceBusinessLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Business look-and-feel. */ public SubstanceBusinessLookAndFeel() { super(new BusinessSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceChallengerDeepLookAndFeel.java0000644000175000017500000000474411136475562031306 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Challenger Deep skin from * {@link ChallengerDeepSkin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin. * SubstanceChallengerDeepLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceChallengerDeepLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceChallengerDeepLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 3.2 */ public class SubstanceChallengerDeepLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Challenger Deep look-and-feel. */ public SubstanceChallengerDeepLookAndFeel() { super(new ChallengerDeepSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceTwilightLookAndFeel.java0000644000175000017500000000465411174274150030227 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Twilight skin from * {@link TwilightSkin}. You can set this look-and-feel by: *
    *
  • * -Dswing.defaultlaf=org.jvnet.substance.skin.SubstanceTwilightLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceTwilightLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceTwilightLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 5.2 */ public class SubstanceTwilightLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Twilight look-and-feel. */ public SubstanceTwilightLookAndFeel() { super(new TwilightSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/BusinessBlueSteelSkin.java0000644000175000017500000001251711245410516026737 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.painter.border.ClassicBorderPainter; import org.jvnet.substance.painter.decoration.*; import org.jvnet.substance.painter.gradient.ClassicGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * Business Blue Steel skin. This class is part of officially * supported API. * * @author Kirill Grouchnikov * @since version 3.3 */ public class BusinessBlueSteelSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Business Blue Steel"; /** * Creates a new Business skin. */ public BusinessBlueSteelSkin() { SubstanceColorScheme activeScheme = new SteelBlueColorScheme().tint( 0.15).named("Business Blue Steel Active"); SubstanceColorScheme defaultScheme = new MetallicColorScheme().tint( 0.05).named("Business Blue Steel Default"); SubstanceColorScheme disabledScheme = new LightGrayColorScheme().tint( 0.05).named("Business Blue Steel Disabled"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); defaultSchemeBundle .registerHighlightColorScheme(new BlendBiColorScheme( new TerracottaColorScheme(), new SunGlareColorScheme(), 0.5).tint(0.2).named("Business Blue Steel Highlight")); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); SubstanceColorScheme activeHeaderScheme = activeScheme.saturate(0.2) .named("Business Blue Steel Active Header"); SubstanceColorScheme defaultHeaderScheme = activeScheme.saturate(-0.2) .named("Business Blue Steel Default Header"); SubstanceColorSchemeBundle headerSchemeBundle = new SubstanceColorSchemeBundle( activeHeaderScheme, defaultHeaderScheme, defaultHeaderScheme); headerSchemeBundle.registerColorScheme(defaultHeaderScheme, 0.5f, ComponentState.DISABLED_UNSELECTED, ComponentState.DISABLED_SELECTED); this.registerDecorationAreaSchemeBundle(headerSchemeBundle, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER, DecorationAreaType.TOOLBAR); SubstanceColorScheme activeGeneralScheme = activeScheme.saturate(-0.5) .named("Business Blue Steel Active General"); SubstanceColorScheme defaultGeneralScheme = activeScheme.tint(0.3) .saturate(-0.2).named("Business Blue Steel Default General"); SubstanceColorSchemeBundle generalSchemeBundle = new SubstanceColorSchemeBundle( activeGeneralScheme, defaultGeneralScheme, disabledScheme); generalSchemeBundle.registerColorScheme(defaultGeneralScheme, 0.7f, ComponentState.DISABLED_UNSELECTED); this.registerDecorationAreaSchemeBundle(generalSchemeBundle, DecorationAreaType.FOOTER, DecorationAreaType.GENERAL); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new ClassicGradientPainter(); this.borderPainter = new ClassicBorderPainter(); BrushedMetalDecorationPainter decorationPainter = new BrushedMetalDecorationPainter(); decorationPainter.setBaseDecorationPainter(new ArcDecorationPainter()); decorationPainter.setTextureAlpha(0.3f); this.decorationPainter = decorationPainter; this.highlightPainter = new ClassicHighlightPainter(); this.borderPainter = new ClassicBorderPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceMistSilverLookAndFeel.java0000644000175000017500000000470011136475562030535 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Mist Silver skin from * {@link MistSilverSkin}. You can set this look-and-feel by: *
    *
  • * -Dswing.defaultlaf=org.jvnet.substance.skin.SubstanceMistSilverLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceMistSilverLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceMistSilverLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 4.0 */ public class SubstanceMistSilverLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Mist Silver look-and-feel. */ public SubstanceMistSilverLookAndFeel() { super(new MistSilverSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/nebula.colorschemes0000644000175000017500000000251511157724524025533 0ustar drazzibdrazzibNebula Active { kind=Light colorUltraLight=#F6F8FA colorExtraLight=#DFE6ED colorLight=#C1D6E9 colorMid=#A3B8CB colorDark=#62778A colorUltraDark=#42576A colorForeground=#000000 } Nebula Default { kind=Light colorUltraLight=#FBFBFC colorExtraLight=#F4F7FC colorLight=#F1F2F4 colorMid=#D6D9DF colorDark=#95989E colorUltraDark=#75787E colorForeground=#2A2E36 } Nebula Disabled { kind=Light colorUltraLight=#E3EFE9 colorExtraLight=#DFE2E6 colorLight=#DADDE3 colorMid=#D6D9DF colorDark=#C9CCD2 colorUltraDark=#BCBFC5 colorForeground=#848B98 } Nebula Pressed { kind=Dark colorUltraLight=#8FA9C0 colorExtraLight=#7695B2 colorLight=#5B89B4 colorMid=#33628C colorDark=#1C3851 colorUltraDark=#000000 colorForeground=#FFFFFF } Nebula Rollover Selected { kind=Light colorUltraLight=#F8FAFC colorExtraLight=#E8FDFF colorLight=#D4E9FC colorMid=#B6CBDE colorDark=#3B556D colorUltraDark=#00051D colorForeground=#000000 } Nebula Rollover Unselected { kind=Light colorUltraLight=#FFFFFF colorExtraLight=#FDFDFE colorLight=#F7F8FA colorMid=#E9ECF2 colorDark=#7A7E86 colorUltraDark=#55585E colorForeground=#2A2E36 } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceRavenGraphiteLookAndFeel.java0000644000175000017500000000473311136475562031201 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Raven Graphite skin from * {@link RavenGraphiteSkin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin. * SubstanceRavenGraphiteLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceRavenGraphiteLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceRavenGraphiteLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 3.3 */ public class SubstanceRavenGraphiteLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Raven Graphite look-and-feel. */ public SubstanceRavenGraphiteLookAndFeel() { super(new RavenGraphiteSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/DustSkin.java0000644000175000017500000001712411246437224024263 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import java.awt.Color; import org.jvnet.substance.api.*; import org.jvnet.substance.api.painter.overlay.BottomLineOverlayPainter; import org.jvnet.substance.api.painter.overlay.TopLineOverlayPainter; import org.jvnet.substance.painter.border.*; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.decoration.MatteDecorationPainter; import org.jvnet.substance.painter.gradient.StandardGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * Dust skin. This class is part of officially supported API. * * @author Kirill Grouchnikov * @since version 5.2 */ public class DustSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Dust"; /** * Overlay painter to paint a dark line along the bottom edge of the * menubar. */ private BottomLineOverlayPainter menuOverlayPainter; /** * Overlay painter to paint a light line along the top edge of the toolbars. */ private TopLineOverlayPainter toolbarOverlayPainter; /** * Creates a new Dust skin. */ public DustSkin() { SubstanceSkin.ColorSchemes schemes = SubstanceSkin .getColorSchemes(DustSkin.class.getClassLoader().getResource( "org/jvnet/substance/skin/dust.colorschemes")); SubstanceColorScheme activeScheme = schemes.get("Dust Active"); SubstanceColorScheme defaultScheme = schemes.get("Dust Default"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, defaultScheme); defaultSchemeBundle.registerColorScheme(defaultScheme, 0.5f, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(activeScheme, 0.5f, ComponentState.DISABLED_SELECTED); // borders SubstanceColorScheme borderDefaultScheme = schemes .get("Dust Border Default"); SubstanceColorScheme borderActiveScheme = schemes .get("Dust Border Active"); defaultSchemeBundle.registerColorScheme(borderDefaultScheme, ColorSchemeAssociationKind.BORDER, ComponentState.DEFAULT, ComponentState.DISABLED_SELECTED, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(borderActiveScheme, ColorSchemeAssociationKind.BORDER, ComponentState .getActiveStates()); defaultSchemeBundle.registerColorScheme(borderDefaultScheme, ColorSchemeAssociationKind.MARK); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); // header color scheme bundle SubstanceColorScheme headerActiveScheme = schemes .get("Dust Header Active"); SubstanceColorScheme headerDefaultScheme = schemes .get("Dust Header Default"); SubstanceColorScheme headerWatermarkScheme = schemes .get("Dust Header Watermark"); SubstanceColorScheme headerSeparatorScheme = schemes .get("Dust Header Separator"); SubstanceColorScheme headerBorderScheme = schemes .get("Dust Header Border"); SubstanceColorSchemeBundle headerSchemeBundle = new SubstanceColorSchemeBundle( headerActiveScheme, headerDefaultScheme, headerDefaultScheme); headerSchemeBundle.registerColorScheme(headerDefaultScheme, 0.7f, ComponentState.DISABLED_UNSELECTED); headerSchemeBundle.registerColorScheme(headerActiveScheme, 0.7f, ComponentState.DISABLED_SELECTED); headerSchemeBundle.registerColorScheme(headerBorderScheme, ColorSchemeAssociationKind.BORDER); headerSchemeBundle.registerColorScheme(headerSeparatorScheme, ColorSchemeAssociationKind.SEPARATOR); headerSchemeBundle.registerHighlightColorScheme(headerActiveScheme, 1.0f); // the next line is to have consistent coloring during the rollover // menu animations headerSchemeBundle.registerHighlightColorScheme(headerActiveScheme, 0.0f, ComponentState.DEFAULT); this.registerDecorationAreaSchemeBundle(headerSchemeBundle, DecorationAreaType.TOOLBAR); this.registerDecorationAreaSchemeBundle(headerSchemeBundle, headerWatermarkScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER, DecorationAreaType.FOOTER); setSelectedTabFadeStart(0.1); setSelectedTabFadeEnd(0.3); // add two overlay painters to create a bezel line between // menu bar and toolbars this.menuOverlayPainter = new BottomLineOverlayPainter( new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { return scheme.getUltraDarkColor().darker(); } }); this.toolbarOverlayPainter = new TopLineOverlayPainter( new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { Color fg = scheme.getForegroundColor(); return new Color(fg.getRed(), fg.getGreen(), fg .getBlue(), 32); } }); this.addOverlayPainter(this.menuOverlayPainter, DecorationAreaType.HEADER); this.addOverlayPainter(this.toolbarOverlayPainter, DecorationAreaType.TOOLBAR); this.buttonShaper = new ClassicButtonShaper(); this.watermark = null; this.gradientPainter = new StandardGradientPainter(); this.decorationPainter = new MatteDecorationPainter(); this.highlightPainter = new ClassicHighlightPainter(); this.borderPainter = new CompositeBorderPainter("Dust", new ClassicBorderPainter(), new DelegateBorderPainter( "Dust Inner", new ClassicBorderPainter(), 0x60FFFFFF, 0x30FFFFFF, 0x18FFFFFF, new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.shiftBackground( scheme.getUltraLightColor(), 0.8).tint( 0.6).saturate(0.2); } })); } public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceOfficeBlue2007LookAndFeel.java0000644000175000017500000000474611136475562030762 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Office Blue 2007 skin * from {@link OfficeBlue2007Skin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin. * SubstanceOfficeBlue2007LookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceOfficeBlue2007LookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceOfficeBlue2007LookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 3.1 */ public class SubstanceOfficeBlue2007LookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Office Blue 2007 look-and-feel. */ public SubstanceOfficeBlue2007LookAndFeel() { super(new OfficeBlue2007Skin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/RavenSkin.java0000644000175000017500000000775711245410652024425 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import java.awt.Color; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.painter.border.GlassBorderPainter; import org.jvnet.substance.painter.decoration.ArcDecorationPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.gradient.GlassGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; import org.jvnet.substance.watermark.SubstanceCrosshatchWatermark; /** * Raven skin. This class is part of officially supported API. * * @author Kirill Grouchnikov * @since version 3.1 */ public class RavenSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Raven"; /** * Creates a new Raven skin. */ public RavenSkin() { SubstanceColorScheme activeScheme = new EbonyColorScheme(); SubstanceColorScheme defaultScheme = new DarkMetallicColorScheme(); SubstanceColorScheme disabledScheme = new ShadeColorScheme( activeScheme, 0.5) { Color foreColor = new Color(80, 80, 80); @Override public Color getForegroundColor() { return foreColor; } }.named("Raven Disabled"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.registerAsDecorationArea(defaultScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER, DecorationAreaType.FOOTER, DecorationAreaType.GENERAL, DecorationAreaType.TOOLBAR); this.watermarkScheme = activeScheme.shade(0.4); this.buttonShaper = new ClassicButtonShaper(); this.watermark = new SubstanceCrosshatchWatermark(); this.gradientPainter = new GlassGradientPainter(); this.decorationPainter = new ArcDecorationPainter(); this.highlightPainter = new ClassicHighlightPainter(); this.borderPainter = new GlassBorderPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceBusinessBlueSteelLookAndFeel.java0000644000175000017500000000500111136475562032027 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Business Blue Steel skin * from {@link BusinessBlueSteelSkin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin. * SubstanceBusinessBlueSteelLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceBusinessBlueSteelLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 3.3 */ public class SubstanceBusinessBlueSteelLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Business Blue Steel look-and-feel. */ public SubstanceBusinessBlueSteelLookAndFeel() { super(new BusinessBlueSteelSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/SaharaSkin.java0000644000175000017500000001001011136475562024533 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.painter.border.ClassicBorderPainter; import org.jvnet.substance.painter.decoration.ClassicDecorationPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.gradient.ClassicGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; /** * Sahara skin. This class is part of officially supported API. * * @author Kirill Grouchnikov */ public class SaharaSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Sahara"; /** * Creates a new Sahara skin. */ public SaharaSkin() { SubstanceColorScheme activeScheme = new DesertSandColorScheme(); SubstanceColorScheme defaultScheme = new MetallicColorScheme(); SubstanceColorScheme disabledScheme = new LightGrayColorScheme(); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); defaultSchemeBundle.registerHighlightColorScheme(new OliveColorScheme() .tint(0.2).named("Sahara Highlight")); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.registerAsDecorationArea(activeScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE); SubstanceColorScheme generalBgScheme = SubstanceColorSchemeUtilities .getColorScheme(SaharaSkin.class .getClassLoader() .getResource( "org/jvnet/substance/skin/lightgray-general-watermark.colorscheme")); this.registerAsDecorationArea(generalBgScheme, DecorationAreaType.GENERAL, DecorationAreaType.HEADER); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new ClassicGradientPainter(); this.borderPainter = new ClassicBorderPainter(); this.decorationPainter = new ClassicDecorationPainter(); this.highlightPainter = new ClassicHighlightPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/OfficeSilver2007Skin.java0000644000175000017500000003017711246710506026235 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import java.awt.Color; import org.jvnet.substance.api.*; import org.jvnet.substance.api.painter.border.DelegateFractionBasedBorderPainter; import org.jvnet.substance.api.painter.border.FractionBasedBorderPainter; import org.jvnet.substance.api.painter.decoration.FractionBasedDecorationPainter; import org.jvnet.substance.api.painter.fill.FractionBasedFillPainter; import org.jvnet.substance.api.painter.overlay.BottomLineOverlayPainter; import org.jvnet.substance.painter.border.CompositeBorderPainter; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * Office Silver 2007 skin. This class is part of officially * supported API. * * @author Kirill Grouchnikov */ public class OfficeSilver2007Skin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Office Silver 2007"; /** * Creates a new Office Silver 2007 skin. */ public OfficeSilver2007Skin() { SubstanceSkin.ColorSchemes colorSchemes = SubstanceSkin .getColorSchemes(OfficeSilver2007Skin.class .getClassLoader() .getResource( "org/jvnet/substance/skin/office2007.colorschemes")); SubstanceColorScheme activeScheme = colorSchemes .get("Office Silver Active"); SubstanceColorScheme defaultScheme = colorSchemes .get("Office Silver Default"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, defaultScheme); defaultSchemeBundle.registerColorScheme(defaultScheme, 0.5f, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(activeScheme, 0.5f, ComponentState.DISABLED_SELECTED); SubstanceColorScheme rolloverScheme = colorSchemes .get("Office Silver Rollover"); SubstanceColorScheme rolloverSelectedScheme = colorSchemes .get("Office Silver Rollover Selected"); SubstanceColorScheme selectedScheme = colorSchemes .get("Office Silver Selected"); SubstanceColorScheme pressedScheme = colorSchemes .get("Office Silver Pressed"); SubstanceColorScheme pressedSelectedScheme = colorSchemes .get("Office Silver Pressed Selected"); // register state-specific color schemes on rollovers and selections defaultSchemeBundle.registerColorScheme(rolloverScheme, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerColorScheme(rolloverSelectedScheme, ComponentState.ROLLOVER_SELECTED); defaultSchemeBundle.registerColorScheme(selectedScheme, ComponentState.SELECTED); defaultSchemeBundle.registerColorScheme(pressedScheme, ComponentState.PRESSED_UNSELECTED); defaultSchemeBundle.registerColorScheme(pressedSelectedScheme, ComponentState.PRESSED_SELECTED); // register state-specific highlight color schemes on rollover and // selections defaultSchemeBundle.registerHighlightColorScheme(rolloverScheme, 0.8f, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerHighlightColorScheme(selectedScheme, 0.8f, ComponentState.SELECTED); defaultSchemeBundle.registerHighlightColorScheme( rolloverSelectedScheme, 0.8f, ComponentState.ROLLOVER_SELECTED); defaultSchemeBundle.registerHighlightColorScheme(selectedScheme, 0.8f, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); // borders and marks SubstanceColorScheme borderDefaultScheme = colorSchemes .get("Office Silver Border Default"); SubstanceColorScheme borderActiveScheme = colorSchemes .get("Office Silver Border Active"); SubstanceColorScheme borderRolloverScheme = colorSchemes .get("Office Border Rollover"); SubstanceColorScheme borderRolloverSelectedScheme = colorSchemes .get("Office Border Rollover Selected"); SubstanceColorScheme borderSelectedScheme = colorSchemes .get("Office Border Selected"); SubstanceColorScheme borderPressedScheme = colorSchemes .get("Office Border Pressed"); defaultSchemeBundle.registerColorScheme(borderDefaultScheme, ColorSchemeAssociationKind.BORDER, ComponentState.DEFAULT); defaultSchemeBundle.registerColorScheme(borderDefaultScheme, ColorSchemeAssociationKind.BORDER, ComponentState.DISABLED_SELECTED, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(borderActiveScheme, ColorSchemeAssociationKind.BORDER, ComponentState.ACTIVE); defaultSchemeBundle.registerColorScheme(borderRolloverScheme, ColorSchemeAssociationKind.BORDER, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerColorScheme(borderRolloverSelectedScheme, ColorSchemeAssociationKind.BORDER, ComponentState.ROLLOVER_SELECTED, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); defaultSchemeBundle.registerColorScheme(borderSelectedScheme, ColorSchemeAssociationKind.BORDER, ComponentState.SELECTED); defaultSchemeBundle.registerColorScheme(borderPressedScheme, ColorSchemeAssociationKind.BORDER, ComponentState.PRESSED_SELECTED, ComponentState.PRESSED_UNSELECTED); SubstanceColorScheme markDefaultScheme = colorSchemes .get("Office Silver Mark Default"); defaultSchemeBundle.registerColorScheme(markDefaultScheme, ColorSchemeAssociationKind.MARK, ComponentState.DEFAULT); defaultSchemeBundle.registerColorScheme(markDefaultScheme, ColorSchemeAssociationKind.MARK, ComponentState.DISABLED_SELECTED, ComponentState.DISABLED_UNSELECTED); // defaultSchemeBundle.registerColorScheme(borderActiveScheme, // ColorSchemeAssociationKind.MARK, ComponentState.ACTIVE); // defaultSchemeBundle.registerColorScheme(borderRolloverSelectedScheme, // ColorSchemeAssociationKind.MARK, // ComponentState.ROLLOVER_SELECTED); // defaultSchemeBundle.registerColorScheme(borderSelectedScheme, // ColorSchemeAssociationKind.MARK, ComponentState.SELECTED); // defaultSchemeBundle.registerColorScheme(borderPressedScheme, // ColorSchemeAssociationKind.MARK, // ComponentState.ROLLOVER_UNSELECTED, // ComponentState.PRESSED_SELECTED, // ComponentState.PRESSED_UNSELECTED); registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); // tabs and tab borders SubstanceColorScheme tabSelectedScheme = colorSchemes .get("Office Silver Tab Selected"); SubstanceColorScheme tabRolloverScheme = colorSchemes .get("Office Silver Tab Rollover"); defaultSchemeBundle.registerColorScheme(tabSelectedScheme, ColorSchemeAssociationKind.TAB, ComponentState.SELECTED, ComponentState.ROLLOVER_SELECTED, ComponentState.PRESSED_SELECTED, ComponentState.PRESSED_UNSELECTED); defaultSchemeBundle.registerColorScheme(tabRolloverScheme, ColorSchemeAssociationKind.TAB, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerColorScheme(borderDefaultScheme, ColorSchemeAssociationKind.TAB_BORDER, ComponentState.SELECTED, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerColorScheme(rolloverSelectedScheme, ColorSchemeAssociationKind.TAB_BORDER, ComponentState.ROLLOVER_SELECTED); // separator SubstanceColorScheme separatorScheme = colorSchemes .get("Office Silver Separator"); defaultSchemeBundle.registerColorScheme(separatorScheme, ColorSchemeAssociationKind.SEPARATOR); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.watermarkScheme = colorSchemes.get("Office Silver Watermark"); SubstanceColorScheme generalWatermarkScheme = colorSchemes .get("Office Silver Header Watermark"); this.registerAsDecorationArea(generalWatermarkScheme, DecorationAreaType.FOOTER, DecorationAreaType.HEADER, DecorationAreaType.TOOLBAR); SubstanceColorScheme titleWatermarkScheme = colorSchemes .get("Office Silver Title Watermark"); this.registerAsDecorationArea(titleWatermarkScheme, DecorationAreaType.GENERAL, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE); setSelectedTabFadeStart(0.6); setSelectedTabFadeEnd(0.9); this.addOverlayPainter(new BottomLineOverlayPainter( new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { Color fg = scheme.getForegroundColor(); return new Color(fg.getRed(), fg.getGreen(), fg .getBlue(), 72); } }), DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE); this.buttonShaper = new ClassicButtonShaper(); this.watermark = null; this.gradientPainter = new FractionBasedFillPainter( "Office Silver 2007", new float[] { 0.0f, 0.49999f, 0.5f, 1.0f }, new ColorSchemeSingleColorQuery[] { ColorSchemeSingleColorQuery.ULTRALIGHT, ColorSchemeSingleColorQuery.LIGHT, ColorSchemeSingleColorQuery.ULTRADARK, ColorSchemeSingleColorQuery.EXTRALIGHT }); FractionBasedBorderPainter outerBorderPainter = new FractionBasedBorderPainter( "Office Silver 2007 Outer", new float[] { 0.0f, 0.5f, 1.0f }, new ColorSchemeSingleColorQuery[] { ColorSchemeSingleColorQuery.LIGHT, ColorSchemeSingleColorQuery.ULTRADARK, ColorSchemeSingleColorQuery.MID }); SubstanceBorderPainter innerBorderPainter = new DelegateFractionBasedBorderPainter( "Office Silver 2007 Inner", outerBorderPainter, new int[] { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }, new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.tint(0.8f); } }); this.borderPainter = new CompositeBorderPainter("Office Silver 2007", outerBorderPainter, innerBorderPainter); this.decorationPainter = new FractionBasedDecorationPainter( "Office Blue 2007", new float[] { 0.0f, 0.2499999f, 0.25f, 0.3f, 0.7f, 1.0f }, new ColorSchemeSingleColorQuery[] { ColorSchemeSingleColorQuery.ULTRALIGHT, ColorSchemeSingleColorQuery.EXTRALIGHT, ColorSchemeSingleColorQuery.DARK, ColorSchemeSingleColorQuery.MID, ColorSchemeSingleColorQuery.LIGHT, ColorSchemeSingleColorQuery.ULTRALIGHT }); this.highlightPainter = new ClassicHighlightPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceCremeCoffeeLookAndFeel.java0000644000175000017500000000470711136475562030606 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Creme Coffee skin from * {@link CremeCoffeeSkin}. You can set this look-and-feel by: *
    *
  • * -Dswing.defaultlaf=org.jvnet.substance.skin.SubstanceCremeCoffeeLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceCremeCoffeeLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceCremeCoffeeLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 3.1 */ public class SubstanceCremeCoffeeLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Creme Coffee look-and-feel. */ public SubstanceCremeCoffeeLookAndFeel() { super(new CremeCoffeeSkin()); } }substance-5.3.orig/src/org/jvnet/substance/skin/SkinInfo.java0000644000175000017500000000522011246715676024243 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.utils.TraitInfoImpl; /** * Information on a single skin. This class is part of officially supported API. * * @author Kirill Grouchnikov */ public class SkinInfo extends TraitInfoImpl { /** * Simple constructor. * * @param skinDisplayName * Display name of this skin. * @param skinClassName * Class name of this skin. */ public SkinInfo(String skinDisplayName, String skinClassName) { super(skinDisplayName, skinClassName); } /* * (non-Javadoc) * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (obj instanceof SkinInfo) { return this.getDisplayName().equals( ((SkinInfo) obj).getDisplayName()); } return false; } /* * (non-Javadoc) * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { return this.getDisplayName().hashCode(); } } substance-5.3.orig/src/org/jvnet/substance/skin/AutumnSkin.java0000644000175000017500000001257511246706756024633 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.api.*; import org.jvnet.substance.api.painter.overlay.BottomLineOverlayPainter; import org.jvnet.substance.api.painter.overlay.TopShadowOverlayPainter; import org.jvnet.substance.painter.border.*; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.decoration.MarbleNoiseDecorationPainter; import org.jvnet.substance.painter.gradient.MatteGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * Autumn skin. This class is part of officially supported API. * * @author Kirill Grouchnikov * @since version 4.0 */ public class AutumnSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Autumn"; /** * Overlay painter to paint separator lines on some decoration areas. */ private BottomLineOverlayPainter bottomLineOverlayPainter; /** * Creates a new Autumn skin. */ public AutumnSkin() { SubstanceSkin.ColorSchemes schemes = SubstanceSkin .getColorSchemes(AutumnSkin.class.getClassLoader().getResource( "org/jvnet/substance/skin/autumn.colorschemes")); SubstanceColorScheme activeScheme = schemes.get("Autumn Active"); SubstanceColorScheme defaultScheme = schemes.get("Autumn Default"); SubstanceColorScheme disabledScheme = defaultScheme; SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); defaultSchemeBundle.registerColorScheme(disabledScheme, 0.6f, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(activeScheme, 0.6f, ComponentState.DISABLED_SELECTED); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); SubstanceColorScheme watermarkScheme = schemes.get("Autumn Watermark"); this.registerAsDecorationArea(activeScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER); this.registerAsDecorationArea(watermarkScheme, DecorationAreaType.GENERAL, DecorationAreaType.FOOTER, DecorationAreaType.TOOLBAR); // add an overlay painter to paint a drop shadow along the top // edge of toolbars this.addOverlayPainter(TopShadowOverlayPainter.getInstance(), DecorationAreaType.TOOLBAR); // add an overlay painter to paint separator lines along the bottom // edges of title panes and menu bars this.bottomLineOverlayPainter = new BottomLineOverlayPainter( ColorSchemeSingleColorQuery.DARK); this.addOverlayPainter(this.bottomLineOverlayPainter, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new MatteGradientPainter(); this.borderPainter = new CompositeBorderPainter("Autumn", new ClassicBorderPainter(), new DelegateBorderPainter( "Autumn Inner", new ClassicBorderPainter(), new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.tint(0.8f); } })); this.highlightPainter = new ClassicHighlightPainter(); MarbleNoiseDecorationPainter decorationPainter = new MarbleNoiseDecorationPainter(); decorationPainter.setTextureAlpha(0.7f); this.decorationPainter = decorationPainter; } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceEmeraldDuskLookAndFeel.java0000644000175000017500000000471111136475562030636 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Emerald Dusk skin from * {@link EmeraldDuskSkin}. You can set this look-and-feel by: *
    *
  • * -Dswing.defaultlaf=org.jvnet.substance.skin.SubstanceEmeraldDuskLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceEmeraldDuskLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceEmeraldDuskLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 3.2 */ public class SubstanceEmeraldDuskLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Emerald Dusk look-and-feel. */ public SubstanceEmeraldDuskLookAndFeel() { super(new EmeraldDuskSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceAutumnLookAndFeel.java0000644000175000017500000000462511136475562027713 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Autumn skin from * {@link AutumnSkin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin.SubstanceAutumnLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceAutumnLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceAutumnLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 4.0 */ public class SubstanceAutumnLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Autumn look-and-feel. */ public SubstanceAutumnLookAndFeel() { super(new AutumnSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/MagmaSkin.java0000644000175000017500000001216711165401232024356 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import java.awt.Color; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.painter.border.GlassBorderPainter; import org.jvnet.substance.painter.decoration.ArcDecorationPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.gradient.GlassGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; import org.jvnet.substance.watermark.SubstancePlanktonWatermark; /** * Magma skin. This class is part of officially supported API. * * @author Kirill Grouchnikov * @since version 3.1 */ public class MagmaSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Magma"; /** * Creates a new Magma skin. */ public MagmaSkin() { SubstanceColorScheme shiftRed = new ShiftColorScheme( new SunsetColorScheme(), Color.red, 0.3); SubstanceColorScheme defaultScheme = new CharcoalColorScheme(); SubstanceColorScheme activeScheme = shiftRed.saturate(0.4).named( "Magma Active"); SubstanceColorScheme disabledScheme = new ShadeColorScheme( new CharcoalColorScheme(), 0.5) { Color foreColor = new Color(104, 93, 90); @Override public Color getForegroundColor() { return this.foreColor; } }.named("Magma Disabled"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); defaultSchemeBundle.registerColorScheme(new CharcoalColorScheme(), ColorSchemeAssociationKind.BORDER, ComponentState .getActiveStates()); defaultSchemeBundle.registerColorScheme(activeScheme, ColorSchemeAssociationKind.MARK, ComponentState .getActiveStates()); defaultSchemeBundle.registerColorScheme(disabledScheme, 0.7f, ComponentState.DISABLED_UNSELECTED, ComponentState.DISABLED_SELECTED); defaultSchemeBundle.registerHighlightColorScheme(activeScheme .saturate(-0.2), 0.7f, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerHighlightColorScheme(activeScheme, 0.7f, ComponentState.SELECTED); defaultSchemeBundle.registerHighlightColorScheme(activeScheme, 0.9f, ComponentState.ROLLOVER_SELECTED); defaultSchemeBundle.registerHighlightColorScheme(activeScheme .saturate(-0.2), 0.7f, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.registerAsDecorationArea(defaultScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER, DecorationAreaType.FOOTER, DecorationAreaType.GENERAL, DecorationAreaType.TOOLBAR); this.setSelectedTabFadeStart(1.0); this.setSelectedTabFadeEnd(1.0); this.watermarkScheme = defaultScheme.shade(0.5); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new GlassGradientPainter(); this.decorationPainter = new ArcDecorationPainter(); this.watermark = new SubstancePlanktonWatermark(); this.borderPainter = new GlassBorderPainter(); this.highlightPainter = new ClassicHighlightPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/BusinessBlackSteelSkin.java0000644000175000017500000001476111246437326027100 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import java.awt.Color; import org.jvnet.substance.api.*; import org.jvnet.substance.api.painter.overlay.TopShadowOverlayPainter; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.painter.border.ClassicBorderPainter; import org.jvnet.substance.painter.decoration.*; import org.jvnet.substance.painter.gradient.ClassicGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * Business Black Steel skin. This class is part of officially * supported API. * * @author Kirill Grouchnikov * @since version 3.3 */ public class BusinessBlackSteelSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Business Black Steel"; /** * Creates a new Business skin. */ public BusinessBlackSteelSkin() { SubstanceColorScheme activeScheme = new SteelBlueColorScheme().tint( 0.15).named("Business Black Steel Active"); SubstanceColorScheme defaultScheme = new MetallicColorScheme().tint( 0.05).named("Business Black Steel Default"); SubstanceColorScheme disabledScheme = new LightGrayColorScheme().tint( 0.05).named("Business Black Steel Disabled"); // the default color scheme bundle SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); defaultSchemeBundle.registerHighlightColorScheme(activeScheme, 0.6f, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerHighlightColorScheme(activeScheme, 0.8f, ComponentState.SELECTED); defaultSchemeBundle.registerHighlightColorScheme(activeScheme, 0.95f, ComponentState.ROLLOVER_SELECTED); defaultSchemeBundle.registerHighlightColorScheme(activeScheme, 0.8f, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); // color scheme bundle for title panes SubstanceColorScheme activeHeaderScheme = new EbonyColorScheme() .shiftBackground(Color.black, 0.3).tint(0.05).named( "Business Black Steel Active Header"); SubstanceColorScheme defaultHeaderScheme = new EbonyColorScheme().tint( 0.05).named("Business Black Steel Default Header"); SubstanceColorSchemeBundle headerSchemeBundle = new SubstanceColorSchemeBundle( activeHeaderScheme, defaultHeaderScheme, disabledScheme); headerSchemeBundle.registerColorScheme(defaultHeaderScheme, 0.5f, ComponentState.DISABLED_UNSELECTED, ComponentState.DISABLED_SELECTED); headerSchemeBundle.registerHighlightColorScheme(activeScheme, 0.6f, ComponentState.ROLLOVER_UNSELECTED); headerSchemeBundle.registerHighlightColorScheme(activeScheme, 0.8f, ComponentState.SELECTED); headerSchemeBundle.registerHighlightColorScheme(activeScheme, 0.95f, ComponentState.ROLLOVER_SELECTED); headerSchemeBundle.registerHighlightColorScheme(activeScheme, 0.8f, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); this.registerDecorationAreaSchemeBundle(headerSchemeBundle, activeHeaderScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER); // color scheme bundle for general areas SubstanceColorScheme activeGeneralScheme = activeScheme.shade(0.1) .saturate(-0.5).named("Business Black Steel Active General"); SubstanceColorScheme defaultGeneralScheme = activeScheme.tint(0.3) .saturate(-0.7).named("Business Black Steel Default General"); SubstanceColorSchemeBundle generalSchemeBundle = new SubstanceColorSchemeBundle( activeGeneralScheme, defaultGeneralScheme, disabledScheme); generalSchemeBundle.registerColorScheme(disabledScheme, 0.5f, ComponentState.DISABLED_UNSELECTED); this.registerDecorationAreaSchemeBundle(generalSchemeBundle, DecorationAreaType.FOOTER, DecorationAreaType.GENERAL); // add an overlay painter to paint a drop shadow along the top // edge of toolbars this.addOverlayPainter(TopShadowOverlayPainter.getInstance(), DecorationAreaType.TOOLBAR); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new ClassicGradientPainter(); this.borderPainter = new ClassicBorderPainter(); BrushedMetalDecorationPainter decorationPainter = new BrushedMetalDecorationPainter(); decorationPainter.setBaseDecorationPainter(new ArcDecorationPainter()); decorationPainter.setTextureAlpha(0.02f); this.decorationPainter = decorationPainter; this.highlightPainter = new ClassicHighlightPainter(); this.borderPainter = new ClassicBorderPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/NebulaBrickWallSkin.java0000644000175000017500000000512711245410600026331 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.colorscheme.OrangeColorScheme; import org.jvnet.substance.painter.decoration.DecorationAreaType; /** * Nebula Brick Wall skin. This class is part of officially * supported API. * * @author Kirill Grouchnikov * @since version 4.0 */ public class NebulaBrickWallSkin extends NebulaSkin { /** * Display name for this skin. */ public static final String NAME = "Nebula Brick Wall"; /** * Creates a new Nebula Brick Wall skin. */ public NebulaBrickWallSkin() { super(); this.registerAsDecorationArea(new OrangeColorScheme(), DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ @Override public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/NebulaSkin.java0000644000175000017500000001412211246706750024550 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import java.awt.Color; import org.jvnet.substance.api.*; import org.jvnet.substance.api.painter.overlay.BottomLineOverlayPainter; import org.jvnet.substance.api.painter.overlay.TopShadowOverlayPainter; import org.jvnet.substance.painter.border.FlatBorderPainter; import org.jvnet.substance.painter.decoration.*; import org.jvnet.substance.painter.gradient.SubduedGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * Nebula skin. This class is part of officially supported API. * * @author Kirill Grouchnikov * @since version 4.0 */ public class NebulaSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Nebula"; /** * Overlay painter to paint separator lines on some decoration areas. */ private BottomLineOverlayPainter bottomLineOverlayPainter; /** * Creates a new Nebula skin. */ public NebulaSkin() { SubstanceSkin.ColorSchemes schemes = SubstanceSkin .getColorSchemes(NebulaSkin.class.getClassLoader().getResource( "org/jvnet/substance/skin/nebula.colorschemes")); SubstanceColorScheme activeScheme = schemes.get("Nebula Active"); SubstanceColorScheme defaultScheme = schemes.get("Nebula Default"); SubstanceColorScheme rolloverUnselectedScheme = schemes .get("Nebula Rollover Unselected"); SubstanceColorScheme pressedScheme = schemes.get("Nebula Pressed"); SubstanceColorScheme rolloverSelectedScheme = schemes .get("Nebula Rollover Selected"); SubstanceColorScheme disabledScheme = schemes.get("Nebula Disabled"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); defaultSchemeBundle.registerColorScheme(rolloverUnselectedScheme, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerColorScheme(rolloverSelectedScheme, ComponentState.ROLLOVER_SELECTED); defaultSchemeBundle.registerColorScheme(pressedScheme, ComponentState.PRESSED_SELECTED, ComponentState.PRESSED_UNSELECTED, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); defaultSchemeBundle.registerHighlightColorScheme(pressedScheme, 0.6f, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerHighlightColorScheme(pressedScheme, 0.8f, ComponentState.SELECTED); defaultSchemeBundle.registerHighlightColorScheme(pressedScheme, 0.95f, ComponentState.ROLLOVER_SELECTED); defaultSchemeBundle.registerHighlightColorScheme(pressedScheme, 0.8f, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.registerAsDecorationArea(activeScheme.saturate(-0.5), DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER, DecorationAreaType.FOOTER, DecorationAreaType.GENERAL); // add an overlay painter to paint a drop shadow along the top // edge of toolbars this.addOverlayPainter(TopShadowOverlayPainter.getInstance(), DecorationAreaType.TOOLBAR); // add an overlay painter to paint separator lines along the bottom // edges of title panes and menu bars this.bottomLineOverlayPainter = new BottomLineOverlayPainter( new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { Color dark = scheme.getDarkColor(); return new Color(dark.getRed(), dark.getGreen(), dark .getBlue(), 160); } }); this.addOverlayPainter(this.bottomLineOverlayPainter, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new SubduedGradientPainter(); MarbleNoiseDecorationPainter decorationPainter = new MarbleNoiseDecorationPainter(); decorationPainter.setBaseDecorationPainter(new ArcDecorationPainter()); decorationPainter.setTextureAlpha(0.3f); this.decorationPainter = decorationPainter; this.highlightPainter = new ClassicHighlightPainter(); this.borderPainter = new FlatBorderPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/TwilightSkin.java0000644000175000017500000002355111246662360025141 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import java.awt.Color; import org.jvnet.substance.api.*; import org.jvnet.substance.api.painter.overlay.*; import org.jvnet.substance.painter.border.*; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.decoration.MatteDecorationPainter; import org.jvnet.substance.painter.gradient.StandardGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * Twilight skin. This class is part of officially supported API. * * @author Kirill Grouchnikov * @since version 5.2 */ public class TwilightSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Twilight"; /** * Overlay painter to paint a dark line along the bottom edge of the * toolbars. */ private BottomLineOverlayPainter toolbarBottomLineOverlayPainter; /** * Overlay painter to paint a light line along the top edge of the toolbars. */ private TopLineOverlayPainter toolbarTopLineOverlayPainter; /** * Overlay painter to paint a bezel line along the top edge of the footer. */ private TopBezelOverlayPainter footerTopBezelOverlayPainter; /** * Creates a new Twilight skin. */ public TwilightSkin() { SubstanceSkin.ColorSchemes schemes = SubstanceSkin .getColorSchemes(TwilightSkin.class .getClassLoader() .getResource( "org/jvnet/substance/skin/twilight.colorschemes")); SubstanceColorScheme activeScheme = schemes.get("Twilight Active"); SubstanceColorScheme defaultScheme = schemes.get("Twilight Default"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, defaultScheme); defaultSchemeBundle.registerColorScheme(defaultScheme, 0.5f, ComponentState.DISABLED_UNSELECTED); // borders SubstanceColorScheme borderDisabledSelectedScheme = schemes .get("Twilight Selected Disabled Border"); SubstanceColorScheme borderScheme = schemes.get("Twilight Border"); defaultSchemeBundle.registerColorScheme(borderDisabledSelectedScheme, ColorSchemeAssociationKind.BORDER, ComponentState.DISABLED_SELECTED); defaultSchemeBundle.registerColorScheme(borderScheme, ColorSchemeAssociationKind.BORDER); // marks SubstanceColorScheme markActiveScheme = schemes .get("Twilight Mark Active"); defaultSchemeBundle.registerColorScheme(markActiveScheme, ColorSchemeAssociationKind.MARK, ComponentState .getActiveStates()); // separators SubstanceColorScheme separatorScheme = schemes .get("Twilight Separator"); defaultSchemeBundle.registerColorScheme(separatorScheme, ColorSchemeAssociationKind.SEPARATOR); SubstanceColorScheme watermarkScheme = schemes .get("Twilight Watermark"); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, watermarkScheme, DecorationAreaType.NONE); SubstanceColorSchemeBundle decorationsSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, defaultScheme); decorationsSchemeBundle.registerColorScheme(defaultScheme, 0.5f, ComponentState.DISABLED_UNSELECTED); // borders decorationsSchemeBundle.registerColorScheme( borderDisabledSelectedScheme, ColorSchemeAssociationKind.BORDER, ComponentState.DISABLED_SELECTED); decorationsSchemeBundle.registerColorScheme(borderScheme, ColorSchemeAssociationKind.BORDER); // marks decorationsSchemeBundle.registerColorScheme(markActiveScheme, ColorSchemeAssociationKind.MARK, ComponentState .getActiveStates()); // separators SubstanceColorScheme separatorDecorationsScheme = schemes .get("Twilight Decorations Separator"); decorationsSchemeBundle.registerColorScheme(separatorDecorationsScheme, ColorSchemeAssociationKind.SEPARATOR); SubstanceColorScheme decorationsWatermarkScheme = schemes .get("Twilight Decorations Watermark"); this.registerDecorationAreaSchemeBundle(decorationsSchemeBundle, decorationsWatermarkScheme, DecorationAreaType.TOOLBAR, DecorationAreaType.GENERAL, DecorationAreaType.FOOTER); SubstanceColorSchemeBundle headerSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, defaultScheme); headerSchemeBundle.registerColorScheme(defaultScheme, 0.5f, ComponentState.DISABLED_UNSELECTED); // borders headerSchemeBundle.registerColorScheme(borderDisabledSelectedScheme, ColorSchemeAssociationKind.BORDER, ComponentState.DISABLED_SELECTED); headerSchemeBundle.registerColorScheme(borderScheme, ColorSchemeAssociationKind.BORDER); // marks headerSchemeBundle.registerColorScheme(markActiveScheme, ColorSchemeAssociationKind.MARK, ComponentState .getActiveStates()); headerSchemeBundle.registerHighlightColorScheme(activeScheme, 0.7f, ComponentState.ROLLOVER_UNSELECTED, ComponentState.ROLLOVER_ARMED, ComponentState.ARMED); headerSchemeBundle.registerHighlightColorScheme(activeScheme, 0.8f, ComponentState.SELECTED); headerSchemeBundle.registerHighlightColorScheme(activeScheme, 1.0f, ComponentState.ROLLOVER_SELECTED); SubstanceColorScheme headerWatermarkScheme = schemes .get("Twilight Header Watermark"); this.registerDecorationAreaSchemeBundle(headerSchemeBundle, headerWatermarkScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER); setSelectedTabFadeStart(0.2); setSelectedTabFadeEnd(0.9); // Add overlay painters to paint drop shadows along the bottom // edges of toolbars and footers this.addOverlayPainter(BottomShadowOverlayPainter.getInstance(), DecorationAreaType.TOOLBAR); this.addOverlayPainter(BottomShadowOverlayPainter.getInstance(), DecorationAreaType.FOOTER); // add an overlay painter to paint a dark line along the bottom // edge of toolbars this.toolbarBottomLineOverlayPainter = new BottomLineOverlayPainter( new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { return scheme.getUltraDarkColor().darker(); } }); this.addOverlayPainter(this.toolbarBottomLineOverlayPainter, DecorationAreaType.TOOLBAR); // add an overlay painter to paint a dark line along the bottom // edge of toolbars this.toolbarTopLineOverlayPainter = new TopLineOverlayPainter( new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { Color fg = scheme.getForegroundColor(); return new Color(fg.getRed(), fg.getGreen(), fg .getBlue(), 32); } }); this.addOverlayPainter(this.toolbarTopLineOverlayPainter, DecorationAreaType.TOOLBAR); // add an overlay painter to paint a bezel line along the top // edge of footer this.footerTopBezelOverlayPainter = new TopBezelOverlayPainter( new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { return scheme.getUltraDarkColor().darker(); } }, new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { Color fg = scheme.getForegroundColor(); return new Color(fg.getRed(), fg.getGreen(), fg .getBlue(), 32); } }); this.addOverlayPainter(this.footerTopBezelOverlayPainter, DecorationAreaType.FOOTER); this.buttonShaper = new ClassicButtonShaper(); this.watermark = null; this.gradientPainter = new StandardGradientPainter(); this.decorationPainter = new MatteDecorationPainter(); this.highlightPainter = new ClassicHighlightPainter(); this.borderPainter = new CompositeBorderPainter("Twilight", new ClassicBorderPainter(), new DelegateBorderPainter( "Twilight Inner", new ClassicBorderPainter(), 0x40FFFFFF, 0x20FFFFFF, 0x00FFFFFF, new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.tint(0.3); } })); } public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceModerateLookAndFeel.java0000644000175000017500000000464711136475562030206 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Moderate skin from * {@link ModerateSkin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin.SubstanceModerateLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceModerateLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceModerateLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 3.1 */ public class SubstanceModerateLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Moderate look-and-feel. */ public SubstanceModerateLookAndFeel() { super(new ModerateSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/RavenGraphiteGlassSkin.java0000644000175000017500000001715711246437240027101 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import java.awt.Color; import org.jvnet.substance.api.*; import org.jvnet.substance.api.painter.overlay.BottomLineOverlayPainter; import org.jvnet.substance.api.painter.overlay.TopLineOverlayPainter; import org.jvnet.substance.colorscheme.EbonyColorScheme; import org.jvnet.substance.painter.border.*; import org.jvnet.substance.painter.decoration.ArcDecorationPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.gradient.GlassGradientPainter; import org.jvnet.substance.painter.highlight.GlassHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Raven Graphite Glass skin. This class is part of officially * supported API. * * @author Kirill Grouchnikov * @since version 3.3 */ public class RavenGraphiteGlassSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Raven Graphite Glass"; /** * Overlay painter to paint a dark line along the bottom edge of the * menubar. */ private BottomLineOverlayPainter menuOverlayPainter; /** * Overlay painter to paint a light line along the top edge of the toolbars. */ private TopLineOverlayPainter toolbarOverlayPainter; /** * Creates a new Raven Graphite skin. */ public RavenGraphiteGlassSkin() { SubstanceSkin.ColorSchemes schemes = SubstanceSkin .getColorSchemes(RavenGraphiteGlassSkin.class .getClassLoader() .getResource( "org/jvnet/substance/skin/ravengraphite.colorschemes")); SubstanceColorScheme activeScheme = schemes .get("Raven Graphite Active"); SubstanceColorScheme selectedDisabledScheme = schemes .get("Raven Graphite Selected Disabled"); SubstanceColorScheme disabledScheme = schemes .get("Raven Graphite Disabled"); SubstanceColorScheme defaultScheme = schemes .get("Raven Graphite Default"); SubstanceColorScheme backgroundScheme = schemes .get("Raven Graphite Background"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); // highlight fill scheme + custom alphas SubstanceColorScheme highlightScheme = schemes .get("Raven Graphite Highlight"); defaultSchemeBundle.registerHighlightColorScheme(highlightScheme, 0.6f, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerHighlightColorScheme(highlightScheme, 0.8f, ComponentState.SELECTED); defaultSchemeBundle.registerHighlightColorScheme(highlightScheme, 1.0f, ComponentState.ROLLOVER_SELECTED); defaultSchemeBundle.registerHighlightColorScheme(highlightScheme, 0.75f, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); // highlight border scheme SubstanceColorScheme borderScheme = schemes .get("Raven Graphite Border"); SubstanceColorScheme separatorScheme = schemes .get("Raven Graphite Separator"); defaultSchemeBundle.registerColorScheme(new EbonyColorScheme(), ColorSchemeAssociationKind.HIGHLIGHT_BORDER, ComponentState .getActiveStates()); defaultSchemeBundle.registerColorScheme(borderScheme, ColorSchemeAssociationKind.BORDER); defaultSchemeBundle.registerColorScheme(separatorScheme, ColorSchemeAssociationKind.SEPARATOR); // text highlight scheme SubstanceColorScheme textHighlightScheme = schemes .get("Raven Graphite Text Highlight"); defaultSchemeBundle.registerColorScheme(textHighlightScheme, ColorSchemeAssociationKind.TEXT_HIGHLIGHT, ComponentState.SELECTED, ComponentState.ROLLOVER_SELECTED); defaultSchemeBundle.registerColorScheme(highlightScheme, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); // register schemes for disabled states defaultSchemeBundle.registerColorScheme(disabledScheme, 0.5f, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(selectedDisabledScheme, 0.5f, ComponentState.DISABLED_SELECTED); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, backgroundScheme, DecorationAreaType.NONE); this.registerAsDecorationArea(backgroundScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER);// , DecorationAreaType.TOOLBAR); this.setSelectedTabFadeStart(0.1); this.setSelectedTabFadeEnd(0.3); // add two overlay painters to create a bezel line between // menu bar and toolbars this.menuOverlayPainter = new BottomLineOverlayPainter( ColorSchemeSingleColorQuery.MID); this.toolbarOverlayPainter = new TopLineOverlayPainter( new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { return SubstanceColorUtilities.getAlphaColor(scheme .getForegroundColor(), 32); } }); this.addOverlayPainter(this.menuOverlayPainter, DecorationAreaType.HEADER); this.addOverlayPainter(this.toolbarOverlayPainter, DecorationAreaType.TOOLBAR); this.buttonShaper = new ClassicButtonShaper(); this.watermark = null; this.gradientPainter = new GlassGradientPainter(); this.decorationPainter = new ArcDecorationPainter(); this.highlightPainter = new GlassHighlightPainter(); this.borderPainter = new CompositeBorderPainter("Raven Graphite Glass", new ClassicBorderPainter(), new DelegateBorderPainter( "Raven Graphite Glass Inner", new ClassicBorderPainter(), 0xA0FFFFFF, 0x60FFFFFF, 0x60FFFFFF, new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.tint(0.25f); } })); this.highlightBorderPainter = new ClassicBorderPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceNebulaLookAndFeel.java0000644000175000017500000000462511136475562027650 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Nebula skin from * {@link NebulaSkin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin.SubstanceNebulaLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceNebulaLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceNebulaLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 4.0 */ public class SubstanceNebulaLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Nebula look-and-feel. */ public SubstanceNebulaLookAndFeel() { super(new NebulaSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceDustCoffeeLookAndFeel.java0000644000175000017500000000467211162451130030453 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Dust Coffee skin from * {@link DustSkin}. You can set this look-and-feel by: *
    *
  • * -Dswing.defaultlaf=org.jvnet.substance.skin.SubstanceDustCoffeeLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceDustCoffeeLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceDustCoffeeLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 5.2 */ public class SubstanceDustCoffeeLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Dust Coffee look-and-feel. */ public SubstanceDustCoffeeLookAndFeel() { super(new DustCoffeeSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceOfficeSilver2007LookAndFeel.java0000644000175000017500000000477011136475562031334 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Office Silver 2007 skin * from {@link OfficeSilver2007Skin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin. * SubstanceOfficeSilver2007LookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceOfficeSilver2007LookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceOfficeSilver2007LookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 3.1 */ public class SubstanceOfficeSilver2007LookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Office Silver 2007 look-and-feel. */ public SubstanceOfficeSilver2007LookAndFeel() { super(new OfficeSilver2007Skin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceNebulaBrickWallLookAndFeel.java0000644000175000017500000000475711136475562031451 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Nebula Brick Wall skin * from {@link NebulaBrickWallSkin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin. * SubstanceNebulaBrickWallLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceNebulaBrickWallLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceNebulaBrickWallLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 4.0 */ public class SubstanceNebulaBrickWallLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Nebula Brick Wall look-and-feel. */ public SubstanceNebulaBrickWallLookAndFeel() { super(new NebulaBrickWallSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/RavenGraphiteSkin.java0000644000175000017500000001567511245410646026112 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import java.awt.Color; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.EbonyColorScheme; import org.jvnet.substance.painter.border.*; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.decoration.FlatDecorationPainter; import org.jvnet.substance.painter.gradient.SimplisticGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * Raven Graphite skin. This class is part of officially supported * API. * * @author Kirill Grouchnikov * @since version 3.3 */ public class RavenGraphiteSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Raven Graphite"; /** * Creates a new Raven Graphite skin. */ public RavenGraphiteSkin() { SubstanceSkin.ColorSchemes schemes = SubstanceSkin .getColorSchemes(RavenGraphiteSkin.class .getClassLoader() .getResource( "org/jvnet/substance/skin/ravengraphite.colorschemes")); SubstanceColorScheme activeScheme = schemes .get("Raven Graphite Active"); SubstanceColorScheme selectedDisabledScheme = schemes .get("Raven Graphite Selected Disabled"); SubstanceColorScheme disabledScheme = schemes .get("Raven Graphite Disabled"); SubstanceColorScheme defaultScheme = schemes .get("Raven Graphite Default"); SubstanceColorScheme backgroundScheme = schemes .get("Raven Graphite Background"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); // highlight fill scheme + custom alpha for rollover unselected state SubstanceColorScheme highlightScheme = schemes .get("Raven Graphite Highlight"); defaultSchemeBundle.registerHighlightColorScheme(highlightScheme, 0.6f, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerHighlightColorScheme(highlightScheme, 0.8f, ComponentState.SELECTED); defaultSchemeBundle.registerHighlightColorScheme(highlightScheme, 1.0f, ComponentState.ROLLOVER_SELECTED); defaultSchemeBundle.registerHighlightColorScheme(highlightScheme, 0.75f, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); // highlight border scheme SubstanceColorScheme borderScheme = schemes .get("Raven Graphite Border"); SubstanceColorScheme separatorScheme = schemes .get("Raven Graphite Separator"); defaultSchemeBundle.registerColorScheme(new EbonyColorScheme(), ColorSchemeAssociationKind.HIGHLIGHT_BORDER, ComponentState .getActiveStates()); defaultSchemeBundle.registerColorScheme(borderScheme, ColorSchemeAssociationKind.BORDER); defaultSchemeBundle.registerColorScheme(separatorScheme, ColorSchemeAssociationKind.SEPARATOR); // text highlight scheme SubstanceColorScheme textHighlightScheme = schemes .get("Raven Graphite Text Highlight"); defaultSchemeBundle.registerColorScheme(textHighlightScheme, ColorSchemeAssociationKind.TEXT_HIGHLIGHT, ComponentState.SELECTED, ComponentState.ROLLOVER_SELECTED); defaultSchemeBundle.registerColorScheme(highlightScheme, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); defaultSchemeBundle.registerColorScheme(disabledScheme, 0.5f, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(selectedDisabledScheme, 0.5f, ComponentState.DISABLED_SELECTED); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, backgroundScheme, DecorationAreaType.NONE); this.setSelectedTabFadeStart(0.1); this.setSelectedTabFadeEnd(0.3); this.buttonShaper = new ClassicButtonShaper(); this.watermark = null; this.gradientPainter = new SimplisticGradientPainter() { @Override public Color getBottomFillColor( SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return getMidFillColorBottom(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } @Override public Color getTopFillColor( SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return super.getBottomFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } }; this.decorationPainter = new FlatDecorationPainter(); this.highlightPainter = new ClassicHighlightPainter(); this.borderPainter = new CompositeBorderPainter("Raven Graphite", new ClassicBorderPainter(), new DelegateBorderPainter( "Raven Graphite Inner", new ClassicBorderPainter(), 0xA0FFFFFF, 0x60FFFFFF, 0x60FFFFFF, new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.tint(0.25f); } })); this.highlightBorderPainter = new ClassicBorderPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/EmeraldDuskSkin.java0000644000175000017500000001003011245410554025525 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import java.awt.Color; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.CharcoalColorScheme; import org.jvnet.substance.colorscheme.ToneColorScheme; import org.jvnet.substance.painter.border.GlassBorderPainter; import org.jvnet.substance.painter.decoration.ArcDecorationPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.gradient.GlassGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * Emerald Dusk skin. This class is part of officially supported * API. * * @author Kirill Grouchnikov * @since version 3.2 */ public class EmeraldDuskSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Emerald Dusk"; /** * Creates a new Emerald Dusk skin. */ public EmeraldDuskSkin() { SubstanceColorScheme activeScheme = new CharcoalColorScheme().hueShift( 0.3).named("Emerald Dusk Active"); SubstanceColorScheme defaultScheme = new CharcoalColorScheme() .hueShift(0.4).named("Emerald Dusk Default"); SubstanceColorScheme disabledScheme = new ToneColorScheme(activeScheme, 0.3) { Color foreColor = new Color(120, 134, 128); @Override public Color getForegroundColor() { return foreColor; } }.named("Emerald Dusk Disabled"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.registerAsDecorationArea(defaultScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER, DecorationAreaType.FOOTER, DecorationAreaType.GENERAL, DecorationAreaType.TOOLBAR); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new GlassGradientPainter(); this.decorationPainter = new ArcDecorationPainter(); this.borderPainter = new GlassBorderPainter(); this.highlightPainter = new ClassicHighlightPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/SkinChangeListener.java0000644000175000017500000000426011136475562026241 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * The listener interface for receiving events on changing the skin in * Substance look and feel. This class is part of officially supported * API. * * @author Kirill Grouchnikov */ public interface SkinChangeListener { /** * Invoked when the current Substance skin is changed. * * @see SubstanceLookAndFeel#setSkin(SubstanceSkin) * @see SubstanceLookAndFeel#setSkin(String) */ public void skinChanged(); } substance-5.3.orig/src/org/jvnet/substance/skin/autumn.colorschemes0000644000175000017500000000123611157724270025573 0ustar drazzibdrazzibAutumn Active { kind=Light colorUltraLight=#FDDDAC colorExtraLight=#FCEF9F colorLight=#FCD592 colorMid=#F9BE84 colorDark=#F8B87A colorUltraDark=#AC623B colorForeground=#AC623B } Autumn Default { kind=Light colorUltraLight=#FFF2DF colorExtraLight=#FFE3C5 colorLight=#FDD1A4 colorMid=#FBCD9C colorDark=#FCC896 colorUltraDark=#AC623B colorForeground=#AC623B } Autumn Watermark { kind=Light colorUltraLight=#FFF2DF colorExtraLight=#FFE3C5 colorLight=#FEDAB5 colorMid=#FED8B2 colorDark=#FDD4AA colorUltraDark=#FDD1A5 colorForeground=#AC623B } substance-5.3.orig/src/org/jvnet/substance/skin/OfficeBlue2007Skin.java0000644000175000017500000002772111246710504025657 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import java.awt.Color; import org.jvnet.substance.api.*; import org.jvnet.substance.api.painter.border.DelegateFractionBasedBorderPainter; import org.jvnet.substance.api.painter.border.FractionBasedBorderPainter; import org.jvnet.substance.api.painter.decoration.FractionBasedDecorationPainter; import org.jvnet.substance.api.painter.fill.FractionBasedFillPainter; import org.jvnet.substance.api.painter.overlay.BottomLineOverlayPainter; import org.jvnet.substance.painter.border.CompositeBorderPainter; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * Office Blue 2007 skin. This class is part of officially * supported API. * * @author Kirill Grouchnikov * @since version 3.1 */ public class OfficeBlue2007Skin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Office Blue 2007"; /** * Creates a new Office Blue 2007 skin. */ public OfficeBlue2007Skin() { SubstanceSkin.ColorSchemes colorSchemes = SubstanceSkin .getColorSchemes(OfficeBlue2007Skin.class .getClassLoader() .getResource( "org/jvnet/substance/skin/office2007.colorschemes")); SubstanceColorScheme activeScheme = colorSchemes .get("Office Blue Active"); SubstanceColorScheme defaultScheme = colorSchemes .get("Office Blue Default"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, defaultScheme); defaultSchemeBundle.registerColorScheme(defaultScheme, 0.5f, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(activeScheme, 0.5f, ComponentState.DISABLED_SELECTED); SubstanceColorScheme rolloverScheme = colorSchemes .get("Office Blue Rollover"); SubstanceColorScheme rolloverSelectedScheme = colorSchemes .get("Office Blue Rollover Selected"); SubstanceColorScheme selectedScheme = colorSchemes .get("Office Blue Selected"); SubstanceColorScheme pressedScheme = colorSchemes .get("Office Blue Pressed"); SubstanceColorScheme pressedSelectedScheme = colorSchemes .get("Office Blue Pressed Selected"); // register state-specific color schemes on rollovers and selections defaultSchemeBundle.registerColorScheme(rolloverScheme, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerColorScheme(rolloverSelectedScheme, ComponentState.ROLLOVER_SELECTED); defaultSchemeBundle.registerColorScheme(selectedScheme, ComponentState.SELECTED); defaultSchemeBundle.registerColorScheme(pressedScheme, ComponentState.PRESSED_UNSELECTED); defaultSchemeBundle.registerColorScheme(pressedSelectedScheme, ComponentState.PRESSED_SELECTED); // register state-specific highlight color schemes on rollover and // selections defaultSchemeBundle.registerHighlightColorScheme(rolloverScheme, 0.8f, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerHighlightColorScheme(selectedScheme, 0.8f, ComponentState.SELECTED); defaultSchemeBundle.registerHighlightColorScheme( rolloverSelectedScheme, 0.8f, ComponentState.ROLLOVER_SELECTED); defaultSchemeBundle.registerHighlightColorScheme(selectedScheme, 0.8f, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); // borders and marks SubstanceColorScheme borderDefaultScheme = colorSchemes .get("Office Blue Border Default"); SubstanceColorScheme borderActiveScheme = colorSchemes .get("Office Blue Border Active"); SubstanceColorScheme borderRolloverScheme = colorSchemes .get("Office Border Rollover"); SubstanceColorScheme borderRolloverSelectedScheme = colorSchemes .get("Office Border Rollover Selected"); SubstanceColorScheme borderSelectedScheme = colorSchemes .get("Office Border Selected"); SubstanceColorScheme borderPressedScheme = colorSchemes .get("Office Border Pressed"); defaultSchemeBundle.registerColorScheme(borderDefaultScheme, ColorSchemeAssociationKind.BORDER, ComponentState.DEFAULT); defaultSchemeBundle.registerColorScheme(borderDefaultScheme, ColorSchemeAssociationKind.BORDER, ComponentState.DISABLED_SELECTED, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(borderActiveScheme, ColorSchemeAssociationKind.BORDER, ComponentState.ACTIVE); defaultSchemeBundle.registerColorScheme(borderRolloverScheme, ColorSchemeAssociationKind.BORDER, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerColorScheme(borderRolloverSelectedScheme, ColorSchemeAssociationKind.BORDER, ComponentState.ROLLOVER_SELECTED, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); defaultSchemeBundle.registerColorScheme(borderSelectedScheme, ColorSchemeAssociationKind.BORDER, ComponentState.SELECTED); defaultSchemeBundle.registerColorScheme(borderPressedScheme, ColorSchemeAssociationKind.BORDER, ComponentState.PRESSED_SELECTED, ComponentState.PRESSED_UNSELECTED); // defaultSchemeBundle.registerColorScheme(borderDefaultScheme, // ColorSchemeAssociationKind.MARK, ComponentState.DEFAULT); // defaultSchemeBundle.registerColorScheme(borderDefaultScheme, // ColorSchemeAssociationKind.MARK, // ComponentState.DISABLED_SELECTED, // ComponentState.DISABLED_UNSELECTED); // defaultSchemeBundle.registerColorScheme(borderActiveScheme, // ColorSchemeAssociationKind.MARK, ComponentState.ACTIVE); // defaultSchemeBundle.registerColorScheme(borderRolloverSelectedScheme, // ColorSchemeAssociationKind.MARK, // ComponentState.ROLLOVER_SELECTED); // defaultSchemeBundle.registerColorScheme(borderSelectedScheme, // ColorSchemeAssociationKind.MARK, ComponentState.SELECTED); // defaultSchemeBundle.registerColorScheme(borderPressedScheme, // ColorSchemeAssociationKind.MARK, // ComponentState.ROLLOVER_UNSELECTED, // ComponentState.PRESSED_SELECTED, // ComponentState.PRESSED_UNSELECTED); // tabs and tab borders SubstanceColorScheme tabSelectedScheme = colorSchemes .get("Office Blue Tab Selected"); SubstanceColorScheme tabRolloverScheme = colorSchemes .get("Office Blue Tab Rollover"); defaultSchemeBundle.registerColorScheme(tabSelectedScheme, ColorSchemeAssociationKind.TAB, ComponentState.SELECTED, ComponentState.ROLLOVER_SELECTED, ComponentState.PRESSED_SELECTED, ComponentState.PRESSED_UNSELECTED); defaultSchemeBundle.registerColorScheme(tabRolloverScheme, ColorSchemeAssociationKind.TAB, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerColorScheme(borderDefaultScheme, ColorSchemeAssociationKind.TAB_BORDER, ComponentState.SELECTED, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerColorScheme(rolloverSelectedScheme, ColorSchemeAssociationKind.TAB_BORDER, ComponentState.ROLLOVER_SELECTED); // separator SubstanceColorScheme separatorScheme = colorSchemes .get("Office Blue Separator"); defaultSchemeBundle.registerColorScheme(separatorScheme, ColorSchemeAssociationKind.SEPARATOR); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.watermarkScheme = colorSchemes.get("Office Blue Watermark"); SubstanceColorScheme generalWatermarkScheme = colorSchemes .get("Office Blue Header Watermark"); this.registerAsDecorationArea(generalWatermarkScheme, DecorationAreaType.FOOTER, DecorationAreaType.HEADER, DecorationAreaType.TOOLBAR); SubstanceColorScheme titleWatermarkScheme = colorSchemes .get("Office Blue Title Watermark"); this.registerAsDecorationArea(titleWatermarkScheme, DecorationAreaType.GENERAL, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE); setSelectedTabFadeStart(0.7); setSelectedTabFadeEnd(0.9); this.addOverlayPainter(new BottomLineOverlayPainter( new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { Color fg = scheme.getForegroundColor(); return new Color(fg.getRed(), fg.getGreen(), fg .getBlue(), 72); } }), DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE); this.buttonShaper = new ClassicButtonShaper(); this.watermark = null; this.gradientPainter = new FractionBasedFillPainter("Office Blue 2007", new float[] { 0.0f, 0.49999f, 0.5f, 1.0f }, new ColorSchemeSingleColorQuery[] { ColorSchemeSingleColorQuery.ULTRALIGHT, ColorSchemeSingleColorQuery.LIGHT, ColorSchemeSingleColorQuery.ULTRADARK, ColorSchemeSingleColorQuery.EXTRALIGHT }); FractionBasedBorderPainter outerBorderPainter = new FractionBasedBorderPainter( "Office Blue 2007 Outer", new float[] { 0.0f, 0.5f, 1.0f }, new ColorSchemeSingleColorQuery[] { ColorSchemeSingleColorQuery.EXTRALIGHT, ColorSchemeSingleColorQuery.DARK, ColorSchemeSingleColorQuery.MID }); SubstanceBorderPainter innerBorderPainter = new DelegateFractionBasedBorderPainter( "Office Blue 2007 Inner", outerBorderPainter, new int[] { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }, new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.tint(0.8f); } }); this.borderPainter = new CompositeBorderPainter("Office Blue 2007", outerBorderPainter, innerBorderPainter); this.decorationPainter = new FractionBasedDecorationPainter( "Office Blue 2007", new float[] { 0.0f, 0.1199999f, 0.12f, 0.5f, 0.9f, 1.0f }, new ColorSchemeSingleColorQuery[] { ColorSchemeSingleColorQuery.LIGHT, ColorSchemeSingleColorQuery.LIGHT, ColorSchemeSingleColorQuery.ULTRADARK, ColorSchemeSingleColorQuery.MID, ColorSchemeSingleColorQuery.ULTRALIGHT, ColorSchemeSingleColorQuery.LIGHT }); this.highlightPainter = new ClassicHighlightPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/skin/CremeCoffeeSkin.java0000644000175000017500000001044011245410536025475 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.CremeColorScheme; import org.jvnet.substance.colorscheme.LightGrayColorScheme; import org.jvnet.substance.painter.border.*; import org.jvnet.substance.painter.decoration.ArcDecorationPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.gradient.MatteGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; /** * Creme Coffee skin. This class is part of officially supported * API. * * @author Kirill Grouchnikov * @since version 4.1 */ public class CremeCoffeeSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Creme Coffee"; /** * Creates a new Creme Coffee skin. */ public CremeCoffeeSkin() { SubstanceColorScheme activeScheme = SubstanceColorSchemeUtilities .getColorScheme(CremeCoffeeSkin.class .getClassLoader() .getResource( "org/jvnet/substance/skin/coffee-active.colorscheme")); SubstanceColorScheme defaultScheme = new CremeColorScheme(); SubstanceColorScheme disabledScheme = new LightGrayColorScheme().tint( 0.35).named("Creme Coffee Disabled"); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.registerAsDecorationArea(defaultScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER, DecorationAreaType.FOOTER, DecorationAreaType.GENERAL, DecorationAreaType.TOOLBAR); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new MatteGradientPainter(); this.decorationPainter = new ArcDecorationPainter(); this.highlightPainter = new ClassicHighlightPainter(); this.borderPainter = new CompositeBorderPainter("Creme Coffee", new GlassBorderPainter(), new DelegateBorderPainter( "Creme Coffee Inner", new GlassBorderPainter(), new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.tint(0.8f); } })); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } }substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceDustLookAndFeel.java0000644000175000017500000000461011157465474027357 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Dust skin from * {@link DustSkin}. You can set this look-and-feel by: *
    *
  • * -Dswing.defaultlaf=org.jvnet.substance.skin.SubstanceDustLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceDustLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceDustLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 5.2 */ public class SubstanceDustLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Dust look-and-feel. */ public SubstanceDustLookAndFeel() { super(new DustSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceMistAquaLookAndFeel.java0000644000175000017500000000465111136475562030165 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Mist Aqua skin from * {@link MistAquaSkin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin.SubstanceMistAquaLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceMistAquaLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceMistAquaLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 4.0 */ public class SubstanceMistAquaLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Mist Aqua look-and-feel. */ public SubstanceMistAquaLookAndFeel() { super(new MistAquaSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceRavenLookAndFeel.java0000644000175000017500000000461411136475562027513 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Raven skin from * {@link RavenSkin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin.SubstanceRavenLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceRavenLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceRavenLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 3.1 */ public class SubstanceRavenLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Raven look-and-feel. */ public SubstanceRavenLookAndFeel() { super(new RavenSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceCremeLookAndFeel.java0000644000175000017500000000461411136475562027473 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Creme skin from * {@link CremeSkin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin.SubstanceCremeLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceCremeLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceCremeLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 3.1 */ public class SubstanceCremeLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Creme look-and-feel. */ public SubstanceCremeLookAndFeel() { super(new CremeSkin()); } } substance-5.3.orig/src/org/jvnet/substance/skin/SubstanceSaharaLookAndFeel.java0000644000175000017500000000462511136475562027641 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Sahara skin from * {@link SaharaSkin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.skin.SubstanceSaharaLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.skin.SubstanceSaharaLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceSaharaLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 3.1 */ public class SubstanceSaharaLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Sahara look-and-feel. */ public SubstanceSaharaLookAndFeel() { super(new SaharaSkin()); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceCheckBoxUI.java0000644000175000017500000002401711253517604025345 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicButtonListener; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.animation.FadeState; import org.jvnet.substance.api.*; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; import org.jvnet.substance.utils.*; /** * UI for check boxes in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceCheckBoxUI extends SubstanceRadioButtonUI { /** * Prefix for the checkbox-related properties in the {@link UIManager}. */ private final static String propertyPrefix = "CheckBox" + "."; // /** // * Listener for fade animations. // */ // protected FadeStateListener substanceFadeStateListener; // // /** // * Property change listener. Listens on changes to // * {@link AbstractButton#MODEL_CHANGED_PROPERTY} property. // */ // protected PropertyChangeListener substancePropertyListener; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceCheckBoxUI((JToggleButton) comp); } /** * Hash map for storing icons. */ private static LazyResettableHashMap icons = new LazyResettableHashMap( "SubstanceCheckBoxUI"); /** * Simple constructor. * * @param button * The associated button. */ public SubstanceCheckBoxUI(JToggleButton button) { super(button); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicRadioButtonUI#getPropertyPrefix() */ @Override protected String getPropertyPrefix() { return propertyPrefix; } // /* // * (non-Javadoc) // * // * @seejavax.swing.plaf.basic.BasicButtonUI#installListeners(javax.swing. // * AbstractButton) // */ // @Override // protected void installListeners(final AbstractButton b) { // super.installListeners(b); // this.substanceFadeStateListener = new FadeStateListener(b, // b.getModel(), SubstanceCoreUtilities.getFadeCallback(b, false)); // this.substanceFadeStateListener.registerListeners(); // // this.substancePropertyListener = new PropertyChangeListener() { // public void propertyChange(PropertyChangeEvent evt) { // if (AbstractButton.MODEL_CHANGED_PROPERTY.equals(evt // .getPropertyName())) { // if (substanceFadeStateListener != null) // substanceFadeStateListener.unregisterListeners(); // substanceFadeStateListener = new FadeStateListener(b, b // .getModel(), SubstanceCoreUtilities // .getFadeCallback(b, false)); // substanceFadeStateListener.registerListeners(); // } // } // }; // b.addPropertyChangeListener(this.substancePropertyListener); // } // // /* // * (non-Javadoc) // * // * // @seejavax.swing.plaf.basic.BasicButtonUI#uninstallListeners(javax.swing. // * AbstractButton) // */ // @Override // protected void uninstallListeners(AbstractButton b) { // this.substanceFadeStateListener.unregisterListeners(); // this.substanceFadeStateListener = null; // // b.removePropertyChangeListener(this.substancePropertyListener); // this.substancePropertyListener = null; // // super.uninstallListeners(b); // } /* * (non-Javadoc) * * @see * org.jvnet.substance.SubstanceRadioButtonUI#installDefaults(javax.swing * .AbstractButton) */ @Override protected void installDefaults(AbstractButton b) { super.installDefaults(b); button.setRolloverEnabled(true); Border border = b.getBorder(); if (border == null || border instanceof UIResource) { b.setBorder(SubstanceSizeUtils.getCheckBoxBorder(SubstanceSizeUtils .getComponentFontSize(b))); } } /** * Returns the icon that matches the current and previous states of the * checkbox. * * @param button * Button (should be {@link JCheckBox}). * @param currState * Current state of the checkbox. * @param prevState * Previous state of the checkbox. * @return Matching icon. */ private static Icon getIcon(JToggleButton button, ComponentState currState, ComponentState prevState) { float checkMarkVisibility = currState.isKindActive(FadeKind.SELECTION) ? 10 : 0; boolean isCheckMarkFadingOut = false; SubstanceColorScheme currFillColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.FILL, currState); SubstanceColorScheme prevFillColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.FILL, prevState); SubstanceColorScheme currMarkColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.MARK, currState); SubstanceColorScheme prevMarkColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.MARK, prevState); SubstanceColorScheme currBorderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.BORDER, currState); SubstanceColorScheme prevBorderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.BORDER, prevState); float cyclePos = 0; FadeState fadeState = SubstanceFadeUtilities.getFadeState(button, FadeKind.SELECTION, FadeKind.ROLLOVER, FadeKind.PRESS); if (fadeState != null) { cyclePos = fadeState.getFadePosition(); if (fadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; if (fadeState.fadeKind == FadeKind.SELECTION) { checkMarkVisibility = fadeState.getFadePosition(); isCheckMarkFadingOut = !fadeState.isFadingIn(); } } int fontSize = SubstanceSizeUtils.getComponentFontSize(button); int checkMarkSize = SubstanceSizeUtils.getCheckBoxMarkSize(fontSize); SubstanceGradientPainter fillPainter = SubstanceCoreUtilities .getGradientPainter(button); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(button); // System.out.println(prevState + " -> [" + cyclePos + "] " + // currState); // System.out.println("\t" + prevBorderColorScheme.getDisplayName() // + " -> " + currBorderColorScheme.getDisplayName()); HashMapKey key = SubstanceCoreUtilities.getHashKey(fontSize, checkMarkSize, currState.name(), prevState.name(), fillPainter .getDisplayName(), borderPainter.getDisplayName(), currFillColorScheme.getDisplayName(), prevFillColorScheme .getDisplayName(), currMarkColorScheme.getDisplayName(), prevMarkColorScheme .getDisplayName(), currBorderColorScheme .getDisplayName(), prevBorderColorScheme .getDisplayName(), cyclePos, checkMarkVisibility, isCheckMarkFadingOut); Icon result = SubstanceCheckBoxUI.icons.get(key); if (result != null) return result; result = new ImageIcon(SubstanceImageCreator.getCheckBox(button, fillPainter, borderPainter, checkMarkSize, currState, prevState, currFillColorScheme, prevFillColorScheme, currMarkColorScheme, prevMarkColorScheme, currBorderColorScheme, prevBorderColorScheme, cyclePos, checkMarkVisibility, isCheckMarkFadingOut)); SubstanceCheckBoxUI.icons.put(key, result); return result; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicButtonUI#createButtonListener(javax.swing * .AbstractButton) */ @Override protected BasicButtonListener createButtonListener(AbstractButton b) { return new RolloverButtonListener(b); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicRadioButtonUI#getDefaultIcon() */ @Override public Icon getDefaultIcon() { ComponentState currState = ComponentState.getState(this.button); ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(this.button); return SubstanceCheckBoxUI.getIcon(this.button, currState, prevState); } /** * Returns memory usage string. * * @return Memory usage string. */ public static String getMemoryUsage() { StringBuffer sb = new StringBuffer(); sb.append("SubstanceCheckBox: \n"); sb.append("\t" + SubstanceCheckBoxUI.icons.size() + " icons"); return sb.toString(); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceSpinnerUI.java0000644000175000017500000004404211225435214025270 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.EnumSet; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicSpinnerUI; import org.jvnet.lafwidget.animation.*; import org.jvnet.substance.api.*; import org.jvnet.substance.api.SubstanceConstants.Side; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.border.SubstanceBorder; import org.jvnet.substance.utils.icon.TransitionAwareIcon; /** * UI for spinners in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceSpinnerUI extends BasicSpinnerUI { /** * Tracks changes to editor, removing the border as necessary. */ protected PropertyChangeListener substancePropertyChangeListener; /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /** * The next (increment) button. */ protected SubstanceSpinnerButton nextButton; /** * The previous (decrement) button. */ protected SubstanceSpinnerButton prevButton; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceSpinnerUI(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSpinnerUI#createNextButton() */ @Override protected Component createNextButton() { this.nextButton = new SubstanceSpinnerButton(this.spinner, SwingConstants.NORTH); this.nextButton.setFont(this.spinner.getFont()); this.nextButton.setName("Spinner.nextButton"); Icon icon = new TransitionAwareIcon(this.nextButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { int fontSize = SubstanceSizeUtils .getComponentFontSize(spinner); return SubstanceImageCreator.getArrowIcon( SubstanceSizeUtils .getSpinnerArrowIconWidth(fontSize), SubstanceSizeUtils .getSpinnerArrowIconHeight(fontSize), SubstanceSizeUtils .getArrowStrokeWidth(fontSize), SwingConstants.NORTH, scheme); } }, "substance.spinner.nextButton"); this.nextButton.setIcon(icon); int spinnerButtonSize = SubstanceSizeUtils .getScrollBarWidth(SubstanceSizeUtils .getComponentFontSize(spinner)); this.nextButton.setPreferredSize(new Dimension(spinnerButtonSize, spinnerButtonSize)); this.nextButton.setMinimumSize(new Dimension(5, 5)); // Set openSides = EnumSet.of(Side.BOTTOM, Side.TOP, Side.RIGHT); this.nextButton.putClientProperty( SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, EnumSet .allOf(Side.class)); this.installNextButtonListeners(this.nextButton); return this.nextButton; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSpinnerUI#createPreviousButton() */ @Override protected Component createPreviousButton() { this.prevButton = new SubstanceSpinnerButton(this.spinner, SwingConstants.SOUTH); this.prevButton.setFont(this.spinner.getFont()); this.prevButton.setName("Spinner.previousButton"); Icon icon = new TransitionAwareIcon(this.prevButton, new TransitionAwareIcon.Delegate() { public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { // System.out.println(spinner.getFont().getSize()); int fontSize = SubstanceSizeUtils .getComponentFontSize(spinner); float spinnerArrowIconHeight = SubstanceSizeUtils .getSpinnerArrowIconHeight(fontSize); // System.out.println("OLD height : " // + spinnerArrowIconHeight); return SubstanceImageCreator.getArrowIcon( SubstanceSizeUtils .getSpinnerArrowIconWidth(fontSize), spinnerArrowIconHeight, SubstanceSizeUtils .getArrowStrokeWidth(fontSize), SwingConstants.SOUTH, scheme); } }, "substance.spinner.prevButton"); this.prevButton.setIcon(icon); int spinnerButtonSize = SubstanceSizeUtils .getScrollBarWidth(SubstanceSizeUtils .getComponentFontSize(this.prevButton)); this.prevButton.setPreferredSize(new Dimension(spinnerButtonSize, spinnerButtonSize)); this.prevButton.setMinimumSize(new Dimension(5, 5)); // Set openSides = EnumSet.of(Side.BOTTOM, Side.TOP, Side.RIGHT); this.prevButton.putClientProperty( SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, EnumSet .allOf(Side.class)); this.installPreviousButtonListeners(this.prevButton); return this.prevButton; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSpinnerUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); JComponent editor = this.spinner.getEditor(); if ((editor != null) && (editor instanceof JSpinner.DefaultEditor)) { JTextField tf = ((JSpinner.DefaultEditor) editor).getTextField(); if (tf != null) { int fontSize = SubstanceSizeUtils .getComponentFontSize(this.spinner); Insets ins = SubstanceSizeUtils .getSpinnerTextBorderInsets(fontSize); tf.setBorder(new EmptyBorder(ins.top, ins.left, ins.bottom, ins.right)); tf.setFont(spinner.getFont()); } } Border b = this.spinner.getBorder(); if (b == null || b instanceof UIResource) { this.spinner.setBorder(new SubstanceBorder(SubstanceSizeUtils .getSpinnerBorderInsets(SubstanceSizeUtils .getComponentFontSize(this.spinner)))); } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSpinnerUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); this.substancePropertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("editor".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (substanceFadeStateListener != null) { substanceFadeStateListener .unregisterListeners(); substanceFadeStateListener = null; } if (spinner == null) return; JComponent editor = spinner.getEditor(); if ((editor != null) && (editor instanceof JSpinner.DefaultEditor)) { JTextField tf = ((JSpinner.DefaultEditor) editor) .getTextField(); if (tf != null) { Insets ins = SubstanceSizeUtils .getSpinnerTextBorderInsets(SubstanceSizeUtils .getComponentFontSize(spinner)); tf.setBorder(new EmptyBorder(ins.top, ins.left, ins.bottom, ins.right)); substanceFadeStateListener = new FadeStateListener( tf, null, new FadeTrackerAdapter() { @Override public void fadeEnded( FadeKind fadeKind) { if (spinner != null) spinner.repaint(); } @Override public void fadePerformed( FadeKind fadeKind, float fadeCycle10) { if (spinner != null) spinner.repaint(); } }); substanceFadeStateListener .registerListeners(); } } } }); } if ("font".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (spinner != null) { spinner.updateUI(); } } }); } if ("background".equals(evt.getPropertyName())) { JComponent editor = spinner.getEditor(); if ((editor != null) && (editor instanceof JSpinner.DefaultEditor)) { JTextField tf = ((JSpinner.DefaultEditor) editor) .getTextField(); if (tf != null) { // Use SubstanceColorResource to distingish between // color set by application and color set // (propagated) // by Substance. In the second case we can replace // that color (even though it's not a UIResource). Color tfBackground = tf.getBackground(); boolean canReplace = SubstanceCoreUtilities .canReplaceChildBackgroundColor(tfBackground); // fix for issue 387 - if spinner background // is null, do nothing if (spinner.getBackground() == null) canReplace = false; if (canReplace) { tf.setBackground(new SubstanceColorResource( spinner.getBackground())); } } } } } }; this.spinner .addPropertyChangeListener(this.substancePropertyChangeListener); JComponent editor = spinner.getEditor(); if ((editor != null) && (editor instanceof JSpinner.DefaultEditor)) { JTextField tf = ((JSpinner.DefaultEditor) editor).getTextField(); this.substanceFadeStateListener = new FadeStateListener(tf, null, new FadeTrackerAdapter() { @Override public void fadeEnded(FadeKind fadeKind) { if (spinner != null) spinner.repaint(); } @Override public void fadePerformed(FadeKind fadeKind, float fadeCycle10) { if (spinner != null) spinner.repaint(); } }); this.substanceFadeStateListener.registerListeners(); } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSpinnerUI#uninstallListeners() */ @Override protected void uninstallListeners() { // listener can be null is there is a custom editor installed // on the spinner. if (this.substanceFadeStateListener != null) { this.substanceFadeStateListener.unregisterListeners(); this.substanceFadeStateListener = null; } this.spinner .removePropertyChangeListener(this.substancePropertyChangeListener); this.substancePropertyChangeListener = null; super.uninstallListeners(); } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#paint(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void paint(Graphics g, JComponent c) { super.paint(g, c); if (hasFocus(this.spinner) || FadeTracker.getInstance().isTracked(this.spinner, FadeKind.FOCUS)) { this.paintFocus(g, this.spinner.getEditor().getBounds()); } if (this.spinner.isEnabled()) { Graphics2D g2d = (Graphics2D) g.create(); g2d.setColor(Color.red); SubstanceColorScheme borderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(c, ColorSchemeAssociationKind.BORDER, ComponentState.DEFAULT); if (this.spinner.getComponentOrientation().isLeftToRight()) { g2d.translate(this.spinner.getEditor().getX() + this.spinner.getEditor().getWidth(), -5); SubstanceImageCreator.paintSimpleBorder(this.spinner, g2d, 2 * nextButton.getWidth(), this.spinner.getHeight() + 10, borderColorScheme, borderColorScheme, 0.0f); } else { g2d.translate(-5, -5); SubstanceImageCreator.paintSimpleBorder(this.spinner, g2d, 5 + this.spinner.getEditor().getX(), this.spinner .getHeight() + 10, borderColorScheme, borderColorScheme, 0.0f); } g2d.dispose(); } } /** * Checks if a component or any of its children have focus. * * @param comp * Component. * @return true if the component of any of its children have * focus, false otherwise. */ private static boolean hasFocus(Component comp) { if (comp.hasFocus()) return true; if (comp instanceof Container) { Container cont = (Container) comp; for (int i = 0; i < cont.getComponentCount(); i++) { Component child = cont.getComponent(i); if (hasFocus(child)) return true; } } return false; } /** * Paints the focus indication. * * @param g * Graphics. * @param bounds * Bounds for text. */ protected void paintFocus(Graphics g, Rectangle bounds) { // JComponent editor = spinner.getEditor(); // if ((editor != null) && (editor instanceof JSpinner.DefaultEditor)) { // JTextField tf = ((JSpinner.DefaultEditor) editor).getTextField(); // if (tf != null) { // SubstanceCoreUtilities.paintFocus(g, this.spinner, tf, null, // bounds, 0.4f, 2 + SubstanceSizeUtils // .getExtraPadding(SubstanceSizeUtils // .getComponentFontSize(spinner))); // } // } } /* * (non-Javadoc) * * @see * javax.swing.plaf.ComponentUI#getPreferredSize(javax.swing.JComponent) */ @Override public Dimension getPreferredSize(JComponent c) { Dimension nextD = this.nextButton.getPreferredSize(); Dimension previousD = this.prevButton.getPreferredSize(); Dimension editorD = spinner.getEditor().getPreferredSize(); Dimension size = new Dimension(editorD.width, editorD.height); size.width += Math.max(nextD.width, previousD.width); Insets insets = this.spinner.getInsets(); size.width += insets.left + insets.right; size.height += insets.top + insets.bottom; return size; } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void update(Graphics g, JComponent c) { SubstanceTextUtilities.paintTextCompBackground(g, c); this.paint(g, c); } @Override protected LayoutManager createLayout() { return new SpinnerLayoutManager(); } /** * Layout manager for the spinner. * * @author Kirill Grouchnikov */ protected class SpinnerLayoutManager implements LayoutManager { public void addLayoutComponent(String name, Component comp) { } public void removeLayoutComponent(Component comp) { } public Dimension minimumLayoutSize(Container parent) { return this.preferredLayoutSize(parent); } public Dimension preferredLayoutSize(Container parent) { Dimension nextD = nextButton.getPreferredSize(); Dimension previousD = prevButton.getPreferredSize(); Dimension editorD = spinner.getEditor().getPreferredSize(); /* * Force the editors height to be a multiple of 2 */ editorD.height = ((editorD.height + 1) / 2) * 2; Dimension size = new Dimension(editorD.width, editorD.height); size.width += Math.max(nextD.width, previousD.width); Insets insets = parent.getInsets(); size.width += insets.left + insets.right; size.height += insets.top + insets.bottom; Insets buttonInsets = SubstanceSizeUtils .getSpinnerArrowButtonInsets(SubstanceSizeUtils .getComponentFontSize(spinner)); size.width += (buttonInsets.left + buttonInsets.right); return size; } public void layoutContainer(Container parent) { int width = parent.getWidth(); int height = parent.getHeight(); Insets insets = parent.getInsets(); Dimension nextD = nextButton.getPreferredSize(); Dimension previousD = prevButton.getPreferredSize(); int buttonsWidth = Math.max(nextD.width, previousD.width); int editorHeight = height - (insets.top + insets.bottom); Insets buttonInsets = SubstanceSizeUtils .getSpinnerArrowButtonInsets(SubstanceSizeUtils .getComponentFontSize(spinner)); /* * Deal with the spinner's componentOrientation property. */ int editorX, editorWidth, buttonsX; if (parent.getComponentOrientation().isLeftToRight()) { editorX = insets.left; editorWidth = width - insets.left - buttonsWidth - buttonInsets.right - buttonInsets.left; buttonsX = width - buttonsWidth - buttonInsets.right; } else { buttonsX = buttonInsets.left; editorX = buttonsX + buttonsWidth + buttonInsets.left; editorWidth = width - buttonInsets.left - buttonsWidth - insets.right - buttonInsets.left; } int nextY = buttonInsets.top; int nextHeight = (height / 2) + (height % 2) - nextY; int previousY = buttonInsets.top + nextHeight; int previousHeight = height - previousY - buttonInsets.bottom; spinner.getEditor().setBounds(editorX, insets.top, editorWidth, editorHeight); nextButton.setBounds(buttonsX, nextY, buttonsWidth, nextHeight); prevButton.setBounds(buttonsX, previousY, buttonsWidth, previousHeight); // System.out.println("next : " + nextButton.getBounds()); // System.out.println("prev : " + prevButton.getBounds()); } } } substance-5.3.orig/src/org/jvnet/substance/painter/0000755000175000017500000000000011006431212022326 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/painter/noise/0000755000175000017500000000000011256731150023456 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/painter/noise/SharpenFilter.java0000644000175000017500000000417411136475562027106 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.noise; /** * Noise filter that produces sharpened distribution. This class is part of * officially supported API. * * @author Kirill Grouchnikov */ public class SharpenFilter implements NoiseFilter { /* * (non-Javadoc) * * @see org.jvnet.substance.painter.noise.NoiseFilter#apply(double, double, * double, double) */ public double apply(double x, double y, double z, double origValue) { return Math.sqrt(origValue); } } substance-5.3.orig/src/org/jvnet/substance/painter/noise/MedianBeakFilter.java0000644000175000017500000000446411136475562027470 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.noise; /** * Noise filter that produces median-beak distribution. For values 0.0 and 1.0 * the resulting value is 1.0, for value 0.5 the resulting value is 0.0. The * filter signature is that of the downward-pointing beak. This class is part of * officially supported API. * * @author Kirill Grouchnikov */ public class MedianBeakFilter implements NoiseFilter { /* * (non-Javadoc) * * @see org.jvnet.substance.painter.noise.NoiseFilter#apply(double, double, * double, double) */ public double apply(double x, double y, double z, double origValue) { return Math.sqrt(Math.abs(2 * origValue - 1)); } } substance-5.3.orig/src/org/jvnet/substance/painter/noise/NoiseFilter.java0000644000175000017500000000463311136475562026563 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.noise; /** * Base interface for noise filters. This class is part of officially supported * API. * * @author Kirill Grouchnikov */ public interface NoiseFilter { /** * Applies filter on the noise at the specified location. * * @param x * X coordinate. * @param y * Y coordinate. * @param z * Z coordinate. * @param origValue * The original noise value. * @return New noise value. */ public double apply(double x, double y, double z, double origValue); /** * Kind of trigonometric function. * * @author Kirill Grouchnikov */ public enum TrigKind { /** * Sine. */ SINE, /** * Cosine. */ COSINE } } substance-5.3.orig/src/org/jvnet/substance/painter/noise/FabricFilter.java0000644000175000017500000001265111136475562026673 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.noise; import java.util.LinkedList; /** * Noise filter that produces fabric-like distribution. This filter contains a * collection of links, each one with its own orientation. Using a combination * of filter links it's possible to create a composite complex fabric effect. * This class is part of officially supported API. * * @author Kirill Grouchnikov */ public class FabricFilter implements NoiseFilter { /** * Fabric links. */ protected LinkedList links; /** * A single fabric link. * * @author Kirill Grouchnikov */ public static class FabricFilterLink extends BaseNoiseFilter { /** * Creates a new fabric link. * * @param xFactor * Stretch factor for X axis. * @param yFactor * Stretch factor for Y axis. * @param zFactor * Stretch factor for Z axis. * @param valueFactor * Stretch factor for value. * @param trigKind * Trigonometry function. */ public FabricFilterLink(double xFactor, double yFactor, double zFactor, double valueFactor, TrigKind trigKind) { super(xFactor, yFactor, zFactor, valueFactor, trigKind); } /** * Creates a new fabric link oriented along X axis. * * @param xFactor * Stretch factor for X axis. * @param valueFactor * Stretch factor for value. * @param trigKind * Trigonometry function. * @return Fabric link oriented along X axis. */ public static FabricFilterLink getXLink(double xFactor, double valueFactor, TrigKind trigKind) { return new FabricFilterLink(xFactor, 0.0, 0.0, valueFactor, trigKind); } /** * Creates a new fabric link oriented along Y axis. * * @param yFactor * Stretch factor for Y axis. * @param valueFactor * Stretch factor for value. * @param trigKind * Trigonometry function. * @return Fabric link oriented along Y axis. */ public static FabricFilterLink getYLink(double yFactor, double valueFactor, TrigKind trigKind) { return new FabricFilterLink(0.0, yFactor, 0.0, valueFactor, trigKind); } /** * Creates a new fabric link oriented along Z axis. * * @param zFactor * Stretch factor for Z axis. * @param valueFactor * Stretch factor for value. * @param trigKind * Trigonometry function. * @return Fabric link oriented along Z axis. */ public static FabricFilterLink getZLink(double zFactor, double valueFactor, TrigKind trigKind) { return new FabricFilterLink(0.0, 0.0, zFactor, valueFactor, trigKind); } /* * (non-Javadoc) * * @see org.jvnet.substance.painter.noise.NoiseFilter#apply(double, * double, double, double) */ public double apply(double x, double y, double z, double origValue) { double trans = this.xFactor * x + this.yFactor * y + this.zFactor * z + this.valueFactor * origValue; double trig = (this.trigKind == TrigKind.COSINE) ? Math.cos(trans) : Math.sin(trans); return trig; } } /** * Creates fabric filter. * * @param links * Fabric links. */ public FabricFilter(FabricFilterLink... links) { this.links = new LinkedList(); for (FabricFilterLink link : links) { this.links.add(link); } } /* * (non-Javadoc) * * @see org.jvnet.substance.painter.noise.NoiseFilter#apply(double, double, * double, double) */ public double apply(double x, double y, double z, double origValue) { double val = 1.0; for (FabricFilterLink link : this.links) val *= link.apply(x, y, z, origValue); return 0.5 + 0.5 * val; } } substance-5.3.orig/src/org/jvnet/substance/painter/noise/CompoundNoiseFilter.java0000644000175000017500000000513311136475562030264 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.noise; import java.util.LinkedList; /** * Compound noise filter that contains a chain of filters. This class is part of * officially supported API. * * @author Kirill Grouchnikov */ public class CompoundNoiseFilter implements NoiseFilter { /** * Filter chain. */ protected LinkedList chain; /** * Creates a new compound filter. * * @param chain * Filter chain. */ public CompoundNoiseFilter(NoiseFilter... chain) { this.chain = new LinkedList(); for (NoiseFilter link : chain) { this.chain.add(link); } } /* * (non-Javadoc) * * @see org.jvnet.substance.painter.noise.NoiseFilter#apply(double, double, * double, double) */ public double apply(double x, double y, double z, double origValue) { double val = origValue; for (NoiseFilter link : this.chain) val = link.apply(x, y, z, val); return val; } } substance-5.3.orig/src/org/jvnet/substance/painter/noise/WoodFilter.java0000644000175000017500000000476511136475562026424 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.noise; /** * Noise filter that produces wood-like distribution. This class is part of * officially supported API. * * @author Kirill Grouchnikov */ public class WoodFilter implements NoiseFilter { /** * Stretch factor. */ protected double factor; /** * Creates new wood filter with default stretch factor. */ public WoodFilter() { this(20.0); } /** * Create new wood filter. * * @param factor * Stretch factor. */ public WoodFilter(double factor) { this.factor = factor; } /* * (non-Javadoc) * * @see org.jvnet.substance.painter.noise.NoiseFilter#apply(double, double, * double, double) */ public double apply(double x, double y, double z, double origValue) { return this.factor * origValue - (int) (this.factor * origValue); } } substance-5.3.orig/src/org/jvnet/substance/painter/noise/NoiseFactory.java0000644000175000017500000001103511136475562026737 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.noise; import java.awt.Color; import java.awt.image.*; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.utils.*; /** * Factory for creating noise images. This class is part of officially supported * API. * * @author Kirill Grouchnikov. */ public class NoiseFactory { /** * Returns a noise image. * * @param skin * The skin to use for rendering the image. * @param width * Image width. * @param height * Image height. * @param xFactor * X stretch factor. * @param yFactor * Y stretch factor. * @param hasConstantZ * Indication whether the Z is constant. * @param noiseFilter * Noise filter to apply. * @param toBlur * Indication whether the resulting image should be blurred. * @param isPreview * Indication whether the image is in preview mode. * @return Noise image. */ public static BufferedImage getNoiseImage(SubstanceSkin skin, int width, int height, double xFactor, double yFactor, boolean hasConstantZ, NoiseFilter noiseFilter, boolean toBlur, boolean isPreview) { SubstanceColorScheme scheme = skin.getWatermarkColorScheme(); Color c1 = scheme.getWatermarkDarkColor(); // c1 = new Color(255, 0, 0, 0); // System.out.println(c1.getAlpha()); // Color c2 = scheme.getWatermarkStampColor(); Color c3 = scheme.getWatermarkLightColor(); BufferedImage dst = SubstanceCoreUtilities.getBlankImage(width, height); // // new BufferedImage(width, height, // BufferedImage.TYPE_INT_ARGB); // Borrow from Sebastien Petrucci fast blur code - direct access // to the raster data int[] dstBuffer = ((DataBufferInt) dst.getRaster().getDataBuffer()) .getData(); // System.out.println((dstBuffer[0] >>> 24) & 0xFF); double m2 = xFactor * width * xFactor * width + yFactor * height * yFactor * height; int pos = 0; for (int j = 0; j < height; j++) { double jj = yFactor * j; for (int i = 0; i < width; i++) { double ii = xFactor * i; double z = hasConstantZ ? 1.0 : Math.sqrt(m2 - ii * ii - jj * jj); double noise = 0.5 + 0.5 * PerlinNoiseGenerator .noise(ii, jj, z); if (noiseFilter != null) noise = noiseFilter.apply(i, j, z, noise); double likeness = Math.max(0.0, Math.min(1.0, 2.0 * noise)); // likeness = 0.0; dstBuffer[pos++] = SubstanceColorUtilities.getInterpolatedRGB( c3, c1, likeness); } } // System.out.println((dstBuffer[0] >>> 24) & 0xFF); if (toBlur) { ConvolveOp convolve = new ConvolveOp(new Kernel(3, 3, new float[] { .08f, .08f, .08f, .08f, .38f, .08f, .08f, .08f, .08f }), ConvolveOp.EDGE_NO_OP, null); dst = convolve.filter(dst, null); } return dst; } } substance-5.3.orig/src/org/jvnet/substance/painter/noise/MarbleFilter.java0000644000175000017500000000760211136475562026707 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.noise; /** * Noise filter that produces marble-like distribution. This class is part of * officially supported API. * * @author Kirill Grouchnikov */ public class MarbleFilter extends BaseNoiseFilter { /** * Creates a new marble filter. * * @param xFactor * Stretch factor for X axis. * @param yFactor * Stretch factor for Y axis. * @param zFactor * Stretch factor for Z axis. * @param trigKind * Trigonometry function. */ public MarbleFilter(double xFactor, double yFactor, double zFactor, TrigKind trigKind) { super(xFactor, yFactor, zFactor, 1.0, trigKind); } /** * Creates a new marble filter oriented along X axis. * * @param xFactor * Stretch factor for X axis. * @param trigKind * Trigonometry function. * @return Marble filter oriented along X axis. */ public static MarbleFilter getXFilter(double xFactor, TrigKind trigKind) { return new MarbleFilter(xFactor, 0.0, 0.0, trigKind); } /** * Creates a new marble filter oriented along Y axis. * * @param yFactor * Stretch factor for Y axis. * @param trigKind * Trigonometry function. * @return Marble filter oriented along Y axis. */ public static MarbleFilter getYFilter(double yFactor, TrigKind trigKind) { return new MarbleFilter(0.0, yFactor, 0.0, trigKind); } /** * Creates a new marble filter oriented along Z axis. * * @param zFactor * Stretch factor for Z axis. * @param trigKind * Trigonometry function. * @return Marble filter oriented along Z axis. */ public static MarbleFilter getZFilter(double zFactor, TrigKind trigKind) { return new MarbleFilter(0.0, 0.0, zFactor, trigKind); } /* * (non-Javadoc) * * @see org.jvnet.substance.painter.noise.NoiseFilter#apply(double, double, * double, double) */ public double apply(double x, double y, double z, double origValue) { double trans = this.xFactor * x + this.yFactor * y + this.zFactor * z + origValue; double trig = (this.trigKind == TrigKind.COSINE) ? Math.cos(trans) : Math.sin(trans); return 0.5 + 0.5 * trig; } } substance-5.3.orig/src/org/jvnet/substance/painter/noise/BaseNoiseFilter.java0000644000175000017500000000556411136475562027362 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.noise; /** * Base class for stretch noise filters. This class is part of officially * supported API. * * @author Kirill Grouchnikov. */ public abstract class BaseNoiseFilter implements NoiseFilter { /** * Stretch factor for X axis. */ protected double xFactor; /** * Stretch factor for Y axis. */ protected double yFactor; /** * Stretch factor for Z axis. */ protected double zFactor; /** * Stretch factor for value. */ protected double valueFactor; /** * Trigonometry function. */ protected TrigKind trigKind; /** * Creates a new base filter. * * @param xFactor * Stretch factor for X axis. * @param yFactor * Stretch factor for Y axis. * @param zFactor * Stretch factor for Z axis. * @param valueFactor * Stretch factor for value. * @param trigKind * Trigonometry function. */ public BaseNoiseFilter(double xFactor, double yFactor, double zFactor, double valueFactor, TrigKind trigKind) { this.xFactor = xFactor; this.yFactor = yFactor; this.zFactor = zFactor; this.valueFactor = valueFactor; this.trigKind = trigKind; } } substance-5.3.orig/src/org/jvnet/substance/painter/gradient/0000755000175000017500000000000011256731150024136 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/painter/gradient/SimplisticGradientPainter.java0000644000175000017500000000717711136475562032147 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.gradient; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Gradient painter that returns images with simplistic appearance. This class * is for internal use only. * * @author Kirill Grouchnikov */ public class SimplisticGradientPainter extends StandardGradientPainter { /** * Reusable instance of this painter. */ public static final SimplisticGradientPainter INSTANCE = new SimplisticGradientPainter(); /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.SubstanceGradientPainter#getDisplayName() */ @Override public String getDisplayName() { return "Simplistic"; } @Override public Color getTopFillColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return super.getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } @Override public Color getMidFillColorTop(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getInterpolatedColor(super .getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), super .getBottomFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), 0.5); } @Override public Color getTopShineColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return null; } @Override public Color getBottomShineColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return null; } } substance-5.3.orig/src/org/jvnet/substance/painter/gradient/MatteGradientPainter.java0000644000175000017500000001052211136475562031065 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.gradient; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Gradient painter that returns images with matte appearance. This class is * part of officially supported API. * * @author Kirill Grouchnikov * @since version 4.0 */ public class MatteGradientPainter extends ClassicGradientPainter { /** * Creates a new matte gradient painter. */ public MatteGradientPainter() { super(); } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.SubstanceGradientPainter#getDisplayName() */ @Override public String getDisplayName() { return "Matte"; } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.ClassicGradientPainter#getTopFillColor(org * .jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getTopFillColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getInterpolatedColor(super .getBottomFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), super .getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), 0.5); } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.ClassicGradientPainter#getMidFillColorTop * (org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getMidFillColorTop(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getInterpolatedColor(super .getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), super .getBottomFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), 0.7); } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.StandardGradientPainter#getBottomFillColor * (org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getBottomFillColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return super.getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } } substance-5.3.orig/src/org/jvnet/substance/painter/gradient/GlassGradientPainter.java0000644000175000017500000001405511136475562031071 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.gradient; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Gradient painter that returns images with classic appearance. This class is * part of officially supported API. * * @author Kirill Grouchnikov */ public class GlassGradientPainter extends StandardGradientPainter { /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.SubstanceGradientPainter#getDisplayName() */ public String getDisplayName() { return "Glass"; } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.StandardGradientPainter#getTopFillColor(org * .jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getTopFillColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getInterpolatedColor(super .getBottomFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), super .getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), 0.6); } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.StandardGradientPainter#getMidFillColorTop * (org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getMidFillColorTop(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getInterpolatedColor(this .getTopFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), super .getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), 0.8); } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.StandardGradientPainter#getMidFillColorBottom * (org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getMidFillColorBottom( SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return super.getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.StandardGradientPainter#getBottomFillColor * (org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getBottomFillColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getInterpolatedColor(this .getMidFillColorBottom(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), super.getBottomFillColor( interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), 0.7); } // // @Override // public Color getTopBorderColor(ColorScheme interpolationScheme1, // ColorScheme interpolationScheme2, double cycleCoef, // boolean useCyclePosAsInterpolation) { // return SubstanceColorUtilities.getInterpolatedColor(super // .getTopBorderColor(interpolationScheme1, interpolationScheme2, // cycleCoef, useCyclePosAsInterpolation), super // .getMidBorderColor(interpolationScheme1, interpolationScheme2, // cycleCoef, useCyclePosAsInterpolation), 0.0); // } // // @Override // public Color getMidBorderColor(ColorScheme interpolationScheme1, // ColorScheme interpolationScheme2, double cycleCoef, // boolean useCyclePosAsInterpolation) { // return this.getTopBorderColor(interpolationScheme1, // interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); // } // // @Override // public Color getBottomBorderColor(ColorScheme interpolationScheme1, // ColorScheme interpolationScheme2, double cycleCoef, // boolean useCyclePosAsInterpolation) { // return this.getTopBorderColor(interpolationScheme1, // interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); // } } substance-5.3.orig/src/org/jvnet/substance/painter/gradient/StandardGradientPainter.java0000644000175000017500000003745011146544630031556 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.gradient; import java.awt.*; import java.awt.MultipleGradientPaint.CycleMethod; import java.awt.image.BufferedImage; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; import org.jvnet.substance.utils.SubstanceCoreUtilities; /** * Gradient painter that returns images with subtle 3D gradient appearance. This * class is part of officially supported API. * * @author Kirill Grouchnikov */ public class StandardGradientPainter extends BaseGradientPainter { /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.SubstanceGradientPainter#getDisplayName() */ public String getDisplayName() { return "Standard"; } /* * (non-Javadoc) * * @seeorg.jvnet.substance.painter.gradient.SubstanceGradientPainter# * paintContourBackground(java.awt.Graphics, java.awt.Component, int, int, * java.awt.Shape, boolean, org.jvnet.substance.api.SubstanceColorScheme, * org.jvnet.substance.api.SubstanceColorScheme, float, boolean, boolean) */ public void paintContourBackground(Graphics g, Component comp, int width, int height, Shape contour, boolean isFocused, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos, boolean hasShine, boolean useCyclePosAsInterpolation) { // long millis = System.nanoTime(); Graphics2D graphics = (Graphics2D) g.create(); SubstanceColorScheme interpolationScheme1 = colorScheme1; SubstanceColorScheme interpolationScheme2 = useCyclePosAsInterpolation ? colorScheme2 : colorScheme1; double cycleCoef = 1.0 - cyclePos; Color topFillColor = this.getTopFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); Color midFillColorTop = this.getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); Color midFillColorBottom = this.getMidFillColorBottom( interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); Color bottomFillColor = this.getBottomFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); Color topShineColor = this.getTopShineColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); Color bottomShineColor = this.getBottomShineColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); // Fill background // long millis000 = System.nanoTime(); //graphics.clip(contour); MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0, height, new float[] { 0.0f, 0.4999999f, 0.5f, 1.0f }, new Color[] { topFillColor, midFillColorTop, midFillColorBottom, bottomFillColor }, CycleMethod.REPEAT); graphics.setPaint(gradient); graphics.fill(contour); // long millis003 = 0, millis004 = 0, millis005 = 0; if (hasShine && (topShineColor != null) && (bottomShineColor != null)) { graphics.clip(contour); int shineHeight = (int) (height / 1.8); int kernelSize = (int) Math.min(12, Math.pow(Math .min(width, height), 0.8) / 4); if (kernelSize < 3) kernelSize = 3; BufferedImage blurredGhostContour = SubstanceCoreUtilities .getBlankImage(width + 2 * kernelSize, height + 2 * kernelSize); Graphics2D blurredGhostGraphics = (Graphics2D) blurredGhostContour .getGraphics().create(); blurredGhostGraphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); blurredGhostGraphics.setColor(Color.black); blurredGhostGraphics.translate(kernelSize, kernelSize); int step = kernelSize > 5 ? 2 : 1; for (int strokeSize = 2 * kernelSize - 1; strokeSize > 0; strokeSize -= step) { float transp = 1.0f - strokeSize / (2.0f * kernelSize); blurredGhostGraphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC, transp)); blurredGhostGraphics.setStroke(new BasicStroke(strokeSize)); blurredGhostGraphics.draw(contour); } blurredGhostGraphics.dispose(); // millis003 = System.nanoTime(); BufferedImage reverseGhostContour = SubstanceCoreUtilities .getBlankImage(width + 2 * kernelSize, height + 2 * kernelSize); Graphics2D reverseGraphics = (Graphics2D) reverseGhostContour .getGraphics(); Color bottomShineColorTransp = new Color(bottomShineColor.getRed(), bottomShineColor.getGreen(), bottomShineColor.getBlue(), 64); GradientPaint gradientShine = new GradientPaint(0, kernelSize, topShineColor, 0, kernelSize + shineHeight, bottomShineColorTransp); reverseGraphics.setPaint(gradientShine); reverseGraphics.fillRect(0, kernelSize, width + 2 * kernelSize, kernelSize + shineHeight); reverseGraphics.setComposite(AlphaComposite.DstOut); reverseGraphics.drawImage(blurredGhostContour, 0, 0, null); // millis004 = System.nanoTime(); graphics.drawImage(reverseGhostContour, 0, 0, width - 1, shineHeight, kernelSize, kernelSize, kernelSize + width - 1, kernelSize + shineHeight, null); BufferedImage overGhostContour = SubstanceCoreUtilities .getBlankImage(width + 2 * kernelSize, height + 2 * kernelSize); Graphics2D overGraphics = (Graphics2D) overGhostContour .getGraphics(); overGraphics.setPaint(new GradientPaint(0, kernelSize, topFillColor, 0, kernelSize + height / 2, midFillColorTop)); overGraphics.fillRect(kernelSize, kernelSize, kernelSize + width, kernelSize + shineHeight); overGraphics.setComposite(AlphaComposite.DstIn); overGraphics.drawImage(blurredGhostContour, 0, 0, null); // millis005 = System.nanoTime(); graphics.drawImage(overGhostContour, 0, 0, width - 1, shineHeight, kernelSize, kernelSize, kernelSize + width - 1, kernelSize + shineHeight, null); } graphics.dispose(); // long millis006 = System.nanoTime(); // long millis2 = System.nanoTime(); // if (width * height > 5000) { // System.out.println("new - " + width + "*" + height + " = " // + format(millis2 - millis)); // System.out.println("\tfill : " + format(millis001 - millis000)); // System.out.println("\tcontour : " + format(millis003 - millis001)); // System.out.println("\trevert : " + format(millis004 - millis003)); // System.out.println("\toverlay : " + format(millis005 - millis004)); // System.out.println("\tborder : " + format(millis006 - millis005)); // } } // /** // * Computes the color of the top portion of the border. Override to // provide // * different visual. // * // * @param interpolationScheme1 // * The first interpolation scheme. // * @param interpolationScheme2 // * The second interpolation scheme. // * @param cycleCoef // * Cycle coefficient. // * @param useCyclePosAsInterpolation // * Indicates whether the cycle coefficient should be used as the // * interpolation parameter. // * @return The color of the top portion of the border. // */ // public Color getTopBorderColor(ColorScheme interpolationScheme1, // ColorScheme interpolationScheme2, double cycleCoef, // boolean useCyclePosAsInterpolation) { // return SubstanceColorUtilities.getTopBorderColor(interpolationScheme1, // interpolationScheme2, cycleCoef); // } // // /** // * Computes the color of the middle portion of the border. Override to // * provide different visual. // * // * @param interpolationScheme1 // * The first interpolation scheme. // * @param interpolationScheme2 // * The second interpolation scheme. // * @param cycleCoef // * Cycle coefficient. // * @param useCyclePosAsInterpolation // * Indicates whether the cycle coefficient should be used as the // * interpolation parameter. // * @return The color of the middle portion of the border. // */ // public Color getMidBorderColor(ColorScheme interpolationScheme1, // ColorScheme interpolationScheme2, double cycleCoef, // boolean useCyclePosAsInterpolation) { // return SubstanceColorUtilities.getMidBorderColor(interpolationScheme1, // interpolationScheme2, cycleCoef); // } // // /** // * Computes the color of the bottom portion of the border. Override to // * provide different visual. // * // * @param interpolationScheme1 // * The first interpolation scheme. // * @param interpolationScheme2 // * The second interpolation scheme. // * @param cycleCoef // * Cycle coefficient. // * @param useCyclePosAsInterpolation // * Indicates whether the cycle coefficient should be used as the // * interpolation parameter. // * @return The color of the bottom portion of the border. // */ // public Color getBottomBorderColor(ColorScheme interpolationScheme1, // ColorScheme interpolationScheme2, double cycleCoef, // boolean useCyclePosAsInterpolation) { // return SubstanceColorUtilities.getBottomBorderColor( // interpolationScheme1, interpolationScheme2, cycleCoef); // } /** * Computes the color of the top portion of the fill. Override to provide * different visual. * * @param interpolationScheme1 * The first interpolation scheme. * @param interpolationScheme2 * The second interpolation scheme. * @param cycleCoef * Cycle coefficient. * @param useCyclePosAsInterpolation * Indicates whether the cycle coefficient should be used as the * interpolation parameter. * @return The color of the top portion of the fill. */ public Color getTopFillColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getTopFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } /** * Computes the color of the middle portion of the fill from the top. * Override to provide different visual. * * @param interpolationScheme1 * The first interpolation scheme. * @param interpolationScheme2 * The second interpolation scheme. * @param cycleCoef * Cycle coefficient. * @param useCyclePosAsInterpolation * Indicates whether the cycle coefficient should be used as the * interpolation parameter. * @return The color of the middle portion of the fill from the top. */ public Color getMidFillColorTop(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getMidFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } /** * Computes the color of the middle portion of the fill from the bottom. * Override to provide different visual. * * @param interpolationScheme1 * The first interpolation scheme. * @param interpolationScheme2 * The second interpolation scheme. * @param cycleCoef * Cycle coefficient. * @param useCyclePosAsInterpolation * Indicates whether the cycle coefficient should be used as the * interpolation parameter. * @return The color of the middle portion of the fill from the bottom. */ public Color getMidFillColorBottom( SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return this.getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } /** * Computes the color of the bottom portion of the fill. Override to provide * different visual. * * @param interpolationScheme1 * The first interpolation scheme. * @param interpolationScheme2 * The second interpolation scheme. * @param cycleCoef * Cycle coefficient. * @param useCyclePosAsInterpolation * Indicates whether the cycle coefficient should be used as the * interpolation parameter. * @return The color of the bottom portion of the fill. */ public Color getBottomFillColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getBottomFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } /** * Computes the color of the top portion of the shine. Override to provide * different visual. * * @param interpolationScheme1 * The first interpolation scheme. * @param interpolationScheme2 * The second interpolation scheme. * @param cycleCoef * Cycle coefficient. * @param useCyclePosAsInterpolation * Indicates whether the cycle coefficient should be used as the * interpolation parameter. * @return The color of the top portion of the shine. */ public Color getTopShineColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getTopShineColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } /** * Computes the color of the bottom portion of the shine. Override to * provide different visual. * * @param interpolationScheme1 * The first interpolation scheme. * @param interpolationScheme2 * The second interpolation scheme. * @param cycleCoef * Cycle coefficient. * @param useCyclePosAsInterpolation * Indicates whether the cycle coefficient should be used as the * interpolation parameter. * @return The color of the bottom portion of the shine. */ public Color getBottomShineColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getBottomShineColor( interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } }substance-5.3.orig/src/org/jvnet/substance/painter/gradient/BaseGradientPainter.java0000644000175000017500000000362711162714624030667 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.gradient; /** * Base class for gradient painters. This class is part of officially supported * API. * * @author Kirill Grouchnikov */ public abstract class BaseGradientPainter implements SubstanceGradientPainter { } substance-5.3.orig/src/org/jvnet/substance/painter/gradient/ClassicGradientPainter.java0000644000175000017500000000763611136475562031410 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.gradient; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Gradient painter that returns images with classic appearance. This class is * part of officially supported API. * * @author Kirill Grouchnikov */ public class ClassicGradientPainter extends StandardGradientPainter { /** * Reusable instance of this painter. */ public static final ClassicGradientPainter INSTANCE = new ClassicGradientPainter(); /** * Creates a new classic gradient painter. */ public ClassicGradientPainter() { } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.SubstanceGradientPainter#getDisplayName() */ @Override public String getDisplayName() { return "Classic"; } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.StandardGradientPainter#getTopFillColor(org * .jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getTopFillColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getInterpolatedColor(super .getBottomFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), super .getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), 0.5); } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.StandardGradientPainter#getMidFillColorTop * (org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getMidFillColorTop(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getInterpolatedColor(super .getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), super .getBottomFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), 0.7); } } substance-5.3.orig/src/org/jvnet/substance/painter/gradient/FlatGradientPainter.java0000644000175000017500000001434411136475562030707 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.gradient; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Gradient painter that returns images with flat appearance. This class is * for internal use only. * * @author Kirill Grouchnikov */ public class FlatGradientPainter extends StandardGradientPainter { /** * Creates a new flat gradient painter. */ public FlatGradientPainter() { } /* * (non-Javadoc) * * @see org.jvnet.substance.painter.StandardGradientPainter#getDisplayName() */ @Override public String getDisplayName() { return "Flat"; } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.StandardGradientPainter#getMidFillColorTop * (org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getMidFillColorTop(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { if (!useCyclePosAsInterpolation) { return SubstanceColorUtilities.getInterpolatedColor( interpolationScheme1.getDarkColor(), interpolationScheme2 .getMidColor(), cycleCoef); } else { return SubstanceColorUtilities.getInterpolatedColor( interpolationScheme1.getDarkColor(), interpolationScheme2 .getDarkColor(), cycleCoef); } } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.StandardGradientPainter#getTopFillColor(org * .jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getTopFillColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return this.getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.StandardGradientPainter#getMidFillColorBottom * (org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getMidFillColorBottom( SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return this.getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.StandardGradientPainter#getBottomFillColor * (org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getBottomFillColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return this.getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.StandardGradientPainter#getTopShineColor( * org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getTopShineColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return null; } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.StandardGradientPainter#getBottomShineColor * (org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getBottomShineColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return null; } // @Override // public Color getMidBorderColor(ColorScheme interpolationScheme1, // ColorScheme interpolationScheme2, double cycleCoef, // boolean useCyclePosAsInterpolation) { // return super.getTopBorderColor(interpolationScheme1, // interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); // } // // @Override // public Color getBottomBorderColor(ColorScheme interpolationScheme1, // ColorScheme interpolationScheme2, double cycleCoef, // boolean useCyclePosAsInterpolation) { // return super.getTopBorderColor(interpolationScheme1, // interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); // } // } substance-5.3.orig/src/org/jvnet/substance/painter/gradient/SubstanceGradientPainter.java0000644000175000017500000000716111136475562031747 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.gradient; import java.awt.*; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.trait.SubstanceTrait; /** * Gradient painter interface for Substance look and feel. This class is * part of officially supported API. * * @author Kirill Grouchnikov */ public interface SubstanceGradientPainter extends SubstanceTrait { /** * Paints the background that matches the specified parameters. * * @param g * Graphics context. * @param comp * Component to paint. * @param width * Width of a UI component. * @param height * Height of a UI component. * @param contour * Contour of a UI component. * @param isFocused * Indication whether component owns the focus. * @param colorScheme1 * The first color scheme. * @param colorScheme2 * The second color scheme. * @param cyclePos * Cycle position. Is used for rollover and pulsation effects. * Must be in 0..1 range. * @param hasShine * Indication whether the returned image should have a 3D shine * spot in its top half. * @param useCyclePosAsInterpolation * Indicates the algorithm to use for computing various colors. * If true, the cyclePos is used to * interpolate colors between different color components of both * color schemes. If false, the * cyclePos is used to interpolate colors between * different color components of the first color scheme. */ public void paintContourBackground(Graphics g, Component comp, int width, int height, Shape contour, boolean isFocused, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos, boolean hasShine, boolean useCyclePosAsInterpolation); } substance-5.3.orig/src/org/jvnet/substance/painter/gradient/SubduedGradientPainter.java0000644000175000017500000000535311136475562031414 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.gradient; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Gradient painter that returns images with subdued 3D gradient appearance. * This class is part of officially supported API. * * @author Kirill Grouchnikov */ public class SubduedGradientPainter extends StandardGradientPainter { /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.SubstanceGradientPainter#getDisplayName() */ public String getDisplayName() { return "Subdued"; } @Override public Color getTopFillColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getInterpolatedColor(super .getTopFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), this .getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), 0.3); } } substance-5.3.orig/src/org/jvnet/substance/painter/border/0000755000175000017500000000000011256731150023616 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/painter/border/GlassInnerBorderPainter.java0000644000175000017500000000607411163116512031212 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.border; import org.jvnet.substance.api.SubstanceConstants.ColorShiftKind; /** * Implementation of border painter that uses the {@link GlassBorderPainter} * gradients and paints the inner contour of the border in addition to the outer * contour. * * @author Kirill Grouchnikov * @deprecated Will be removed in version 6.0. Use * {@link CompositeBorderPainter} and {@link DelegateBorderPainter} * instead. */ @Deprecated public class GlassInnerBorderPainter extends InnerDelegateBorderPainter { /** * Display name. */ private static final String NAME = "Glass Inner"; /** * Creates a new inner border painter based on a {@link GlassBorderPainter}. */ public GlassInnerBorderPainter() { super(NAME, new GlassBorderPainter()); } /** * Creates a new inner border painter based on a {@link GlassBorderPainter}. * * @param shiftCoef * Shift coefficient. Must be in 0.0-1.0 range. * @param shiftKind * Shift kind. */ public GlassInnerBorderPainter(float shiftCoef, ColorShiftKind shiftKind) { super(NAME + " " + shiftCoef + " " + shiftKind.name(), new GlassBorderPainter(), shiftCoef, shiftKind); } /* * (non-Javadoc) * * @see * org.jvnet.substance.border.InnerDelegateBorderPainter#getDisplayName() */ @Override public String getDisplayName() { return NAME; } }substance-5.3.orig/src/org/jvnet/substance/painter/border/NullBorderPainter.java0000644000175000017500000000662311163123416030060 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.border; import java.awt.*; import org.jvnet.substance.api.SubstanceColorScheme; /** * Empty implementation of {@link SubstanceBorderPainter} which doesn't paint * any border. This is useful for migration of custom gradient painters which, * until version 4.0, were used to paint both the control background and the * control border. Starting from version 4.0, the borders are painted by the * currently installed border painter, and as such, a custom gradient painter * that paints a border will be overriden by the current border painter. To * allow easier migration (splitting the old custom gradient painter into a * custom gradient painter and a custom border painter), you can use this * implementation that will not override the custom border. * * @author Kirill Grouchnikov * @deprecated Will be removed in version 6.0 */ @Deprecated public class NullBorderPainter implements SubstanceBorderPainter { /* * (non-Javadoc) * * @see org.jvnet.substance.border.SubstanceBorderPainter#getDisplayName() */ public String getDisplayName() { return "Null"; } /* * (non-Javadoc) * * @see * org.jvnet.substance.border.SubstanceBorderPainter#paintBorder(java.awt * .Graphics, java.awt.Component, int, int, java.awt.Shape, java.awt.Shape, * org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, float, boolean) */ public void paintBorder(Graphics g, Component c, int width, int height, Shape contour, Shape innerContour, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos, boolean useCyclePosAsInterpolation) { } @Override public boolean isPaintingInnerContour() { return false; } } substance-5.3.orig/src/org/jvnet/substance/painter/border/GlassBorderPainter.java0000644000175000017500000001001011136475562030214 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.border; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Border painter that returns images with classic appearance. This class is * part of officially supported API. * * @author Kirill Grouchnikov */ public class GlassBorderPainter extends StandardBorderPainter { /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.SubstanceGradientPainter#getDisplayName() */ public String getDisplayName() { return "Glass"; } /* * (non-Javadoc) * * @see * org.jvnet.substance.border.StandardBorderPainter#getTopBorderColor(org * .jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getTopBorderColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getInterpolatedColor(super .getTopBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), super .getMidBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), 0.0); } /* * (non-Javadoc) * * @see * org.jvnet.substance.border.StandardBorderPainter#getMidBorderColor(org * .jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getMidBorderColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return this.getTopBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } /* * (non-Javadoc) * * @see * org.jvnet.substance.border.StandardBorderPainter#getBottomBorderColor * (org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getBottomBorderColor( SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return this.getTopBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } } substance-5.3.orig/src/org/jvnet/substance/painter/border/DelegateBorderPainter.java0000644000175000017500000002167711246715744030703 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.border; import java.awt.*; import org.jvnet.substance.api.ColorSchemeTransform; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.*; /** * Delegate border painter that allows tweaking the visual appearance of * borders. * * @author Kirill Grouchnikov */ public class DelegateBorderPainter extends StandardBorderPainter { /** * Display name of this border painter. */ protected String displayName; /** * The delegate border painter. */ protected StandardBorderPainter delegate; /** * 8-digit hexadecimal mask applied on the top color painted by * {@link #delegate}. Can be used to apply custom translucency. For example, * value 0x80FFFFFF will result in 50% translucency of the original top * border color. */ protected int topMask; /** * 8-digit hexadecimal mask applied on the middle color painted by * {@link #delegate}. Can be used to apply custom translucency. For example, * value 0x80FFFFFF will result in 50% translucency of the original middle * border color. */ protected int midMask; /** * 8-digit hexadecimal mask applied on the bottom color painted by * {@link #delegate}. Can be used to apply custom translucency. For example, * value 0x80FFFFFF will result in 50% translucency of the original bottom * border color. */ protected int bottomMask; /** * Transformation to be applied on the color schemes prior to compute the * colors to be used for border painting. */ protected ColorSchemeTransform transform; /** * Creates a new delegate border painter * * @param displayName * Display name of this border painter. * @param delegate * The delegate border painter. * @param transform * Transformation to be applied on the color schemes prior to * compute the colors to be used for border painting. */ public DelegateBorderPainter(String displayName, StandardBorderPainter delegate, ColorSchemeTransform transform) { this(displayName, delegate, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, transform); } /** * Creates a new delegate border painter * * @param displayName * Display name of this border painter. * @param delegate * The delegate border painter. * @param topMask * 8-digit hexadecimal mask applied on the top color painted by * the delegate. * @param midMask * 8-digit hexadecimal mask applied on the middle color painted * by the delegate. * @param bottomMask * 8-digit hexadecimal mask applied on the bottom color painted * by the delegate. * @param transform * Transformation to be applied on the color schemes prior to * compute the colors to be used for border painting. */ public DelegateBorderPainter(String displayName, StandardBorderPainter delegate, int topMask, int midMask, int bottomMask, ColorSchemeTransform transform) { this.displayName = displayName; this.delegate = delegate; this.topMask = topMask; this.midMask = midMask; this.bottomMask = bottomMask; this.transform = transform; } /** * Map of transformed color schemes (to speed up the subsequent lookups). */ protected final static LazyResettableHashMap transformMap = new LazyResettableHashMap( "DelegateBorderPainter"); @Override public Color getTopBorderColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return new Color(this.topMask & this.delegate.getTopBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation).getRGB(), true); } @Override public Color getMidBorderColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return new Color(this.midMask & this.delegate.getMidBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation).getRGB(), true); } @Override public Color getBottomBorderColor( SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return new Color(this.bottomMask & this.delegate.getBottomBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation).getRGB(), true); } @Override public void paintBorder(Graphics g, Component c, int width, int height, Shape contour, Shape innerContour, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos, boolean useCyclePosAsInterpolation) { super.paintBorder(g, c, width, height, contour, innerContour, getShiftScheme(colorScheme1), getShiftScheme(colorScheme2), cyclePos, useCyclePosAsInterpolation); } @Override public String getDisplayName() { return this.displayName; } /** * Retrieves a transformed color scheme. * * @param orig * Original color scheme. * @return Transformed color scheme. */ private SubstanceColorScheme getShiftScheme(SubstanceColorScheme orig) { HashMapKey key = SubstanceCoreUtilities.getHashKey(orig .getDisplayName(), this.getDisplayName(), this.transform); if (!transformMap.containsKey(key)) { transformMap.put(key, this.transform.transform(orig)); } return transformMap.get(key); } } substance-5.3.orig/src/org/jvnet/substance/painter/border/ClassicBorderPainter.java0000644000175000017500000001001411136475562030530 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.border; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Border painter that returns images with classic appearance. This class is * part of officially supported API. * * @author Kirill Grouchnikov */ public class ClassicBorderPainter extends StandardBorderPainter { /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.SubstanceGradientPainter#getDisplayName() */ public String getDisplayName() { return "Classic"; } /* * (non-Javadoc) * * @see * org.jvnet.substance.border.StandardBorderPainter#getTopBorderColor(org * .jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getTopBorderColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getInterpolatedColor(super .getTopBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), super .getMidBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation), 0.0); } /* * (non-Javadoc) * * @see * org.jvnet.substance.border.StandardBorderPainter#getMidBorderColor(org * .jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getMidBorderColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return this.getTopBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } /* * (non-Javadoc) * * @see * org.jvnet.substance.border.StandardBorderPainter#getBottomBorderColor * (org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getBottomBorderColor( SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return this.getTopBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } } substance-5.3.orig/src/org/jvnet/substance/painter/border/ClassicInnerBorderPainter.java0000644000175000017500000000614411163116524031523 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.border; import org.jvnet.substance.api.SubstanceConstants.ColorShiftKind; /** * Implementation of border painter that uses the {@link ClassicBorderPainter} * gradients and paints the inner contour of the border in addition to the outer * contour. * * @author Kirill Grouchnikov * @deprecated Will be removed in version 6.0. Use * {@link CompositeBorderPainter} and {@link DelegateBorderPainter} * instead. */ @Deprecated public class ClassicInnerBorderPainter extends InnerDelegateBorderPainter { /** * Display name. */ private static final String NAME = "Classic Inner"; /** * Creates a new inner border painter based on a * {@link ClassicBorderPainter * }. */ public ClassicInnerBorderPainter() { super(NAME, new ClassicBorderPainter()); } /** * Creates a new inner border painter based on a * {@link ClassicBorderPainter * }. * * @param shiftCoef * Shift coefficient. Must be in 0.0-1.0 range. * @param shiftKind * Shift kind. */ public ClassicInnerBorderPainter(float shiftCoef, ColorShiftKind shiftKind) { super(NAME + " " + shiftCoef + " " + shiftKind.name(), new ClassicBorderPainter(), shiftCoef, shiftKind); } /* * (non-Javadoc) * * @see * org.jvnet.substance.border.InnerDelegateBorderPainter#getDisplayName() */ @Override public String getDisplayName() { return NAME; } }substance-5.3.orig/src/org/jvnet/substance/painter/border/FlatInnerBorderPainter.java0000644000175000017500000000606311163116500031022 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.border; import org.jvnet.substance.api.SubstanceConstants.ColorShiftKind; /** * Implementation of border painter that uses the {@link FlatBorderPainter} * gradients and paints the inner contour of the border in addition to the outer * contour. * * @author Kirill Grouchnikov * @deprecated Will be removed in version 6.0. Use * {@link CompositeBorderPainter} and {@link DelegateBorderPainter} * instead. */ @Deprecated public class FlatInnerBorderPainter extends InnerDelegateBorderPainter { /** * Display name. */ private static final String NAME = "Flat Inner"; /** * Creates a new inner border painter based on a {@link FlatBorderPainter}. */ public FlatInnerBorderPainter() { super(NAME, new FlatBorderPainter()); } /** * Creates a new inner border painter based on a {@link FlatBorderPainter}. * * @param shiftCoef * Shift coefficient. Must be in 0.0-1.0 range. * @param shiftKind * Shift kind. */ public FlatInnerBorderPainter(float shiftCoef, ColorShiftKind shiftKind) { super(NAME + " " + shiftCoef + " " + shiftKind.name(), new FlatBorderPainter(), shiftCoef, shiftKind); } /* * (non-Javadoc) * * @see * org.jvnet.substance.border.InnerDelegateBorderPainter#getDisplayName() */ @Override public String getDisplayName() { return NAME; } }substance-5.3.orig/src/org/jvnet/substance/painter/border/FlatBorderPainter.java0000644000175000017500000000620711136475562030046 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.border; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; /** * Border painter that returns images with flat appearance. This class is part * of officially supported API. * * @author Kirill Grouchnikov */ public class FlatBorderPainter extends StandardBorderPainter { @Override public String getDisplayName() { return "Flat"; } /* * (non-Javadoc) * * @see * org.jvnet.substance.border.StandardBorderPainter#getMidBorderColor(org * .jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getMidBorderColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return super.getTopBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } /* * (non-Javadoc) * * @see * org.jvnet.substance.border.StandardBorderPainter#getBottomBorderColor * (org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, double, boolean) */ @Override public Color getBottomBorderColor( SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return super.getTopBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } } substance-5.3.orig/src/org/jvnet/substance/painter/border/CompositeBorderPainter.java0000644000175000017500000000703411246074670031116 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.border; import java.awt.*; import org.jvnet.substance.api.SubstanceColorScheme; /** * Composite border painter that delegates the painting of outer and inner * contours. * * @author Kirill Grouchnikov * @since version 5.2 */ public class CompositeBorderPainter implements SubstanceBorderPainter { /** * Display name of this border painter. */ private String displayName; /** * Delegate painter for painting the inner contrours. */ private SubstanceBorderPainter inner; /** * Delegate painter for painting the outer contours. */ private SubstanceBorderPainter outer; /** * Creates a new composite border painter. * * @param displayName * Display name. * @param outer * Delegate painter for painting the outer contours. * @param inner * Delegate painter for painting the inner contrours. */ public CompositeBorderPainter(String displayName, SubstanceBorderPainter outer, SubstanceBorderPainter inner) { this.displayName = displayName; this.outer = outer; this.inner = inner; } @Override public boolean isPaintingInnerContour() { return true; } @Override public void paintBorder(Graphics g, Component c, int width, int height, Shape contour, Shape innerContour, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos, boolean useCyclePosAsInterpolation) { if (innerContour != null) { this.inner.paintBorder(g, c, width, height, innerContour, null, colorScheme1, colorScheme2, cyclePos, useCyclePosAsInterpolation); } if (contour != null) { this.outer.paintBorder(g, c, width, height, contour, null, colorScheme1, colorScheme2, cyclePos, useCyclePosAsInterpolation); } } @Override public String getDisplayName() { return this.displayName; } } substance-5.3.orig/src/org/jvnet/substance/painter/border/InnerDelegateBorderPainter.java0000644000175000017500000001462511246715750031667 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.border; import java.awt.*; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.SubstanceConstants.ColorShiftKind; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.utils.*; /** * Abstract base class for painters that provide inner painting. The * implementation is based on three main parts: *
    *
  • The delegate border painter that paints the outer and inner parts of the * border.
  • *
  • Shift kind that specifies how to compute the color scheme of the inner * part based on the color scheme of the border.
  • *
  • Shift coefficient that specifies how different is the color scheme of the * inner part from the color scheme of the border.
  • *
* * @author Kirill Grouchnikov * @deprecated Will be removed in version 6.0. Use * {@link CompositeBorderPainter} and {@link DelegateBorderPainter} * instead. */ @Deprecated public abstract class InnerDelegateBorderPainter implements SubstanceBorderPainter { /** * Display name of this painter. */ protected String painterName; /** * Mandatory delegate painter. */ protected SubstanceBorderPainter delegate; /** * Shift coefficient. Must be in 0.0-1.0 range. */ protected float shiftCoef; /** * Color shift kind. */ protected ColorShiftKind shiftKind; /** * Map of shifted color schemes (to speed up the subsequent lookups). */ protected final static LazyResettableHashMap shiftMap = new LazyResettableHashMap( "InnerDelegateBorderPainter"); /** * Creates an inner painter. * * @param painterName * Painter display name. * @param delegate * Delegate painter. */ public InnerDelegateBorderPainter(String painterName, SubstanceBorderPainter delegate) { this(painterName, delegate, 0.7f, ColorShiftKind.TINT); } /** * Creates an inner painter. * * @param painterName * Painter display name. * @param delegate * Delegate painter. * @param shiftCoef * Shift coefficient. Must be in 0.0-1.0 range. * @param shiftKind * Color shift kind. */ public InnerDelegateBorderPainter(String painterName, SubstanceBorderPainter delegate, float shiftCoef, ColorShiftKind shiftKind) { this.painterName = painterName; this.delegate = delegate; this.shiftCoef = shiftCoef; this.shiftKind = shiftKind; } /* * (non-Javadoc) * * @see org.jvnet.substance.border.SubstanceBorderPainter#getDisplayName() */ public String getDisplayName() { return this.painterName; } /* * (non-Javadoc) * * @see * org.jvnet.substance.border.SubstanceBorderPainter#paintBorder(java.awt * .Graphics, java.awt.Component, int, int, java.awt.Shape, java.awt.Shape, * org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, float, boolean) */ public void paintBorder(Graphics g, Component comp, int width, int height, Shape contour, Shape innerContour, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos, boolean useCyclePosAsInterpolation) { if (innerContour != null) { this.delegate.paintBorder(g, comp, width, height, innerContour, null, getShiftScheme(colorScheme1), getShiftScheme(colorScheme2), cyclePos, useCyclePosAsInterpolation); } if (contour != null) { this.delegate.paintBorder(g, comp, width, height, contour, null, colorScheme1, colorScheme2, cyclePos, useCyclePosAsInterpolation); } } /** * Retrieves a shifted color scheme. * * @param orig * Original color scheme. * @return Shifted color scheme. */ public SubstanceColorScheme getShiftScheme(SubstanceColorScheme orig) { HashMapKey key = SubstanceCoreUtilities.getHashKey(orig .getDisplayName(), this.shiftCoef, this.shiftKind.name()); if (!shiftMap.containsKey(key)) { switch (shiftKind) { case TINT: shiftMap.put(key, new TintColorScheme(orig, this.shiftCoef)); break; case TONE: shiftMap.put(key, new ToneColorScheme(orig, this.shiftCoef)); break; case SHADE: shiftMap.put(key, new ShadeColorScheme(orig, this.shiftCoef)); break; case THEME_LIGHT: shiftMap.put(key, new ShiftColorScheme(orig, orig .getUltraLightColor().brighter(), this.shiftCoef)); break; } } return shiftMap.get(key); } /** * Returns the painting delegate. * * @return Painting delegate. */ public SubstanceBorderPainter getDelegate() { return this.delegate; } @Override public boolean isPaintingInnerContour() { return true; } } substance-5.3.orig/src/org/jvnet/substance/painter/border/SubstanceBorderPainter.java0000644000175000017500000001047411163124246031076 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.border; import java.awt.*; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.trait.SubstanceTrait; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; /** * Border painter interface for Substance look and feel. This class is * part of officially supported API.
*
* * Starting from version 4.0, the borders of some controls (buttons, check * boxes, tabs, scroll bars etc) are painted by border painters. Up until * version 4.0 this has been done by gradient painters ( * {@link SubstanceGradientPainter}) instead. Note that a custom gradient * painter may continue painting the borders, but these will be overriden by the * current border painter. To allow easier migration, use * {@link NullBorderPainter}. * * @author Kirill Grouchnikov * @since version 4.0 */ public interface SubstanceBorderPainter extends SubstanceTrait { /** * Paints the control border. * * @param g * Graphics. * @param c * Component. * @param width * Width of a UI component. * @param height * Height of a UI component. * @param contour * Contour of a UI component. * @param innerContour * Inner contour of a UI component. May be ignored if the * specific implementation paints only the outside border. * @param colorScheme1 * The first color scheme. * @param colorScheme2 * The second color scheme. * @param cyclePos * Cycle position. Is used for rollover and pulsation effects. * Must be in 0..1 range. * @param useCyclePosAsInterpolation * Indicates the algorithm to use for computing various colors. * If true, the cyclePos is used to * interpolate colors between different color components of both * color schemes. If false, the * cyclePos is used to interpolate colors between * different color components of the first color scheme. */ public void paintBorder(Graphics g, Component c, int width, int height, Shape contour, Shape innerContour, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos, boolean useCyclePosAsInterpolation); /** * Returns boolean indication whether this border painter is painting the * inner contours. * * @return true if this border painter is painting the inner * contours, false otherwise. */ public boolean isPaintingInnerContour(); } substance-5.3.orig/src/org/jvnet/substance/painter/border/SimplisticSoftBorderPainter.java0000644000175000017500000000622411136475562032133 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.border; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; /** * Border painter that returns images with classic appearance. This class is * for internal use only. * * @author Kirill Grouchnikov */ public class SimplisticSoftBorderPainter extends StandardBorderPainter { /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.SubstanceGradientPainter#getDisplayName() */ public String getDisplayName() { return "Simplistic Soft Border"; } @Override public Color getTopBorderColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return super.getMidBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } @Override public Color getMidBorderColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return super.getBottomBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } @Override public Color getBottomBorderColor( SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return super.getBottomBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } } substance-5.3.orig/src/org/jvnet/substance/painter/border/StandardBorderPainter.java0000644000175000017500000001644611171115706030714 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.border; import java.awt.*; import java.awt.MultipleGradientPaint.CycleMethod; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.*; /** * The default border painter. This class is part of officially supported API. * * @author Kirill Grouchnikov */ public class StandardBorderPainter implements SubstanceBorderPainter { /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.SubstanceGradientPainter#getDisplayName() */ public String getDisplayName() { return "Standard"; } @Override public boolean isPaintingInnerContour() { return false; } /* * (non-Javadoc) * * @see * org.jvnet.substance.border.SubstanceBorderPainter#paintBorder(java.awt * .Graphics, java.awt.Component, int, int, java.awt.Shape, java.awt.Shape, * org.jvnet.substance.color.ColorScheme, * org.jvnet.substance.color.ColorScheme, float, boolean) */ public void paintBorder(Graphics g, Component c, int width, int height, Shape contour, Shape innerContour, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos, boolean useCyclePosAsInterpolation) { if (contour == null) return; Graphics2D graphics = (Graphics2D) g.create(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); SubstanceColorScheme interpolationScheme1 = colorScheme1; SubstanceColorScheme interpolationScheme2 = useCyclePosAsInterpolation ? colorScheme2 : colorScheme1; double cycleCoef = 1.0 - cyclePos; Color topBorderColor = getTopBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); Color midBorderColor = getMidBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); Color bottomBorderColor = getBottomBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); if ((topBorderColor != null) && (midBorderColor != null) && (bottomBorderColor != null)) { float strokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(c)); // issue 433 - the "c" can be null when painting // the border of a tree icon used outside the // JTree context. boolean isSpecialButton = (c == null) ? false : c.getClass() .isAnnotationPresent(SubstanceArrowButton.class); int joinKind = isSpecialButton ? BasicStroke.JOIN_MITER : BasicStroke.JOIN_ROUND; int capKind = isSpecialButton ? BasicStroke.CAP_SQUARE : BasicStroke.CAP_BUTT; graphics.setStroke(new BasicStroke(strokeWidth, capKind, joinKind)); MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0, height, new float[] { 0.0f, 0.5f, 1.0f }, new Color[] { topBorderColor, midBorderColor, bottomBorderColor }, CycleMethod.REPEAT); graphics.setPaint(gradient); graphics.draw(contour); } graphics.dispose(); } /** * Computes the color of the top portion of the border. Override to provide * different visual. * * @param interpolationScheme1 * The first interpolation scheme. * @param interpolationScheme2 * The second interpolation scheme. * @param cycleCoef * Cycle coefficient. * @param useCyclePosAsInterpolation * Indicates whether the cycle coefficient should be used as the * interpolation parameter. * @return The color of the top portion of the border. */ public Color getTopBorderColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getTopBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef); } /** * Computes the color of the middle portion of the border. Override to * provide different visual. * * @param interpolationScheme1 * The first interpolation scheme. * @param interpolationScheme2 * The second interpolation scheme. * @param cycleCoef * Cycle coefficient. * @param useCyclePosAsInterpolation * Indicates whether the cycle coefficient should be used as the * interpolation parameter. * @return The color of the middle portion of the border. */ public Color getMidBorderColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getMidBorderColor(interpolationScheme1, interpolationScheme2, cycleCoef); } /** * Computes the color of the bottom portion of the border. Override to * provide different visual. * * @param interpolationScheme1 * The first interpolation scheme. * @param interpolationScheme2 * The second interpolation scheme. * @param cycleCoef * Cycle coefficient. * @param useCyclePosAsInterpolation * Indicates whether the cycle coefficient should be used as the * interpolation parameter. * @return The color of the bottom portion of the border. */ public Color getBottomBorderColor( SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getBottomBorderColor( interpolationScheme1, interpolationScheme2, cycleCoef); } } substance-5.3.orig/src/org/jvnet/substance/painter/decoration/0000755000175000017500000000000011256731150024470 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/painter/decoration/SubstanceDecorationPainter.java0000644000175000017500000000523611136475562032634 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.decoration; import java.awt.Component; import java.awt.Graphics2D; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.api.trait.SubstanceTrait; /** * Decoration painter interface for Substance look and feel. This class * is part of officially supported API. * * @author Kirill Grouchnikov * @since version 4.3 */ public interface SubstanceDecorationPainter extends SubstanceTrait { /** * Paints the decoration area. * * @param graphics * Graphics context. * @param comp * Component. * @param decorationAreaType * Decoration area type. Must not be null. * @param width * Width. * @param height * Height. * @param skin * Skin for painting the decoration area. */ public void paintDecorationArea(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin); } substance-5.3.orig/src/org/jvnet/substance/painter/decoration/ImageWrapperDecorationPainter.java0000644000175000017500000002643711246437064033273 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.decoration; import java.awt.*; import java.awt.image.BufferedImage; import java.util.LinkedHashMap; import java.util.Map.Entry; import javax.swing.*; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.api.painter.overlay.*; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.SubstanceImageCreator; /** * Implementation of {@link SubstanceDecorationPainter} that uses brushed metal * painting on decoration areas. * * @author Kirill Grouchnikov * @since version 4.3 */ public abstract class ImageWrapperDecorationPainter implements SubstanceDecorationPainter { /** * Contains the original (not colorized) image of this painter. */ protected Image originalTile = null; /** * The base decoration painter - the colorized image tiles are painted over * the painting of this painter. Can be null. */ protected SubstanceDecorationPainter baseDecorationPainter; /** * Map of colorized tiles. */ protected LinkedHashMap colorizedTileMap; /** * Alpha channel for the texture image (colorized tiles applied on top of * the {@link #baseDecorationPainter} painting). */ protected float textureAlpha; /** * Creates a new image wrapper decoration painter. */ public ImageWrapperDecorationPainter() { this.textureAlpha = 0.3f; this.colorizedTileMap = new LinkedHashMap() { @Override protected boolean removeEldestEntry(Entry eldest) { return this.size() > 10; } }; } /* * (non-Javadoc) * * @seeorg.jvnet.substance.painter.decoration.SubstanceDecorationPainter# * paintDecorationArea(java.awt.Graphics2D, java.awt.Component, * org.jvnet.substance.painter.decoration.DecorationAreaType, int, int, * org.jvnet.substance.api.SubstanceSkin) */ public void paintDecorationArea(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { switch (decorationAreaType) { case PRIMARY_TITLE_PANE: case SECONDARY_TITLE_PANE: this.paintTitleBackground(graphics, comp, decorationAreaType, width, height, skin); break; default: this.paintExtraBackground(graphics, SubstanceCoreUtilities .getHeaderParent(comp), comp, decorationAreaType, width, height, skin); } } /** * Paints the title background. * * @param graphics * Graphics context. * @param comp * Component. * @param decorationAreaType * Decoration area type. Must not be null. * @param width * Width. * @param height * Height. * @param skin * Skin for painting the title background. */ private void paintTitleBackground(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { SubstanceColorScheme tileScheme = skin .getBackgroundColorScheme(decorationAreaType); if (this.baseDecorationPainter == null) { graphics.setColor(tileScheme.getMidColor()); graphics.fillRect(0, 0, width, height); } else { this.baseDecorationPainter.paintDecorationArea(graphics, comp, decorationAreaType, width, height, skin); } Graphics2D temp = (Graphics2D) graphics.create(); this.tileArea(temp, comp, tileScheme, 0, 0, 0, 0, width, height); temp.dispose(); } /** * Paints the background of non-title decoration areas. * * @param graphics * Graphics context. * @param parent * Component ancestor for computing the correct offset of the * background painting. * @param comp * Component. * @param decorationAreaType * Decoration area type. Must not be null. * @param width * Width. * @param height * Height. * @param skin * Skin for painting the background of non-title decoration * areas. */ private void paintExtraBackground(Graphics2D graphics, Container parent, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { JRootPane rootPane = SwingUtilities.getRootPane(parent); // fix for bug 234 - Window doesn't have a root pane. int dx = 0; int dy = 0; JComponent titlePane = null; if (rootPane != null) { titlePane = SubstanceCoreUtilities.getTitlePane(rootPane); if (titlePane != null) { if (comp.isShowing() && titlePane.isShowing()) { dx += (comp.getLocationOnScreen().x - titlePane .getLocationOnScreen().x); dy += (comp.getLocationOnScreen().y - titlePane .getLocationOnScreen().y); } else { // have to traverse the hierarchy Component c = comp; dx = 0; dy = 0; while (c != rootPane) { dx += c.getX(); dy += c.getY(); c = c.getParent(); } c = titlePane; while (c != rootPane) { dx -= c.getX(); dy -= c.getY(); c = c.getParent(); } } } } SubstanceColorScheme tileScheme = skin .getBackgroundColorScheme(decorationAreaType); if (this.baseDecorationPainter != null) { this.baseDecorationPainter.paintDecorationArea(graphics, comp, decorationAreaType, width, height, skin); } else { graphics.setColor(tileScheme.getMidColor()); graphics.fillRect(0, 0, width, height); } Graphics2D temp = (Graphics2D) graphics.create(); this.tileArea(temp, comp, tileScheme, dx, dy, 0, 0, width, height); temp.dispose(); } /** * Tiles the specified area with colorized version of the image tile. This * is called after the {@link #baseDecorationPainter} has painted the area. * This method should respect the current {@link #textureAlpha} value. * * @param g * Graphic context. * @param comp * Component. * @param tileScheme * Scheme for the tile colorization. * @param offsetTextureX * X offset for the tiling. * @param offsetTextureY * Y offset for the tiling. * @param x * X coordinate of the tiling region. * @param y * Y coordinate of the tiling region. * @param width * Width of the tiling region. * @param height * Height of the tiling region. */ protected void tileArea(Graphics2D g, Component comp, SubstanceColorScheme tileScheme, int offsetTextureX, int offsetTextureY, int x, int y, int width, int height) { Graphics2D graphics = (Graphics2D) g.create(); graphics.setComposite(TransitionLayout.getAlphaComposite(comp, this.textureAlpha, g)); Image colorizedTile = this.getColorizedTile(tileScheme); int tileWidth = colorizedTile.getWidth(null); int tileHeight = colorizedTile.getHeight(null); offsetTextureX = offsetTextureX % tileWidth; offsetTextureY = offsetTextureY % tileHeight; int currTileTop = -offsetTextureY; do { int currTileLeft = -offsetTextureX; do { graphics.drawImage(colorizedTile, currTileLeft, currTileTop, null); currTileLeft += tileWidth; } while (currTileLeft < width); currTileTop += tileHeight; } while (currTileTop < height); graphics.dispose(); } /** * Sets the base decoration painter. * * @param baseDecorationPainter * Base decoration painter. */ public void setBaseDecorationPainter( SubstanceDecorationPainter baseDecorationPainter) { this.baseDecorationPainter = baseDecorationPainter; } /** * Sets the alpha channel for the image texture. * * @param textureAlpha * Alpha channel for the image texture. */ public void setTextureAlpha(float textureAlpha) { this.textureAlpha = textureAlpha; } /** * Sets indication whether this painter paints separators. * * @param isPaintingSeparators * If true, this painter will paint horizontal * separators on the bottom of each component passed to either * {@link #paintTitleBackground(Graphics2D, Component, DecorationAreaType, int, int, SubstanceSkin)} * or * {@link #paintExtraBackground(Graphics2D, Container, Component, DecorationAreaType, int, int, SubstanceSkin)} * . * @deprecated This method will be removed in version 6.0. Use * {@link SubstanceSkin#addOverlayPainter(SubstanceOverlayPainter, DecorationAreaType...)} * with {@link BottomLineOverlayPainter}, * {@link TopLineOverlayPainter} or * {@link TopBezelOverlayPainter} instead. Calling this method * in version 5.3 will not have any visual effect. */ @Deprecated public void setPaintingSeparators(boolean isPaintingSeparators) { } /** * Returns a colorized image tile. * * @param scheme * Color scheme for the colorization. * @return Colorized tile. */ protected Image getColorizedTile(SubstanceColorScheme scheme) { Image result = this.colorizedTileMap.get(scheme.getDisplayName()); if (result == null) { BufferedImage tileBi = new BufferedImage(this.originalTile .getWidth(null), this.originalTile.getHeight(null), BufferedImage.TYPE_INT_ARGB); tileBi.getGraphics().drawImage(this.originalTile, 0, 0, null); result = SubstanceImageCreator.getColorSchemeImage(tileBi, scheme, 0.0f); this.colorizedTileMap.put(scheme.getDisplayName(), result); } return result; } } substance-5.3.orig/src/org/jvnet/substance/painter/decoration/MatteDecorationPainter.java0000644000175000017500000001574611253517164031761 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.decoration; import java.awt.*; import javax.swing.*; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.utils.SubstanceCoreUtilities; /** * Implementation of {@link SubstanceDecorationPainter} that uses matte painting * on decoration areas. * * @author Kirill Grouchnikov * @since version 4.3 */ public class MatteDecorationPainter implements SubstanceDecorationPainter { /** * The display name for the decoration painters of this class. */ public static final String DISPLAY_NAME = "Matte"; /* * (non-Javadoc) * * @see org.jvnet.substance.utils.SubstanceTrait#getDisplayName() */ public String getDisplayName() { return DISPLAY_NAME; } /* * (non-Javadoc) * * @seeorg.jvnet.substance.painter.decoration.SubstanceDecorationPainter# * paintDecorationArea(java.awt.Graphics2D, java.awt.Component, * org.jvnet.substance.painter.decoration.DecorationAreaType, int, int, * org.jvnet.substance.api.SubstanceSkin) */ public void paintDecorationArea(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { switch (decorationAreaType) { case PRIMARY_TITLE_PANE: case SECONDARY_TITLE_PANE: this.paintTitleBackground(graphics, comp, width, height, skin .getBackgroundColorScheme(decorationAreaType)); break; default: this.paintExtraBackground(graphics, SubstanceCoreUtilities .getHeaderParent(comp), comp, width, height, skin .getBackgroundColorScheme(decorationAreaType)); } } /** * Paints the title background. * * @param graphics * Graphics context. * @param comp * Component. * @param width * Width. * @param height * Height. * @param scheme * Color scheme for painting the title background. */ private void paintTitleBackground(Graphics2D graphics, Component comp, int width, int height, SubstanceColorScheme scheme) { Graphics2D temp = (Graphics2D) graphics.create(); this.fill(temp, comp, scheme, 0, 0, 0, width, height); temp.dispose(); } /** * Paints the background of non-title decoration areas. * * @param graphics * Graphics context. * @param parent * Component ancestor for computing the correct offset of the * background painting. * @param comp * Component. * @param width * Width. * @param height * Height. * @param scheme * Color scheme for painting the title background. */ private void paintExtraBackground(Graphics2D graphics, Container parent, Component comp, int width, int height, SubstanceColorScheme scheme) { JRootPane rootPane = SwingUtilities.getRootPane(parent); // fix for bug 234 - Window doesn't have a root pane. int dx = 0; int dy = 0; JComponent titlePane = null; if (rootPane != null) { titlePane = SubstanceCoreUtilities.getTitlePane(rootPane); if (titlePane != null) { if (comp.isShowing() && titlePane.isShowing()) { dx += (comp.getLocationOnScreen().x - titlePane .getLocationOnScreen().x); dy += (comp.getLocationOnScreen().y - titlePane .getLocationOnScreen().y); } else { // have to traverse the hierarchy Component c = comp; dx = 0; dy = 0; while (c != rootPane) { dx += c.getX(); dy += c.getY(); c = c.getParent(); } c = titlePane; while (c != rootPane) { dx -= c.getX(); dy -= c.getY(); c = c.getParent(); } } } } // int pWidth = (titlePane == null) ? parent.getWidth() : titlePane // .getWidth(); // int pHeight = parent.getHeight(); // Graphics2D temp = (Graphics2D) graphics.create(); this.fill(temp, comp, scheme, dy, 0, 0, width, height); temp.dispose(); } /** * Fills the relevant part with the gradient fill. * * @param graphics * Graphics. * @param comp * Component. * @param scheme * Color scheme to use. * @param offsetY * Vertical offset. * @param x * X coordinate of the fill area. * @param y * Y coordinate of the fill area. * @param width * Fill area width. * @param height * Fill area height. */ protected void fill(Graphics2D graphics, Component comp, SubstanceColorScheme scheme, int offsetY, int x, int y, int width, int height) { // System.out.println(comp.getClass().getName() + ":" // + scheme.getDisplayName()); // 0 - 50 : light -> medium // 50 - : medium fill int flexPoint = 50; int startY = y + offsetY; if (startY < 0) startY = 0; int endY = startY + height; int currStart = 0; if (flexPoint >= startY) { graphics.setPaint(new GradientPaint(x, currStart - offsetY, scheme .getLightColor(), x, flexPoint - offsetY, scheme .getMidColor())); graphics.fillRect(x, currStart - offsetY, width, flexPoint); } currStart += flexPoint; if (currStart > endY) return; graphics.setColor(scheme.getMidColor()); graphics.fillRect(x, currStart - offsetY, width, endY - currStart + offsetY); } } substance-5.3.orig/src/org/jvnet/substance/painter/decoration/ClassicDecorationPainter.java0000644000175000017500000001147211246715756032271 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.decoration; import java.awt.*; import java.awt.image.BufferedImage; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.painter.gradient.ClassicGradientPainter; import org.jvnet.substance.utils.*; /** * Decoration painter that paints a classic gradient. This class is part of * officially supported API. * * @author Kirill Grouchnikov * @since version 4.3 */ public class ClassicDecorationPainter implements SubstanceDecorationPainter { /** * The display name for the decoraion painters of this class. */ public static final String DISPLAY_NAME = "Classic"; /** * Cache for small objects. */ protected final static LazyResettableHashMap smallImageCache = new LazyResettableHashMap( "ClassicDecorationPainter"); /** * Single gradient painter instance. */ protected ClassicGradientPainter painter; /** * Creates new classic title painter. */ public ClassicDecorationPainter() { this.painter = new ClassicGradientPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.utils.SubstanceTrait#getDisplayName() */ public String getDisplayName() { return DISPLAY_NAME; } /* * (non-Javadoc) * * @seeorg.jvnet.substance.painter.decoration.SubstanceDecorationPainter# * paintDecorationArea(java.awt.Graphics2D, java.awt.Component, * org.jvnet.substance.painter.decoration.DecorationAreaType, int, int, * org.jvnet.substance.skin.SubstanceSkin) */ public void paintDecorationArea(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { SubstanceColorScheme scheme = skin .getBackgroundColorScheme(decorationAreaType); if (width * height < 100000) { HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height, scheme.getDisplayName()); BufferedImage result = smallImageCache.get(key); if (result == null) { result = SubstanceCoreUtilities.getBlankImage(width, height); this.internalPaint((Graphics2D) result.getGraphics(), comp, width, height, scheme); smallImageCache.put(key, result); } graphics.drawImage(result, 0, 0, null); return; } this.internalPaint(graphics, comp, width, height, scheme); } /** * Paints the specified area. * * @param graphics * Graphics context. * @param comp * Component. * @param width * Width. * @param height * Height. * @param leftTitleX * Title start poisition. * @param rightTitleX * Title end position. * @param scheme * Substance color scheme for painting the area. */ protected void internalPaint(Graphics2D graphics, Component comp, int width, int height, SubstanceColorScheme scheme) { Graphics2D g2d = (Graphics2D) graphics.create(); g2d.translate(-3, -3); this.painter.paintContourBackground(g2d, comp, width + 6, height + 6, new Rectangle(width + 6, height + 6), false, scheme, scheme, 0, false, false); g2d.dispose(); } } substance-5.3.orig/src/org/jvnet/substance/painter/decoration/FlatDecorationPainter.java0000644000175000017500000000573111136475562031573 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.decoration; import java.awt.Component; import java.awt.Graphics2D; import org.jvnet.substance.api.SubstanceSkin; /** * Decoration painter that paints a flat appearance. This class is part of * officially supported API. * * @author Kirill Grouchnikov * @since version 4.3 */ public class FlatDecorationPainter implements SubstanceDecorationPainter { /** * The display name for the decoration painters of this class. */ public static final String DISPLAY_NAME = "Flat"; /* * (non-Javadoc) * * @see org.jvnet.substance.utils.SubstanceTrait#getDisplayName() */ public String getDisplayName() { return DISPLAY_NAME; } /* * (non-Javadoc) * * @seeorg.jvnet.substance.painter.decoration.SubstanceDecorationPainter# * paintDecorationArea(java.awt.Graphics2D, java.awt.Component, * org.jvnet.substance.painter.decoration.DecorationAreaType, int, int, * org.jvnet.substance.skin.SubstanceSkin) */ public void paintDecorationArea(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { graphics .setColor(skin.getBackgroundColorScheme( DecorationAreaType.PRIMARY_TITLE_PANE) .getBackgroundFillColor()); graphics.fillRect(0, 0, width, height); } } substance-5.3.orig/src/org/jvnet/substance/painter/decoration/MarbleNoiseDecorationPainter.java0000644000175000017500000000521311136475562033100 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.decoration; import org.jvnet.substance.painter.noise.NoiseFactory; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; /** * Implementation of {@link SubstanceDecorationPainter} that uses marble noise * painting on decoration areas. * * @author Kirill Grouchnikov * @since version 4.3 */ public class MarbleNoiseDecorationPainter extends ImageWrapperDecorationPainter { /** * The display name for the decoration painters of this class. */ public static final String DISPLAY_NAME = "Marble Noise"; /** * Creates a new marble noise decoration painter. */ public MarbleNoiseDecorationPainter() { super(); this.originalTile = NoiseFactory.getNoiseImage( SubstanceColorSchemeUtilities.METALLIC_SKIN, 400, 400, 0.8, 0.8, false, null, true, true); } /* * (non-Javadoc) * * @see org.jvnet.substance.utils.SubstanceTrait#getDisplayName() */ public String getDisplayName() { return DISPLAY_NAME; } } substance-5.3.orig/src/org/jvnet/substance/painter/decoration/DecorationAreaType.java0000644000175000017500000000614311136475562031072 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.decoration; /** * Enumeration of available decoration area types. This class is part of * officially supported API. * * @author Kirill Grouchnikov * @since version 4.3 */ public enum DecorationAreaType { /** * Title pane of top-level windows (frames, dialogs). */ PRIMARY_TITLE_PANE, /** * Title pane of non top-level windows (internal frames, desktop icons). */ SECONDARY_TITLE_PANE, /** * Tool bar. */ TOOLBAR, /** * Any area that can be placed in the top portion of its window. Menu bar is * an example of a core Swing component. JXHeader and * JXTitledPanel titled area (components from SwingX suite) are examples of * third-party components. */ HEADER, /** * Any area that can be placed in the bottom portion of its window. * JXStatusBar component from SwingX suite is an example of a * third-party component. */ FOOTER, /** * Any general area that does not fit for the other types. * JXTaskPaneContainer component from SwingX suite is an example of a * third-party component. */ GENERAL, /** * The default decoration area type. Components placed in areas with this * type do not get any special background decoration painting. */ NONE } substance-5.3.orig/src/org/jvnet/substance/painter/decoration/BrushedMetalDecorationPainter.java0000644000175000017500000000643511136475562033266 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.decoration; import java.net.URL; import javax.imageio.ImageIO; import org.jvnet.substance.utils.SubstanceCoreUtilities; /** * Implementation of {@link SubstanceDecorationPainter} that uses brushed metal * painting on decoration areas. * * @author Kirill Grouchnikov * @since version 4.0 */ public class BrushedMetalDecorationPainter extends ImageWrapperDecorationPainter { /** * The display name for the decoration painters of this class. */ public static final String DISPLAY_NAME = "Brushed Metal"; /** * Creates a new brushed metal decoration painter. */ public BrushedMetalDecorationPainter() { super(); try { // the following is fix by Dag Joar and Christian Schlichtherle // for application running with -Xbootclasspath VM flag. In this // case, the using MyClass.class.getClassLoader() would return // null, but the context class loader will function properly // that classes will be properly loaded regardless of whether // the lib is added to the system class path, the extension class // path and regardless of the class loader architecture set up by // some frameworks. ClassLoader cl = SubstanceCoreUtilities .getClassLoaderForResources(); URL metalUrl = cl.getResource("resource/brushed.gif"); this.originalTile = ImageIO.read(metalUrl); } catch (Exception exc) { // ignore - probably specified incorrect file // or file is not image } } /* * (non-Javadoc) * * @see org.jvnet.substance.utils.SubstanceTrait#getDisplayName() */ public String getDisplayName() { return DISPLAY_NAME; } } substance-5.3.orig/src/org/jvnet/substance/painter/decoration/ArcDecorationPainter.java0000644000175000017500000002007211246721636031403 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.decoration; import java.awt.*; import java.awt.MultipleGradientPaint.CycleMethod; import java.awt.geom.GeneralPath; import java.awt.image.BufferedImage; import javax.swing.*; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.utils.SubstanceCoreUtilities; /** * Implementation of {@link SubstanceDecorationPainter} that uses "arc" painting * on title panes and lighter gradient near the center of the application frame. * * @author Kirill Grouchnikov */ public class ArcDecorationPainter implements SubstanceDecorationPainter { /** * The display name for the decoration painters of this class. */ public static final String DISPLAY_NAME = "Arc"; /* * (non-Javadoc) * * @see org.jvnet.substance.utils.SubstanceTrait#getDisplayName() */ public String getDisplayName() { return DISPLAY_NAME; } /* * (non-Javadoc) * * @seeorg.jvnet.substance.painter.decoration.SubstanceDecorationPainter# * paintDecorationArea(java.awt.Graphics2D, java.awt.Component, * org.jvnet.substance.painter.decoration.DecorationAreaType, int, int, * org.jvnet.substance.skin.SubstanceSkin) */ public void paintDecorationArea(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { switch (decorationAreaType) { case PRIMARY_TITLE_PANE: case SECONDARY_TITLE_PANE: this.paintTitleBackground(graphics, comp, width, height, skin .getBackgroundColorScheme(decorationAreaType)); break; default: this.paintExtraBackground(graphics, SubstanceCoreUtilities .getHeaderParent(comp), comp, width, height, skin .getBackgroundColorScheme(decorationAreaType)); } } /** * Paints the title background. * * @param graphics * Graphics context. * @param comp * Component. * @param width * Width. * @param height * Height. * @param scheme * Color scheme for painting the title background. */ private void paintTitleBackground(Graphics2D graphics, Component comp, int width, int height, SubstanceColorScheme scheme) { // System.out.println(scheme.getDisplayName()); // create rectangular background and later draw it on // result image with contour clip. BufferedImage rectangular = SubstanceCoreUtilities.getBlankImage(width, height); Graphics2D rgraphics = (Graphics2D) rectangular.getGraphics(); // Fill background GeneralPath clipTop = new GeneralPath(); clipTop.moveTo(0, 0); clipTop.lineTo(width, 0); clipTop.lineTo(width, height / 2); clipTop.quadTo(width / 2, height / 4, 0, height / 2); clipTop.lineTo(0, 0); rgraphics.setClip(clipTop); LinearGradientPaint gradientTop = new LinearGradientPaint(0, 0, width, 0, new float[] { 0.0f, 0.5f, 1.0f }, new Color[] { scheme.getLightColor(), scheme.getUltraLightColor(), scheme.getLightColor() }, CycleMethod.REPEAT); rgraphics.setPaint(gradientTop); rgraphics.fillRect(0, 0, width, height); GeneralPath clipBottom = new GeneralPath(); clipBottom.moveTo(0, height); clipBottom.lineTo(width, height); clipBottom.lineTo(width, height / 2); clipBottom.quadTo(width / 2, height / 4, 0, height / 2); clipBottom.lineTo(0, height); rgraphics.setClip(clipBottom); LinearGradientPaint gradientBottom = new LinearGradientPaint(0, 0, width, 0, new float[] { 0.0f, 0.5f, 1.0f }, new Color[] { scheme.getMidColor(), scheme.getLightColor(), scheme.getMidColor() }, CycleMethod.REPEAT); rgraphics.setPaint(gradientBottom); rgraphics.fillRect(0, 0, width, height); GeneralPath mid = new GeneralPath(); mid.moveTo(width, height / 2); mid.quadTo(width / 2, height / 4, 0, height / 2); // rgraphics.setClip(new Rectangle(0, 0, width / 2, height)); // rgraphics // .setClip(new Rectangle(width / 2, 0, width - width / 2, height)); rgraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rgraphics.setClip(new Rectangle(0, 0, width, height)); rgraphics.draw(mid); graphics.drawImage(rectangular, 0, 0, null); } /** * Paints the background of non-title decoration areas. * * @param graphics * Graphics context. * @param parent * Component ancestor for computing the correct offset of the * background painting. * @param comp * Component. * @param width * Width. * @param height * Height. * @param scheme * Color scheme for painting the title background. */ private void paintExtraBackground(Graphics2D graphics, Container parent, Component comp, int width, int height, SubstanceColorScheme scheme) { // System.out.println(comp.getClass().getSimpleName() + " -- W: " + // width // + ", H: " + height); // System.out.println(graphics.getTransform()); // System.out.println(graphics.getClip()); JRootPane rootPane = SwingUtilities.getRootPane(parent); // fix for bug 234 - Window doesn't have a root pane. int dx = 0; JComponent titlePane = null; if (rootPane != null) { titlePane = SubstanceCoreUtilities.getTitlePane(rootPane); if (titlePane != null) { if (comp.isShowing() && titlePane.isShowing()) { dx += (comp.getLocationOnScreen().x - titlePane .getLocationOnScreen().x); } else { // have to traverse the hierarchy Component c = comp; dx = 0; while (c != rootPane) { dx += c.getX(); c = c.getParent(); } c = titlePane; while (c != rootPane) { dx -= c.getX(); c = c.getParent(); } } } } // int dy = comp.getY(); int pWidth = (titlePane == null) ? parent.getWidth() : titlePane .getWidth(); // int pHeight = parent.getHeight(); // System.out.println("DX: " + dx + ", pW: " + pWidth);// + ", pH: " + // pHeight); if (pWidth != 0) { LinearGradientPaint gradientBottom = new LinearGradientPaint(-dx, 0, -dx + pWidth, 0, new float[] { 0.0f, 0.5f, 1.0f }, new Color[] { scheme.getMidColor(), scheme.getLightColor(), scheme.getMidColor() }, CycleMethod.REPEAT); Graphics2D g2d = (Graphics2D) graphics.create(); g2d.setPaint(gradientBottom); g2d.fillRect(-dx, 0, pWidth, height); g2d.dispose(); } } } substance-5.3.orig/src/org/jvnet/substance/painter/decoration/Glass3DDecorationPainter.java0000644000175000017500000000601111136475562032135 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.decoration; import java.awt.Component; import java.awt.Graphics2D; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.utils.SubstanceImageCreator; /** * Decoration painter that paints a 3D glass gradient. This class is part of * officially supported API. * * @author Kirill Grouchnikov * @since version 4.3 */ public class Glass3DDecorationPainter implements SubstanceDecorationPainter { /** * The display name for the decoration painters of this class. */ public static final String DISPLAY_NAME = "Glass 3D"; /* * (non-Javadoc) * * @see org.jvnet.substance.utils.SubstanceTrait#getDisplayName() */ public String getDisplayName() { return DISPLAY_NAME; } /* * (non-Javadoc) * * @seeorg.jvnet.substance.painter.decoration.SubstanceDecorationPainter# * paintDecorationArea(java.awt.Graphics2D, java.awt.Component, * org.jvnet.substance.painter.decoration.DecorationAreaType, int, int, * org.jvnet.substance.skin.SubstanceSkin) */ public void paintDecorationArea(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { SubstanceImageCreator.paintRectangularBackground(comp, graphics, 0, 0, width, height, skin.getBackgroundColorScheme(decorationAreaType), 0.0f, false); } } substance-5.3.orig/src/org/jvnet/substance/painter/utils/0000755000175000017500000000000011256731150023501 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/painter/utils/SeparatorPainterUtils.java0000644000175000017500000004504611247452516030667 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.utils; import java.awt.*; import java.awt.image.BufferedImage; import java.util.Collection; import javax.swing.JSeparator; import javax.swing.SwingConstants; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.*; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.utils.*; /** * Contains utility methods related to painting separators. This class is for * internal use only. * * @author Kirill Grouchnikov */ public class SeparatorPainterUtils { /** * Cached images of separators. */ private static LazyResettableHashMap cached = new LazyResettableHashMap( "SeparatorPainterUtils"); /** * Paints a separator. * * @param c * Component. * @param graphics * Graphics context. * @param width * Separator width. * @param height * Separator height. * @param orientation * Separator orientation. */ public static void paintSeparator(Component c, Graphics graphics, int width, int height, int orientation) { paintSeparator(c, graphics, width, height, orientation, true, 10); } /** * Paints a separator. * * @param c * Component. * @param graphics * Graphics context. * @param scheme * Color scheme. * @param width * Separator width. * @param height * Separator height. * @param orientation * Separator orientation. * @param hasShadow * If true, the separator painting will have shadow. * @param maxGradLength * Specifies the maximum pixel length of "ramp" portions of the * separator. The ramp portions are located on separator ends and * allow providing a faded appearance on those ends. */ public static void paintSeparator(Component c, Graphics graphics, int width, int height, int orientation, boolean hasShadow, int maxGradLength) { paintSeparator(c, graphics, width, height, orientation, hasShadow, maxGradLength, maxGradLength, false); } /** * Paints a separator. * * @param c * Component. * @param g * Graphics context. * @param width * Separator width. * @param height * Separator height. * @param orientation * Separator orientation. * @param hasShadow * If true, the separator painting will have shadow. * @param maxGradLengthStart * Specifies the maximum pixel length of the starting "ramp" * portion of the separator. The starting ramp portion is located * on top / left separator end and allows providing a faded * appearance on that end. * @param maxGradLengthEnd * Specifies the maximum pixel length of the ending "ramp" * portion of the separator. The ending ramp portion is located * on bottom / right separator end and allows providing a faded * appearance on that end. * @param toEnforceAlphaColors * If true, the fade sequences will always use alpha * colors. This may affect the performance. */ public static void paintSeparator(Component c, Graphics g, int width, int height, int orientation, boolean hasShadow, int maxGradLengthStart, int maxGradLengthEnd, boolean toEnforceAlphaColors) { SubstanceColorScheme compScheme = SubstanceColorSchemeUtilities .getColorScheme(c, ColorSchemeAssociationKind.SEPARATOR, ComponentState.DEFAULT); paintSeparator(c, g, compScheme, width, height, orientation, hasShadow, maxGradLengthStart, maxGradLengthEnd, toEnforceAlphaColors); } /** * Paints a separator. * * @param c * Component. * @param g * Graphics context. * @param scheme * Color scheme. * @param width * Separator width. * @param height * Separator height. * @param orientation * Separator orientation. * @param hasShadow * If true, the separator painting will have shadow. * @param maxGradLengthStart * Specifies the maximum pixel length of the starting "ramp" * portion of the separator. The starting ramp portion is located * on top / left separator end and allows providing a faded * appearance on that end. * @param maxGradLengthEnd * Specifies the maximum pixel length of the ending "ramp" * portion of the separator. The ending ramp portion is located * on bottom / right separator end and allows providing a faded * appearance on that end. * @param toEnforceAlphaColors * If true, the fade sequences will always use alpha * colors. This may affect the performance. */ public static void paintSeparator(Component c, Graphics g, SubstanceColorScheme scheme, int width, int height, int orientation, boolean hasShadow, int maxGradLengthStart, int maxGradLengthEnd, boolean toEnforceAlphaColors) { DecorationAreaType decorationAreaType = SubstanceLookAndFeel .getDecorationType(c); SubstanceSkin skin = SubstanceCoreUtilities.getSkin(c); // use alpha colors when the control is in a painted decoration area // (where skin can use different background colors) or in a decoration // area that has overlays. boolean toUseAlphaColors = ((decorationAreaType == null) || (decorationAreaType == DecorationAreaType.NONE)) ? false : skin.isRegisteredAsDecorationArea(decorationAreaType) || (skin.getOverlayPainters(decorationAreaType).size() > 0); toUseAlphaColors = toUseAlphaColors || toEnforceAlphaColors; Color backgrFill = SubstanceColorUtilities.getBackgroundFillColor(c); int fontSize = SubstanceSizeUtils.getComponentFontSize(c); float borderStrokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(fontSize); if ((orientation == JSeparator.HORIZONTAL) && (height == 0)) { height = (int) Math.ceil(2.0 * borderStrokeWidth); } if ((orientation == JSeparator.VERTICAL) && (width == 0)) { width = (int) Math.ceil(2.0 * borderStrokeWidth); } if ((width == 0) || (height == 0)) return; HashMapKey key = SubstanceCoreUtilities.getHashKey(fontSize, scheme .getDisplayName(), width, height, orientation, hasShadow, maxGradLengthStart, maxGradLengthEnd, toUseAlphaColors, backgrFill.getRGB()); if (!cached.containsKey(key)) { BufferedImage toCache = SubstanceCoreUtilities.getBlankImage(width, height); Graphics2D graphics = toCache.createGraphics(); boolean isDark = scheme.isDark(); Color foreLight = isDark ? scheme.getLightColor() : SubstanceColorUtilities.getInterpolatedColor(scheme .getLightColor(), scheme.getDarkColor(), 0.8); Color foreDark = isDark ? scheme.getExtraLightColor() : SubstanceColorUtilities.getInterpolatedColor(scheme .getMidColor(), scheme.getDarkColor(), 0.4); Color back = isDark ? scheme.getDarkColor() : scheme .getUltraLightColor(); Color foreLight12 = toUseAlphaColors ? SubstanceColorUtilities .getAlphaColor(foreLight, 32) : SubstanceColorUtilities .getInterpolatedColor(foreLight, backgrFill, 0.12); Color foreDark95 = toUseAlphaColors ? SubstanceColorUtilities .getAlphaColor(foreDark, 240) : SubstanceColorUtilities .getInterpolatedColor(foreDark, backgrFill, 0.95); Color back12 = toUseAlphaColors ? SubstanceColorUtilities .getAlphaColor(back, 32) : SubstanceColorUtilities .getInterpolatedColor(back, backgrFill, 0.12); Color back95 = toUseAlphaColors ? SubstanceColorUtilities .getAlphaColor(back, 240) : SubstanceColorUtilities .getInterpolatedColor(back, backgrFill, 0.95); graphics.setStroke(new BasicStroke(borderStrokeWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); if (orientation == JSeparator.VERTICAL) { int gradStart = Math.min(maxGradLengthStart, height / 2); int gradEnd = Math.min(maxGradLengthEnd, height / 2); graphics.translate(Math.max(0, width / 2 - 1), 0); graphics.setPaint(new GradientPaint(0, 0, foreLight12, 0, gradStart, foreDark95)); graphics.drawLine(0, 0, 0, gradStart); graphics.setColor(foreDark95); graphics.drawLine(0, gradStart, 0, height - gradEnd); graphics.setPaint(new GradientPaint(0, height - gradEnd, foreDark95, 0, height, foreLight12)); graphics.drawLine(0, height - gradEnd, 0, height); if (hasShadow) { int offset = (int) borderStrokeWidth; graphics.setPaint(new GradientPaint(offset, 0, back12, offset, gradStart, back95)); graphics.drawLine(offset, 0, offset, gradStart); graphics.setColor(back95); graphics.drawLine(offset, gradStart, offset, height - gradEnd); graphics.setPaint(new GradientPaint(offset, height - gradEnd, back95, offset, height, back12)); graphics.drawLine(offset, height - gradEnd, offset, height); } } else { // HORIZONTAL int gradStart = Math.min(maxGradLengthStart, width / 2); int gradEnd = Math.min(maxGradLengthEnd, width / 2); graphics.translate(0, Math.max(0, height / 2 - 1)); graphics.setPaint(new GradientPaint(0, 0, foreLight12, gradStart, 0, foreDark95)); graphics.drawLine(0, 0, gradStart, 0); graphics.setColor(foreDark95); graphics.drawLine(gradStart, 0, width - gradEnd, 0); graphics.setPaint(new GradientPaint(width - gradEnd, 0, foreDark95, width, 0, foreLight12)); graphics.drawLine(width - gradEnd, 0, width, 0); if (hasShadow) { int offset = (int) borderStrokeWidth; graphics.setPaint(new GradientPaint(0, offset, back12, gradStart, offset, back95)); graphics.drawLine(0, offset, gradStart, offset); graphics.setColor(back95); graphics.drawLine(gradStart, offset, width - gradEnd, offset); graphics.setPaint(new GradientPaint(width - gradEnd, offset, back95, width, offset, back12)); graphics.drawLine(width - gradEnd, offset, width, offset); } } graphics.dispose(); cached.put(key, toCache); } Graphics2D g2d = (Graphics2D) g.create(); g2d.drawImage(cached.get(key), 0, 0, null); g2d.dispose(); } /** * Paints vertical separator lines. * * @param g * Graphics context. * @param c * Component. * @param scheme * Color scheme for painting the vertical separator lines. * @param y * The top Y coordinate of the lines. * @param x * The X coordinates of the lines. * @param height * The height of the lines. * @param fadeStartFraction * The start fraction of the fade out sequence. */ public static void paintVerticalLines(Graphics g, Component c, SubstanceColorScheme scheme, int y, Collection x, int height, float fadeStartFraction) { int componentFontSize = SubstanceSizeUtils.getComponentFontSize(c); Color backgrFill = SubstanceColorUtilities.getBackgroundFillColor(c); HashMapKey key = SubstanceCoreUtilities.getHashKey(componentFontSize, scheme.getDisplayName(), 0, height, SwingConstants.VERTICAL, true, 0.0, fadeStartFraction, backgrFill.getRGB()); float borderStrokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(componentFontSize); int offset = (int) borderStrokeWidth; if (!cached.containsKey(key)) { BufferedImage toCache = SubstanceCoreUtilities.getBlankImage(Math .max(2, (int) Math.ceil(2.0 * borderStrokeWidth)), height); Graphics2D graphics = toCache.createGraphics(); boolean isDark = scheme.isDark(); Color foreLight = isDark ? scheme.getLightColor() : SubstanceColorUtilities.getInterpolatedColor(scheme .getLightColor(), scheme.getDarkColor(), 0.8); Color foreDark = isDark ? scheme.getExtraLightColor() : SubstanceColorUtilities.getInterpolatedColor(scheme .getMidColor(), scheme.getDarkColor(), 0.4); Color back = isDark ? scheme.getDarkColor() : scheme .getUltraLightColor(); graphics.setStroke(new BasicStroke(borderStrokeWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); Color foreLight12 = SubstanceColorUtilities.getInterpolatedColor( foreLight, backgrFill, 0.12); Color foreDark95 = SubstanceColorUtilities.getInterpolatedColor( foreDark, backgrFill, 0.95); Color back12 = SubstanceColorUtilities.getInterpolatedColor(back, backgrFill, 0.12); Color back95 = SubstanceColorUtilities.getInterpolatedColor(back, backgrFill, 0.95); LinearGradientPaint forePaint = new LinearGradientPaint(0, 0, 0, height, new float[] { 0.0f, fadeStartFraction, 1.0f }, new Color[] { foreDark95, foreDark95, foreLight12 }); graphics.setPaint(forePaint); graphics.translate(borderStrokeWidth / 2, 0); graphics.drawLine(0, 0, 0, height); LinearGradientPaint backPaint = new LinearGradientPaint(0, 0, 0, height, new float[] { 0.0f, fadeStartFraction, 1.0f }, new Color[] { back95, back95, back12 }); graphics.setPaint(backPaint); graphics.drawLine(offset, 0, offset, height); graphics.dispose(); cached.put(key, toCache); } Graphics2D g2d = (Graphics2D) g.create(); Image singleLine = cached.get(key); for (int lineX : x) { g2d.drawImage(singleLine, lineX - offset / 2, y, null); } g2d.dispose(); } /** * Paints horizontal separator lines. * * @param g * Graphics context. * @param c * Component. * @param scheme * Color scheme for painting the horizontal separator lines. * @param x * The left X coordinate of the lines. * @param y * The Y coordinates of the lines. * @param width * The width of the lines. * @param fadeStartFraction * The start fraction of the fade out sequence. * @param isLtr * If true, the lines are left-to-right and the fade * out is on the right side. Otherwise, the fade out is on the * left side. */ public static void paintHorizontalLines(Graphics g, Component c, SubstanceColorScheme scheme, int x, Collection y, int width, float fadeStartFraction, boolean isLtr) { int componentFontSize = SubstanceSizeUtils.getComponentFontSize(c); Color backgrFill = SubstanceColorUtilities.getBackgroundFillColor(c); HashMapKey key = SubstanceCoreUtilities.getHashKey(componentFontSize, scheme.getDisplayName(), width, 0, SwingConstants.VERTICAL, true, 0.0, fadeStartFraction, isLtr, backgrFill.getRGB()); float borderStrokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(componentFontSize); int offset = (int) borderStrokeWidth; if (!cached.containsKey(key)) { BufferedImage toCache = SubstanceCoreUtilities.getBlankImage(width, Math.max(2, (int) Math.ceil(2.0 * borderStrokeWidth))); Graphics2D graphics = toCache.createGraphics(); boolean isDark = scheme.isDark(); Color foreLight = isDark ? scheme.getLightColor() : SubstanceColorUtilities.getInterpolatedColor(scheme .getLightColor(), scheme.getDarkColor(), 0.8); Color foreDark = isDark ? scheme.getExtraLightColor() : SubstanceColorUtilities.getInterpolatedColor(scheme .getMidColor(), scheme.getDarkColor(), 0.4); Color back = isDark ? scheme.getDarkColor() : scheme .getUltraLightColor(); graphics.setStroke(new BasicStroke(borderStrokeWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)); Color foreLight12 = SubstanceColorUtilities.getInterpolatedColor( foreLight, backgrFill, 0.12); Color foreDark95 = SubstanceColorUtilities.getInterpolatedColor( foreDark, backgrFill, 0.95); Color back12 = SubstanceColorUtilities.getInterpolatedColor(back, backgrFill, 0.12); Color back95 = SubstanceColorUtilities.getInterpolatedColor(back, backgrFill, 0.95); LinearGradientPaint forePaint = new LinearGradientPaint(0, 0, width, 0, new float[] { 0.0f, fadeStartFraction, 1.0f }, new Color[] { isLtr ? foreDark95 : foreLight12, foreDark95, isLtr ? foreLight12 : foreDark95 }); graphics.setPaint(forePaint); graphics.drawLine(0, 0, width, 0); LinearGradientPaint backPaint = new LinearGradientPaint(0, 9, width, 0, new float[] { 0.0f, fadeStartFraction, 1.0f }, new Color[] { isLtr ? back95 : back12, back95, isLtr ? back12 : back95 }); graphics.setPaint(backPaint); graphics.drawLine(0, offset, width, offset); graphics.dispose(); cached.put(key, toCache); } Graphics2D g2d = (Graphics2D) g.create(); Image singleLine = cached.get(key); for (int lineY : y) { g2d.drawImage(singleLine, x, lineY - offset / 2, null); } g2d.dispose(); } } substance-5.3.orig/src/org/jvnet/substance/painter/utils/BackgroundPaintingUtils.java0000644000175000017500000001707011247452504031146 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.utils; import java.awt.*; import javax.swing.CellRendererPane; import javax.swing.JComponent; import org.jvnet.lafwidget.LafWidgetUtilities; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.utils.SubstanceColorUtilities; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.watermark.SubstanceWatermark; /** * Delegate for painting filled backgrounds. * * @author Kirill Grouchnikov */ public class BackgroundPaintingUtils { /** * Updates the background of the specified component on the specified * graphic context. The background is updated only if the component is * opaque. * * @param g * Graphic context. * @param c * Component. */ public static void updateIfOpaque(Graphics g, Component c) { if (TransitionLayout.isOpaque(c)) update(g, c, false); } /** * Updates the background of the specified component on the specified * graphic context. The background is not painted when the * force parameter is false and at least one of * the following conditions holds: *
    *
  • The component is in a cell renderer.
  • *
  • The component is not showing on the screen.
  • *
  • The component is in the preview mode.
  • *
* * @param g * Graphic context. * @param c * Component. * @param force * If true, the painting of background is enforced. */ public static void update(Graphics g, Component c, boolean force) { // failsafe for LAF change if (!SubstanceLookAndFeel.isCurrentLookAndFeel()) { return; } boolean isInCellRenderer = (c.getParent() instanceof CellRendererPane); boolean isPreviewMode = false; if (c instanceof JComponent) { isPreviewMode = (Boolean.TRUE.equals(((JComponent) c) .getClientProperty(LafWidgetUtilities.PREVIEW_MODE))); } if (!force && !isPreviewMode && !c.isShowing() && !isInCellRenderer) { return; } Graphics2D graphics = (Graphics2D) g.create(); // optimization - do not call fillRect on graphics // with anti-alias turned on graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); graphics.setComposite(TransitionLayout.getAlphaComposite(c, g)); DecorationAreaType decorationType = SubstanceLookAndFeel .getDecorationType(c); SubstanceSkin skin = SubstanceCoreUtilities.getSkin(c); if ((decorationType != null) && (skin.isRegisteredAsDecorationArea(decorationType))) { // use the decoration painter DecorationPainterUtils .paintDecorationBackground(graphics, c, force); // and add overlays OverlayPainterUtils .paintOverlays(graphics, c, skin, decorationType); } else { // fill the area with solid color Color backgr = SubstanceColorUtilities.getBackgroundFillColor(c); graphics.setColor(backgr); graphics.fillRect(0, 0, c.getWidth(), c.getHeight()); // add overlays OverlayPainterUtils .paintOverlays(graphics, c, skin, decorationType); // boolean isPaintingDropShadows = skin // .isPaintingDropShadows(decorationAreaType); // if (isPaintingDropShadows) { // Color fillColor = skin.getMainActiveColorScheme( // decorationAreaType).getBackgroundFillColor().darker(); // // // need to handle components "embedded" in other components // int dy = 0; // int totalOffsetY = 0; // Component comp = c; // while (comp.getParent() != null) { // Component parent = comp.getParent(); // dy += comp.getY(); // if (DecorationPainterUtils // .getImmediateDecorationType(parent) != null) { // totalOffsetY += dy; // dy = 0; // } // comp = parent; // } // // graphics.translate(0, -totalOffsetY); // graphics.setPaint(new GradientPaint(0, 0, // SubstanceColorUtilities.getAlphaColor(fillColor, 160), // 0, 4, SubstanceColorUtilities.getAlphaColor(fillColor, // 16))); // graphics.fillRect(0, 0, c.getWidth(), 4); // graphics.translate(0, totalOffsetY); // } // and paint watermark SubstanceWatermark watermark = SubstanceCoreUtilities.getSkin(c) .getWatermark(); if ((watermark != null) && !isPreviewMode && !isInCellRenderer && c.isShowing() && SubstanceCoreUtilities.toDrawWatermark(c)) { watermark.drawWatermarkImage(graphics, c, 0, 0, c.getWidth(), c .getHeight()); } } graphics.dispose(); } /** * Updates the background of the specified component on the specified * graphic context in the specified rectangle. * * @param g * Graphic context. * @param c * Component. * @param fillColor * Fill color. * @param rect * The rectangle to fill. */ public static void fillAndWatermark(Graphics g, JComponent c, Color fillColor, Rectangle rect) { // failsafe for LAF change if (!SubstanceLookAndFeel.isCurrentLookAndFeel()) { return; } boolean isInCellRenderer = (c.getParent() instanceof CellRendererPane); if ((!c.isShowing()) && (!isInCellRenderer)) { return; } Graphics2D graphics = (Graphics2D) g.create(); graphics.setComposite(TransitionLayout.getAlphaComposite(c, g)); graphics.setColor(fillColor); graphics.fillRect(rect.x, rect.y, rect.width, rect.height); graphics.setComposite(TransitionLayout.getAlphaComposite(c, 1.0f, g)); // stamp watermark SubstanceWatermark watermark = SubstanceCoreUtilities.getSkin(c) .getWatermark(); if ((watermark != null) && !isInCellRenderer && c.isShowing() && SubstanceCoreUtilities.toDrawWatermark(c)) watermark.drawWatermarkImage(graphics, c, rect.x, rect.y, rect.width, rect.height); graphics.dispose(); } } substance-5.3.orig/src/org/jvnet/substance/painter/utils/DecorationPainterUtils.java0000644000175000017500000002142711247452512031007 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.utils; import java.awt.*; import javax.swing.CellRendererPane; import javax.swing.JComponent; import org.jvnet.lafwidget.LafWidgetUtilities; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.decoration.SubstanceDecorationPainter; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.watermark.SubstanceWatermark; /** * Contains utility methods related to decoration painters. This class is for * internal use only. * * @author Kirill Grouchnikov */ public class DecorationPainterUtils { /** * Client property for marking a component with an instance of * {@link DecorationAreaType} enum. */ private static final String DECORATION_AREA_TYPE = "substancelaf.internal.painter.decorationAreaType"; /** * Client property for specifying whether the value of * {@link #DECORATION_AREA_TYPE} client property should propagate to the * component children. */ // private static final String DECORATION_AREA_PROPAGATES = // "substancelaf.internal.painter.decorationAreaPropagates"; /** * Sets the decoration type of the specified component. * * @param comp * Component. * @param type * Decoration type of the component and its children if * isPropagatingToChildren is true. * @param isPropagatingToChildren * If true, the decoration type will be applied to * the component children. */ public static void setDecorationType(JComponent comp, DecorationAreaType type) {// , boolean isPropagatingToChildren) { comp.putClientProperty(DECORATION_AREA_TYPE, type); // if (!isPropagatingToChildren) { // comp.putClientProperty(DECORATION_AREA_PROPAGATES, Boolean.FALSE); // } } /** * Clears the client properties related to the decoration area type. * * @param comp * Component. */ public static void clearDecorationType(JComponent comp) { if (comp != null) { comp.putClientProperty(DECORATION_AREA_TYPE, null); // comp.putClientProperty(DECORATION_AREA_PROPAGATES, null); } } /** * Returns the decoration area type of the specified component. The * component and its ancestor hierarchy are scanned for the registered * decoration area type. The farthest ancestor that was passed to * {@link #setDecorationType(JComponent, DecorationAreaType, boolean)} with * the isPropagatingToChildren not set to false * (the second part is not checked for the component itself) defines the * result. * * @param comp * Component. * @return Decoration area type of the component. */ public static DecorationAreaType getDecorationType(Component comp) { Component c = comp; DecorationAreaType result = null; while (c != null) { if (c instanceof JComponent) { JComponent jc = (JComponent) c; Object prop = jc.getClientProperty(DECORATION_AREA_TYPE); if (prop instanceof DecorationAreaType) { if (prop == DecorationAreaType.NONE) return null; return (DecorationAreaType) prop; } } c = c.getParent(); } return result; } /** * Returns the immediate decoration area type of the specified component. * The component is checked for the registered decoration area type. If * {@link #setDecorationType(JComponent, DecorationAreaType, boolean)} was * not called on this component, this method returns null. * * @param comp * Component. * @return Immediate decoration area type of the component. */ public static DecorationAreaType getImmediateDecorationType(Component comp) { Component c = comp; if (c instanceof JComponent) { JComponent jc = (JComponent) c; Object prop = jc.getClientProperty(DECORATION_AREA_TYPE); if (prop instanceof DecorationAreaType) return (DecorationAreaType) prop; } return null; } /** * Paints the decoration background on the specified component. The * decoration background is not painted when the force * parameter is false and at least one of the following * conditions holds: *
    *
  • The component is in a cell renderer.
  • *
  • The component is not showing on the screen.
  • *
  • The component is in the preview mode.
  • *
* * @param g * Graphics context. * @param c * Component. * @param force * If true, the painting of decoration background is * enforced. */ public static void paintDecorationBackground(Graphics g, Component c, boolean force) { DecorationAreaType decorationType = SubstanceLookAndFeel .getDecorationType(c); paintDecorationBackground(g, c, decorationType, force); } /** * Paints the decoration background on the specified component. See comments * on {@link #paintDecorationBackground(Graphics, Component, boolean)} for * the cases when the decoration background painting is skipped. * * @param g * Graphics context. * @param c * Component. * @param decorationType * Decoration area type of the component. * @param force * If true, the painting of decoration background is * enforced. #see * {@link #paintDecorationBackground(Graphics, Component, boolean)} */ private static void paintDecorationBackground(Graphics g, Component c, DecorationAreaType decorationType, boolean force) { // System.out.println("Painting " + c.getClass().getSimpleName()); boolean isInCellRenderer = (c.getParent() instanceof CellRendererPane); boolean isPreviewMode = false; if (c instanceof JComponent) { isPreviewMode = (Boolean.TRUE.equals(((JComponent) c) .getClientProperty(LafWidgetUtilities.PREVIEW_MODE))); } if (!force && !isPreviewMode && !c.isShowing() && !isInCellRenderer) { return; } if ((c.getHeight() == 0) || (c.getWidth() == 0)) return; SubstanceSkin skin = SubstanceCoreUtilities.getSkin(c); SubstanceDecorationPainter painter = skin.getDecorationPainter(); Graphics2D g2d = (Graphics2D) g.create(); painter.paintDecorationArea(g2d, c, decorationType, c.getWidth(), c .getHeight(), skin); SubstanceWatermark watermark = SubstanceCoreUtilities.getSkin(c) .getWatermark(); if ((watermark != null) && !isPreviewMode && !isInCellRenderer && c.isShowing() && SubstanceCoreUtilities.toDrawWatermark(c)) { // paint the watermark over the component watermark.drawWatermarkImage(g2d, c, 0, 0, c.getWidth(), c .getHeight()); // paint the background second time with 50% // translucency, making the watermark' bleed' through. g2d.setComposite(TransitionLayout.getAlphaComposite(c, 0.5f, g)); painter.paintDecorationArea(g2d, c, decorationType, c.getWidth(), c .getHeight(), skin); } g2d.dispose(); } } substance-5.3.orig/src/org/jvnet/substance/painter/utils/OverlayPainterUtils.java0000644000175000017500000000604111247122100030317 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.utils; import java.awt.*; import java.util.List; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.api.painter.overlay.SubstanceOverlayPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; /** * Contains utility methods related to overlay painters. This class is for * internal use only. * * @author Kirill Grouchnikov */ public class OverlayPainterUtils { /** * Paints all registered overlays on the specified component. Overlay * painters are registered with * {@link SubstanceSkin#addOverlayPainter(SubstanceOverlayPainter, DecorationAreaType...)} * API. * * @param g * Graphics context. * @param c * Component. * @param skin * Component skin. * @param decorationAreaType * Component decoration area type. */ public static void paintOverlays(Graphics g, Component c, SubstanceSkin skin, DecorationAreaType decorationAreaType) { List overlayPainters = skin .getOverlayPainters(decorationAreaType); if (overlayPainters.size() == 0) return; for (SubstanceOverlayPainter overlayPainter : overlayPainters) { Graphics2D g2d = (Graphics2D) g.create(); overlayPainter.paintOverlay(g2d, c, decorationAreaType, c .getWidth(), c.getHeight(), skin); g2d.dispose(); } } } substance-5.3.orig/src/org/jvnet/substance/painter/utils/HighlightPainterUtils.java0000644000175000017500000002622311246715770030635 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.utils; import java.awt.*; import java.awt.geom.GeneralPath; import java.awt.image.BufferedImage; import java.util.EnumSet; import java.util.Set; import javax.swing.CellRendererPane; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.api.*; import org.jvnet.substance.api.SubstanceConstants.Side; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.highlight.SubstanceHighlightPainter; import org.jvnet.substance.utils.*; /** * Contains utility methods related to highlight painters. This class is for * internal use only. * * @author Kirill Grouchnikov */ public class HighlightPainterUtils { /** * Cache for small objects. */ protected final static LazyResettableHashMap smallCache = new LazyResettableHashMap( "SubstanceHighlightUtils"); /** * Updates the specified component with the background that matches the * provided parameters. * * @param g * Graphic context. * @param rendererPane * Renderer pane. Can be null. * @param c * Component. * @param rect * Rectangle to highlight. * @param borderAlpha * Border alpha. * @param openSides * The sides specified in this set will not be painted. Can be * null or empty. * @param currState * The current state of the component. * @param prevState * The previous state of the component. * @param cyclePos * Cycle position. Is used for rollover and pulsation effects. * Must be in 0..1 range. */ public static void paintHighlight(Graphics g, CellRendererPane rendererPane, Component c, Rectangle rect, float borderAlpha, Set openSides, ComponentState currState, ComponentState prevState, float cyclePos) { // fix for bug 65 if ((rect.width <= 0) || (rect.height <= 0)) return; // fix for issue 442 - use renderer pane for computing the // color schemes when necessary Component compForQuerying = (rendererPane != null) ? rendererPane : c; SubstanceColorScheme currScheme = SubstanceColorSchemeUtilities .getColorScheme(compForQuerying, ColorSchemeAssociationKind.HIGHLIGHT, currState); SubstanceColorScheme prevScheme = (cyclePos > 0.0f) ? SubstanceColorSchemeUtilities .getColorScheme(compForQuerying, ColorSchemeAssociationKind.HIGHLIGHT, prevState) : currScheme; SubstanceColorScheme currBorderScheme = SubstanceColorSchemeUtilities .getColorScheme(compForQuerying, ColorSchemeAssociationKind.HIGHLIGHT_BORDER, currState); SubstanceColorScheme prevBorderScheme = (cyclePos > 0.0f) ? SubstanceColorSchemeUtilities .getColorScheme(compForQuerying, ColorSchemeAssociationKind.HIGHLIGHT_BORDER, prevState) : currBorderScheme; // if (c instanceof JMenu) { // System.out.println(((JMenu) c).getText() + ":" + prevState + " [" // + prevScheme.getDisplayName() + "] -> " + currState + " [" // + currScheme.getDisplayName() + "]"); // } paintHighlight(g, rendererPane, c, rect, borderAlpha, openSides, currScheme, prevScheme, currBorderScheme, prevBorderScheme, cyclePos); } /** * Paints the highlight for the specified component. * * @param g * Graphic context. * @param rendererPane * Renderer pane. Can be null. * @param c * Component. * @param rect * Rectangle to highlight. * @param borderAlpha * Border alpha. * @param openSides * The sides specified in this set will not be painted. Can be * null or empty. * @param currScheme * The first color scheme. * @param prevScheme * The second color scheme. * @param currBorderScheme * The first border color scheme. * @param prevBorderScheme * The second border color scheme. * @param cyclePos * Cycle position. Is used for rollover and pulsation effects. * Must be in 0..1 range. */ public static void paintHighlight(Graphics g, CellRendererPane rendererPane, Component c, Rectangle rect, float borderAlpha, Set openSides, SubstanceColorScheme currScheme, SubstanceColorScheme prevScheme, SubstanceColorScheme currBorderScheme, SubstanceColorScheme prevBorderScheme, float cyclePos) { // fix for bug 65 if ((rect.width <= 0) || (rect.height <= 0)) return; Component compForQuerying = (rendererPane != null) ? rendererPane : c; SubstanceHighlightPainter highlightPainter = SubstanceCoreUtilities .getSkin(compForQuerying).getHighlightPainter(); SubstanceBorderPainter highlightBorderPainter = SubstanceCoreUtilities .getHighlightBorderPainter(compForQuerying); Graphics2D g2d = (Graphics2D) g.create(rect.x, rect.y, rect.width, rect.height); if (openSides == null) { openSides = EnumSet.noneOf(Side.class); } if (rect.width * rect.height < 100000) { String openKey = ""; for (Side oSide : openSides) { openKey += oSide.name() + "-"; } HashMapKey key = SubstanceCoreUtilities.getHashKey(highlightPainter .getDisplayName(), highlightBorderPainter.getDisplayName(), rect.width, rect.height, currScheme.getDisplayName(), prevScheme.getDisplayName(), currBorderScheme .getDisplayName(), prevBorderScheme .getDisplayName(), cyclePos, borderAlpha, openKey); BufferedImage result = smallCache.get(key); if (result == null) { // System.out.println("Cache miss"); result = SubstanceCoreUtilities.getBlankImage(rect.width, rect.height); Graphics2D resGraphics = result.createGraphics(); highlightPainter.paintHighlight(resGraphics, c, rect.width, rect.height, openSides, currScheme, prevScheme, cyclePos); paintHighlightBorder(resGraphics, c, rect.width, rect.height, borderAlpha, openSides, highlightBorderPainter, currBorderScheme, prevBorderScheme, cyclePos); resGraphics.dispose(); smallCache.put(key, result); } else { // System.out.println("Cache hit"); } g2d.drawImage(result, 0, 0, null); return; } highlightPainter.paintHighlight(g2d, c, rect.width, rect.height, openSides, currScheme, prevScheme, cyclePos); paintHighlightBorder(g2d, c, rect.width, rect.height, borderAlpha, openSides, highlightBorderPainter, currBorderScheme, prevBorderScheme, cyclePos); g2d.dispose(); } /** * Paints the highlight border for the specified component. * * @param graphics * Graphic context. * @param comp * Component. * @param width * Border width. * @param height * Border width. * @param borderAlpha * Border alpha. * @param openSides * The sides specified in this set will not be painted. Can be * null or empty. * @param highlightBorderPainter * Border painter for the highlights. * @param borderColorScheme1 * The first border color scheme. * @param borderColorScheme2 * The second border color scheme. * @param cyclePos * Cycle position. Is used for rollover and pulsation effects. * Must be in 0..1 range. */ private static void paintHighlightBorder(Graphics2D graphics, Component comp, int width, int height, float borderAlpha, Set openSides, SubstanceBorderPainter highlightBorderPainter, SubstanceColorScheme borderColorScheme1, SubstanceColorScheme borderColorScheme2, float cyclePos) { if (borderAlpha <= 0.0f) return; int openDelta = 3 + (int) (Math.ceil(3.0 * SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(comp)))); int deltaLeft = openSides.contains(Side.LEFT) ? openDelta : 0; int deltaRight = openSides.contains(Side.RIGHT) ? openDelta : 0; int deltaTop = openSides.contains(Side.TOP) ? openDelta : 0; int deltaBottom = openSides.contains(Side.BOTTOM) ? openDelta : 0; int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(comp)) / 2.0); GeneralPath contour = SubstanceOutlineUtilities.getBaseOutline(width + deltaLeft + deltaRight, height + deltaTop + deltaBottom, 0.0f, null, borderDelta); Graphics2D g2d = (Graphics2D) graphics.create(); g2d.translate(-deltaLeft, -deltaTop); g2d.setComposite(TransitionLayout.getAlphaComposite(null, borderAlpha, graphics)); int borderThickness = (int) SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(comp)); GeneralPath contourInner = SubstanceOutlineUtilities.getBaseOutline( width + deltaLeft + deltaRight, height + deltaTop + deltaBottom, 0.0f, null, borderDelta + borderThickness); highlightBorderPainter.paintBorder(g2d, comp, width + deltaLeft + deltaRight, height + deltaTop + deltaBottom, contour, contourInner, borderColorScheme1, borderColorScheme2, cyclePos, true); g2d.dispose(); } /** * Returns the memory usage string. * * @return Memory usage string. */ public static String getMemoryUsage() { StringBuffer sb = new StringBuffer(); sb.append("SubstanceHighlightUtils: \n"); sb.append("\t" + smallCache.size() + " smalls"); return sb.toString(); } } substance-5.3.orig/src/org/jvnet/substance/painter/highlight/0000755000175000017500000000000011256731150024310 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/painter/highlight/ClassicHighlightPainter.java0000644000175000017500000000630111150161064031701 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.highlight; import java.awt.*; import java.util.Set; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.SubstanceConstants.Side; import org.jvnet.substance.painter.gradient.ClassicGradientPainter; /** * Highlight painter that paints a classic gradient. This class is part of * officially supported API. * * @author Kirill Grouchnikov * @since version 4.3 */ public class ClassicHighlightPainter implements SubstanceHighlightPainter { /** * The display name for the highlight painters of this class. */ public static final String DISPLAY_NAME = "Classic"; /** * Single gradient painter instance. */ protected ClassicGradientPainter painter; /** * Creates new classic title painter. */ public ClassicHighlightPainter() { this.painter = new ClassicGradientPainter(); } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.SubstanceGradientPainter#getDisplayName() */ public String getDisplayName() { return DISPLAY_NAME; } @Override public void paintHighlight(Graphics2D graphics, Component comp, int width, int height, Set openSides, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos) { Graphics2D g2d = (Graphics2D) graphics.create(); g2d.translate(-3, -3); this.painter.paintContourBackground(g2d, comp, width + 6, height + 6, new Rectangle(width + 6, height + 6), false, colorScheme1, colorScheme2, cyclePos, false, true); g2d.dispose(); } } substance-5.3.orig/src/org/jvnet/substance/painter/highlight/GlassHighlightPainter.java0000644000175000017500000000626111150161124031373 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.highlight; import java.awt.*; import java.util.Set; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.SubstanceConstants.Side; import org.jvnet.substance.painter.gradient.GlassGradientPainter; /** * Highlight painter that paints a glass gradient. This class is part of * officially supported API. * * @author Kirill Grouchnikov * @since version 4.3 */ public class GlassHighlightPainter implements SubstanceHighlightPainter { /** * The display name for the highlight painters of this class. */ public static final String DISPLAY_NAME = "Glass"; /** * Single gradient painter instance. */ protected GlassGradientPainter painter; /** * Creates new classic title painter. */ public GlassHighlightPainter() { this.painter = new GlassGradientPainter(); } /* * (non-Javadoc) * * @see * org.jvnet.substance.painter.SubstanceGradientPainter#getDisplayName() */ public String getDisplayName() { return DISPLAY_NAME; } @Override public void paintHighlight(Graphics2D graphics, Component comp, int width, int height, Set openSides, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos) { Graphics2D g2d = (Graphics2D) graphics.create(); g2d.translate(-3, -3); this.painter.paintContourBackground(g2d, comp, width + 6, height + 6, new Rectangle(width + 6, height + 6), false, colorScheme1, colorScheme2, cyclePos, false, true); g2d.dispose(); } } substance-5.3.orig/src/org/jvnet/substance/painter/highlight/SubstanceHighlightPainter.java0000644000175000017500000000635611150161034032256 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.painter.highlight; import java.awt.Component; import java.awt.Graphics2D; import java.util.Set; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.SubstanceConstants.Side; import org.jvnet.substance.api.trait.SubstanceTrait; /** * Highlight painter interface for Substance look and feel. This class is * part of officially supported API.
*
* * @author Kirill Grouchnikov * @since version 4.3 */ public interface SubstanceHighlightPainter extends SubstanceTrait { /** * Paints the highlight. * * @param graphics * Graphics context. * @param comp * Component. * @param width * Width. * @param height * Height. * @param borderAlpha * Border alpha factor. * @param openSides * The sides specified in this set will not be painted. Can be * null or empty. * @param colorScheme1 * The first color scheme. * @param colorScheme2 * The second color scheme. * @param borderColorScheme1 * The first border color scheme. * @param borderColorScheme2 * The second border color scheme. * @param cyclePos * Cycle position. Is used for rollover and selection animations. * Must be in 0..1 range. */ public void paintHighlight(Graphics2D graphics, Component comp, int width, int height, Set openSides, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos); } substance-5.3.orig/src/org/jvnet/substance/watermark/0000755000175000017500000000000011256731152022676 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/watermark/SubstanceWatermark.java0000644000175000017500000000667211136475562027370 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.watermark; import java.awt.Component; import java.awt.Graphics; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.api.trait.SubstanceTrait; /** * Interface for watermarks. This class is part of officially supported API. * * @author Kirill Grouchnikov */ public interface SubstanceWatermark extends SubstanceTrait { /** * Draws the watermark on the specified graphics context in the specified * region. * * @param graphics * Graphics context. * @param c * Component that is painted. * @param x * Left X of the region. * @param y * Top Y of the region. * @param width * Region width. * @param height * Region height. */ public void drawWatermarkImage(Graphics graphics, Component c, int x, int y, int width, int height); /** * Updates the current watermark image. * * @param skin * Skin for the watermark. * @return true if the watermark has been updated successfully, * false otherwise. */ public boolean updateWatermarkImage(SubstanceSkin skin); /** * Draws the preview of the watermark image. * * @param g * Graphic context. * @param x * the x coordinate of the watermark to be drawn. * @param y * The y coordinate of the watermark to be drawn. * @param width * The width of the watermark to be drawn. * @param height * The height of the watermark to be drawn. */ public void previewWatermark(Graphics g, int x, int y, int width, int height); /** * Disposes the memory associated with this watermark. */ public void dispose(); } substance-5.3.orig/src/org/jvnet/substance/watermark/SubstanceNullWatermark.java0000644000175000017500000000712111136475562030211 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.watermark; import java.awt.*; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.utils.SubstanceCoreUtilities; /** * Implementation of {@link SubstanceWatermark} that paints a translucent fill * (with no pattern). This class is part of officially supported API. * * @author Kirill Grouchnikov * @author Chris Hall */ public class SubstanceNullWatermark implements SubstanceWatermark { /** * Simple constructor. */ public SubstanceNullWatermark() { } /* * (non-Javadoc) * * @see * org.jvnet.substance.watermark.SubstanceWatermark#drawWatermarkImage(java * .awt.Graphics, int, int, int, int) */ public void drawWatermarkImage(Graphics graphics, Component c, int x, int y, int width, int height) { SubstanceSkin skin = SubstanceCoreUtilities.getSkin(c); Graphics2D g2d = (Graphics2D) graphics.create(); g2d.setComposite(TransitionLayout.getAlphaComposite(c, 0.2f, graphics)); g2d.setColor(skin.getWatermarkColorScheme().getWatermarkLightColor()); g2d.fillRect(x, y, width, height); g2d.dispose(); } /* * (non-Javadoc) * * @see * org.jvnet.substance.watermark.SubstanceWatermark#previewWatermark(java * .awt.Graphics, int, int, int, int) */ public void previewWatermark(Graphics g, int x, int y, int width, int height) { } /* * (non-Javadoc) * * @see * org.jvnet.substance.watermark.SubstanceWatermark#updateWatermarkImage * (org.jvnet.substance.skin.SubstanceSkin) */ public boolean updateWatermarkImage(SubstanceSkin skin) { return true; } /* * (non-Javadoc) * * @see org.jvnet.substance.api.trait.SubstanceTrait#getDisplayName() */ public String getDisplayName() { return "Null"; } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#dispose() */ public void dispose() { } }substance-5.3.orig/src/org/jvnet/substance/watermark/SubstanceNoiseWatermark.java0000644000175000017500000001355311126424404030346 0ustar drazzibdrazzibpackage org.jvnet.substance.watermark; import java.awt.*; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.painter.noise.NoiseFactory; import org.jvnet.substance.painter.noise.NoiseFilter; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; /** * Base class for noise-based watermarks. This class is part of officially * supported API. * * @author Kirill Grouchnikov */ public class SubstanceNoiseWatermark implements SubstanceWatermark { /** * Watermark image (screen-sized). */ private Image watermarkImage = null; /** * Display name of this watermark. */ protected String displayName; /** * Factor along X axis. */ protected double xFactor; /** * Factor along Y axis. */ protected double yFactor; /** * Indicates whether this watermark is based on constant Z * values. */ protected boolean hasConstantZ; /** * Noise filter of this watermark. */ protected NoiseFilter noiseFilter; /** * Indicates whether the resulting image (after applying the * {@link #noiseFilter}) should be blurred. */ protected boolean toBlur; /** * Creates a new noise-based watermark. * * @param displayName * Display name of this watermark. * @param xFactor * Factor along X axis. * @param yFactor * Factor along Y axis. * @param hasConstantZ * Indicates whether this watermark is based on * constant Z values. * @param noiseFilter * Noise filter of this watermark. * @param toBlur * Indicates whether the resulting image should be blurred. */ public SubstanceNoiseWatermark(String displayName, double xFactor, double yFactor, boolean hasConstantZ, NoiseFilter noiseFilter, boolean toBlur) { this.displayName = displayName; this.xFactor = xFactor; this.yFactor = yFactor; this.hasConstantZ = hasConstantZ; this.noiseFilter = noiseFilter; this.toBlur = toBlur; } /* * (non-Javadoc) * * @see * org.jvnet.substance.watermark.SubstanceWatermark#drawWatermarkImage(java * .awt.Graphics, java.awt.Component, int, int, int, int) */ public void drawWatermarkImage(Graphics graphics, Component c, int x, int y, int width, int height) { if (!c.isShowing()) return; int dx = c.getLocationOnScreen().x; int dy = c.getLocationOnScreen().y; graphics.drawImage(this.watermarkImage, x, y, x + width, y + height, x + dx, y + dy, x + dx + width, y + dy + height, null); } /* * (non-Javadoc) * * @see * org.jvnet.substance.watermark.SubstanceWatermark#updateWatermarkImage * (org.jvnet.substance.skin.SubstanceSkin) */ public boolean updateWatermarkImage(SubstanceSkin skin) { // fix by Chris for bug 67 - support for multiple screens Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice gd : gds) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); virtualBounds = virtualBounds.union(gc.getBounds()); } int screenWidth = virtualBounds.width; int screenHeight = virtualBounds.height; this.watermarkImage = SubstanceCoreUtilities.getBlankImage(screenWidth, screenHeight); Graphics2D graphics = (Graphics2D) this.watermarkImage.getGraphics() .create(); boolean status = this.drawWatermarkImage(skin, graphics, 0, 0, screenWidth, screenHeight, false); graphics.dispose(); return status; } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#getDisplayName() */ public String getDisplayName() { return this.displayName; } /* * (non-Javadoc) * * @see * org.jvnet.substance.watermark.SubstanceWatermark#previewWatermark(java * .awt.Graphics, int, int, int, int) */ public void previewWatermark(Graphics g, int x, int y, int width, int height) { this.drawWatermarkImage(SubstanceColorSchemeUtilities.METALLIC_SKIN, (Graphics2D) g, x, y, width, height, true); } /** * Draws the specified portion of the watermark image. * * @param skin * Skin to use for painting the watermark. * @param graphics * Graphic context. * @param x * the x coordinate of the watermark to be drawn. * @param y * The y coordinate of the watermark to be drawn. * @param width * The width of the watermark to be drawn. * @param height * The height of the watermark to be drawn. * @param isPreview * Indication whether the result is a preview image. * @return Indication whether the draw succeeded. */ private boolean drawWatermarkImage(SubstanceSkin skin, Graphics2D graphics, int x, int y, int width, int height, boolean isPreview) { SubstanceColorScheme scheme = skin.getWatermarkColorScheme(); if (isPreview) { graphics.drawImage(NoiseFactory.getNoiseImage(skin, width, height, this.xFactor, this.yFactor, this.hasConstantZ, this.noiseFilter, this.toBlur, true), x, y, null); } else { int alpha = scheme.isDark() ? 200 : 140; graphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, alpha / 255.0f)); graphics.drawImage(NoiseFactory.getNoiseImage(skin, width, height, this.xFactor, this.yFactor, this.hasConstantZ, this.noiseFilter, this.toBlur, false), x, y, null); } return true; } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#dispose() */ public void dispose() { this.watermarkImage = null; } } substance-5.3.orig/src/org/jvnet/substance/watermark/SubstanceCrosshatchWatermark.java0000644000175000017500000001563111136475562031405 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.watermark; import java.awt.*; import java.awt.image.BufferedImage; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; /** * Simple implementation of {@link SubstanceWatermark}, drawing cross hatches as * watermark. This implementation is inspired by Office 12 background. This * class is part of officially supported API. * * @author Kirill Grouchnikov * @author Chris Hall */ public class SubstanceCrosshatchWatermark implements SubstanceWatermark { /** * Watermark image (screen-sized). */ private static Image watermarkImage = null; /* * (non-Javadoc) * * @see * org.jvnet.substance.watermark.SubstanceWatermark#drawWatermarkImage(java * .awt.Graphics, int, int, int, int) */ public void drawWatermarkImage(Graphics graphics, Component c, int x, int y, int width, int height) { if (!c.isShowing()) return; int dx = c.getLocationOnScreen().x; int dy = c.getLocationOnScreen().y; graphics.drawImage(SubstanceCrosshatchWatermark.watermarkImage, x, y, x + width, y + height, x + dx, y + dy, x + dx + width, y + dy + height, null); } /* * (non-Javadoc) * * @see * org.jvnet.substance.watermark.SubstanceWatermark#updateWatermarkImage * (org.jvnet.substance.skin.SubstanceSkin) */ public boolean updateWatermarkImage(SubstanceSkin skin) { // fix by Chris for bug 67 - support for multiple screens Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice gd : gds) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); virtualBounds = virtualBounds.union(gc.getBounds()); } int screenWidth = virtualBounds.width; int screenHeight = virtualBounds.height; SubstanceCrosshatchWatermark.watermarkImage = SubstanceCoreUtilities .getBlankImage(screenWidth, screenHeight); Graphics2D graphics = (Graphics2D) SubstanceCrosshatchWatermark.watermarkImage .getGraphics().create(); boolean status = this.drawWatermarkImage(skin, graphics, 0, 0, screenWidth, screenHeight, false); graphics.dispose(); return status; } /* * (non-Javadoc) * * @see * org.jvnet.substance.watermark.SubstanceWatermark#previewWatermark(java * .awt.Graphics, int, int, int, int) */ public void previewWatermark(Graphics g, int x, int y, int width, int height) { this.drawWatermarkImage(SubstanceColorSchemeUtilities.METALLIC_SKIN, (Graphics2D) g, x, y, width, height, true); } /** * Draws the specified portion of the watermark image. * * @param skin * Skin to use for painting the watermark. * @param graphics * Graphic context. * @param x * the x coordinate of the watermark to be drawn. * @param y * The y coordinate of the watermark to be drawn. * @param width * The width of the watermark to be drawn. * @param height * The height of the watermark to be drawn. * @param isPreview * Indication whether the result is a preview image. * @return Indication whether the draw succeeded. */ private boolean drawWatermarkImage(SubstanceSkin skin, Graphics2D graphics, int x, int y, int width, int height, boolean isPreview) { Color stampColorDark = null; Color stampColorAll = null; Color stampColorLight = null; SubstanceColorScheme scheme = skin.getWatermarkColorScheme(); if (isPreview) { stampColorDark = scheme.isDark() ? Color.white : Color.black; stampColorAll = Color.lightGray; stampColorLight = scheme.isDark() ? Color.black : Color.white; } else { stampColorDark = scheme.getWatermarkDarkColor(); stampColorAll = scheme.getWatermarkStampColor(); stampColorLight = scheme.getWatermarkLightColor(); } graphics.setColor(stampColorAll); graphics.fillRect(0, 0, width, height); BufferedImage tile = SubstanceCoreUtilities.getBlankImage(4, 4); tile.setRGB(0, 0, stampColorDark.getRGB()); tile.setRGB(2, 2, stampColorDark.getRGB()); tile.setRGB(0, 1, stampColorLight.getRGB()); tile.setRGB(2, 3, stampColorLight.getRGB()); Graphics2D g2d = (Graphics2D) graphics.create(); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f)); for (int row = y; row < (y + height); row += 4) { for (int col = x; col < (x + width); col += 4) { g2d.drawImage(tile, col, row, null); } } g2d.dispose(); return true; } /* * (non-Javadoc) * * @see org.jvnet.substance.api.trait.SubstanceTrait#getDisplayName() */ public String getDisplayName() { return SubstanceCrosshatchWatermark.getName(); } /** * Returns the name of all watermarks of this class. * * @return The name of all watermarks of this class. */ public static String getName() { return "Crosshatch"; } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#dispose() */ public void dispose() { watermarkImage = null; } } substance-5.3.orig/src/org/jvnet/substance/watermark/SubstanceImageWatermark.java0000644000175000017500000003230411136475562030322 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.watermark; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import java.io.InputStream; import java.net.URL; import javax.imageio.IIOException; import javax.imageio.ImageIO; import javax.swing.JComponent; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceApi; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.api.SubstanceConstants.ImageWatermarkKind; import org.jvnet.substance.utils.SubstanceCoreUtilities; /** * Implementation of {@link SubstanceWatermark}, drawing specified image as * watermark. This class is part of officially supported API. * * @author Kirill Grouchnikov * @author Chris Hall * @author Mark Haag */ public class SubstanceImageWatermark implements SubstanceWatermark { /** * Watermark image (screen-sized). */ protected Image watermarkImage = null; /** * Watermark image kind. */ private ImageWatermarkKind kind = ImageWatermarkKind.SCREEN_CENTER_SCALE; /** * Watermark image opacity. */ private float opacity = 0.2f; /** * The original image (as read from the disk / HTTP connection). */ protected BufferedImage origImage; /** * The original image location. */ protected String origImageLocation; /** * Creates an instance with specified image. * * @param imageLocation * Image location. Can point to a local file or HTTP URL (needs * to start with http in the later case). */ @SubstanceApi public SubstanceImageWatermark(String imageLocation) { if (imageLocation != null) { try { if (imageLocation.startsWith("http")) { URL url = new URL(imageLocation); BufferedImage tempImage = ImageIO.read(url); this.origImage = SubstanceCoreUtilities .createCompatibleImage(tempImage); } else { try { this.origImage = SubstanceCoreUtilities .createCompatibleImage(ImageIO.read(new File( imageLocation))); } catch (IIOException iioe) { this.origImage = SubstanceCoreUtilities .createCompatibleImage(ImageIO .read(SubstanceImageWatermark.class .getClassLoader().getResource( imageLocation))); } } } catch (Exception exc) { // ignore - probably specified incorrect file // or file is not image exc.printStackTrace(); } } this.origImageLocation = imageLocation; } /** * Creates an instance from the specified input stream. * * @param inputStream * Input stream. */ @SubstanceApi public SubstanceImageWatermark(InputStream inputStream) { if (inputStream != null) { try { BufferedImage tempImage = ImageIO.read(inputStream); this.origImage = SubstanceCoreUtilities .createCompatibleImage(tempImage); } catch (Exception exc) { // ignore - probably specified incorrect input stream // or stream doesn't contain an image exc.printStackTrace(); } } this.origImageLocation = null; } /* * (non-Javadoc) * * @see * org.jvnet.substance.watermark.SubstanceWatermark#drawWatermarkImage(java * .awt.Graphics, int, int, int, int) */ public void drawWatermarkImage(Graphics graphics, Component c, int x, int y, int width, int height) { if (!c.isShowing()) return; int dx = 0; int dy = 0; Component topParent = null; switch (getKind()) { case SCREEN_CENTER_SCALE: case SCREEN_TILE: dx = c.getLocationOnScreen().x; dy = c.getLocationOnScreen().y; break; case APP_ANCHOR: case APP_TILE: if (c instanceof JComponent) { topParent = ((JComponent) c).getTopLevelAncestor(); } else { Component comp = c; while (comp.getParent() != null) { comp = comp.getParent(); } topParent = comp; } dx = c.getLocationOnScreen().x - topParent.getLocationOnScreen().x; dy = c.getLocationOnScreen().y - topParent.getLocationOnScreen().y; break; case APP_CENTER: if (c instanceof JComponent) { topParent = ((JComponent) c).getTopLevelAncestor(); } else { Component comp = c; while (comp.getParent() != null) { comp = comp.getParent(); } topParent = comp; } dx = c.getLocationOnScreen().x - topParent.getLocationOnScreen().x; dy = c.getLocationOnScreen().y - topParent.getLocationOnScreen().y; dx -= (topParent.getWidth() / 2 - this.origImage.getWidth() / 2); dy -= (topParent.getHeight() / 2 - this.origImage.getHeight() / 2); } graphics.drawImage(watermarkImage, x, y, x + width, y + height, x + dx, y + dy, x + dx + width, y + dy + height, null); } /* * (non-Javadoc) * * @see * org.jvnet.substance.watermark.SubstanceWatermark#previewWatermark(java * .awt.Graphics, int, int, int, int) */ public void previewWatermark(Graphics g, int x, int y, int width, int height) { } /* * (non-Javadoc) * * @see * org.jvnet.substance.watermark.SubstanceWatermark#updateWatermarkImage * (org.jvnet.substance.skin.SubstanceSkin) */ public boolean updateWatermarkImage(SubstanceSkin skin) { if (this.origImage == null) { return false; } // fix by Chris for bug 67 - support for multiple screens Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice gd : gds) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); virtualBounds = virtualBounds.union(gc.getBounds()); } int screenWidth = virtualBounds.width; int screenHeight = virtualBounds.height; int origImageWidth = this.origImage.getWidth(); int origImageHeight = this.origImage.getHeight(); if (getKind() == ImageWatermarkKind.SCREEN_CENTER_SCALE) { watermarkImage = SubstanceCoreUtilities.getBlankImage(screenWidth, screenHeight); Graphics2D graphics = (Graphics2D) watermarkImage.getGraphics() .create(); Composite comp = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, opacity); graphics.setComposite(comp); // decide if need to scale or center boolean isWidthFits = (origImageWidth <= screenWidth); boolean isHeightFits = (origImageHeight <= screenHeight); // see of need to scale or simply center if (isWidthFits && isHeightFits) { graphics.drawImage(this.origImage, (screenWidth - origImageWidth) / 2, (screenHeight - origImageHeight) / 2, null); graphics.dispose(); return true; } if (isWidthFits) { // height doesn't fit double scaleFact = (double) screenHeight / (double) origImageHeight; int dx = (int) (screenWidth - scaleFact * origImageWidth) / 2; // The following line is Mark Haag's to make the // scaling less jaggy graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); graphics.drawImage(this.origImage, dx, 0, screenWidth - dx, screenHeight, 0, 0, origImageWidth, origImageHeight, null); graphics.dispose(); return true; } if (isHeightFits) { // width doesn't fit double scaleFact = (double) screenWidth / (double) origImageWidth; int dy = (int) (screenHeight - scaleFact * origImageHeight) / 2; // The following line is Mark Haag's to make the // scaling less jaggy graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); graphics.drawImage(this.origImage, 0, dy, screenWidth, screenHeight - dy, 0, 0, origImageWidth, origImageHeight, null); graphics.dispose(); return true; } // none fits double scaleFactY = (double) screenHeight / (double) origImageHeight; double scaleFactX = (double) screenWidth / (double) origImageWidth; double scaleFact = Math.min(scaleFactX, scaleFactY); int dx = Math.max(0, (int) (screenWidth - scaleFact * origImageWidth) / 2); int dy = Math.max(0, (int) (screenHeight - scaleFact * origImageHeight) / 2); // The following line is Mark Haag's to make the // scaling less jaggy graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); graphics.drawImage(this.origImage, dx, dy, screenWidth - dx, screenHeight - dy, 0, 0, origImageWidth, origImageHeight, null); graphics.dispose(); return true; } if ((getKind() == ImageWatermarkKind.SCREEN_TILE) || (getKind() == ImageWatermarkKind.APP_TILE)) { watermarkImage = SubstanceCoreUtilities.getBlankImage(screenWidth, screenHeight); Graphics2D graphics = (Graphics2D) watermarkImage.getGraphics() .create(); Composite comp = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, opacity); graphics.setComposite(comp); int replicateX = 1 + screenWidth / origImageWidth; int replicateY = 1 + screenHeight / origImageHeight; for (int i = 0; i < replicateX; i++) { for (int j = 0; j < replicateY; j++) { graphics.drawImage(this.origImage, i * origImageWidth, j * origImageHeight, null); } } graphics.dispose(); return true; } if ((getKind() == ImageWatermarkKind.APP_ANCHOR) || (getKind() == ImageWatermarkKind.APP_CENTER)) { watermarkImage = SubstanceCoreUtilities.getBlankImage( origImageWidth, origImageHeight); Graphics2D graphics = (Graphics2D) watermarkImage.getGraphics() .create(); Composite comp = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, opacity); graphics.setComposite(comp); graphics.drawImage(this.origImage, 0, 0, null); graphics.dispose(); return true; } return false; } /* * (non-Javadoc) * * @see org.jvnet.substance.api.trait.SubstanceTrait#getDisplayName() */ public String getDisplayName() { return "Image"; } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#dispose() */ public void dispose() { watermarkImage = null; } /** * Returns the location of the original image. * * @return The location of the original image. */ public String getOrigImageLocation() { return this.origImageLocation; } /** * Sets image watermark kind. * * @param kind * Image watermark kind. */ @SubstanceApi public void setKind(ImageWatermarkKind kind) { if (kind == null) { throw new IllegalArgumentException( "Can't pass null to SubstanceImageWatermark.setKind()"); } this.kind = kind; this.updateWatermarkImage(SubstanceLookAndFeel.getCurrentSkin(null)); } /** * Returns the image watermark kind. * * @return Image watermark kind. */ @SubstanceApi public ImageWatermarkKind getKind() { return this.kind; } /** * Returns the image watermark opacity. * * @return Image watermark opacity. */ @SubstanceApi public float getOpacity() { return this.opacity; } /** * Sets image watermark opacity. * * @param opacity * Image watermark opacity. * @throws IllegalArgumentException * if the argument is not in 0.0-1.0 range. */ @SubstanceApi public void setOpacity(float opacity) { if ((opacity < 0.0f) || (opacity > 1.0f)) { throw new IllegalArgumentException( "SubstanceImageWatermark.setOpacity() can get value in 0.0-1.0 range, was passed value " + opacity); } this.opacity = opacity; this.updateWatermarkImage(SubstanceLookAndFeel.getCurrentSkin(null)); } }substance-5.3.orig/src/org/jvnet/substance/watermark/SubstancePlanktonWatermark.java0000644000175000017500000000447611136475562031077 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.watermark; import org.jvnet.substance.painter.noise.CompoundNoiseFilter; import org.jvnet.substance.painter.noise.MedianBeakFilter; /** * Noise-base implementation of * {@link org.jvnet.substance.watermark.SubstanceWatermark}, that imitates * plankton formation. This class is part of officially supported API. * * @author Kirill Grouchnikov */ public class SubstancePlanktonWatermark extends SubstanceNoiseWatermark { /** * Creates a new plankton watermark. */ public SubstancePlanktonWatermark() { super("Plankton", 0.1, 0.1, false, new CompoundNoiseFilter( new MedianBeakFilter(), new MedianBeakFilter()), false); } } substance-5.3.orig/src/org/jvnet/substance/watermark/SubstanceStripeWatermark.java0000644000175000017500000001424511136475562030552 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.watermark; import java.awt.*; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; /** * Simple implementation of * {@link org.jvnet.substance.watermark.SubstanceWatermark}, drawing darker even * lines as watermark. This is the default watermark implementation. This class * is part of officially supported API. * * @author Kirill Grouchnikov * @author Chris Hall */ public class SubstanceStripeWatermark implements SubstanceWatermark { /** * Watermark image (screen-sized). */ private static Image watermarkImage = null; /* * (non-Javadoc) * * @see * org.jvnet.substance.watermark.SubstanceWatermark#drawWatermarkImage(java * .awt.Graphics, int, int, int, int) */ public void drawWatermarkImage(Graphics graphics, Component c, int x, int y, int width, int height) { if (!c.isShowing()) return; // System.err.println(System.currentTimeMillis() + ":" // + c.getClass().getName() + ":" + x + ":" + y + ":" + width // + ":" + height); int dx = c.getLocationOnScreen().x; int dy = c.getLocationOnScreen().y; graphics.drawImage(SubstanceStripeWatermark.watermarkImage, x, y, x + width, y + height, x + dx, y + dy, x + dx + width, y + dy + height, null); } /* * (non-Javadoc) * * @see * org.jvnet.substance.watermark.SubstanceWatermark#updateWatermarkImage * (org.jvnet.substance.skin.SubstanceSkin) */ public boolean updateWatermarkImage(SubstanceSkin skin) { // fix by Chris for bug 67 - support for multiple screens Rectangle virtualBounds = new Rectangle(); GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice[] gds = ge.getScreenDevices(); for (GraphicsDevice gd : gds) { GraphicsConfiguration gc = gd.getDefaultConfiguration(); virtualBounds = virtualBounds.union(gc.getBounds()); } int screenWidth = virtualBounds.width; int screenHeight = virtualBounds.height; SubstanceStripeWatermark.watermarkImage = SubstanceCoreUtilities .getBlankImage(screenWidth, screenHeight); Graphics2D graphics = (Graphics2D) SubstanceStripeWatermark.watermarkImage .getGraphics().create(); boolean status = this.drawWatermarkImage(skin, graphics, 0, 0, screenWidth, screenHeight, false); graphics.dispose(); return status; } /* * (non-Javadoc) * * @see * org.jvnet.substance.watermark.SubstanceWatermark#previewWatermark(java * .awt.Graphics, int, int, int, int) */ public void previewWatermark(Graphics g, int x, int y, int width, int height) { this.drawWatermarkImage(SubstanceColorSchemeUtilities.METALLIC_SKIN, (Graphics2D) g, x, y, width, height, true); } /** * Draws the specified portion of the watermark image. * * @param skin * Skin to use for painting the watermark. * @param graphics * Graphic context. * @param x * the x coordinate of the watermark to be drawn. * @param y * The y coordinate of the watermark to be drawn. * @param width * The width of the watermark to be drawn. * @param height * The height of the watermark to be drawn. * @param isPreview * Indication whether the result is a preview image. * @return Indication whether the draw succeeded. */ private boolean drawWatermarkImage(SubstanceSkin skin, Graphics2D graphics, int x, int y, int width, int height, boolean isPreview) { Color stampColor = null; SubstanceColorScheme scheme = skin.getWatermarkColorScheme(); if (isPreview) stampColor = scheme.isDark() ? Color.lightGray : Color.darkGray; else { stampColor = scheme.getWatermarkStampColor(); } graphics.setColor(stampColor); for (int row = y; row < (y + height); row += 2) { graphics.drawLine(x, row, x + width, row); } if (isPreview) { graphics.setColor(Color.gray); for (int row = y + 1; row < (y + height); row += 2) { graphics.drawLine(x, row, x + width, row); } } return true; } /* * (non-Javadoc) * * @see org.jvnet.substance.api.trait.SubstanceTrait#getDisplayName() */ public String getDisplayName() { return "Stripes"; } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#dispose() */ public void dispose() { watermarkImage = null; } } substance-5.3.orig/src/org/jvnet/substance/SubstanceListUI.java0000644000175000017500000006300011256343460024565 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.awt.event.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.*; import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicListUI; import org.jvnet.lafwidget.LafWidgetUtilities; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.api.*; import org.jvnet.substance.api.renderers.SubstanceDefaultListCellRenderer; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.painter.utils.HighlightPainterUtils; import org.jvnet.substance.utils.*; /** * UI for lists in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceListUI extends BasicListUI { /** * Holds the list of currently selected indices. */ protected Map selectedIndices; /** * Holds the currently rolled-over index, or -1 is there is none such. */ protected int rolledOverIndex; /** * Property listener that listens to the * {@link SubstanceLookAndFeel#WATERMARK_TO_BLEED} property. */ protected PropertyChangeListener substancePropertyChangeListener; /** * Local cache of JList's client property "List.isFileList" */ protected boolean isFileList; /** * Local cache of JList's component orientation property */ protected boolean isLeftToRight; /** * Listener for fade animations on list selections. */ protected ListSelectionListener substanceFadeSelectionListener; /** * Listener for fade animations on list rollovers. */ protected RolloverFadeListener substanceFadeRolloverListener; /** * Map of previous fade states (for state-aware color scheme transitions). */ private Map prevStateMap; /** * Map of next fade states (for state-aware color scheme transitions). */ private Map nextStateMap; private ComponentListener substanceComponentListener; /** * Listener for fade animations on list rollovers. * * @author Kirill Grouchnikov */ private class RolloverFadeListener implements MouseListener, MouseMotionListener { public void mouseClicked(MouseEvent e) { } public void mouseEntered(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void mouseExited(MouseEvent e) { // if (SubstanceCoreUtilities.toBleedWatermark(list)) // return; fadeOutRolloverIndication(); // System.out.println("Nulling RO index"); resetRolloverIndex(); // rolledOverIndex = -1; // list.putClientProperty(ROLLED_OVER_INDEX, null); } public void mouseMoved(MouseEvent e) { // if (SubstanceCoreUtilities.toBleedWatermark(list)) // return; if (!list.isEnabled()) return; handleMove(e); } public void mouseDragged(MouseEvent e) { // if (SubstanceCoreUtilities.toBleedWatermark(list)) // return; if (!list.isEnabled()) return; handleMove(e); } /** * Handles various mouse move events and initiates the fade animation if * necessary. * * @param e * Mouse event. */ private void handleMove(MouseEvent e) { boolean fadeAllowed = !LafWidgetUtilities.hasNoFades(list, FadeKind.ROLLOVER); // no rollover effects on non-Substance renderers if (!(list.getCellRenderer() instanceof SubstanceDefaultListCellRenderer)) fadeAllowed = false; if (!fadeAllowed) { fadeOutRolloverIndication(); resetRolloverIndex(); // rolledOverIndex = -1; // list.putClientProperty(ROLLED_OVER_INDEX, null); return; } int roIndex = list.locationToIndex(e.getPoint()); if ((roIndex >= 0) && (roIndex < list.getModel().getSize())) { // test actual hit if (!list.getCellBounds(roIndex, roIndex) .contains(e.getPoint())) { roIndex = -1; } } if ((roIndex < 0) || (roIndex >= list.getModel().getSize())) { fadeOutRolloverIndication(); // System.out.println("Nulling RO index"); resetRolloverIndex(); // rolledOverIndex = -1; // list.putClientProperty(ROLLED_OVER_INDEX, null); } else { // check if this is the same index // Integer currRoIndex = (Integer) list // .getClientProperty(ROLLED_OVER_INDEX); if ((rolledOverIndex >= 0) && (rolledOverIndex == roIndex)) return; fadeOutRolloverIndication(); FadeTracker.getInstance().trackFadeIn(FadeKind.ROLLOVER, list, roIndex, false, new CellRepaintCallback(list, roIndex)); // System.out.println("Setting RO index to " + roIndex); rolledOverIndex = roIndex; // list.putClientProperty(ROLLED_OVER_INDEX, roIndex); } } } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceListUI(); } /** * Creates a UI delegate for list. */ public SubstanceListUI() { super(); prevStateMap = new HashMap(); nextStateMap = new HashMap(); rolledOverIndex = -1; selectedIndices = new HashMap(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicListUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); isFileList = Boolean.TRUE.equals(list .getClientProperty("List.isFileList")); isLeftToRight = list.getComponentOrientation().isLeftToRight(); if (SubstanceCoreUtilities.toDrawWatermark(list)) { list.setOpaque(false); } for (int i = 0; i < list.getModel().getSize(); i++) { if (list.isSelectedIndex(i)) { selectedIndices.put(i, list.getModel().getElementAt(i)); prevStateMap.put(i, ComponentState.SELECTED); } } this.list.putClientProperty(SubstanceCoreUtilities.USE_HIGHLIGHT, Boolean.TRUE); // this.list.putClientProperty(SubstanceListUI.SELECTED_INDICES, // selected); } @Override protected void uninstallDefaults() { selectedIndices.clear(); // this.list.putClientProperty(SubstanceListUI.SELECTED_INDICES, null); super.uninstallDefaults(); } /** * Repaints a single cell during the fade animation cycle. * * @author Kirill Grouchnikov */ protected class CellRepaintCallback extends UIThreadFadeTrackerAdapter { /** * Associated list. */ protected JList list; /** * Associated (animated) cell index. */ protected int cellIndex; /** * Renderer component for the cell. */ private Component rendererComponent; /** * Creates a new animation repaint callback. * * @param list * Associated list. * @param cellIndex * Associated (animated) cell index. */ public CellRepaintCallback(JList list, int cellIndex) { this.list = list; this.cellIndex = cellIndex; // verify if this index still exists in the model (the list may have // shrunk!) - issue 413 if (cellIndex < list.getModel().getSize()) { this.rendererComponent = list.getCellRenderer() .getListCellRendererComponent( list, list.getModel().getElementAt(cellIndex), cellIndex, list.getSelectionModel().isSelectedIndex( cellIndex), list.hasFocus() && (cellIndex == list .getLeadSelectionIndex())); } } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.utils.FadeTracker$FadeTrackerCallback#fadeEnded * (org.jvnet.lafwidget.utils.FadeTracker.FadeKind) */ @Override public void fadeEnded(FadeKind fadeKind) { if ((SubstanceListUI.this.list == list) && (cellIndex < list.getModel().getSize())) { ComponentState currState = getCellState(cellIndex, this.rendererComponent); if (currState == ComponentState.DEFAULT) { prevStateMap.remove(cellIndex); nextStateMap.remove(cellIndex); } else { prevStateMap.put(cellIndex, currState); nextStateMap.put(cellIndex, currState); } // System.out.println(tabIndex + "->" // + prevStateMap.get(tabIndex).name()); } repaintCell(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.animation.FadeTrackerAdapter#fadeReversed(org * .jvnet.lafwidget.animation.FadeKind, boolean, float) */ @Override public void fadeReversed(FadeKind fadeKind, boolean isFadingIn, float fadeCycle10) { if ((SubstanceListUI.this.list == list) && (cellIndex < list.getModel().getSize())) { ComponentState nextState = nextStateMap.get(cellIndex); if (nextState == null) { prevStateMap.remove(cellIndex); } else { prevStateMap.put(cellIndex, nextState); } // System.out.println(tabIndex + "->" // + prevStateMap.get(tabIndex).name()); } repaintCell(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.utils.FadeTracker$FadeTrackerCallback#fadePerformed * (org.jvnet.lafwidget.utils.FadeTracker.FadeKind, float) */ @Override public void fadePerformed(FadeKind fadeKind, float fade) { if ((SubstanceListUI.this.list == list) && (cellIndex < list.getModel().getSize())) { nextStateMap.put(cellIndex, getCellState(cellIndex, this.rendererComponent)); } repaintCell(); } /** * Repaints the associated cell. */ private void repaintCell() { SwingUtilities.invokeLater(new Runnable() { public void run() { if (SubstanceListUI.this.list == null) { // may happen if the LAF was switched in the meantime return; } try { maybeUpdateLayoutState(); int cellCount = list.getModel().getSize(); if ((cellCount > 0) && (cellIndex < cellCount)) { // need to retrieve the cell rectangle since the // cells can be moved while animating Rectangle rect = SubstanceListUI.this .getCellBounds(list, cellIndex, cellIndex); // System.out.println("Repainting " + cellIndex // + " at " + rect); list.repaint(rect); } } catch (RuntimeException re) { return; } } }); } } @Override protected void installListeners() { super.installListeners(); // Add listener for the selection animation substanceFadeSelectionListener = new ListSelectionListener() { protected void cancelFades(Set initiatedFadeSequences) { FadeTracker fadeTrackerInstance = FadeTracker.getInstance(); for (long fadeId : initiatedFadeSequences) { fadeTrackerInstance.cancelFadeInstance(fadeId); } } public void valueChanged(ListSelectionEvent e) { // optimization on large lists and large selections if (LafWidgetUtilities.hasNoFades(list, FadeKind.SELECTION)) return; // no selection animations on non-Substance renderers if (!(list.getCellRenderer() instanceof SubstanceDefaultListCellRenderer)) return; Set initiatedFadeSequences = new HashSet(); boolean fadeCanceled = false; // if (SubstanceCoreUtilities.toBleedWatermark(list)) // return; FadeTracker fadeTrackerInstance = FadeTracker.getInstance(); // Map currSelected = (Map) // SubstanceListUI.this.list // .getClientProperty(SubstanceListUI.SELECTED_INDICES); for (int i = e.getFirstIndex(); i <= e.getLastIndex(); i++) { if (i >= list.getModel().getSize()) continue; if (list.isSelectedIndex(i)) { // check if was selected before if (!selectedIndices.containsKey(i)) { // start fading in // System.out.println("Fade in on index " + i); if (!fadeCanceled) { long fadeId = fadeTrackerInstance.trackFadeIn( FadeKind.SELECTION, list, i, false, new CellRepaintCallback(list, i)); initiatedFadeSequences.add(fadeId); if (initiatedFadeSequences.size() > 25) { cancelFades(initiatedFadeSequences); initiatedFadeSequences.clear(); fadeCanceled = true; } } selectedIndices.put(i, list.getModel() .getElementAt(i)); } } else { // check if was selected before and still points to the // same element if (selectedIndices.containsKey(i)) { if (selectedIndices.get(i) == list.getModel() .getElementAt(i)) { // start fading out // System.out.println("Fade out on index " + i); if (!fadeCanceled) { long fadeId = fadeTrackerInstance .trackFadeOut(FadeKind.SELECTION, list, i, false, new CellRepaintCallback( list, i)); initiatedFadeSequences.add(fadeId); if (initiatedFadeSequences.size() > 25) { cancelFades(initiatedFadeSequences); initiatedFadeSequences.clear(); fadeCanceled = true; } } } selectedIndices.remove(i); } } } } }; list.getSelectionModel().addListSelectionListener( substanceFadeSelectionListener); substanceFadeRolloverListener = new RolloverFadeListener(); list.addMouseMotionListener(substanceFadeRolloverListener); list.addMouseListener(substanceFadeRolloverListener); substancePropertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (SubstanceLookAndFeel.WATERMARK_VISIBLE.equals(evt .getPropertyName())) { list.setOpaque(!SubstanceCoreUtilities .toDrawWatermark(list)); } } }; list.addPropertyChangeListener(substancePropertyChangeListener); this.substanceComponentListener = new ComponentAdapter() { @Override public void componentMoved(ComponentEvent e) { // clear the rollover indexes since these are no longer // in sync with the mouse location fadeOutRolloverIndication(); resetRolloverIndex(); } }; this.list.addComponentListener(this.substanceComponentListener); } @Override protected void uninstallListeners() { list.getSelectionModel().removeListSelectionListener( substanceFadeSelectionListener); substanceFadeSelectionListener = null; list.removeMouseMotionListener(substanceFadeRolloverListener); list.removeMouseListener(substanceFadeRolloverListener); substanceFadeRolloverListener = null; list.removePropertyChangeListener(substancePropertyChangeListener); substancePropertyChangeListener = null; this.list.removeComponentListener(this.substanceComponentListener); this.substanceComponentListener = null; super.uninstallListeners(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicListUI#paintCell(java.awt.Graphics, int, * java.awt.Rectangle, javax.swing.ListCellRenderer, javax.swing.ListModel, * javax.swing.ListSelectionModel, int) */ @Override protected void paintCell(Graphics g, int row, Rectangle rowBounds, ListCellRenderer cellRenderer, ListModel dataModel, ListSelectionModel selModel, int leadIndex) { Object value = dataModel.getElementAt(row); boolean cellHasFocus = list.hasFocus() && (row == leadIndex); boolean isSelected = selModel.isSelectedIndex(row); Component rendererComponent = cellRenderer .getListCellRendererComponent(list, value, row, isSelected, cellHasFocus); if (!(rendererComponent instanceof SubstanceDefaultListCellRenderer)) { // if it's not Substance renderer - ask the Basic delegate to paint // it. super.paintCell(g, row, rowBounds, cellRenderer, dataModel, selModel, leadIndex); return; } boolean isWatermarkBleed = updateInfo.toDrawWatermark; int cx = rowBounds.x; int cy = rowBounds.y; int cw = rowBounds.width; int ch = rowBounds.height; if (isFileList) { // Shrink renderer to preferred size. This is mostly used on Windows // where selection is only shown around the file name, instead of // across the whole list cell. int w = Math .min(cw, rendererComponent.getPreferredSize().width + 4); if (!isLeftToRight) { cx += (cw - w); } cw = w; } Graphics2D g2d = (Graphics2D) g.create(); g2d.setComposite(TransitionLayout.getAlphaComposite(list, g)); if (!isWatermarkBleed) { Color background = rendererComponent.getBackground(); // optimization - only render background if it's different // from the list background if ((background != null) && (!list.getBackground().equals(background) || this.updateInfo.isInDecorationArea)) { g2d.setColor(background); g2d.fillRect(cx, cy, cw, ch); } } else { BackgroundPaintingUtils.fillAndWatermark(g2d, this.list, rendererComponent.getBackground(), new Rectangle(cx, cy, cw, ch)); } ComponentState prevState = getPrevCellState(row); ComponentState currState = getCellState(row, rendererComponent); // Compute the alpha values for the animation. float startAlpha = this.updateInfo.getHighlightAlpha(prevState); float endAlpha = this.updateInfo.getHighlightAlpha(currState); // if the renderer is disabled, do not show any highlights float totalAlpha = endAlpha; float fadeCoef = 0.0f; if (rendererComponent.isEnabled()) { FadeState state = SubstanceFadeUtilities.getFadeState(list, row, FadeKind.SELECTION, FadeKind.ROLLOVER); if (state != null) { fadeCoef = state.getFadePosition(); // compute the total alpha of the overlays. if (state.isFadingIn()) { totalAlpha = startAlpha + (endAlpha - startAlpha) * fadeCoef; } else { totalAlpha = startAlpha + (endAlpha - startAlpha) * (1.0f - fadeCoef); } if (state.isFadingIn()) fadeCoef = 1.0f - fadeCoef; } } SubstanceColorScheme prevScheme = this.updateInfo .getHighlightColorScheme(prevState); SubstanceColorScheme currScheme = this.updateInfo .getHighlightColorScheme(currState); SubstanceColorScheme prevBorderScheme = this.updateInfo .getHighlightBorderColorScheme(prevState); SubstanceColorScheme currBorderScheme = this.updateInfo .getHighlightBorderColorScheme(currState); Rectangle cellRect = new Rectangle(cx, cy, cw, ch); if (totalAlpha > 0.0f) { g2d.setComposite(TransitionLayout.getAlphaComposite(list, totalAlpha, g)); HighlightPainterUtils.paintHighlight(g2d, this.rendererPane, rendererComponent, cellRect, 0.8f, null, currScheme, prevScheme, currBorderScheme, prevBorderScheme, fadeCoef); g2d.setComposite(TransitionLayout.getAlphaComposite(list, g)); } rendererPane.paintComponent(g2d, rendererComponent, list, cx, cy, cw, ch, true); g2d.dispose(); } /** * Returns the previous state for the specified cell. * * @param cellIndex * Cell index. * @return The previous state for the specified cell. */ public ComponentState getPrevCellState(int cellIndex) { if (prevStateMap.containsKey(cellIndex)) return prevStateMap.get(cellIndex); return getCellState(cellIndex, null); // return ComponentState.DEFAULT; } /** * Returns the current state for the specified cell. * * @param cellIndex * Cell index. * @param rendererComponent * Renderer component for the specified cell index. * @return The current state for the specified cell. */ public ComponentState getCellState(int cellIndex, Component rendererComponent) { boolean isEnabled = this.list.isEnabled(); if (rendererComponent != null) { isEnabled = isEnabled && rendererComponent.isEnabled(); } boolean isRollover = (rolledOverIndex >= 0) && (rolledOverIndex == cellIndex); boolean isSelected = list.isSelectedIndex(cellIndex); return ComponentState.getState(isEnabled, isRollover, isSelected); } /** * Resets the rollover index. */ public void resetRolloverIndex() { rolledOverIndex = -1; } /** * Initiates the fade out effect. */ private void fadeOutRolloverIndication() { // Integer prevRoIndex = (Integer) list // .getClientProperty(ROLLED_OVER_INDEX); // if (prevRoIndex == null) // return; if (rolledOverIndex < 0) return; FadeTracker.getInstance().trackFadeOut(FadeKind.ROLLOVER, list, rolledOverIndex, false, new CellRepaintCallback(list, rolledOverIndex)); } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void update(Graphics g, JComponent c) { BackgroundPaintingUtils.updateIfOpaque(g, c); Graphics2D g2d = (Graphics2D) g.create(); SubstanceStripingUtils.setup(c); this.updateInfo = new UpdateOptimizationInfo(); this.paint(g2d, c); SubstanceStripingUtils.tearDown(c); g2d.dispose(); this.updateInfo = null; } /** * Returns the current default color scheme. This method is for internal use * only. * * @return The current default color scheme. */ public SubstanceColorScheme getDefaultColorScheme() { if (this.updateInfo != null) return this.updateInfo.defaultScheme; return null; } public SubstanceColorScheme getHighlightColorScheme(ComponentState state) { if (this.updateInfo != null) return updateInfo.getHighlightColorScheme(state); return null; } private UpdateOptimizationInfo updateInfo; private class UpdateOptimizationInfo { public boolean toDrawWatermark; private Map highlightSchemeMap; private Map borderSchemeMap; private Map highlightAlphaMap; public SubstanceColorScheme defaultScheme; public Map opacity; public DecorationAreaType decorationAreaType; public boolean isInDecorationArea; public UpdateOptimizationInfo() { this.toDrawWatermark = SubstanceCoreUtilities.toDrawWatermark(list); this.defaultScheme = SubstanceColorSchemeUtilities.getColorScheme( list, ComponentState.DEFAULT); this.highlightAlphaMap = new EnumMap( ComponentState.class); this.highlightSchemeMap = new EnumMap( ComponentState.class); this.borderSchemeMap = new EnumMap( ComponentState.class); this.opacity = new HashMap(); this.decorationAreaType = SubstanceLookAndFeel .getDecorationType(list); SubstanceSkin skin = SubstanceCoreUtilities.getSkin(list); this.isInDecorationArea = (this.decorationAreaType != null) && skin .isRegisteredAsDecorationArea(this.decorationAreaType) && TransitionLayout.isOpaque(list); } public SubstanceColorScheme getHighlightColorScheme(ComponentState state) { if (!this.highlightSchemeMap.containsKey(state)) { this.highlightSchemeMap.put(state, SubstanceColorSchemeUtilities.getColorScheme(list, ColorSchemeAssociationKind.HIGHLIGHT, state)); } return this.highlightSchemeMap.get(state); } public SubstanceColorScheme getHighlightBorderColorScheme( ComponentState state) { if (!this.borderSchemeMap.containsKey(state)) { this.borderSchemeMap.put(state, SubstanceColorSchemeUtilities .getColorScheme(list, ColorSchemeAssociationKind.HIGHLIGHT_BORDER, state)); } return this.borderSchemeMap.get(state); } public float getHighlightAlpha(ComponentState state) { if (!this.highlightAlphaMap.containsKey(state)) { this.highlightAlphaMap.put(state, SubstanceColorSchemeUtilities .getHighlightAlpha(list, state)); } return this.highlightAlphaMap.get(state); } } } substance-5.3.orig/src/org/jvnet/substance/SubstanceScrollBarUI.java0000644000175000017500000033424111246720556025551 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.awt.event.*; import java.awt.geom.GeneralPath; import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.EnumSet; import java.util.Set; import javax.swing.*; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicScrollBarUI; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.api.*; import org.jvnet.substance.api.SubstanceConstants.ScrollPaneButtonPolicyKind; import org.jvnet.substance.api.SubstanceConstants.Side; import org.jvnet.substance.painter.border.SimplisticSoftBorderPainter; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.gradient.SimplisticGradientPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.shaper.ClassicButtonShaper; import org.jvnet.substance.shaper.SubstanceButtonShaper; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.icon.ArrowButtonTransitionAwareIcon; import org.jvnet.substance.utils.scroll.SubstanceScrollButton; /** * UI for scroll bars in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceScrollBarUI extends BasicScrollBarUI implements Trackable { /** * The second decrease button. Is shown under * {@link SubstanceConstants.ScrollPaneButtonPolicyKind#ADJACENT}, * {@link SubstanceConstants.ScrollPaneButtonPolicyKind#MULTIPLE} and * {@link SubstanceConstants.ScrollPaneButtonPolicyKind#MULTIPLE_BOTH} * modes. * * @since version 3.1 */ protected JButton mySecondDecreaseButton; /** * The second increase button. Is shown only under * {@link SubstanceConstants.ScrollPaneButtonPolicyKind#MULTIPLE_BOTH} mode. * * @since version 3.1 */ protected JButton mySecondIncreaseButton; /** * Surrogate button model for tracking the thumb transitions. */ private ButtonModel thumbModel; /** * Stores computed images for vertical thumbs. */ private static LazyResettableHashMap thumbVerticalMap = new LazyResettableHashMap( "SubstanceScrollBarUI.thumbVertical"); /** * Stores computed images for horizontal thumbs. */ private static LazyResettableHashMap thumbHorizontalMap = new LazyResettableHashMap( "SubstanceScrollBarUI.thumbHorizontal"); /** * Stores computed images for full vertical tracks under * {@link DefaultControlBackgroundComposite}. */ private static LazyResettableHashMap trackFullVerticalMap = new LazyResettableHashMap( "SubstanceScrollBarUI.trackFullVertical"); /** * Stores computed images for full horizontal tracks under * {@link DefaultControlBackgroundComposite}. */ private static LazyResettableHashMap trackFullHorizontalMap = new LazyResettableHashMap( "SubstanceScrollBarUI.trackFullHorizontal"); /** * Mouse listener on the associated scroll bar. */ private MouseListener substanceMouseListener; /** * Listener for thumb fade animations. */ private RolloverControlListener substanceThumbRolloverListener; /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /** * Property change listener. * */ private PropertyChangeListener substancePropertyListener; /** * Scroll bar width. */ protected int scrollBarWidth; /** * Cache of images for horizontal tracks. */ private static LazyResettableHashMap trackHorizontalMap = new LazyResettableHashMap( "SubstanceScrollBarUI.trackHorizontal"); /** * Cache of images for vertical tracks. */ private static LazyResettableHashMap trackVerticalMap = new LazyResettableHashMap( "SubstanceScrollBarUI.trackVertical"); /** * Listener on adjustments made to the scrollbar model - this is for the * overlay mode (see {@link SubstanceLookAndFeel#OVERLAY_PROPERTY} and * repaiting both scrollbars with the viewport. * * @since version 3.2 */ protected AdjustmentListener substanceAdjustmentListener; /** * Surrogate model to sync between rollover effects of scroll buttons and * scroll track / scroll thumb. * * @since version 3.2 */ protected CompositeButtonModel compositeScrollTrackModel; /** * Surrogate model to sync between rollover effects of scroll buttons and * scroll track / scroll thumb. * * @since version 3.2 */ protected CompositeButtonModel compositeButtonsModel; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceScrollBarUI(comp); } /** * Simple constructor. * * @param b * Associated component. */ protected SubstanceScrollBarUI(JComponent b) { super(); this.thumbModel = new DefaultButtonModel(); this.thumbModel.setArmed(false); this.thumbModel.setSelected(false); this.thumbModel.setPressed(false); this.thumbModel.setRollover(false); b.setOpaque(false); } /** * Creates a decrease button. * * @param orientation * Button orientation. * @param isRegular * if true, the regular (upper / left) decrease * button is created, if false, the additional * (lower / right) decrease button is created for * {@link SubstanceConstants.ScrollPaneButtonPolicyKind#ADJACENT} * , * {@link SubstanceConstants.ScrollPaneButtonPolicyKind#MULTIPLE} * and * {@link SubstanceConstants.ScrollPaneButtonPolicyKind#MULTIPLE_BOTH} * kinds. * @return Decrease button. */ protected JButton createGeneralDecreaseButton(final int orientation, boolean isRegular) { JButton result = new SubstanceScrollButton(orientation); result.setFont(this.scrollbar.getFont()); Icon icon = new ArrowButtonTransitionAwareIcon(result, orientation); // new TransitionAwareIcon(result, // new TransitionAwareIcon.Delegate() { // public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { // return SubstanceImageCreator.getArrowIcon( // SubstanceSizeUtils // .getComponentFontSize(scrollbar), // orientation, scheme); // } // }); result.setIcon(icon); result.setFont(scrollbar.getFont()); result.setPreferredSize(new Dimension(this.scrollBarWidth, this.scrollBarWidth)); Set openSides = EnumSet.noneOf(Side.class); Set straightSides = EnumSet.noneOf(Side.class); switch (orientation) { case NORTH: openSides.add(Side.BOTTOM); if (!isRegular) openSides.add(Side.TOP); if (isRegular) straightSides.add(Side.TOP); break; case EAST: openSides.add(Side.LEFT); if (!isRegular) openSides.add(Side.RIGHT); if (isRegular) straightSides.add(Side.RIGHT); break; case WEST: openSides.add(Side.RIGHT); if (!isRegular) openSides.add(Side.LEFT); if (isRegular) straightSides.add(Side.LEFT); break; } result.putClientProperty( SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, openSides); result.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, straightSides); return result; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicScrollBarUI#createDecreaseButton(int) */ @Override protected JButton createDecreaseButton(int orientation) { return this.createGeneralDecreaseButton(orientation, true); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicScrollBarUI#createIncreaseButton(int) */ @Override protected JButton createIncreaseButton(int orientation) { return this.createGeneralIncreaseButton(orientation, true); } /** * Creates a increase button. * * @param orientation * Button orientation. * @param isRegular * if true, the regular (lower / right) increase * button is created, if false, the additional * (upper / left) increase button is created for * {@link SubstanceConstants.ScrollPaneButtonPolicyKind#MULTIPLE_BOTH} * kind. * @return Increase button. */ protected JButton createGeneralIncreaseButton(final int orientation, boolean isRegular) { JButton result = new SubstanceScrollButton(orientation); result.setFont(this.scrollbar.getFont()); Icon icon = new ArrowButtonTransitionAwareIcon(result, orientation); // Icon icon = new TransitionAwareIcon(result, // new TransitionAwareIcon.Delegate() { // public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { // return SubstanceImageCreator.getArrowIcon( // SubstanceSizeUtils // .getComponentFontSize(scrollbar), // orientation, scheme); // } // }); result.setIcon(icon); result.setFont(scrollbar.getFont()); // JButton result = new SubstanceScrollBarButton(icon, orientation); result.setPreferredSize(new Dimension(this.scrollBarWidth, this.scrollBarWidth)); Set openSides = EnumSet.noneOf(Side.class); Set straightSides = EnumSet.noneOf(Side.class); switch (orientation) { case SOUTH: openSides.add(Side.TOP); if (!isRegular) openSides.add(Side.BOTTOM); if (isRegular) straightSides.add(Side.BOTTOM); break; case EAST: openSides.add(Side.LEFT); if (!isRegular) openSides.add(Side.RIGHT); if (isRegular) straightSides.add(Side.RIGHT); break; case WEST: openSides.add(Side.RIGHT); if (!isRegular) openSides.add(Side.LEFT); if (isRegular) straightSides.add(Side.LEFT); break; } result.putClientProperty( SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, openSides); result.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, straightSides); return result; } /** * Returns the image for a horizontal track. * * @param trackBounds * Track bounds. * @param leftActiveButton * The closest left button in the scroll bar. May be * null. * @param rightActiveButton * The closest right button in the scroll bar. May be * null . * @return Horizontal track image. */ private BufferedImage getTrackHorizontal(Rectangle trackBounds, SubstanceScrollButton leftActiveButton, SubstanceScrollButton rightActiveButton) { int width = Math.max(1, trackBounds.width); int height = Math.max(1, trackBounds.height); ComponentState compLeftState = this.getState(leftActiveButton); ComponentState compRightState = this.getState(rightActiveButton); Component tracked = SubstanceFadeUtilities.getTracked( FadeKind.ROLLOVER, this.scrollbar, this.decrButton, this.incrButton, this.mySecondDecreaseButton, this.mySecondIncreaseButton); if (tracked != null) { ComponentState state = (tracked == this.scrollbar) ? ComponentState .getState(this.thumbModel, null) : ComponentState.getState( ((AbstractButton) tracked).getModel(), null); float cyclePos = state.getCyclePosition(); FadeState highest = SubstanceFadeUtilities .getFadeStateWithHighestFadeCycle(FadeKind.ROLLOVER, this.scrollbar, this.decrButton, this.incrButton, this.mySecondDecreaseButton, this.mySecondIncreaseButton); if (highest != null) { cyclePos = highest.getFadePosition(); if (!highest.isFadingIn()) cyclePos = 1.0f - cyclePos; } SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(this.scrollbar); HashMapKey key = SubstanceCoreUtilities .getHashKey(cyclePos, width, height, ((leftActiveButton == null) ? "null" : ComponentState.getState( leftActiveButton.getModel(), leftActiveButton).name()), ((leftActiveButton == null) ? "null" : SubstanceCoreUtilities .getPrevComponentState( leftActiveButton).name()), ((rightActiveButton == null) ? "null" : ComponentState.getState( rightActiveButton.getModel(), rightActiveButton).name()), ((rightActiveButton == null) ? "null" : SubstanceCoreUtilities .getPrevComponentState( rightActiveButton).name()), ((compLeftState == null) ? "null" : compLeftState .name()), ((compRightState == null) ? "null" : compRightState .name()), ((compLeftState == null) ? "null" : SubstanceColorSchemeUtilities .getColorScheme(leftActiveButton, compLeftState) .getDisplayName()), ((compRightState == null) ? "null" : SubstanceColorSchemeUtilities .getColorScheme(rightActiveButton, compRightState) .getDisplayName()), SubstanceColorSchemeUtilities.getColorScheme( this.scrollbar, ComponentState.DEFAULT) .getDisplayName(), shaper.getDisplayName(), SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(scrollbar))); // System.out.println(key); if (trackFullHorizontalMap.containsKey(key)) { // System.out.println("Cache hit"); return trackFullHorizontalMap.get(key); } // System.out.println("Cache miss"); // System.out.println("New image for horizontal track"); BufferedImage imageBack = getTrackBackHorizontal(this.scrollbar, leftActiveButton, rightActiveButton, width, height); Graphics2D backGraphics = imageBack.createGraphics(); BufferedImage imageDefault = getTrackHorizontal(this.scrollbar, compLeftState, compRightState, width, height); backGraphics.drawImage(imageDefault, 0, 0, null); BufferedImage imageActive = getTrackHorizontal(this.scrollbar, compLeftState, compRightState, width, height); backGraphics.setComposite(AlphaComposite.SrcOver.derive(cyclePos)); // System.out.println("Painting " + cyclePos); backGraphics.drawImage(imageActive, 0, 0, null); trackFullHorizontalMap.put(key, imageBack); return imageBack; } SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(this.scrollbar); HashMapKey key = SubstanceCoreUtilities .getHashKey(width, height, ((compLeftState == null) ? "null" : ComponentState.getState(leftActiveButton.getModel(), leftActiveButton).name()), ((compLeftState == null) ? "null" : SubstanceCoreUtilities.getPrevComponentState( leftActiveButton).name()), ((compRightState == null) ? "null" : ComponentState .getState(rightActiveButton.getModel(), rightActiveButton).name()), ((compRightState == null) ? "null" : SubstanceCoreUtilities.getPrevComponentState( rightActiveButton).name()), ((compLeftState == null) ? "null" : compLeftState .name()), ((compRightState == null) ? "null" : compRightState.name()), ((compLeftState == null) ? "null" : SubstanceColorSchemeUtilities.getColorScheme( leftActiveButton, compLeftState) .getDisplayName()), ((compRightState == null) ? "null" : SubstanceColorSchemeUtilities.getColorScheme( rightActiveButton, compRightState) .getDisplayName()), SubstanceColorSchemeUtilities.getColorScheme( this.scrollbar, ComponentState.DEFAULT) .getDisplayName(), shaper.getDisplayName(), SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(scrollbar))); // System.out.println(key); if (trackFullHorizontalMap.containsKey(key)) { // System.out.println("Cache hit"); return trackFullHorizontalMap.get(key); } // System.out.println("Cache miss"); // System.out.println("New image for horizontal track"); BufferedImage trackBack = getTrackBackHorizontal(this.scrollbar, leftActiveButton, rightActiveButton, width, height); Graphics2D backGraphics = trackBack.createGraphics(); BufferedImage scrollTrackImage = getTrackHorizontal(this.scrollbar, compLeftState, compRightState, width, height); backGraphics.drawImage(scrollTrackImage, 0, 0, null); backGraphics.dispose(); // System.out.println("Cache update"); trackFullHorizontalMap.put(key, trackBack); return trackBack; } /** * Returns the image for a horizontal track. * * @param scrollBar * Scroll bar. * @param trackBounds * Track bounds. * @param compLeftState * The state of the left button in the scroll bar. * @param compRightState * The state of the closest right button in the scroll bar. * @param width * Scroll track width. * @param height * Scroll track height. * @param graphicsComposite * Composite to apply before painting the track. * @return Horizontal track image. */ private static BufferedImage getTrackHorizontal(JScrollBar scrollBar, ComponentState compLeftState, ComponentState compRightState, int width, int height) { SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(scrollBar); SubstanceColorScheme mainScheme = SubstanceColorSchemeUtilities .getColorScheme(scrollBar, scrollBar.isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED); SubstanceColorScheme mainBorderScheme = SubstanceColorSchemeUtilities .getColorScheme(scrollBar, ColorSchemeAssociationKind.BORDER, scrollBar.isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED); HashMapKey key = SubstanceCoreUtilities.getHashKey(mainScheme .getDisplayName(), mainBorderScheme.getDisplayName(), width, height, ((compLeftState == null) ? "null" : compLeftState .name()), ((compRightState == null) ? "null" : compRightState.name()), shaper.getDisplayName()); float radius = height / 2; if (shaper instanceof ClassicButtonShaper) radius = SubstanceSizeUtils .getClassicButtonCornerRadius(SubstanceSizeUtils .getComponentFontSize(scrollBar)); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(scrollBar)) / 2.0); Shape contour = SubstanceOutlineUtilities.getBaseOutline(width, height, radius, null, borderDelta); BufferedImage result = SubstanceScrollBarUI.trackHorizontalMap.get(key); if (result == null) { result = SubstanceCoreUtilities.getBlankImage(width, height); SimplisticGradientPainter.INSTANCE.paintContourBackground(result .createGraphics(), scrollBar, width, height, contour, false, mainScheme, mainScheme, 0, true, false); SubstanceBorderPainter borderPainter = new SimplisticSoftBorderPainter(); borderPainter.paintBorder(result.getGraphics(), scrollBar, width, height, contour, null, mainBorderScheme, mainBorderScheme, 0, false); SubstanceScrollBarUI.trackHorizontalMap.put(key, result); } return result; } /** * Returns the image for a horizontal track. * * @param scrollBar * Scroll bar. * @param trackBounds * Track bounds. * @param leftActiveButton * The closest left button in the scroll bar. May be * null. * @param rightActiveButton * The closest right button in the scroll bar. May be * null . * @param width * Scroll track width. * @param height * Scroll track height. * @param graphicsComposite * Composite to apply before painting the track. * @return Horizontal track image. */ private static BufferedImage getTrackBackHorizontal(JScrollBar scrollBar, AbstractButton leftActiveButton, AbstractButton rightActiveButton, int width, int height) { SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(scrollBar); int radius = height / 2; if (shaper instanceof ClassicButtonShaper) radius = 2; BufferedImage opaque = SubstanceImageCreator .getCompositeRoundedBackground(scrollBar, width, height, radius, leftActiveButton, rightActiveButton, false); return opaque; } /** * Returns the image for a vertical track. * * @param trackBounds * Track bounds. * @param scrollBar * Scroll bar. * @param topActiveButton * The closest top button in the scroll bar. May be * null. * @param bottomActiveButton * The closest bottom button in the scroll bar. May be * null. * @return Vertical track image. */ private BufferedImage getTrackVertical(Rectangle trackBounds, SubstanceScrollButton topActiveButton, SubstanceScrollButton bottomActiveButton) { int width = Math.max(1, trackBounds.width); int height = Math.max(1, trackBounds.height); ComponentState compTopState = this.getState(topActiveButton); ComponentState compBottomState = this.getState(bottomActiveButton); Component tracked = SubstanceFadeUtilities.getTracked( FadeKind.ROLLOVER, this.scrollbar, this.decrButton, this.incrButton, this.mySecondDecreaseButton, this.mySecondIncreaseButton); if (tracked != null) { ComponentState state = (tracked == this.scrollbar) ? ComponentState .getState(this.thumbModel, null) : ComponentState.getState( ((AbstractButton) tracked).getModel(), null); float cyclePos = state.getCyclePosition(); FadeState highest = SubstanceFadeUtilities .getFadeStateWithHighestFadeCycle(FadeKind.ROLLOVER, this.scrollbar, this.decrButton, this.incrButton, this.mySecondDecreaseButton, this.mySecondIncreaseButton); if (highest != null) { cyclePos = highest.getFadePosition(); if (!highest.isFadingIn()) cyclePos = 1.0f - cyclePos; } SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(this.scrollbar); HashMapKey key = SubstanceCoreUtilities.getHashKey(cyclePos, width, height, ((topActiveButton == null) ? "null" : ComponentState .getState(topActiveButton.getModel(), topActiveButton).name()), ((topActiveButton == null) ? "null" : SubstanceCoreUtilities.getPrevComponentState( topActiveButton).name()), ((bottomActiveButton == null) ? "null" : ComponentState .getState(bottomActiveButton.getModel(), bottomActiveButton).name()), ((bottomActiveButton == null) ? "null" : SubstanceCoreUtilities.getPrevComponentState( bottomActiveButton).name()), ((compTopState == null) ? "null" : compTopState.name()), ((compBottomState == null) ? "null" : compBottomState .name()), ((compBottomState == null) ? "null" : SubstanceColorSchemeUtilities.getColorScheme( bottomActiveButton, compBottomState) .getDisplayName()), ((compTopState == null) ? "null" : SubstanceColorSchemeUtilities.getColorScheme( topActiveButton, compTopState) .getDisplayName()), SubstanceColorSchemeUtilities.getColorScheme( this.scrollbar, ComponentState.DEFAULT) .getDisplayName(), shaper.getDisplayName(), SubstanceSizeUtils.getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(scrollbar))); // System.out.println(key); if (trackFullVerticalMap.containsKey(key)) { // System.out.println("Cache hit"); return trackFullVerticalMap.get(key); } // System.out.println("Cache miss"); // System.out.println("New image for vertical track"); BufferedImage imageBack = getTrackBackVertical(this.scrollbar, topActiveButton, bottomActiveButton, width, height); Graphics2D backGraphics = imageBack.createGraphics(); BufferedImage imageDefault = getTrackVertical(this.scrollbar, compTopState, compBottomState, width, height); backGraphics.drawImage(imageDefault, 0, 0, null); BufferedImage imageActive = getTrackVertical(this.scrollbar, compTopState, compBottomState, width, height); backGraphics.setComposite(AlphaComposite.SrcOver.derive(cyclePos)); // System.out.println("Painting " + cyclePos); backGraphics.drawImage(imageActive, 0, 0, null); // System.out.println("Cache update"); trackFullVerticalMap.put(key, imageBack); return imageBack; } SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(this.scrollbar); HashMapKey key = SubstanceCoreUtilities .getHashKey( width, height, ((compTopState == null) ? "null" : ComponentState .getState(topActiveButton.getModel(), topActiveButton).name()), ((compTopState == null) ? "null" : SubstanceCoreUtilities.getPrevComponentState( topActiveButton).name()), ((compBottomState == null) ? "null" : ComponentState .getState(bottomActiveButton.getModel(), bottomActiveButton).name()), ((compBottomState == null) ? "null" : SubstanceCoreUtilities.getPrevComponentState( bottomActiveButton).name()), ((compTopState == null) ? "null" : compTopState.name()), ((compBottomState == null) ? "null" : compBottomState .name()), ((compBottomState == null) ? "null" : SubstanceColorSchemeUtilities.getColorScheme( bottomActiveButton, compBottomState) .getDisplayName()), ((compTopState == null) ? "null" : SubstanceColorSchemeUtilities.getColorScheme( topActiveButton, compTopState) .getDisplayName()), SubstanceColorSchemeUtilities.getColorScheme( this.scrollbar, ComponentState.DEFAULT) .getDisplayName(), shaper.getDisplayName(), SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(scrollbar))); if (trackFullVerticalMap.containsKey(key)) { // System.out.println("Cache hit"); return trackFullVerticalMap.get(key); } // System.out.println("New image for vertical track"); BufferedImage trackBack = getTrackBackVertical(this.scrollbar, topActiveButton, bottomActiveButton, width, height); Graphics2D backGraphics = trackBack.createGraphics(); BufferedImage scrollTrackImage = getTrackVertical(this.scrollbar, compTopState, compBottomState, width, height); backGraphics.drawImage(scrollTrackImage, 0, 0, null); backGraphics.dispose(); trackFullVerticalMap.put(key, trackBack); // System.out.println("Cache update"); return trackBack; } /** * Returns the image for a vertical track. * * @param trackBounds * Track bounds. * @param scrollBar * Scroll bar. * @param compTopState * The state of the top button in the scroll bar. * @param compBottomState * The state of the closest bottom button in the scroll bar. * @param width * Scroll track width. * @param height * Scroll track height. * @param graphicsComposite * Composite to apply before painting the track. * @return Vertical track image. */ private static BufferedImage getTrackVertical(JScrollBar scrollBar, ComponentState compTopState, ComponentState compBottomState, int width, int height) { SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(scrollBar); SubstanceColorScheme mainScheme = SubstanceColorSchemeUtilities .getColorScheme(scrollBar, scrollBar.isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED); SubstanceColorScheme mainBorderScheme = SubstanceColorSchemeUtilities .getColorScheme(scrollBar, ColorSchemeAssociationKind.BORDER, scrollBar.isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED); HashMapKey key = SubstanceCoreUtilities.getHashKey(mainScheme .getDisplayName(), mainBorderScheme.getDisplayName(), width, height, ((compTopState == null) ? "null" : compTopState.name()), ((compBottomState == null) ? "null" : compBottomState.name()), shaper.getDisplayName()); BufferedImage result = SubstanceScrollBarUI.trackVerticalMap.get(key); if (result == null) { float radius = width / 2; if (shaper instanceof ClassicButtonShaper) radius = SubstanceSizeUtils .getClassicButtonCornerRadius(SubstanceSizeUtils .getComponentFontSize(scrollBar)); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(scrollBar)) / 2.0); Shape contour = SubstanceOutlineUtilities.getBaseOutline(height, width, radius, null, borderDelta); result = SubstanceCoreUtilities.getBlankImage(height, width); SimplisticGradientPainter.INSTANCE.paintContourBackground(result .createGraphics(), scrollBar, height, width, contour, false, mainScheme, mainScheme, 0, true, false); SubstanceBorderPainter borderPainter = new SimplisticSoftBorderPainter(); borderPainter.paintBorder(result.getGraphics(), scrollBar, height, width, contour, null, mainBorderScheme, mainBorderScheme, 0, false); result = SubstanceImageCreator.getRotated(result, 3); SubstanceScrollBarUI.trackVerticalMap.put(key, result); } return result; } /** * Returns the image for a vertical track. * * @param trackBounds * Track bounds. * @param scrollBar * Scroll bar. * @param topActiveButton * The closest top button in the scroll bar. May be * null. * @param bottomActiveButton * The closest bottom button in the scroll bar. May be * null. * @param width * Scroll track width. * @param height * Scroll track height. * @param graphicsComposite * Composite to apply before painting the track. * @return Vertical track image. */ private static BufferedImage getTrackBackVertical(JScrollBar scrollBar, AbstractButton topActiveButton, AbstractButton bottomActiveButton, int width, int height) { SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(scrollBar); int radius = width / 2; if (shaper instanceof ClassicButtonShaper) radius = 2; BufferedImage opaque = SubstanceImageCreator.getRotated( SubstanceImageCreator.getCompositeRoundedBackground(scrollBar, height, width, radius, topActiveButton, bottomActiveButton, true), 3); return opaque; } /** * Retrieves image for vertical thumb. * * @param thumbBounds * Thumb bounding rectangle. * @return Image for vertical thumb. */ private BufferedImage getThumbVertical(Rectangle thumbBounds) { int width = Math.max(1, thumbBounds.width); int height = Math.max(1, thumbBounds.height); // System.out.println(ComponentState.getState(buttonModel, null) // .getColorSchemeKind().name()); Component tracked = SubstanceFadeUtilities.getTracked( FadeKind.ROLLOVER, this.scrollbar, this.decrButton, this.incrButton, this.mySecondDecreaseButton, this.mySecondIncreaseButton); ComponentState state = ComponentState.getState( this.compositeScrollTrackModel, null); if (state.isKindActive(FadeKind.PRESS)) tracked = null; if (tracked != null) { ComponentState trackedState = (tracked == this.scrollbar) ? ComponentState .getState(this.thumbModel, null) : ComponentState.getState(((AbstractButton) tracked) .getModel(), null); ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(this.scrollbar); // enabled scroll bar is always painted as active if (trackedState == ComponentState.DEFAULT) trackedState = ComponentState.ACTIVE; if (prevState == ComponentState.DEFAULT) prevState = ComponentState.ACTIVE; float cyclePos = trackedState.getCyclePosition(); FadeState highest = SubstanceFadeUtilities .getFadeStateWithHighestFadeCycle(FadeKind.ROLLOVER, this.scrollbar, this.decrButton, this.incrButton, this.mySecondDecreaseButton, this.mySecondIncreaseButton); if (highest != null) { cyclePos = highest.getFadePosition(); if (!highest.isFadingIn()) cyclePos = 1.0f - cyclePos; } SubstanceColorScheme scheme2 = SubstanceColorSchemeUtilities .getColorScheme(this.scrollbar, trackedState); SubstanceColorScheme scheme1 = SubstanceColorSchemeUtilities .getColorScheme(this.scrollbar, prevState); SubstanceColorScheme borderScheme2 = SubstanceColorSchemeUtilities .getColorScheme(this.scrollbar, ColorSchemeAssociationKind.BORDER, trackedState); SubstanceColorScheme borderScheme1 = SubstanceColorSchemeUtilities .getColorScheme(this.scrollbar, ColorSchemeAssociationKind.BORDER, prevState); float borderCyclePos = cyclePos; if (scheme1 == scheme2) { // special case for smooth rollover animations on skins // that have the same ROLLOVER and ACTIVE schemes cyclePos = 0.5f - Math.abs(0.5f - cyclePos); } if (borderScheme1 == borderScheme2) { // special case for smooth rollover animations on skins // that have the same ROLLOVER and ACTIVE border schemes borderCyclePos = 0.5f - Math.abs(0.5f - cyclePos); } // System.out.println(prevState.name() + " -> [" + cyclePos + "] + " // + trackedState.name()); // System.out.println("\t" + borderScheme1.getDisplayName() + " -> " // + borderScheme2.getDisplayName()); return getThumbVertical(this.scrollbar, width, height, cyclePos, scheme1, scheme2, borderCyclePos, borderScheme1, borderScheme2); } ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(this.scrollbar); if (state == ComponentState.DEFAULT) state = ComponentState.ACTIVE; if (prevState == ComponentState.DEFAULT) prevState = ComponentState.ACTIVE; float cyclePos = state.getCyclePosition(); SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.scrollbar, state); SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities .getColorScheme(this.scrollbar, ColorSchemeAssociationKind.BORDER, state); SubstanceColorScheme colorScheme2 = colorScheme; SubstanceColorScheme borderScheme2 = borderScheme; FadeTracker fadeTracker = FadeTracker.getInstance(); FadeState fadeState = fadeTracker.getFadeState(this.scrollbar, FadeKind.PRESS); if (fadeState != null) { colorScheme2 = SubstanceColorSchemeUtilities.getColorScheme( this.scrollbar, prevState); borderScheme2 = SubstanceColorSchemeUtilities.getColorScheme( this.scrollbar, ColorSchemeAssociationKind.BORDER, prevState); cyclePos = fadeState.getFadePosition(); if (fadeState.isFadingIn()) { cyclePos = 1.0f - cyclePos; } } else { cyclePos = 0.0f; } // System.out.println(colorScheme.getDisplayName() + "->" // + colorScheme2.getDisplayName() + ":" + cyclePos); return getThumbVertical(this.scrollbar, width, height, cyclePos, colorScheme, colorScheme2, cyclePos, borderScheme, borderScheme2); } /** * Retrieves image for vertical thumb. * * @param scrollBar * Scroll bar. * @param width * Thumb width. * @param height * Thumb height. * @param kind * Color scheme kind. * @param cyclePos * Cycle position. * @param scheme * The first color scheme. * @param scheme2 * The second color scheme. * @param borderScheme * The first border color scheme. * @param borderScheme2 * The second border color scheme. * @return Image for vertical thumb. */ private static BufferedImage getThumbVertical(JScrollBar scrollBar, int width, int height, float cyclePos, SubstanceColorScheme scheme, SubstanceColorScheme scheme2, float borderCyclePos, SubstanceColorScheme borderScheme, SubstanceColorScheme borderScheme2) { SubstanceGradientPainter painter = SubstanceCoreUtilities .getGradientPainter(scrollBar); SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(scrollBar); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(scrollBar); HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height, scheme.getDisplayName(), scheme2.getDisplayName(), borderScheme .getDisplayName(), borderScheme2.getDisplayName(), cyclePos, borderCyclePos, painter.getDisplayName(), shaper .getDisplayName(), borderPainter.getDisplayName()); BufferedImage result = SubstanceScrollBarUI.thumbVerticalMap.get(key); if (result == null) { // System.out.println("Cache miss - computing"); // System.out.println("New image for vertical thumb"); float radius = width / 2; if (shaper instanceof ClassicButtonShaper) radius = SubstanceSizeUtils .getClassicButtonCornerRadius(SubstanceSizeUtils .getComponentFontSize(scrollBar)); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(scrollBar)) / 2.0); GeneralPath contour = SubstanceOutlineUtilities.getBaseOutline( height, width, radius, null, borderDelta); result = SubstanceCoreUtilities.getBlankImage(height, width); painter.paintContourBackground(result.createGraphics(), scrollBar, height, width, contour, false, scheme, scheme2, cyclePos, true, scheme != scheme2); // int borderThickness = (int) SubstanceSizeUtils // .getBorderStrokeWidth(SubstanceSizeUtils // .getComponentFontSize(scrollBar)); // GeneralPath contourInner = SubstanceOutlineUtilities // .getBaseOutline(height, width, radius, null, // borderThickness + borderDelta); borderPainter.paintBorder(result.getGraphics(), scrollBar, height, width, contour, null, borderScheme, borderScheme2, borderCyclePos, borderScheme != borderScheme2); result = SubstanceImageCreator.getRotated(result, 3); // System.out.println(key); SubstanceScrollBarUI.thumbVerticalMap.put(key, result); } return result; } /** * Retrieves image for horizontal thumb. * * @param thumbBounds * Thumb bounding rectangle. * @return Image for horizontal thumb. */ private BufferedImage getThumbHorizontal(Rectangle thumbBounds) { int width = Math.max(1, thumbBounds.width); int height = Math.max(1, thumbBounds.height); Component tracked = SubstanceFadeUtilities.getTracked( FadeKind.ROLLOVER, this.scrollbar, this.decrButton, this.incrButton, this.mySecondDecreaseButton, this.mySecondIncreaseButton); ComponentState state = ComponentState.getState( this.compositeScrollTrackModel, null); if (state.isKindActive(FadeKind.PRESS)) tracked = null; if (tracked != null) { ComponentState trackedState = (tracked == this.scrollbar) ? ComponentState .getState(this.thumbModel, null) : ComponentState.getState(((AbstractButton) tracked) .getModel(), null); ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(this.scrollbar); if (trackedState == ComponentState.DEFAULT) trackedState = ComponentState.ACTIVE; if (prevState == ComponentState.DEFAULT) prevState = ComponentState.ACTIVE; float cyclePos = trackedState.getCyclePosition(); FadeState highest = SubstanceFadeUtilities .getFadeStateWithHighestFadeCycle(FadeKind.ROLLOVER, this.scrollbar, this.decrButton, this.incrButton, this.mySecondDecreaseButton, this.mySecondIncreaseButton); if (highest != null) { cyclePos = highest.getFadePosition(); if (!highest.isFadingIn()) cyclePos = 1.0f - cyclePos; } SubstanceColorScheme scheme2 = SubstanceColorSchemeUtilities .getColorScheme(this.scrollbar, trackedState); SubstanceColorScheme scheme1 = SubstanceColorSchemeUtilities .getColorScheme(this.scrollbar, prevState); SubstanceColorScheme borderScheme2 = SubstanceColorSchemeUtilities .getColorScheme(this.scrollbar, ColorSchemeAssociationKind.BORDER, trackedState); SubstanceColorScheme borderScheme1 = SubstanceColorSchemeUtilities .getColorScheme(this.scrollbar, ColorSchemeAssociationKind.BORDER, prevState); float borderCyclePos = cyclePos; if (scheme1 == scheme2) { // special case for smooth rollover animations on skins // that have the same ROLLOVER and ACTIVE schemes cyclePos = 0.5f - Math.abs(0.5f - cyclePos); } if (borderScheme1 == borderScheme2) { // special case for smooth rollover animations on skins // that have the same ROLLOVER and ACTIVE border schemes borderCyclePos = 0.5f - Math.abs(0.5f - cyclePos); } // System.out.println(prevState.name() + " -> [" + cyclePos + "] + " // + trackedState.name()); // System.out.println("\t" + borderScheme1.getDisplayName() + " -> " // + borderScheme2.getDisplayName()); return getThumbHorizontal(this.scrollbar, width, height, cyclePos, scheme1, scheme2, borderCyclePos, borderScheme1, borderScheme2); } ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(this.scrollbar); float cyclePos = state.getCyclePosition(); if (state == ComponentState.DEFAULT) state = ComponentState.ACTIVE; if (prevState == ComponentState.DEFAULT) prevState = ComponentState.ACTIVE; SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.scrollbar, state); SubstanceColorScheme colorScheme2 = colorScheme; SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities .getColorScheme(this.scrollbar, ColorSchemeAssociationKind.BORDER, state); SubstanceColorScheme borderScheme2 = borderScheme; FadeTracker fadeTracker = FadeTracker.getInstance(); FadeState fadeState = fadeTracker.getFadeState(this.scrollbar, FadeKind.PRESS); if (fadeState != null) { colorScheme2 = SubstanceColorSchemeUtilities.getColorScheme( this.scrollbar, prevState); borderScheme2 = SubstanceColorSchemeUtilities.getColorScheme( this.scrollbar, ColorSchemeAssociationKind.BORDER, prevState); cyclePos = fadeState.getFadePosition(); if (fadeState.isFadingIn()) { cyclePos = 1.0f - cyclePos; } } else { cyclePos = 0.0f; } return getThumbHorizontal(this.scrollbar, width, height, cyclePos, colorScheme, colorScheme2, cyclePos, borderScheme, borderScheme2); } /** * Retrieves image for horizontal thumb. * * @param scrollBar * Scroll bar. * @param width * Thumb width. * @param height * Thumb height. * @param kind * Color scheme kind. * @param cyclePos * Cycle position. * @param scheme * The first color scheme. * @param scheme2 * The second color scheme. * @param borderScheme * The first border color scheme. * @param borderScheme2 * The second border color scheme. * @return Image for horizontal thumb. */ private static BufferedImage getThumbHorizontal(JScrollBar scrollBar, int width, int height, float cyclePos, SubstanceColorScheme scheme, SubstanceColorScheme scheme2, float borderCyclePos, SubstanceColorScheme borderScheme, SubstanceColorScheme borderScheme2) { SubstanceGradientPainter painter = SubstanceCoreUtilities .getGradientPainter(scrollBar); SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(scrollBar); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(scrollBar); // GripPainter gripPainter = SubstanceCoreUtilities.getGripPainter( // scrollBar, null); // System.out.println(state.name()); HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height, scheme.getDisplayName(), scheme2.getDisplayName(), borderScheme .getDisplayName(), borderScheme2.getDisplayName(), cyclePos, borderCyclePos, painter.getDisplayName(), shaper .getDisplayName(), borderPainter.getDisplayName()); // + ":" // + ((gripPainter != null) ? gripPainter.getDisplayName() // : "null"); float radius = height / 2; if (shaper instanceof ClassicButtonShaper) radius = SubstanceSizeUtils .getClassicButtonCornerRadius(SubstanceSizeUtils .getComponentFontSize(scrollBar)); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(scrollBar)) / 2.0); GeneralPath contour = SubstanceOutlineUtilities.getBaseOutline(width, height, radius, null, borderDelta); BufferedImage opaque = SubstanceScrollBarUI.thumbHorizontalMap.get(key); if (opaque == null) { // System.out.println("New image for horizontal thumb"); opaque = SubstanceCoreUtilities.getBlankImage(width, height); painter.paintContourBackground(opaque.createGraphics(), scrollBar, width, height, contour, false, scheme, scheme2, cyclePos, true, scheme != scheme2); // int borderThickness = (int) SubstanceSizeUtils // .getBorderStrokeWidth(SubstanceSizeUtils // .getComponentFontSize(scrollBar)); // GeneralPath contourInner = SubstanceOutlineUtilities // .getBaseOutline(width, height, radius, null, // borderThickness + borderDelta); borderPainter.paintBorder(opaque.getGraphics(), scrollBar, width, height, contour, null, borderScheme, borderScheme2, borderCyclePos, borderScheme != borderScheme2); SubstanceScrollBarUI.thumbHorizontalMap.put(key, opaque); } return opaque; } /** * Returns the scroll button state. * * @param scrollButton * Scroll button. * @return Scroll button state. */ protected ComponentState getState(JButton scrollButton) { if (scrollButton == null) return null; ComponentState result = ComponentState.getState(scrollButton); if ((result == ComponentState.DEFAULT) && SubstanceCoreUtilities.hasFlatAppearance(this.scrollbar, false)) { result = null; } if (SubstanceCoreUtilities.isButtonNeverPainted(scrollButton)) { result = null; } return result; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicScrollBarUI#paintTrack(java.awt.Graphics, * javax.swing.JComponent, java.awt.Rectangle) */ @Override protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) { Graphics2D graphics = (Graphics2D) g.create(); // System.out.println("Track"); ScrollPaneButtonPolicyKind buttonPolicy = SubstanceCoreUtilities .getScrollPaneButtonsPolicyKind(this.scrollbar); SubstanceScrollButton compTopState = null; SubstanceScrollButton compBottomState = null; if (this.decrButton.isShowing() && this.incrButton.isShowing() && this.mySecondDecreaseButton.isShowing() && this.mySecondIncreaseButton.isShowing()) { switch (buttonPolicy) { case OPPOSITE: compTopState = (SubstanceScrollButton) this.decrButton; compBottomState = (SubstanceScrollButton) this.incrButton; break; case ADJACENT: compBottomState = (SubstanceScrollButton) this.mySecondDecreaseButton; break; case MULTIPLE: compTopState = (SubstanceScrollButton) this.decrButton; compBottomState = (SubstanceScrollButton) this.mySecondDecreaseButton; break; case MULTIPLE_BOTH: compTopState = (SubstanceScrollButton) this.mySecondIncreaseButton; compBottomState = (SubstanceScrollButton) this.mySecondDecreaseButton; break; } } if (this.scrollbar.getOrientation() == Adjustable.VERTICAL) { BufferedImage bi = this.getTrackVertical(trackBounds, compTopState, compBottomState); graphics.drawImage(bi, trackBounds.x, trackBounds.y, null); } else { BufferedImage bi = this.scrollbar.getComponentOrientation() .isLeftToRight() ? this.getTrackHorizontal(trackBounds, compTopState, compBottomState) : this.getTrackHorizontal( trackBounds, compBottomState, compTopState); graphics.drawImage(bi, trackBounds.x, trackBounds.y, null); } graphics.dispose(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicScrollBarUI#paintThumb(java.awt.Graphics, * javax.swing.JComponent, java.awt.Rectangle) */ @Override protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { // System.out.println("Thumb"); Graphics2D graphics = (Graphics2D) g.create(); // ControlBackgroundComposite composite = SubstanceCoreUtilities // .getControlBackgroundComposite(this.scrollbar); // JScrollBar scrollBar = (JScrollBar) c; this.thumbModel.setSelected(this.thumbModel.isSelected() || this.isDragging); this.thumbModel.setEnabled(c.isEnabled()); boolean isVertical = (this.scrollbar.getOrientation() == Adjustable.VERTICAL); if (isVertical) { Rectangle adjustedBounds = new Rectangle(thumbBounds.x, thumbBounds.y, thumbBounds.width, thumbBounds.height); BufferedImage thumbImage = this.getThumbVertical(adjustedBounds); graphics.drawImage(thumbImage, adjustedBounds.x, adjustedBounds.y, null); } else { Rectangle adjustedBounds = new Rectangle(thumbBounds.x, thumbBounds.y, thumbBounds.width, thumbBounds.height); BufferedImage thumbImage = this.getThumbHorizontal(adjustedBounds); graphics.drawImage(thumbImage, adjustedBounds.x, adjustedBounds.y, null); } graphics.dispose(); } @Override public void paint(Graphics g, JComponent c) { Graphics2D graphics = (Graphics2D) g.create(); BackgroundPaintingUtils.update(graphics, c, false); float alpha = SubstanceColorSchemeUtilities.getAlpha(this.scrollbar, ComponentState.getState(this.thumbModel, this.scrollbar)); graphics.setComposite(TransitionLayout.getAlphaComposite(c, alpha, g)); super.paint(graphics, c); graphics.dispose(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicScrollBarUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); this.scrollBarWidth = SubstanceSizeUtils .getScrollBarWidth(SubstanceSizeUtils .getComponentFontSize(this.scrollbar)); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicScrollBarUI#installComponents() */ @Override protected void installComponents() { super.installComponents(); switch (this.scrollbar.getOrientation()) { case JScrollBar.VERTICAL: this.mySecondDecreaseButton = this.createGeneralDecreaseButton( NORTH, false); this.mySecondIncreaseButton = this.createGeneralIncreaseButton( SOUTH, false); break; case JScrollBar.HORIZONTAL: if (this.scrollbar.getComponentOrientation().isLeftToRight()) { this.mySecondDecreaseButton = this.createGeneralDecreaseButton( WEST, false); this.mySecondIncreaseButton = this.createGeneralIncreaseButton( EAST, false); } else { this.mySecondDecreaseButton = this.createGeneralDecreaseButton( EAST, false); this.mySecondIncreaseButton = this.createGeneralIncreaseButton( WEST, false); } break; } this.scrollbar.add(this.mySecondDecreaseButton); this.scrollbar.add(this.mySecondIncreaseButton); this.compositeScrollTrackModel = new CompositeButtonModel( this.thumbModel, this.incrButton, this.decrButton, this.mySecondDecreaseButton, this.mySecondIncreaseButton); this.compositeButtonsModel = new CompositeButtonModel( new DefaultButtonModel(), this.incrButton, this.decrButton, this.mySecondDecreaseButton, this.mySecondIncreaseButton); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicScrollBarUI#uninstallComponents() */ @Override protected void uninstallComponents() { this.scrollbar.remove(this.mySecondDecreaseButton); this.scrollbar.remove(this.mySecondIncreaseButton); super.uninstallComponents(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicScrollBarUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); this.substanceMouseListener = new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { SubstanceScrollBarUI.this.scrollbar.repaint(); } @Override public void mouseExited(MouseEvent e) { SubstanceScrollBarUI.this.scrollbar.repaint(); } @Override public void mousePressed(MouseEvent e) { SubstanceScrollBarUI.this.scrollbar.repaint(); } @Override public void mouseReleased(MouseEvent e) { SubstanceScrollBarUI.this.scrollbar.repaint(); } }; this.incrButton.addMouseListener(this.substanceMouseListener); this.decrButton.addMouseListener(this.substanceMouseListener); this.mySecondDecreaseButton .addMouseListener(this.substanceMouseListener); this.mySecondIncreaseButton .addMouseListener(this.substanceMouseListener); this.substanceThumbRolloverListener = new RolloverControlListener(this, this.thumbModel); this.scrollbar.addMouseListener(this.substanceThumbRolloverListener); this.scrollbar .addMouseMotionListener(this.substanceThumbRolloverListener); this.substanceFadeStateListener = new FadeStateListener(this.scrollbar, this.thumbModel, SubstanceCoreUtilities.getFadeCallback( this.scrollbar, this.thumbModel, false, false, this.scrollbar)); this.substanceFadeStateListener.registerListeners(false); this.substancePropertyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("font".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { scrollbar.updateUI(); } }); } if ("background".equals(evt.getPropertyName())) { // propagate application-specific background color to the // scroll buttons. Color newBackgr = (Color) evt.getNewValue(); if (!(newBackgr instanceof UIResource)) { if (mySecondDecreaseButton != null) { if (mySecondDecreaseButton.getBackground() instanceof UIResource) { mySecondDecreaseButton.setBackground(newBackgr); } } if (mySecondIncreaseButton != null) { if (mySecondIncreaseButton.getBackground() instanceof UIResource) { mySecondIncreaseButton.setBackground(newBackgr); } } if (incrButton != null) { if (incrButton.getBackground() instanceof UIResource) { incrButton.setBackground(newBackgr); } } if (decrButton != null) { if (decrButton.getBackground() instanceof UIResource) { decrButton.setBackground(newBackgr); } } } } } }; this.scrollbar .addPropertyChangeListener(this.substancePropertyListener); this.mySecondDecreaseButton.addMouseListener(this.buttonListener); this.mySecondIncreaseButton.addMouseListener(this.buttonListener); this.substanceAdjustmentListener = new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { SubstanceCoreUtilities .testComponentStateChangeThreadingViolation(scrollbar); Component parent = SubstanceScrollBarUI.this.scrollbar .getParent(); if (parent instanceof JScrollPane) { JScrollPane jsp = (JScrollPane) parent; JScrollBar hor = jsp.getHorizontalScrollBar(); JScrollBar ver = jsp.getVerticalScrollBar(); JScrollBar other = null; if (SubstanceScrollBarUI.this.scrollbar == hor) { other = ver; } if (SubstanceScrollBarUI.this.scrollbar == ver) { other = hor; } if ((other != null) && other.isVisible()) other.repaint(); SubstanceScrollBarUI.this.scrollbar.repaint(); } } }; this.scrollbar.addAdjustmentListener(this.substanceAdjustmentListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicScrollBarUI#uninstallListeners() */ @Override protected void uninstallListeners() { // fix for defect 109 - memory leak on changing skin this.incrButton.removeMouseListener(this.substanceMouseListener); this.decrButton.removeMouseListener(this.substanceMouseListener); this.mySecondDecreaseButton .removeMouseListener(this.substanceMouseListener); this.mySecondIncreaseButton .removeMouseListener(this.substanceMouseListener); this.substanceMouseListener = null; this.scrollbar.removeMouseListener(this.substanceThumbRolloverListener); this.scrollbar .removeMouseMotionListener(this.substanceThumbRolloverListener); this.substanceThumbRolloverListener = null; this.substanceFadeStateListener.unregisterListeners(); this.substanceFadeStateListener = null; this.scrollbar .removePropertyChangeListener(this.substancePropertyListener); this.substancePropertyListener = null; this.mySecondDecreaseButton.removeMouseListener(this.buttonListener); this.mySecondIncreaseButton.removeMouseListener(this.buttonListener); this.scrollbar .removeAdjustmentListener(this.substanceAdjustmentListener); this.substanceAdjustmentListener = null; super.uninstallListeners(); } /* * (non-Javadoc) * * @see org.jvnet.substance.Trackable#isInside(java.awt.event.MouseEvent) */ public boolean isInside(MouseEvent me) { // Rectangle thumbB = this.getThumbBounds(); Rectangle trackB = this.getTrackBounds(); if (trackB == null) return false; return trackB.contains(me.getX(), me.getY()); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicScrollBarUI#scrollByBlock(int) */ @Override public void scrollByBlock(int direction) { // This method is called from SubstanceScrollPaneUI to implement wheel // scrolling. int oldValue = this.scrollbar.getValue(); int blockIncrement = this.scrollbar.getBlockIncrement(direction); int delta = blockIncrement * ((direction > 0) ? +1 : -1); int newValue = oldValue + delta; // Check for overflow. if ((delta > 0) && (newValue < oldValue)) { newValue = this.scrollbar.getMaximum(); } else if ((delta < 0) && (newValue > oldValue)) { newValue = this.scrollbar.getMinimum(); } this.scrollbar.setValue(newValue); } /** * Scrolls the associated scroll bar. * * @param direction * Direction. * @param units * Scroll units. */ public void scrollByUnits(int direction, int units) { // This method is called from SubstanceScrollPaneUI to implement wheel // scrolling. int delta; for (int i = 0; i < units; i++) { if (direction > 0) { delta = this.scrollbar.getUnitIncrement(direction); } else { delta = -this.scrollbar.getUnitIncrement(direction); } int oldValue = this.scrollbar.getValue(); int newValue = oldValue + delta; // Check for overflow. if ((delta > 0) && (newValue < oldValue)) { newValue = this.scrollbar.getMaximum(); } else if ((delta < 0) && (newValue > oldValue)) { newValue = this.scrollbar.getMinimum(); } if (oldValue == newValue) { break; } this.scrollbar.setValue(newValue); } } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicScrollBarUI#layoutVScrollbar(javax.swing. * JScrollBar) */ @Override protected void layoutVScrollbar(JScrollBar sb) { ScrollPaneButtonPolicyKind buttonPolicy = SubstanceCoreUtilities .getScrollPaneButtonsPolicyKind(this.scrollbar); this.mySecondDecreaseButton.setBounds(0, 0, 0, 0); this.mySecondIncreaseButton.setBounds(0, 0, 0, 0); switch (buttonPolicy) { case OPPOSITE: super.layoutVScrollbar(sb); break; case NONE: this.layoutVScrollbarNone(sb); break; case ADJACENT: this.layoutVScrollbarAdjacent(sb); break; case MULTIPLE: this.layoutVScrollbarMultiple(sb); break; case MULTIPLE_BOTH: this.layoutVScrollbarMultipleBoth(sb); break; } } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicScrollBarUI#layoutHScrollbar(javax.swing. * JScrollBar) */ @Override protected void layoutHScrollbar(JScrollBar sb) { this.mySecondDecreaseButton.setBounds(0, 0, 0, 0); this.mySecondIncreaseButton.setBounds(0, 0, 0, 0); ScrollPaneButtonPolicyKind buttonPolicy = SubstanceCoreUtilities .getScrollPaneButtonsPolicyKind(this.scrollbar); switch (buttonPolicy) { case OPPOSITE: super.layoutHScrollbar(sb); break; case NONE: this.layoutHScrollbarNone(sb); break; case ADJACENT: this.layoutHScrollbarAdjacent(sb); break; case MULTIPLE: this.layoutHScrollbarMultiple(sb); break; case MULTIPLE_BOTH: this.layoutHScrollbarMultipleBoth(sb); break; } } /** * Lays out the vertical scroll bar when the button policy is * {@link SubstanceConstants.ScrollPaneButtonPolicyKind#ADJACENT}. * * @param sb * Scroll bar. */ protected void layoutVScrollbarAdjacent(JScrollBar sb) { Dimension sbSize = sb.getSize(); Insets sbInsets = sb.getInsets(); /* * Width and left edge of the buttons and thumb. */ int itemW = sbSize.width - (sbInsets.left + sbInsets.right); int itemX = sbInsets.left; /* * Nominal locations of the buttons, assuming their preferred size will * fit. */ int incrButtonH = itemW; int incrButtonY = sbSize.height - (sbInsets.bottom + incrButtonH); int decrButton2H = itemW; int decrButton2Y = incrButtonY - decrButton2H; /* * The thumb must fit within the height left over after we subtract the * preferredSize of the buttons and the insets. */ int sbInsetsH = sbInsets.top + sbInsets.bottom; int sbButtonsH = decrButton2H + incrButtonH; float trackH = sbSize.height - (sbInsetsH + sbButtonsH); /* * Compute the height and origin of the thumb. The case where the thumb * is at the bottom edge is handled specially to avoid numerical * problems in computing thumbY. Enforce the thumbs min/max dimensions. * If the thumb doesn't fit in the track (trackH) we'll hide it later. */ float min = sb.getMinimum(); float extent = sb.getVisibleAmount(); float range = sb.getMaximum() - min; float value = sb.getValue(); int thumbH = (range <= 0) ? this.getMaximumThumbSize().height : (int) (trackH * (extent / range)); thumbH = Math.max(thumbH, this.getMinimumThumbSize().height); thumbH = Math.min(thumbH, this.getMaximumThumbSize().height); int thumbY = decrButton2Y - thumbH; if (value < (sb.getMaximum() - sb.getVisibleAmount())) { float thumbRange = trackH - thumbH; thumbY = (int) (0.5f + (thumbRange * ((value - min) / (range - extent)))); } /* * If the buttons don't fit, allocate half of the available space to * each and move the lower one (incrButton) down. */ int sbAvailButtonH = (sbSize.height - sbInsetsH); if (sbAvailButtonH < sbButtonsH) { incrButtonH = decrButton2H = sbAvailButtonH / 2; incrButtonY = sbSize.height - (sbInsets.bottom + incrButtonH); } this.mySecondIncreaseButton.setBounds(0, 0, 0, 0); this.decrButton.setBounds(0, 0, 0, 0); this.mySecondDecreaseButton.setBounds(itemX, incrButtonY - decrButton2H, itemW, decrButton2H); this.incrButton.setBounds(itemX, incrButtonY - 1, itemW, incrButtonH + 1); /* * Update the trackRect field. */ int itrackY = 0; int itrackH = decrButton2Y - itrackY; this.trackRect.setBounds(itemX, itrackY, itemW, itrackH); /* * If the thumb isn't going to fit, zero it's bounds. Otherwise make * sure it fits between the buttons. Note that setting the thumbs bounds * will cause a repaint. */ if (thumbH >= (int) trackH) { this.setThumbBounds(0, 0, 0, 0); } else { if ((thumbY + thumbH) > decrButton2Y) { thumbY = decrButton2Y - thumbH; } if (thumbY < 0) { thumbY = 0; } this.setThumbBounds(itemX, thumbY, itemW, thumbH); } } /** * Lays out the vertical scroll bar when the button policy is * {@link SubstanceConstants.ScrollPaneButtonPolicyKind#ADJACENT}. * * @param sb * Scroll bar. */ protected void layoutVScrollbarNone(JScrollBar sb) { Dimension sbSize = sb.getSize(); Insets sbInsets = sb.getInsets(); /* * Width and left edge of the buttons and thumb. */ int itemW = sbSize.width - (sbInsets.left + sbInsets.right); int itemX = sbInsets.left; /* * Nominal locations of the buttons, assuming their preferred size will * fit. */ int incrButtonH = 0; int incrButtonY = sbSize.height - (sbInsets.bottom + incrButtonH); int decrButton2H = 0; int decrButton2Y = incrButtonY - decrButton2H; /* * The thumb must fit within the height left over after we subtract the * preferredSize of the buttons and the insets. */ int sbInsetsH = sbInsets.top + sbInsets.bottom; int sbButtonsH = decrButton2H + incrButtonH; float trackH = sbSize.height - (sbInsetsH + sbButtonsH); /* * Compute the height and origin of the thumb. The case where the thumb * is at the bottom edge is handled specially to avoid numerical * problems in computing thumbY. Enforce the thumbs min/max dimensions. * If the thumb doesn't fit in the track (trackH) we'll hide it later. */ float min = sb.getMinimum(); float extent = sb.getVisibleAmount(); float range = sb.getMaximum() - min; float value = sb.getValue(); int thumbH = (range <= 0) ? this.getMaximumThumbSize().height : (int) (trackH * (extent / range)); thumbH = Math.max(thumbH, this.getMinimumThumbSize().height); thumbH = Math.min(thumbH, this.getMaximumThumbSize().height); int thumbY = decrButton2Y - thumbH; if (value < (sb.getMaximum() - sb.getVisibleAmount())) { float thumbRange = trackH - thumbH; thumbY = (int) (0.5f + (thumbRange * ((value - min) / (range - extent)))); } /* * If the buttons don't fit, allocate half of the available space to * each and move the lower one (incrButton) down. */ int sbAvailButtonH = (sbSize.height - sbInsetsH); if (sbAvailButtonH < sbButtonsH) { incrButtonH = 0;// decrButton2H = 0; // incrButtonY = sbSize.height - (sbInsets.bottom + incrButtonH); } this.decrButton.setBounds(0, 0, 0, 0); this.mySecondDecreaseButton.setBounds(0, 0, 0, 0); this.incrButton.setBounds(0, 0, 0, 0); this.mySecondIncreaseButton.setBounds(0, 0, 0, 0); /* * Update the trackRect field. */ int itrackY = 0; int itrackH = decrButton2Y - itrackY; this.trackRect.setBounds(itemX, itrackY, itemW, itrackH); /* * If the thumb isn't going to fit, zero it's bounds. Otherwise make * sure it fits between the buttons. Note that setting the thumbs bounds * will cause a repaint. */ if (thumbH >= (int) trackH) { this.setThumbBounds(0, 0, 0, 0); } else { if ((thumbY + thumbH) > decrButton2Y) { thumbY = decrButton2Y - thumbH; } if (thumbY < 0) { thumbY = 0; } this.setThumbBounds(itemX, thumbY, itemW, thumbH); } } /** * Lays out the vertical scroll bar when the button policy is * {@link SubstanceConstants.ScrollPaneButtonPolicyKind#MULTIPLE}. * * @param sb * Scroll bar. */ protected void layoutVScrollbarMultiple(JScrollBar sb) { Dimension sbSize = sb.getSize(); Insets sbInsets = sb.getInsets(); /* * Width and left edge of the buttons and thumb. */ int itemW = sbSize.width - (sbInsets.left + sbInsets.right); int itemX = sbInsets.left; /* * Nominal locations of the buttons, assuming their preferred size will * fit. */ int incrButtonH = itemW; int incrButtonY = sbSize.height - (sbInsets.bottom + incrButtonH); int decrButton2H = itemW; int decrButton2Y = incrButtonY - decrButton2H; int decrButtonH = itemW; int decrButtonY = sbInsets.top; /* * The thumb must fit within the height left over after we subtract the * preferredSize of the buttons and the insets. */ int sbInsetsH = sbInsets.top + sbInsets.bottom; int sbButtonsH = decrButton2H + incrButtonH + decrButtonH; float trackH = sbSize.height - (sbInsetsH + sbButtonsH); /* * Compute the height and origin of the thumb. The case where the thumb * is at the bottom edge is handled specially to avoid numerical * problems in computing thumbY. Enforce the thumbs min/max dimensions. * If the thumb doesn't fit in the track (trackH) we'll hide it later. */ float min = sb.getMinimum(); float extent = sb.getVisibleAmount(); float range = sb.getMaximum() - min; float value = sb.getValue(); int thumbH = (range <= 0) ? this.getMaximumThumbSize().height : (int) (trackH * (extent / range)); thumbH = Math.max(thumbH, this.getMinimumThumbSize().height); thumbH = Math.min(thumbH, this.getMaximumThumbSize().height); int thumbY = decrButton2Y - thumbH; if (value < (sb.getMaximum() - sb.getVisibleAmount())) { float thumbRange = trackH - thumbH; thumbY = (int) (0.5f + (thumbRange * ((value - min) / (range - extent)))); thumbY += decrButtonY + decrButtonH; } /* * If the buttons don't fit, allocate half of the available space to * each and move the lower one (incrButton) down. */ int sbAvailButtonH = (sbSize.height - sbInsetsH); if (sbAvailButtonH < sbButtonsH) { incrButtonH = decrButton2H = decrButtonH = sbAvailButtonH / 2; incrButtonY = sbSize.height - (sbInsets.bottom + incrButtonH); } this.decrButton.setBounds(itemX, decrButtonY, itemW, decrButtonH); this.mySecondDecreaseButton.setBounds(itemX, incrButtonY - decrButton2H, itemW, decrButton2H); this.incrButton.setBounds(itemX, incrButtonY - 1, itemW, incrButtonH + 1); this.mySecondIncreaseButton.setBounds(0, 0, 0, 0); /* * Update the trackRect field. */ int itrackY = decrButtonY + decrButtonH; int itrackH = decrButton2Y - itrackY; this.trackRect.setBounds(itemX, itrackY, itemW, itrackH); /* * If the thumb isn't going to fit, zero it's bounds. Otherwise make * sure it fits between the buttons. Note that setting the thumbs bounds * will cause a repaint. */ if (thumbH >= (int) trackH) { this.setThumbBounds(0, 0, 0, 0); } else { if ((thumbY + thumbH) > decrButton2Y) { thumbY = decrButton2Y - thumbH; } if (thumbY < (decrButtonY + decrButtonH)) { thumbY = decrButtonY + decrButtonH + 1; } this.setThumbBounds(itemX, thumbY, itemW, thumbH); } } /** * Lays out the vertical scroll bar when the button policy is * {@link SubstanceConstants.ScrollPaneButtonPolicyKind#MULTIPLE_BOTH}. * * @param sb * Scroll bar. */ protected void layoutVScrollbarMultipleBoth(JScrollBar sb) { Dimension sbSize = sb.getSize(); Insets sbInsets = sb.getInsets(); /* * Width and left edge of the buttons and thumb. */ int itemW = sbSize.width - (sbInsets.left + sbInsets.right); int itemX = sbInsets.left; /* * Nominal locations of the buttons, assuming their preferred size will * fit. */ int incrButtonH = itemW; int incrButtonY = sbSize.height - (sbInsets.bottom + incrButtonH); int decrButton2H = itemW; int decrButton2Y = incrButtonY - decrButton2H; int decrButtonH = itemW; int decrButtonY = sbInsets.top; int incrButton2H = itemW; int incrButton2Y = decrButtonY + decrButtonH; /* * The thumb must fit within the height left over after we subtract the * preferredSize of the buttons and the insets. */ int sbInsetsH = sbInsets.top + sbInsets.bottom; int sbButtonsH = decrButton2H + incrButtonH + decrButtonH + incrButton2H; float trackH = sbSize.height - (sbInsetsH + sbButtonsH); /* * Compute the height and origin of the thumb. The case where the thumb * is at the bottom edge is handled specially to avoid numerical * problems in computing thumbY. Enforce the thumbs min/max dimensions. * If the thumb doesn't fit in the track (trackH) we'll hide it later. */ float min = sb.getMinimum(); float extent = sb.getVisibleAmount(); float range = sb.getMaximum() - min; float value = sb.getValue(); int thumbH = (range <= 0) ? this.getMaximumThumbSize().height : (int) (trackH * (extent / range)); thumbH = Math.max(thumbH, this.getMinimumThumbSize().height); thumbH = Math.min(thumbH, this.getMaximumThumbSize().height); int thumbY = decrButton2Y - thumbH; if (value < (sb.getMaximum() - sb.getVisibleAmount())) { float thumbRange = trackH - thumbH; thumbY = (int) (0.5f + (thumbRange * ((value - min) / (range - extent)))); thumbY += incrButton2Y + incrButton2H; } /* * If the buttons don't fit, allocate half of the available space to * each and move the lower one (incrButton) down. */ int sbAvailButtonH = (sbSize.height - sbInsetsH); if (sbAvailButtonH < sbButtonsH) { incrButtonH = decrButton2H = decrButtonH = incrButton2H = sbAvailButtonH / 4; incrButtonY = sbSize.height - (sbInsets.bottom + incrButtonH); } this.decrButton.setBounds(itemX, decrButtonY, itemW, decrButtonH); this.mySecondDecreaseButton.setBounds(itemX, incrButtonY - decrButton2H, itemW, decrButton2H); this.incrButton.setBounds(itemX, incrButtonY - 1, itemW, incrButtonH + 1); this.mySecondIncreaseButton.setBounds(itemX, decrButtonY + decrButtonH - 1, itemW, incrButton2H + 1); /* * Update the trackRect field. */ int itrackY = incrButton2Y + incrButton2H; int itrackH = decrButton2Y - itrackY; this.trackRect.setBounds(itemX, itrackY, itemW, itrackH); /* * If the thumb isn't going to fit, zero it's bounds. Otherwise make * sure it fits between the buttons. Note that setting the thumbs bounds * will cause a repaint. */ if (thumbH >= (int) trackH) { this.setThumbBounds(0, 0, 0, 0); } else { if ((thumbY + thumbH) > decrButton2Y) { thumbY = decrButton2Y - thumbH; } if (thumbY < (incrButton2Y + incrButton2H)) { thumbY = incrButton2Y + incrButton2H + 1; } this.setThumbBounds(itemX, thumbY, itemW, thumbH); } } /** * Lays out the horizontal scroll bar when the button policy is * {@link SubstanceConstants.ScrollPaneButtonPolicyKind#ADJACENT}. * * @param sb * Scroll bar. */ protected void layoutHScrollbarAdjacent(JScrollBar sb) { Dimension sbSize = sb.getSize(); Insets sbInsets = sb.getInsets(); /* * Height and top edge of the buttons and thumb. */ int itemH = sbSize.height - (sbInsets.top + sbInsets.bottom); int itemY = sbInsets.top; boolean ltr = sb.getComponentOrientation().isLeftToRight(); /* * Nominal locations of the buttons, assuming their preferred size will * fit. */ int decrButton2W = itemH; int incrButtonW = itemH; int incrButtonX = ltr ? sbSize.width - (sbInsets.right + incrButtonW) : sbInsets.left; int decrButton2X = ltr ? incrButtonX - decrButton2W : incrButtonX + decrButton2W; /* * The thumb must fit within the width left over after we subtract the * preferredSize of the buttons and the insets. */ int sbInsetsW = sbInsets.left + sbInsets.right; int sbButtonsW = decrButton2W + incrButtonW; float trackW = sbSize.width - (sbInsetsW + sbButtonsW); /* * Compute the width and origin of the thumb. Enforce the thumbs min/max * dimensions. The case where the thumb is at the right edge is handled * specially to avoid numerical problems in computing thumbX. If the * thumb doesn't fit in the track (trackH) we'll hide it later. */ float min = sb.getMinimum(); float max = sb.getMaximum(); float extent = sb.getVisibleAmount(); float range = max - min; float value = sb.getValue(); int thumbW = (range <= 0) ? this.getMaximumThumbSize().width : (int) (trackW * (extent / range)); thumbW = Math.max(thumbW, this.getMinimumThumbSize().width); thumbW = Math.min(thumbW, this.getMaximumThumbSize().width); int thumbX = ltr ? decrButton2X - thumbW : sbInsets.left; if (value < (max - sb.getVisibleAmount())) { float thumbRange = trackW - thumbW; if (ltr) { thumbX = (int) (0.5f + (thumbRange * ((value - min) / (range - extent)))); } else { thumbX = (int) (0.5f + (thumbRange * ((max - extent - value) / (range - extent)))); thumbX += decrButton2X + decrButton2W; } } /* * If the buttons don't fit, allocate half of the available space to * each and move the right one over. */ int sbAvailButtonW = (sbSize.width - sbInsetsW); if (sbAvailButtonW < sbButtonsW) { incrButtonW = decrButton2W = sbAvailButtonW / 2; incrButtonX = ltr ? sbSize.width - (sbInsets.right + incrButtonW) : sbInsets.left; } this.mySecondDecreaseButton.setBounds(decrButton2X + (ltr ? 0 : -1), itemY, decrButton2W + 1, itemH); this.incrButton.setBounds(incrButtonX, itemY, incrButtonW, itemH); this.decrButton.setBounds(0, 0, 0, 0); this.mySecondIncreaseButton.setBounds(0, 0, 0, 0); /* * Update the trackRect field. */ if (ltr) { int itrackX = sbInsets.left; int itrackW = decrButton2X - itrackX; this.trackRect.setBounds(itrackX, itemY, itrackW, itemH); } else { int itrackX = decrButton2X + decrButton2W; int itrackW = sbSize.width - itrackX; this.trackRect.setBounds(itrackX, itemY, itrackW, itemH); } /* * Make sure the thumb fits between the buttons. Note that setting the * thumbs bounds causes a repaint. */ if (thumbW >= (int) trackW) { this.setThumbBounds(0, 0, 0, 0); } else { if (ltr) { if (thumbX + thumbW > decrButton2X) { thumbX = decrButton2X - thumbW; } if (thumbX < 0) { thumbX = 1; } } else { if (thumbX + thumbW > (sbSize.width - sbInsets.left)) { thumbX = sbSize.width - sbInsets.left - thumbW; } if (thumbX < (decrButton2X + decrButton2W)) { thumbX = decrButton2X + decrButton2W + 1; } } this.setThumbBounds(thumbX, itemY, thumbW, itemH); } } /** * Lays out the horizontal scroll bar when the button policy is * {@link SubstanceConstants.ScrollPaneButtonPolicyKind#NONE}. * * @param sb * Scroll bar. */ protected void layoutHScrollbarNone(JScrollBar sb) { Dimension sbSize = sb.getSize(); Insets sbInsets = sb.getInsets(); /* * Height and top edge of the buttons and thumb. */ int itemH = sbSize.height - (sbInsets.top + sbInsets.bottom); int itemY = sbInsets.top; boolean ltr = sb.getComponentOrientation().isLeftToRight(); /* * Nominal locations of the buttons, assuming their preferred size will * fit. */ int decrButton2W = 0; int incrButtonW = 0; int incrButtonX = ltr ? sbSize.width - (sbInsets.right + incrButtonW) : sbInsets.left; int decrButton2X = ltr ? incrButtonX - decrButton2W : incrButtonX + decrButton2W; /* * The thumb must fit within the width left over after we subtract the * preferredSize of the buttons and the insets. */ int sbInsetsW = sbInsets.left + sbInsets.right; int sbButtonsW = decrButton2W + incrButtonW; float trackW = sbSize.width - (sbInsetsW + sbButtonsW); /* * Compute the width and origin of the thumb. Enforce the thumbs min/max * dimensions. The case where the thumb is at the right edge is handled * specially to avoid numerical problems in computing thumbX. If the * thumb doesn't fit in the track (trackH) we'll hide it later. */ float min = sb.getMinimum(); float max = sb.getMaximum(); float extent = sb.getVisibleAmount(); float range = max - min; float value = sb.getValue(); int thumbW = (range <= 0) ? this.getMaximumThumbSize().width : (int) (trackW * (extent / range)); thumbW = Math.max(thumbW, this.getMinimumThumbSize().width); thumbW = Math.min(thumbW, this.getMaximumThumbSize().width); int thumbX = ltr ? decrButton2X - thumbW : sbInsets.left; if (value < (max - sb.getVisibleAmount())) { float thumbRange = trackW - thumbW; if (ltr) { thumbX = (int) (0.5f + (thumbRange * ((value - min) / (range - extent)))); } else { thumbX = (int) (0.5f + (thumbRange * ((max - extent - value) / (range - extent)))); thumbX += decrButton2X + decrButton2W; } } /* * If the buttons don't fit, allocate half of the available space to * each and move the right one over. */ int sbAvailButtonW = (sbSize.width - sbInsetsW); if (sbAvailButtonW < sbButtonsW) { incrButtonW = decrButton2W = 0; // incrButtonX = ltr ? sbSize.width - (sbInsets.right + incrButtonW) // : sbInsets.left; } this.incrButton.setBounds(0, 0, 0, 0); this.decrButton.setBounds(0, 0, 0, 0); this.mySecondIncreaseButton.setBounds(0, 0, 0, 0); this.mySecondDecreaseButton.setBounds(0, 0, 0, 0); /* * Update the trackRect field. */ if (ltr) { int itrackX = sbInsets.left; int itrackW = decrButton2X - itrackX; this.trackRect.setBounds(itrackX, itemY, itrackW, itemH); } else { int itrackX = decrButton2X + decrButton2W; int itrackW = sbSize.width - itrackX; this.trackRect.setBounds(itrackX, itemY, itrackW, itemH); } /* * Make sure the thumb fits between the buttons. Note that setting the * thumbs bounds causes a repaint. */ if (thumbW >= (int) trackW) { this.setThumbBounds(0, 0, 0, 0); } else { if (ltr) { if (thumbX + thumbW > decrButton2X) { thumbX = decrButton2X - thumbW; } if (thumbX < 0) { thumbX = 1; } } else { if (thumbX + thumbW > (sbSize.width - sbInsets.left)) { thumbX = sbSize.width - sbInsets.left - thumbW; } if (thumbX < (decrButton2X + decrButton2W)) { thumbX = decrButton2X + decrButton2W + 1; } } this.setThumbBounds(thumbX, itemY, thumbW, itemH); } } /** * Lays out the horizontal scroll bar when the button policy is * {@link SubstanceConstants.ScrollPaneButtonPolicyKind#MULTIPLE}. * * @param sb * Scroll bar. */ protected void layoutHScrollbarMultiple(JScrollBar sb) { Dimension sbSize = sb.getSize(); Insets sbInsets = sb.getInsets(); /* * Height and top edge of the buttons and thumb. */ int itemH = sbSize.height - (sbInsets.top + sbInsets.bottom); int itemY = sbInsets.top; boolean ltr = sb.getComponentOrientation().isLeftToRight(); /* * Nominal locations of the buttons, assuming their preferred size will * fit. */ int decrButton2W = itemH; int decrButtonW = itemH; int incrButtonW = itemH; int incrButtonX = ltr ? sbSize.width - (sbInsets.right + incrButtonW) : sbInsets.left; int decrButton2X = ltr ? incrButtonX - decrButton2W : incrButtonX + decrButton2W; int decrButtonX = ltr ? sbInsets.left : sbSize.width - sbInsets.right - decrButtonW; /* * The thumb must fit within the width left over after we subtract the * preferredSize of the buttons and the insets. */ int sbInsetsW = sbInsets.left + sbInsets.right; int sbButtonsW = decrButton2W + incrButtonW + decrButtonW; float trackW = sbSize.width - (sbInsetsW + sbButtonsW); /* * Compute the width and origin of the thumb. Enforce the thumbs min/max * dimensions. The case where the thumb is at the right edge is handled * specially to avoid numerical problems in computing thumbX. If the * thumb doesn't fit in the track (trackH) we'll hide it later. */ float min = sb.getMinimum(); float max = sb.getMaximum(); float extent = sb.getVisibleAmount(); float range = max - min; float value = sb.getValue(); int thumbW = (range <= 0) ? this.getMaximumThumbSize().width : (int) (trackW * (extent / range)); thumbW = Math.max(thumbW, this.getMinimumThumbSize().width); thumbW = Math.min(thumbW, this.getMaximumThumbSize().width); int thumbX = ltr ? decrButton2X - thumbW : sbInsets.left; if (value < (max - sb.getVisibleAmount())) { float thumbRange = trackW - thumbW; if (ltr) { thumbX = (int) (0.5f + (thumbRange * ((value - min) / (range - extent)))); thumbX += decrButtonX + decrButtonW; } else { thumbX = (int) (0.5f + (thumbRange * ((max - extent - value) / (range - extent)))); thumbX += decrButton2X + decrButton2W; } } /* * If the buttons don't fit, allocate half of the available space to * each and move the right one over. */ int sbAvailButtonW = (sbSize.width - sbInsetsW); if (sbAvailButtonW < sbButtonsW) { incrButtonW = decrButton2W = decrButtonW = sbAvailButtonW / 2; incrButtonX = ltr ? sbSize.width - (sbInsets.right + incrButtonW) : sbInsets.left; } this.mySecondDecreaseButton.setBounds(decrButton2X + (ltr ? 0 : -1), itemY, decrButton2W + 1, itemH); this.incrButton.setBounds(incrButtonX, itemY, incrButtonW, itemH); this.decrButton.setBounds(decrButtonX, itemY, decrButtonW, itemH); this.mySecondIncreaseButton.setBounds(0, 0, 0, 0); /* * Update the trackRect field. */ if (ltr) { int itrackX = decrButtonX + decrButtonW; int itrackW = decrButton2X - itrackX; this.trackRect.setBounds(itrackX, itemY, itrackW, itemH); } else { int itrackX = decrButton2X + decrButton2W; int itrackW = decrButtonX - itrackX; this.trackRect.setBounds(itrackX, itemY, itrackW, itemH); } /* * Make sure the thumb fits between the buttons. Note that setting the * thumbs bounds causes a repaint. */ if (thumbW >= (int) trackW) { this.setThumbBounds(0, 0, 0, 0); } else { if (ltr) { if (thumbX + thumbW > decrButton2X) { thumbX = decrButton2X - thumbW; } if (thumbX < (decrButtonX + decrButtonW)) { thumbX = decrButtonX + decrButtonW + 1; } } else { if (thumbX + thumbW > decrButtonX) { thumbX = decrButtonX - thumbW; } if (thumbX < (decrButton2X + decrButton2W)) { thumbX = decrButton2X + decrButton2W + 1; } } this.setThumbBounds(thumbX, itemY, thumbW, itemH); } } /** * Lays out the horizontal scroll bar when the button policy is * {@link SubstanceConstants.ScrollPaneButtonPolicyKind#MULTIPLE}. * * @param sb * Scroll bar. */ protected void layoutHScrollbarMultipleBoth(JScrollBar sb) { Dimension sbSize = sb.getSize(); Insets sbInsets = sb.getInsets(); /* * Height and top edge of the buttons and thumb. */ int itemH = sbSize.height - (sbInsets.top + sbInsets.bottom); int itemY = sbInsets.top; boolean ltr = sb.getComponentOrientation().isLeftToRight(); /* * Nominal locations of the buttons, assuming their preferred size will * fit. */ int decrButton2W = itemH; int incrButton2W = itemH; int decrButtonW = itemH; int incrButtonW = itemH; int incrButtonX = ltr ? sbSize.width - (sbInsets.right + incrButtonW) : sbInsets.left; int decrButton2X = ltr ? incrButtonX - decrButton2W : incrButtonX + decrButton2W; int decrButtonX = ltr ? sbInsets.left : sbSize.width - sbInsets.right - decrButtonW; int incrButton2X = ltr ? decrButtonX + decrButtonW : decrButtonX - incrButton2W; /* * The thumb must fit within the width left over after we subtract the * preferredSize of the buttons and the insets. */ int sbInsetsW = sbInsets.left + sbInsets.right; int sbButtonsW = decrButton2W + incrButtonW + decrButtonW + incrButton2W; float trackW = sbSize.width - (sbInsetsW + sbButtonsW); /* * Compute the width and origin of the thumb. Enforce the thumbs min/max * dimensions. The case where the thumb is at the right edge is handled * specially to avoid numerical problems in computing thumbX. If the * thumb doesn't fit in the track (trackH) we'll hide it later. */ float min = sb.getMinimum(); float max = sb.getMaximum(); float extent = sb.getVisibleAmount(); float range = max - min; float value = sb.getValue(); int thumbW = (range <= 0) ? this.getMaximumThumbSize().width : (int) (trackW * (extent / range)); thumbW = Math.max(thumbW, this.getMinimumThumbSize().width); thumbW = Math.min(thumbW, this.getMaximumThumbSize().width); int thumbX = ltr ? decrButton2X - thumbW : sbInsets.left; if (value < (max - sb.getVisibleAmount())) { float thumbRange = trackW - thumbW; if (ltr) { thumbX = (int) (0.5f + (thumbRange * ((value - min) / (range - extent)))); thumbX += incrButton2X + incrButton2W; } else { thumbX = (int) (0.5f + (thumbRange * ((max - extent - value) / (range - extent)))); thumbX += decrButton2X + decrButton2W; } } /* * If the buttons don't fit, allocate half of the available space to * each and move the right one over. */ int sbAvailButtonW = (sbSize.width - sbInsetsW); if (sbAvailButtonW < sbButtonsW) { incrButtonW = decrButton2W = decrButtonW = incrButton2W = sbAvailButtonW / 4; incrButtonX = ltr ? sbSize.width - (sbInsets.right + incrButtonW) : sbInsets.left; } this.mySecondDecreaseButton.setBounds(decrButton2X + (ltr ? 0 : -1), itemY, decrButton2W + 1, itemH); this.mySecondIncreaseButton.setBounds(incrButton2X + (ltr ? -1 : 0), itemY, incrButton2W + 1, itemH); this.incrButton.setBounds(incrButtonX, itemY, incrButtonW, itemH); this.decrButton.setBounds(decrButtonX, itemY, decrButtonW, itemH); /* * Update the trackRect field. */ if (ltr) { int itrackX = incrButton2X + incrButton2W; int itrackW = decrButton2X - itrackX; this.trackRect.setBounds(itrackX, itemY, itrackW, itemH); } else { int itrackX = decrButton2X + decrButton2W; int itrackW = incrButton2X - itrackX; this.trackRect.setBounds(itrackX, itemY, itrackW, itemH); } /* * Make sure the thumb fits between the buttons. Note that setting the * thumbs bounds causes a repaint. */ if (thumbW >= (int) trackW) { this.setThumbBounds(0, 0, 0, 0); } else { if (ltr) { if (thumbX + thumbW > decrButton2X) { thumbX = decrButton2X - thumbW; } if (thumbX < (incrButton2X + incrButton2W)) { thumbX = incrButton2X + incrButton2W + 1; } } else { if (thumbX + thumbW > incrButton2X) { thumbX = incrButton2X - thumbW; } if (thumbX < (decrButton2X + decrButton2W)) { thumbX = decrButton2X + decrButton2W + 1; } } this.setThumbBounds(thumbX, itemY, thumbW, itemH); } } /** * Returns the memory usage string. * * @return The memory usage string. */ public static String getMemoryUsage() { StringBuffer sb = new StringBuffer(); sb.append("SubstanceScrollBarUI: \n"); sb.append("\t" + thumbHorizontalMap.size() + " thumb horizontal, " + thumbVerticalMap.size() + " thumb vertical"); sb.append("\t" + trackHorizontalMap.size() + " track horizontal, " + trackVerticalMap.size() + " track vertical"); sb.append("\t" + trackFullHorizontalMap.size() + " track full horizontal, " + trackFullVerticalMap.size() + " track full vertical"); return sb.toString(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicScrollBarUI#createTrackListener() */ @Override protected TrackListener createTrackListener() { return new SubstanceTrackListener(); } /** * Track mouse drags. Had to take this one from BasicScrollBarUI since the * setValueForm method is private. */ protected class SubstanceTrackListener extends TrackListener { /** * Current scroll direction. */ private transient int direction = +1; /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicScrollBarUI$TrackListener#mouseReleased * (java.awt.event.MouseEvent) */ @Override public void mouseReleased(MouseEvent e) { if (SubstanceScrollBarUI.this.isDragging) { SubstanceScrollBarUI.this.updateThumbState(e.getX(), e.getY()); } if (SwingUtilities.isRightMouseButton(e) || (!SubstanceScrollBarUI.this .getSupportsAbsolutePositioning() && SwingUtilities .isMiddleMouseButton(e))) return; if (!SubstanceScrollBarUI.this.scrollbar.isEnabled()) return; Rectangle r = SubstanceScrollBarUI.this.getTrackBounds(); SubstanceScrollBarUI.this.scrollbar.repaint(r.x, r.y, r.width, r.height); SubstanceScrollBarUI.this.trackHighlight = NO_HIGHLIGHT; SubstanceScrollBarUI.this.isDragging = false; this.offset = 0; SubstanceScrollBarUI.this.scrollTimer.stop(); SubstanceScrollBarUI.this.scrollbar.setValueIsAdjusting(false); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicScrollBarUI$TrackListener#mousePressed * (java.awt.event.MouseEvent) */ @Override public void mousePressed(MouseEvent e) { // If the mouse is pressed above the "thumb" component then reduce // the scrollbars value by one page ("page up"), otherwise increase // it by one page. If there is no thumb then page up if the mouse is // in the upper half of the track. if (SwingUtilities.isRightMouseButton(e) || (!SubstanceScrollBarUI.this .getSupportsAbsolutePositioning() && SwingUtilities .isMiddleMouseButton(e))) return; if (!SubstanceScrollBarUI.this.scrollbar.isEnabled()) return; if (!SubstanceScrollBarUI.this.scrollbar.hasFocus() && SubstanceScrollBarUI.this.scrollbar .isRequestFocusEnabled()) { SubstanceScrollBarUI.this.scrollbar.requestFocus(); } SubstanceScrollBarUI.this.scrollbar.setValueIsAdjusting(true); this.currentMouseX = e.getX(); this.currentMouseY = e.getY(); // Clicked in the Thumb area? if (SubstanceScrollBarUI.this.getThumbBounds().contains( this.currentMouseX, this.currentMouseY)) { switch (SubstanceScrollBarUI.this.scrollbar.getOrientation()) { case JScrollBar.VERTICAL: this.offset = this.currentMouseY - SubstanceScrollBarUI.this.getThumbBounds().y; break; case JScrollBar.HORIZONTAL: this.offset = this.currentMouseX - SubstanceScrollBarUI.this.getThumbBounds().x; break; } SubstanceScrollBarUI.this.isDragging = true; return; } else if (SubstanceScrollBarUI.this .getSupportsAbsolutePositioning() && SwingUtilities.isMiddleMouseButton(e)) { switch (SubstanceScrollBarUI.this.scrollbar.getOrientation()) { case JScrollBar.VERTICAL: this.offset = SubstanceScrollBarUI.this.getThumbBounds().height / 2; break; case JScrollBar.HORIZONTAL: this.offset = SubstanceScrollBarUI.this.getThumbBounds().width / 2; break; } SubstanceScrollBarUI.this.isDragging = true; this.setValueFrom(e); return; } SubstanceScrollBarUI.this.isDragging = false; Dimension sbSize = SubstanceScrollBarUI.this.scrollbar.getSize(); this.direction = +1; switch (SubstanceScrollBarUI.this.scrollbar.getOrientation()) { case JScrollBar.VERTICAL: if (SubstanceScrollBarUI.this.getThumbBounds().isEmpty()) { int scrollbarCenter = sbSize.height / 2; this.direction = (this.currentMouseY < scrollbarCenter) ? -1 : +1; } else { int thumbY = SubstanceScrollBarUI.this.getThumbBounds().y; this.direction = (this.currentMouseY < thumbY) ? -1 : +1; } break; case JScrollBar.HORIZONTAL: if (SubstanceScrollBarUI.this.getThumbBounds().isEmpty()) { int scrollbarCenter = sbSize.width / 2; this.direction = (this.currentMouseX < scrollbarCenter) ? -1 : +1; } else { int thumbX = SubstanceScrollBarUI.this.getThumbBounds().x; this.direction = (this.currentMouseX < thumbX) ? -1 : +1; } if (!SubstanceScrollBarUI.this.scrollbar .getComponentOrientation().isLeftToRight()) { this.direction = -this.direction; } break; } SubstanceScrollBarUI.this.scrollByBlock(this.direction); SubstanceScrollBarUI.this.scrollTimer.stop(); SubstanceScrollBarUI.this.scrollListener .setDirection(this.direction); SubstanceScrollBarUI.this.scrollListener.setScrollByBlock(true); this.startScrollTimerIfNecessary(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicScrollBarUI$TrackListener#mouseDragged * (java.awt.event.MouseEvent) */ @Override public void mouseDragged(MouseEvent e) { // Set the models value to the position of the thumb's top of // Vertical scrollbar, or the left/right of Horizontal scrollbar in // LTR / RTL scrollbar relative to the origin of // the track. if (SwingUtilities.isRightMouseButton(e) || (!SubstanceScrollBarUI.this .getSupportsAbsolutePositioning() && SwingUtilities .isMiddleMouseButton(e))) return; if (!SubstanceScrollBarUI.this.scrollbar.isEnabled() || SubstanceScrollBarUI.this.getThumbBounds().isEmpty()) { return; } if (SubstanceScrollBarUI.this.isDragging) { this.setValueFrom(e); } else { this.currentMouseX = e.getX(); this.currentMouseY = e.getY(); SubstanceScrollBarUI.this.updateThumbState(this.currentMouseX, this.currentMouseY); this.startScrollTimerIfNecessary(); } } /** * Sets the scrollbar value based on the specified mouse event. * * @param e * Mouse event. */ private void setValueFrom(MouseEvent e) { boolean active = SubstanceScrollBarUI.this.isThumbRollover(); BoundedRangeModel model = SubstanceScrollBarUI.this.scrollbar .getModel(); Rectangle thumbR = SubstanceScrollBarUI.this.getThumbBounds(); int thumbMin = 0, thumbMax = 0, thumbPos; ScrollPaneButtonPolicyKind buttonPolicy = SubstanceCoreUtilities .getScrollPaneButtonsPolicyKind(SubstanceScrollBarUI.this.scrollbar); if (SubstanceScrollBarUI.this.scrollbar.getOrientation() == JScrollBar.VERTICAL) { switch (buttonPolicy) { case OPPOSITE: thumbMin = SubstanceScrollBarUI.this.decrButton.getY() + SubstanceScrollBarUI.this.decrButton.getHeight(); thumbMax = SubstanceScrollBarUI.this.incrButton.getY() - thumbR.height; break; case ADJACENT: thumbMin = 0; thumbMax = SubstanceScrollBarUI.this.mySecondDecreaseButton .getY() - thumbR.height; break; case NONE: thumbMin = 0; thumbMax = SubstanceScrollBarUI.this.scrollbar.getSize().height - SubstanceScrollBarUI.this.scrollbar.getInsets().bottom - thumbR.height; break; case MULTIPLE: thumbMin = SubstanceScrollBarUI.this.decrButton.getY() + SubstanceScrollBarUI.this.decrButton.getHeight(); thumbMax = SubstanceScrollBarUI.this.mySecondDecreaseButton .getY() - thumbR.height; break; case MULTIPLE_BOTH: thumbMin = SubstanceScrollBarUI.this.mySecondIncreaseButton .getY() + SubstanceScrollBarUI.this.mySecondIncreaseButton .getHeight(); thumbMax = SubstanceScrollBarUI.this.mySecondDecreaseButton .getY() - thumbR.height; break; } thumbPos = Math.min(thumbMax, Math.max(thumbMin, (e.getY() - this.offset))); SubstanceScrollBarUI.this.setThumbBounds(thumbR.x, thumbPos, thumbR.width, thumbR.height); } else { if (SubstanceScrollBarUI.this.scrollbar .getComponentOrientation().isLeftToRight()) { switch (buttonPolicy) { case OPPOSITE: thumbMin = SubstanceScrollBarUI.this.decrButton.getX() + SubstanceScrollBarUI.this.decrButton .getWidth(); thumbMax = SubstanceScrollBarUI.this.incrButton.getX() - thumbR.width; break; case ADJACENT: thumbMin = 0; thumbMax = SubstanceScrollBarUI.this.mySecondDecreaseButton .getX() - thumbR.width; break; case MULTIPLE: thumbMin = SubstanceScrollBarUI.this.decrButton.getX() + SubstanceScrollBarUI.this.decrButton .getWidth(); thumbMax = SubstanceScrollBarUI.this.mySecondDecreaseButton .getX() - thumbR.width; break; case MULTIPLE_BOTH: thumbMin = SubstanceScrollBarUI.this.mySecondIncreaseButton .getX() + SubstanceScrollBarUI.this.mySecondIncreaseButton .getWidth(); thumbMax = SubstanceScrollBarUI.this.mySecondDecreaseButton .getX() - thumbR.width; break; case NONE: thumbMin = 0; thumbMax = SubstanceScrollBarUI.this.scrollbar .getSize().width - SubstanceScrollBarUI.this.scrollbar .getInsets().right - thumbR.width; break; } } else { switch (buttonPolicy) { case OPPOSITE: thumbMin = SubstanceScrollBarUI.this.incrButton.getX() + SubstanceScrollBarUI.this.incrButton .getWidth(); thumbMax = SubstanceScrollBarUI.this.decrButton.getX() - thumbR.width; break; case ADJACENT: thumbMin = SubstanceScrollBarUI.this.mySecondDecreaseButton .getX() + SubstanceScrollBarUI.this.mySecondDecreaseButton .getWidth(); thumbMax = SubstanceScrollBarUI.this.scrollbar .getSize().width - SubstanceScrollBarUI.this.scrollbar .getInsets().right - thumbR.width; break; case MULTIPLE: thumbMin = SubstanceScrollBarUI.this.mySecondDecreaseButton .getX() + SubstanceScrollBarUI.this.mySecondDecreaseButton .getWidth(); thumbMax = SubstanceScrollBarUI.this.decrButton.getX() - thumbR.width; break; case MULTIPLE_BOTH: thumbMin = SubstanceScrollBarUI.this.mySecondDecreaseButton .getX() + SubstanceScrollBarUI.this.mySecondDecreaseButton .getWidth(); thumbMax = SubstanceScrollBarUI.this.mySecondIncreaseButton .getX() - thumbR.width; break; case NONE: thumbMin = 0; thumbMax = SubstanceScrollBarUI.this.scrollbar .getSize().width - SubstanceScrollBarUI.this.scrollbar .getInsets().right - thumbR.width; break; } } // System.out.println(thumbMin + " : " + thumbMax + " : " // + (e.getX() - offset)); thumbPos = Math.min(thumbMax, Math.max(thumbMin, (e.getX() - this.offset))); SubstanceScrollBarUI.this.setThumbBounds(thumbPos, thumbR.y, thumbR.width, thumbR.height); } /* * Set the scrollbars value. If the thumb has reached the end of the * scrollbar, then just set the value to its maximum. Otherwise * compute the value as accurately as possible. */ if (thumbPos == thumbMax) { if (SubstanceScrollBarUI.this.scrollbar.getOrientation() == JScrollBar.VERTICAL || SubstanceScrollBarUI.this.scrollbar .getComponentOrientation().isLeftToRight()) { SubstanceScrollBarUI.this.scrollbar.setValue(model .getMaximum() - model.getExtent()); } else { SubstanceScrollBarUI.this.scrollbar.setValue(model .getMinimum()); } } else { float valueMax = model.getMaximum() - model.getExtent(); float valueRange = valueMax - model.getMinimum(); float thumbValue = thumbPos - thumbMin; float thumbRange = thumbMax - thumbMin; int value; if (SubstanceScrollBarUI.this.scrollbar.getOrientation() == JScrollBar.VERTICAL || SubstanceScrollBarUI.this.scrollbar .getComponentOrientation().isLeftToRight()) { value = (int) (0.5 + ((thumbValue / thumbRange) * valueRange)); } else { value = (int) (0.5 + (((thumbMax - thumbPos) / thumbRange) * valueRange)); } SubstanceScrollBarUI.this.scrollbar.setValue(value + model.getMinimum()); } SubstanceScrollBarUI.this.setThumbRollover(active); } /** * If necessary, starts the scroll timer. */ private void startScrollTimerIfNecessary() { if (SubstanceScrollBarUI.this.scrollTimer.isRunning()) { return; } switch (SubstanceScrollBarUI.this.scrollbar.getOrientation()) { case JScrollBar.VERTICAL: if (this.direction > 0) { if (SubstanceScrollBarUI.this.getThumbBounds().y + SubstanceScrollBarUI.this.getThumbBounds().height < ((SubstanceTrackListener) SubstanceScrollBarUI.this.trackListener).currentMouseY) { SubstanceScrollBarUI.this.scrollTimer.start(); } } else if (SubstanceScrollBarUI.this.getThumbBounds().y > ((SubstanceTrackListener) SubstanceScrollBarUI.this.trackListener).currentMouseY) { SubstanceScrollBarUI.this.scrollTimer.start(); } break; case JScrollBar.HORIZONTAL: if (this.direction > 0) { if (SubstanceScrollBarUI.this.getThumbBounds().x + SubstanceScrollBarUI.this.getThumbBounds().width < ((SubstanceTrackListener) SubstanceScrollBarUI.this.trackListener).currentMouseX) { SubstanceScrollBarUI.this.scrollTimer.start(); } } else if (SubstanceScrollBarUI.this.getThumbBounds().x > ((SubstanceTrackListener) SubstanceScrollBarUI.this.trackListener).currentMouseX) { SubstanceScrollBarUI.this.scrollTimer.start(); } break; } } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicScrollBarUI$TrackListener#mouseMoved( * java.awt.event.MouseEvent) */ @Override public void mouseMoved(MouseEvent e) { if (!SubstanceScrollBarUI.this.isDragging) { SubstanceScrollBarUI.this.updateThumbState(e.getX(), e.getY()); } } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicScrollBarUI$TrackListener#mouseExited * (java.awt.event.MouseEvent) */ @Override public void mouseExited(MouseEvent e) { if (!SubstanceScrollBarUI.this.isDragging) { SubstanceScrollBarUI.this.setThumbRollover(false); } } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicScrollBarUI#createArrowButtonListener() */ @Override protected ArrowButtonListener createArrowButtonListener() { return new SubstanceArrowButtonListener(); } /** * Listener on arrow buttons. Need to override the super implementation for * the {@link ScrollPaneButtonPolicyKind#MULTIPLE_BOTH} policy. * * @author Kirill Grouchnikov */ protected class SubstanceArrowButtonListener extends ArrowButtonListener { /** * Because we are handling both mousePressed and Actions we need to make * sure we don't fire under both conditions. (keyfocus on scrollbars * causes action without mousePress */ boolean handledEvent; /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicScrollBarUI$ArrowButtonListener#mousePressed * (java.awt.event.MouseEvent) */ @Override public void mousePressed(MouseEvent e) { if (!SubstanceScrollBarUI.this.scrollbar.isEnabled()) { return; } // not an unmodified left mouse button // if(e.getModifiers() != InputEvent.BUTTON1_MASK) {return; } if (!SwingUtilities.isLeftMouseButton(e)) { return; } int direction = ((e.getSource() == SubstanceScrollBarUI.this.incrButton) || (e .getSource() == SubstanceScrollBarUI.this.mySecondIncreaseButton)) ? 1 : -1; SubstanceScrollBarUI.this.scrollByUnit(direction); SubstanceScrollBarUI.this.scrollTimer.stop(); SubstanceScrollBarUI.this.scrollListener.setDirection(direction); SubstanceScrollBarUI.this.scrollListener.setScrollByBlock(false); SubstanceScrollBarUI.this.scrollTimer.start(); this.handledEvent = true; if (!SubstanceScrollBarUI.this.scrollbar.hasFocus() && SubstanceScrollBarUI.this.scrollbar .isRequestFocusEnabled()) { SubstanceScrollBarUI.this.scrollbar.requestFocus(); } } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicScrollBarUI$ArrowButtonListener#mouseReleased * (java.awt.event.MouseEvent) */ @Override public void mouseReleased(MouseEvent e) { SubstanceScrollBarUI.this.scrollTimer.stop(); this.handledEvent = false; SubstanceScrollBarUI.this.scrollbar.setValueIsAdjusting(false); } } /** * Updates the thumb state based on the coordinates. * * @param x * X coordinate. * @param y * Y coordinate. */ private void updateThumbState(int x, int y) { Rectangle rect = this.getThumbBounds(); this.setThumbRollover(rect.contains(x, y)); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicScrollBarUI#getPreferredSize(javax.swing. * JComponent) */ @Override public Dimension getPreferredSize(JComponent c) { if (scrollbar.getOrientation() == JScrollBar.VERTICAL) { return new Dimension(scrollBarWidth, Math.max(48, 5 * scrollBarWidth)); } else { return new Dimension(Math.max(48, 5 * scrollBarWidth), scrollBarWidth); } } }substance-5.3.orig/src/org/jvnet/substance/SubstanceLegacyDefaultLookAndFeel.java0000644000175000017500000000707711136475560030211 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import org.jvnet.substance.api.SubstanceColorSchemeBundle; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.painter.border.StandardBorderPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.decoration.Glass3DDecorationPainter; import org.jvnet.substance.painter.gradient.StandardGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.StandardButtonShaper; import org.jvnet.substance.watermark.SubstanceStripeWatermark; /** * The legacy default look and feel that provides the pre-5.0 default Substance * skin. * * @author Kirill Grouchnikov * @since 5.0 */ public class SubstanceLegacyDefaultLookAndFeel extends SubstanceLookAndFeel { /** * Creates the legacy default look-and-feel. */ public SubstanceLegacyDefaultLookAndFeel() { super(new SubstanceLegacyDefaultSkin()); } /** * Pre-5.0 default skin. * * @author Kirill Grouchnikov */ private static class SubstanceLegacyDefaultSkin extends SubstanceSkin { /** * Creates the default skin. */ public SubstanceLegacyDefaultSkin() { SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( new AquaColorScheme(), new MetallicColorScheme(), new LightGrayColorScheme()); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.watermark = new SubstanceStripeWatermark(); this.buttonShaper = new StandardButtonShaper(); this.gradientPainter = new StandardGradientPainter(); this.borderPainter = new StandardBorderPainter(); this.highlightPainter = new ClassicHighlightPainter(); this.decorationPainter = new Glass3DDecorationPainter(); } public String getDisplayName() { return "Legacy Default"; } } } substance-5.3.orig/src/org/jvnet/substance/api/0000755000175000017500000000000011256731146021455 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/api/SubstanceApi.java0000644000175000017500000000370611136475560024711 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api; import static java.lang.annotation.ElementType.*; import java.lang.annotation.Target; /** * Marks publicly supported Substance API types, fields and methods. * * @author Kirill Grouchnikov * @since version 5.0 */ @Target( { TYPE, FIELD, METHOD, CONSTRUCTOR }) public @interface SubstanceApi { } substance-5.3.orig/src/org/jvnet/substance/api/UiThreadingViolationException.java0000644000175000017500000000410411136475560030270 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api; /** * This exception is thrown by Substance when it detects violations of UI * threading rules. * * @author Kirill Grouchnikov */ public class UiThreadingViolationException extends org.jvnet.lafwidget.UiThreadingViolationException { /** * Creates a new instance of this exception. * * @param message * Message. */ public UiThreadingViolationException(String message) { super(message); } } substance-5.3.orig/src/org/jvnet/substance/api/ColorSchemeAssociationKind.java0000644000175000017500000001454611164752626027544 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api; import java.util.*; import javax.swing.JCheckBox; import javax.swing.JTabbedPane; /** * Allows associating different color schemes to different visual parts of UI * components. For example, the {@link JCheckBox} has three different visual * areas: *
    *
  • Border - assciated with {@link #BORDER}
  • *
  • Fill - associated with {@link #FILL}
  • *
  • Check mark - associated with {@link #MARK}
  • *
* * Applications can create custom instances of this class to further refine the * control over the painting. In this case, the custom UI delegates must be * created to use these new association kinds. * * @author Kirill Grouchnikov * @since version 5.1 */ public class ColorSchemeAssociationKind { /** * All known association kind values. */ private static Set values = new HashSet(); /** * Name for this association kind. */ private String name; /** * Fallback for this association kind. This is used when no color scheme is * associated with this kind. For example, {@link #TAB_BORDER} specifies * that its fallback is {@link #BORDER}. When the {@link JTabbedPane} UI * delegate is painting the tabs, it will try to use the color scheme * associated with {@link #TAB_BORDER}. If none was registered, it will fall * back to use the color scheme associated with {@link #BORDER}, and if that * is not registered as well, will use the color scheme associated with * {@link #FILL}. */ private ColorSchemeAssociationKind fallback; /** * Creates a new association kind. * * @param name * Association kind name. * @param fallback * Fallback association kind. This is used when no color scheme * is associated with this kind. For example, {@link #TAB_BORDER} * specifies that its fallback is {@link #BORDER}. When the * {@link JTabbedPane} UI delegate is painting the tabs, it will * try to use the color scheme associated with * {@link #TAB_BORDER}. If none was registered, it will fall back * to use the color scheme associated with {@link #BORDER}, and * if that is not registered as well, will use the color scheme * associated with {@link #FILL}. */ public ColorSchemeAssociationKind(String name, ColorSchemeAssociationKind fallback) { this.name = name; this.fallback = fallback; values.add(this); } @Override public String toString() { return this.name; } /** * The default visual area that is used for the inner part of most controls. */ public static final ColorSchemeAssociationKind FILL = new ColorSchemeAssociationKind( "fill", null); /** * Highlight visual areas for lists, tables, trees and menus. */ public static final ColorSchemeAssociationKind HIGHLIGHT = new ColorSchemeAssociationKind( "highlight", FILL); /** * Highlight visual areas for text components. */ public static final ColorSchemeAssociationKind TEXT_HIGHLIGHT = new ColorSchemeAssociationKind( "textHighlight", HIGHLIGHT); /** * Visual area of separators. */ public static final ColorSchemeAssociationKind SEPARATOR = new ColorSchemeAssociationKind( "separator", FILL); /** * Fill visual area of the tabs. */ public static final ColorSchemeAssociationKind TAB = new ColorSchemeAssociationKind( "tab", FILL); /** * Border visual area of non-tab controls. */ public static final ColorSchemeAssociationKind BORDER = new ColorSchemeAssociationKind( "border", FILL); /** * Visual area of marks. Used for painting check marks of checkboxes and * radio buttons, as well as arrow icons of combo boxes, spinners and more. */ public static final ColorSchemeAssociationKind MARK = new ColorSchemeAssociationKind( "mark", BORDER); /** * Border visual area of the tabs. */ public static final ColorSchemeAssociationKind TAB_BORDER = new ColorSchemeAssociationKind( "tabBorder", BORDER); /** * Border visual areas for highlighted regions of lists, tables, trees and menus. */ public static final ColorSchemeAssociationKind HIGHLIGHT_BORDER = new ColorSchemeAssociationKind( "highlightBorder", BORDER); /** * Returns all available association kinds. * * @return All available association kinds. */ public static Set values() { return Collections.unmodifiableSet(values); } /** * Returns the fallback for this association kind. * * @return The fallback for this association kind. */ public ColorSchemeAssociationKind getFallback() { return fallback; } }substance-5.3.orig/src/org/jvnet/substance/api/ColorSchemeTransform.java0000644000175000017500000000407711136475560026431 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api; /** * Defines transformation on a color scheme. * * @author Kirill Grouchnikov */ @SubstanceApi public interface ColorSchemeTransform { /** * Transforms the specified color scheme. * * @param scheme * The original color scheme to transform. * @return The transformed color scheme. */ public SubstanceColorScheme transform(SubstanceColorScheme scheme); } substance-5.3.orig/src/org/jvnet/substance/api/renderers/0000755000175000017500000000000011256731146023446 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/api/renderers/SubstanceDefaultTreeCellRenderer.java0000644000175000017500000003134311246715002032650 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.renderers; import java.awt.*; import javax.swing.*; import javax.swing.plaf.*; import javax.swing.tree.TreeCellRenderer; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.SubstanceTreeUI; import org.jvnet.substance.SubstanceTreeUI.TreePathId; import org.jvnet.substance.api.*; import org.jvnet.substance.utils.*; /** * Default renderer for tree cells. * * @author Kirill Grouchnikov */ @SubstanceApi @SubstanceRenderer public class SubstanceDefaultTreeCellRenderer extends JLabel implements TreeCellRenderer { /** Last tree the renderer was painted in. */ private JTree tree; /** Is the value currently selected. */ protected boolean selected; /** True if has focus. */ protected boolean hasFocus; /** * Returns a new instance of SubstanceDefaultTreeCellRenderer. Alignment is * set to left aligned. Icons and text color are determined from the * UIManager. */ public SubstanceDefaultTreeCellRenderer() { this.setHorizontalAlignment(SwingConstants.LEFT); this.putClientProperty(SubstanceLookAndFeel.COLORIZATION_FACTOR, 1.0); } /** * Returns the default icon that is used to represent non-leaf nodes that * are expanded. * * @return The default icon for non-leaf expanded nodes. */ public Icon getDefaultOpenIcon() { return UIManager.getIcon("Tree.openIcon"); } /** * Returns the default icon that is used to represent non-leaf nodes that * are not expanded. * * @return The default icon for non-leaf non-expanded nodes. */ public Icon getDefaultClosedIcon() { return UIManager.getIcon("Tree.closedIcon"); } /** * Returns the default icon that is used to represent leaf nodes. * * @return The default icon for leaf nodes. */ public Icon getDefaultLeafIcon() { return UIManager.getIcon("Tree.leafIcon"); } /** * Subclassed to map FontUIResources to null. If * font is null, or a FontUIResource, this has the * effect of letting the font of the JTree show through. On the other hand, * if font is non-null, and not a FontUIResource, * the font becomes font. */ @Override public void setFont(Font font) { if (font instanceof FontUIResource) font = null; super.setFont(font); } /** * Gets the font of this component. * * @return this component's font; if a font has not been set for this * component, the font of its parent is returned */ @Override public Font getFont() { Font font = super.getFont(); if ((font == null) && (this.tree != null)) { // Strive to return a non-null value, otherwise the html support // will typically pick up the wrong font in certain situations. font = this.tree.getFont(); } return font; } /** * Configures the renderer based on the passed in components. The value is * set from messaging the tree with convertValueToText, which * ultimately invokes toString on value. The * foreground color is set based on the selection and the icon is set based * on on leaf and expanded. */ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { String stringValue = tree.convertValueToText(value, sel, expanded, leaf, row, hasFocus); this.tree = tree; this.hasFocus = hasFocus; this.setText(stringValue); TreeUI treeUI = tree.getUI(); if (treeUI instanceof SubstanceTreeUI) { SubstanceTreeUI ui = (SubstanceTreeUI) treeUI; TreePathId pathId = new TreePathId(tree.getPathForRow(row)); ComponentState state = ui.getPathState(pathId); ComponentState prevState = ui.getPrevPathState(pathId); SubstanceColorScheme scheme = (state == ComponentState.DEFAULT) ? ui .getDefaultColorScheme() : SubstanceColorSchemeUtilities.getColorScheme(tree, ColorSchemeAssociationKind.HIGHLIGHT, state); if (scheme == null) { scheme = SubstanceColorSchemeUtilities.getColorScheme(tree, ColorSchemeAssociationKind.HIGHLIGHT, state); } SubstanceColorScheme prevScheme = scheme; if (prevState != state) { prevScheme = (prevState == ComponentState.DEFAULT) ? ui .getDefaultColorScheme() : SubstanceColorSchemeUtilities .getColorScheme(tree, ColorSchemeAssociationKind.HIGHLIGHT, prevState); if (prevScheme == null) { prevScheme = (prevState == ComponentState.DEFAULT) ? SubstanceColorSchemeUtilities .getColorScheme(tree, prevState) : SubstanceColorSchemeUtilities.getColorScheme( tree, ColorSchemeAssociationKind.HIGHLIGHT, prevState); } } Color color = SubstanceColorUtilities .getInterpolatedForegroundColor(tree, pathId, scheme, state, prevScheme, prevState, FadeKind.SELECTION, FadeKind.ROLLOVER); // System.out.println("[" + row + "," + column + "] - " // + prevState.name() + ":" + state.name() + ":" + color); super.setForeground(new ColorUIResource(color)); } else { if (sel) this.setForeground(UIManager .getColor("Tree.selectionForeground")); else this.setForeground(UIManager.getColor("Tree.textForeground")); } if (SubstanceLookAndFeel.isCurrentLookAndFeel()) SubstanceStripingUtils.applyStripedBackground(tree, row, this); // There needs to be a way to specify disabled icons. if (!tree.isEnabled()) { this.setEnabled(false); if (leaf) { this.setDisabledIcon(SubstanceImageCreator .toGreyscale(SubstanceImageCreator.makeTransparent( tree, this.getDefaultLeafIcon(), 0.5))); } else if (expanded) { this.setDisabledIcon(SubstanceImageCreator .toGreyscale(SubstanceImageCreator.makeTransparent( tree, this.getDefaultOpenIcon(), 0.5))); // setIcon(SubstanceImageCreator.toGreyscale( // SubstanceImageCreator // .makeTransparent(getDefaultOpenIcon(), 0.5))); } else { this.setDisabledIcon(SubstanceImageCreator .toGreyscale(SubstanceImageCreator.makeTransparent( tree, this.getDefaultClosedIcon(), 0.5))); // setIcon(SubstanceImageCreator.toGreyscale( // SubstanceImageCreator // .makeTransparent(getDefaultClosedIcon(), 0.5))); } } else { this.setEnabled(true); if (leaf) { this.setIcon(this.getDefaultLeafIcon()); } else if (expanded) { this.setIcon(this.getDefaultOpenIcon()); } else { this.setIcon(this.getDefaultClosedIcon()); } } this.setComponentOrientation(tree.getComponentOrientation()); this.setOpaque(false); this.selected = sel; if (treeUI instanceof SubstanceTreeUI) { SubstanceTreeUI ui = (SubstanceTreeUI) treeUI; Insets regInsets = ui.getCellRendererInsets(); this .setBorder(new BorderUIResource.EmptyBorderUIResource( regInsets)); } return this; } /** * Overrides JComponent.getPreferredSize to return slightly * wider preferred size value. */ @Override public Dimension getPreferredSize() { Dimension retDimension = super.getPreferredSize(); if (retDimension != null) retDimension = new Dimension(retDimension.width + 3, retDimension.height); return retDimension; } /** * Overridden for performance reasons. See the Implementation Note for more information. */ @Override public void validate() { } /** * Overridden for performance reasons. See the Implementation Note for more information. * * @since 1.5 */ @Override public void invalidate() { } /** * Overridden for performance reasons. See the Implementation Note for more information. */ @Override public void revalidate() { } /** * Overridden for performance reasons. See the Implementation Note for more information. */ @Override public void repaint(long tm, int x, int y, int width, int height) { } /** * Overridden for performance reasons. See the Implementation Note for more information. */ @Override public void repaint(Rectangle r) { } /** * Overridden for performance reasons. See the Implementation Note for more information. * * @since 1.5 */ @Override public void repaint() { } /** * Overridden for performance reasons. See the Implementation Note for more information. */ @Override protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { if ("text".equals(propertyName)) super.firePropertyChange(propertyName, oldValue, newValue); } /** * Overridden for performance reasons. See the Implementation Note for more information. */ @Override public void firePropertyChange(String propertyName, byte oldValue, byte newValue) { } /** * Overridden for performance reasons. See the Implementation Note for more information. */ @Override public void firePropertyChange(String propertyName, char oldValue, char newValue) { } /** * Overridden for performance reasons. See the Implementation Note for more information. */ @Override public void firePropertyChange(String propertyName, short oldValue, short newValue) { } /** * Overridden for performance reasons. See the Implementation Note for more information. */ @Override public void firePropertyChange(String propertyName, int oldValue, int newValue) { } /** * Overridden for performance reasons. See the Implementation Note for more information. */ @Override public void firePropertyChange(String propertyName, long oldValue, long newValue) { } /** * Overridden for performance reasons. See the Implementation Note for more information. */ @Override public void firePropertyChange(String propertyName, float oldValue, float newValue) { } /** * Overridden for performance reasons. See the Implementation Note for more information. */ @Override public void firePropertyChange(String propertyName, double oldValue, double newValue) { } /** * Overridden for performance reasons. See the Implementation Note for more information. */ @Override public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue) { } /* * (non-Javadoc) * * @see javax.swing.JComponent#paint(java.awt.Graphics) */ @Override public final void paint(Graphics g) { super.paint(g); } /* * (non-Javadoc) * * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) */ @Override protected final void paintComponent(Graphics g) { super.paintComponent(g); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsubstance-5.3.orig/src/org/jvnet/substance/api/renderers/SubstanceDefaultTableHeaderCellRenderer.javasubstance-5.3.orig/src/org/jvnet/substance/api/renderers/SubstanceDefaultTableHeaderCellRenderer.jav0000644000175000017500000001733611164750560033765 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.renderers; import java.awt.*; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.plaf.*; import javax.swing.table.*; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.substance.*; import org.jvnet.substance.api.*; import org.jvnet.substance.utils.*; /** * Default renderer for table header cells. * * @author Kirill Grouchnikov */ @SubstanceApi @SubstanceRenderer public class SubstanceDefaultTableHeaderCellRenderer extends DefaultTableCellRenderer implements UIResource { /** * Creates a new cell renderer. */ public SubstanceDefaultTableHeaderCellRenderer() { setHorizontalAlignment(JLabel.CENTER); this.putClientProperty(SubstanceLookAndFeel.COLORIZATION_FACTOR, 1.0); } /* * (non-Javadoc) * * @see * javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax * .swing.JTable, java.lang.Object, boolean, boolean, int, int) */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (table == null) { setBorder(DefaultTableCellRenderer.noFocusBorder); setValue(value); setOpaque(false); return this; } if (table.getTableHeader() == null) { return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); } JTableHeader tableHeader = table.getTableHeader(); TableHeaderUI tableHeaderUI = tableHeader.getUI(); if (SubstanceLookAndFeel.isCurrentLookAndFeel() && (tableHeaderUI instanceof SubstanceTableHeaderUI)) { SubstanceTableHeaderUI ui = (SubstanceTableHeaderUI) tableHeaderUI; ComponentState state = ui.getColumnState(column); ComponentState prevState = ui.getPrevColumnState(column); SubstanceColorScheme scheme = (state == ComponentState.DEFAULT) ? SubstanceColorSchemeUtilities .getColorScheme(tableHeader, state) : SubstanceColorSchemeUtilities.getColorScheme(tableHeader, ColorSchemeAssociationKind.HIGHLIGHT, state); SubstanceColorScheme prevScheme = (prevState == ComponentState.DEFAULT) ? SubstanceColorSchemeUtilities .getColorScheme(tableHeader, prevState) : SubstanceColorSchemeUtilities.getColorScheme(tableHeader, ColorSchemeAssociationKind.HIGHLIGHT, prevState); Color color = SubstanceColorUtilities .getInterpolatedForegroundColor(tableHeader, column, scheme, state, prevScheme, prevState, FadeKind.SELECTION, FadeKind.ROLLOVER); // System.out.println("[column " + column + "] - " + // prevState.name() + ":" // + state.name() + ":" + color + " from " // + scheme.getDisplayName()); super.setForeground(new ColorUIResource(color)); } else { super.setForeground(table.getForeground()); } this.setBackground(tableHeader.getBackground()); // fix for issue 319 - using font from the table header if (tableHeader.getFont() != null) { setFont(tableHeader.getFont()); } else { setFont(table.getFont()); } TableUI tableUI = table.getUI(); if (SubstanceLookAndFeel.isCurrentLookAndFeel() && (tableUI instanceof SubstanceTableUI)) { this.setBorder(new EmptyBorder(((SubstanceTableUI) tableUI) .getCellRendererInsets())); } this.setValue(value); this.setOpaque(false); this.setEnabled(tableHeader.isEnabled() && table.isEnabled()); // fix for defect 242 - not showing sort icon if (SubstanceLookAndFeel.isCurrentLookAndFeel()) { this.setIcon(null); RowSorter rowSorter = table.getRowSorter(); if (rowSorter != null) { setHorizontalTextPosition(JLabel.LEADING); java.util.List sortKeys = rowSorter .getSortKeys(); Icon sortIcon = null; SubstanceColorScheme scheme = null; if (tableHeaderUI instanceof SubstanceTableHeaderUI) { SubstanceTableHeaderUI ui = (SubstanceTableHeaderUI) tableHeaderUI; ComponentState state = ui.getColumnState(column); scheme = SubstanceColorSchemeUtilities.getColorScheme( tableHeader, state); } else { scheme = SubstanceColorSchemeUtilities.getColorScheme( tableHeader, ComponentState.DEFAULT); } if (sortKeys.size() > 0 && sortKeys.get(0).getColumn() == table .convertColumnIndexToModel(column)) { switch (sortKeys.get(0).getSortOrder()) { case ASCENDING: sortIcon = SubstanceImageCreator.getArrowIcon( SubstanceSizeUtils .getComponentFontSize(tableHeader), SwingConstants.NORTH, scheme); break; case DESCENDING: sortIcon = SubstanceImageCreator.getArrowIcon( SubstanceSizeUtils .getComponentFontSize(tableHeader), SwingConstants.SOUTH, scheme); break; case UNSORTED: sortIcon = null; } this.setIcon(sortIcon); } } } return this; } /** * Returns true if the specified column is sorted. * * @param table * Table. * @param columnIndex * Column index. * @return true if the specified column is sorted, * false otherwise. */ public static boolean isColumnSorted(JTable table, int columnIndex) { RowSorter rowSorter = table.getRowSorter(); if (rowSorter != null) { java.util.List sortKeys = rowSorter .getSortKeys(); if (sortKeys.size() > 0 && sortKeys.get(0).getColumn() == table .convertColumnIndexToModel(columnIndex)) { switch (sortKeys.get(0).getSortOrder()) { case ASCENDING: case DESCENDING: return true; } } } return false; } /* * (non-Javadoc) * * @see javax.swing.JComponent#paint(java.awt.Graphics) */ @Override public final void paint(Graphics g) { super.paint(g); } /* * (non-Javadoc) * * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) */ @Override protected final void paintComponent(Graphics g) { super.paintComponent(g); } } substance-5.3.orig/src/org/jvnet/substance/api/renderers/SubstanceRenderer.java0000644000175000017500000000370411256345444027735 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.renderers; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * Marks the default base Substance renderer classes. * * @author Kirill Grouchnikov */ @Retention(RetentionPolicy.RUNTIME) public @interface SubstanceRenderer { } substance-5.3.orig/src/org/jvnet/substance/api/renderers/SubstanceDefaultComboBoxRenderer.java0000644000175000017500000001314311164750462032667 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.renderers; import java.awt.*; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.plaf.ListUI; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.substance.SubstanceListUI; import org.jvnet.substance.api.*; import org.jvnet.substance.utils.*; /** * Renderer for combo boxes. * * @author Kirill Grouchnikov */ @SubstanceApi @SubstanceRenderer public class SubstanceDefaultComboBoxRenderer extends SubstanceDefaultListCellRenderer { /** * The associated combo box. */ private JComboBox combo; /** * Simple constructor. * * @param combo * The associated combo box. */ public SubstanceDefaultComboBoxRenderer(JComboBox combo) { super(); this.combo = combo; // this.setOpaque(true); Insets ins = SubstanceSizeUtils .getListCellRendererInsets(SubstanceSizeUtils .getComponentFontSize(combo)); this .setBorder(new EmptyBorder(ins.top, ins.left, ins.bottom, ins.right)); // // Insets i = b.getBorderInsets(combo); // System.out.println("Combo inner - " + combo.getFont().getSize() +" : // " // + i.top + ", " + i.left + ", " + i.bottom + ", " + i.right); } /* * (non-Javadoc) * * @see * javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing * .JList, java.lang.Object, int, boolean, boolean) */ @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JComponent result = (JComponent) super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus); ListUI listUI = list.getUI(); if (listUI instanceof SubstanceListUI) { SubstanceListUI ui = (SubstanceListUI) listUI; ComponentState state = ui.getCellState(index, result); ComponentState prevState = ui.getPrevCellState(index); // special case for the combobox. The selected value is // painted using the renderer of the list, and the index // is -1. if (index == -1) { boolean isEnabled = this.combo.isEnabled(); if (isSelected && isEnabled) { state = ComponentState.SELECTED; prevState = ComponentState.SELECTED; } if (!isEnabled) { state = ComponentState.DISABLED_UNSELECTED; prevState = ComponentState.DISABLED_UNSELECTED; } } Component compForSchemeQuery = (index == -1) ? combo : list; // use highlight color scheme for selected and focused // elements SubstanceColorScheme scheme = isSelected ? SubstanceColorSchemeUtilities .getColorScheme(compForSchemeQuery, ColorSchemeAssociationKind.HIGHLIGHT, state) : SubstanceColorSchemeUtilities.getColorScheme( compForSchemeQuery, state); Color color = SubstanceColorUtilities .getInterpolatedForegroundColor(compForSchemeQuery, index, scheme, state, scheme, prevState, FadeKind.SELECTION, FadeKind.ROLLOVER); result.setForeground(color); SubstanceStripingUtils.applyStripedBackground(combo, index, this); } result.setOpaque(!isSelected && (index >= 0)); result.setEnabled(combo.isEnabled()); return result; } /* * (non-Javadoc) * * @see javax.swing.JComponent#getPreferredSize() */ @Override public Dimension getPreferredSize() { Dimension size; if ((this.getText() == null) || (this.getText().equals(""))) { this.setText(" "); size = super.getPreferredSize(); this.setText(""); } else { size = super.getPreferredSize(); } return size; } /** * UI resource for renderer (does nothing yet). * * @author Kirill Grouchnikov */ public static class SubstanceUIResource extends SubstanceDefaultComboBoxRenderer implements javax.swing.plaf.UIResource { /** * Creates a new renderer resource. * * @param combo * Combobox. */ public SubstanceUIResource(JComboBox combo) { super(combo); } } } substance-5.3.orig/src/org/jvnet/substance/api/renderers/SubstanceDefaultListCellRenderer.java0000644000175000017500000001470111164750264032673 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.renderers; import java.awt.*; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.plaf.ColorUIResource; import javax.swing.plaf.ListUI; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.substance.SubstanceListUI; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.*; import org.jvnet.substance.utils.*; /** * Default renderer for list cells. * * @author Kirill Grouchnikov */ @SubstanceApi @SubstanceRenderer public class SubstanceDefaultListCellRenderer extends DefaultListCellRenderer { /** * Constructs a default renderer object for an item in a list. */ public SubstanceDefaultListCellRenderer() { super(); this.putClientProperty(SubstanceLookAndFeel.COLORIZATION_FACTOR, 1.0); } /* * (non-Javadoc) * * @see * javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing * .JList, java.lang.Object, int, boolean, boolean) */ @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { this.setComponentOrientation(list.getComponentOrientation()); ListUI listUI = list.getUI(); if (listUI instanceof SubstanceListUI) { SubstanceListUI ui = (SubstanceListUI) listUI; ComponentState state = ui.getCellState(index, this); ComponentState prevState = ui.getPrevCellState(index); SubstanceColorScheme scheme = (state == ComponentState.DEFAULT) ? ui .getDefaultColorScheme() : ui.getHighlightColorScheme(state); if (scheme == null) { scheme = (state == ComponentState.DEFAULT) ? SubstanceColorSchemeUtilities .getColorScheme(list, state) : SubstanceColorSchemeUtilities.getColorScheme(list, ColorSchemeAssociationKind.HIGHLIGHT, state); } SubstanceColorScheme prevScheme = scheme; if (prevState != state) { prevScheme = (prevState == ComponentState.DEFAULT) ? ui .getDefaultColorScheme() : ui .getHighlightColorScheme(prevState); if (prevScheme == null) { prevScheme = (prevState == ComponentState.DEFAULT) ? SubstanceColorSchemeUtilities .getColorScheme(list, prevState) : SubstanceColorSchemeUtilities.getColorScheme( list, ColorSchemeAssociationKind.HIGHLIGHT, prevState); } } Color color = SubstanceColorUtilities .getInterpolatedForegroundColor(list, index, scheme, state, prevScheme, prevState, FadeKind.SELECTION, FadeKind.ROLLOVER); // System.out.println("[row " + index + "] - " + prevState.name() // + "[" + prevScheme.getDisplayName() + "] -> " // + state.name() + "[" + scheme.getDisplayName() + "]\n\t" // + color); super.setForeground(new ColorUIResource(color)); } else { if (isSelected) { this.setForeground(list.getSelectionForeground()); } else { this.setForeground(list.getForeground()); } } if (isSelected) { // setBackground(list.getSelectionBackground()); // this.setForeground(list.getSelectionForeground()); } else { if (SubstanceLookAndFeel.isCurrentLookAndFeel()) SubstanceStripingUtils .applyStripedBackground(list, index, this); // this.setForeground(list.getForeground()); } if (value instanceof Icon) { this.setIcon((Icon) value); this.setText(""); } else { this.setIcon(null); this.setText((value == null) ? "" : value.toString()); } this.setEnabled(list.isEnabled()); this.setFont(list.getFont()); Insets ins = SubstanceSizeUtils .getListCellRendererInsets(SubstanceSizeUtils .getComponentFontSize(list)); this .setBorder(new EmptyBorder(ins.top, ins.left, ins.bottom, ins.right)); this.setOpaque(false); return this; } /** * UI resource for renderer (does nothing yet). * * @author Kirill Grouchnikov */ public static class SubstanceUIResource extends SubstanceDefaultListCellRenderer implements javax.swing.plaf.UIResource { /* * (non-Javadoc) * * @see * javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing * .JList, java.lang.Object, int, boolean, boolean) */ @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } } /* * (non-Javadoc) * * @see javax.swing.JComponent#paint(java.awt.Graphics) */ @Override public final void paint(Graphics g) { super.paint(g); } /* * (non-Javadoc) * * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) */ @Override protected final void paintComponent(Graphics g) { super.paintComponent(g); } } substance-5.3.orig/src/org/jvnet/substance/api/renderers/SubstanceDefaultTableCellRenderer.java0000644000175000017500000003073411256345762033020 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.renderers; import java.awt.*; import java.text.DateFormat; import java.text.NumberFormat; import javax.swing.*; import javax.swing.border.*; import javax.swing.plaf.ColorUIResource; import javax.swing.plaf.TableUI; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableCellRenderer; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.animation.FadeState; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.SubstanceTableUI; import org.jvnet.substance.SubstanceTableUI.TableCellId; import org.jvnet.substance.api.*; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.border.SubstanceBorder; /** * Default renderer for table cells. * * @author Kirill Grouchnikov */ @SubstanceApi @SubstanceRenderer public class SubstanceDefaultTableCellRenderer extends DefaultTableCellRenderer { /** * Renderer for boolean columns. * * @author Kirill Grouchnikov */ @SubstanceRenderer public static class BooleanRenderer extends JCheckBox implements TableCellRenderer { /** * Border for cells that do not have focus. */ private static final Border noFocusBorder = new EmptyBorder(1, 1, 1, 1); /** * Creates a new renderer for boolean columns. */ public BooleanRenderer() { super(); this.setHorizontalAlignment(SwingConstants.CENTER); this.setBorderPainted(true); } /* * (non-Javadoc) * * @see * javax.swing.table.TableCellRenderer#getTableCellRendererComponent * (javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) */ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (isSelected) { this.setForeground(table.getSelectionForeground()); // super.setBackground(table.getSelectionBackground()); } else { this.setForeground(table.getForeground()); } SubstanceStripingUtils.applyStripedBackground(table, row, this); this.setSelected(((value != null) && ((Boolean) value) .booleanValue())); this.setEnabled(table.isEnabled()); TableUI tableUI = table.getUI(); if (tableUI instanceof SubstanceTableUI) { SubstanceTableUI ui = (SubstanceTableUI) tableUI; // Recompute the focus indication to prevent flicker - JTable // registers a listener on selection changes and repaints the // relevant cell before our listener (in TableUI) gets the // chance to start the fade sequence. The result is that the // first frame uses full opacity, and the next frame starts the // fade sequence. So, we use the UI delegate to compute the // focus indication. hasFocus = ui.isFocusedCell(row, column); TableCellId cellFocusId = new TableCellId(row, column); // set indication to make exact comparison (since // focus can be only on one cell). cellFocusId.setExactComparison(true); FadeState focusState = SubstanceFadeUtilities.getFadeState( table, cellFocusId, FadeKind.FOCUS); if (hasFocus || (focusState != null)) { SubstanceBorder border = new SubstanceBorder(); if (focusState != null) { border.setAlpha(focusState.getFadePosition()); } this.setBorder(border); } else { this.setBorder(BooleanRenderer.noFocusBorder); } } else { if (hasFocus) { this.setBorder(UIManager .getBorder("Table.focusCellHighlightBorder")); } else { this.setBorder(BooleanRenderer.noFocusBorder); } } this.setOpaque(false); return this; } /* * (non-Javadoc) * * @see javax.swing.JComponent#paint(java.awt.Graphics) */ @Override public final void paint(Graphics g) { super.paint(g); } /* * (non-Javadoc) * * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) */ @Override protected final void paintComponent(Graphics g) { super.paintComponent(g); } @Override protected final void paintBorder(Graphics g) { } @Override public final void paintComponents(Graphics g) { } } /** * Renderer for icon columns. * * @author Kirill Grouchnikov */ public static class IconRenderer extends SubstanceDefaultTableCellRenderer { /** * Creates a new renderer for icon columns. */ public IconRenderer() { super(); this.setHorizontalAlignment(SwingConstants.CENTER); } @Override public void setValue(Object value) { this.setIcon((value instanceof Icon) ? (Icon) value : null); this.setText(null); } } /** * Renderer for number columns. * * @author Kirill Grouchnikov */ public static class NumberRenderer extends SubstanceDefaultTableCellRenderer { /** * Creates a new renderer for number columns. */ public NumberRenderer() { super(); this.setHorizontalAlignment(SwingConstants.RIGHT); } } /** * Renderer for double columns. * * @author Kirill Grouchnikov */ public static class DoubleRenderer extends NumberRenderer { /** * Number formatter for this renderer. */ NumberFormat formatter; /** * Creates a new renderer for double columns. */ public DoubleRenderer() { super(); } @Override public void setValue(Object value) { if (this.formatter == null) { this.formatter = NumberFormat.getInstance(); } this.setText((value == null) ? "" : this.formatter.format(value)); } } /** * Renderer for date columns. * * @author Kirill Grouchnikov */ public static class DateRenderer extends SubstanceDefaultTableCellRenderer { /** * Date formatter for this renderer. */ DateFormat formatter; /** * Creates a new renderer for date columns. */ public DateRenderer() { super(); } @Override public void setValue(Object value) { if (this.formatter == null) { this.formatter = DateFormat.getDateInstance(); } this.setText((value == null) ? "" : this.formatter.format(value)); } } /** * Creates a default opaque table cell renderer. */ public SubstanceDefaultTableCellRenderer() { this.putClientProperty(SubstanceLookAndFeel.COLORIZATION_FACTOR, 1.0); } /* * (non-Javadoc) * * @see * javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax * .swing.JTable, java.lang.Object, boolean, boolean, int, int) */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (!SubstanceLookAndFeel.isCurrentLookAndFeel()) return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); TableUI tableUI = table.getUI(); SubstanceTableUI ui = (SubstanceTableUI) tableUI; // Recompute the focus indication to prevent flicker - JTable // registers a listener on selection changes and repaints the // relevant cell before our listener (in TableUI) gets the // chance to start the fade sequence. The result is that the // first frame uses full opacity, and the next frame starts the // fade sequence. So, we use the UI delegate to compute the // focus indication. hasFocus = ui.isFocusedCell(row, column); TableCellId cellId = new TableCellId(row, column); Comparable compId = ui.getId(row, column); ComponentState state = ui.getCellState(cellId); ComponentState prevState = ui.getPrevCellState(cellId); SubstanceColorScheme scheme = (state == ComponentState.DEFAULT) ? ui .getDefaultColorScheme() : ui.getHighlightColorScheme(state); if (scheme == null) { scheme = (state == ComponentState.DEFAULT) ? SubstanceColorSchemeUtilities .getColorScheme(table, state) : SubstanceColorSchemeUtilities.getColorScheme(table, ColorSchemeAssociationKind.HIGHLIGHT, state); } SubstanceColorScheme prevScheme = scheme; if (prevState != state) { prevScheme = (prevState == ComponentState.DEFAULT) ? ui .getDefaultColorScheme() : ui .getHighlightColorScheme(prevState); if (prevScheme == null) { prevScheme = (prevState == ComponentState.DEFAULT) ? SubstanceColorSchemeUtilities .getColorScheme(table, prevState) : SubstanceColorSchemeUtilities .getColorScheme(table, ColorSchemeAssociationKind.HIGHLIGHT, prevState); } } // SubstanceColorScheme scheme = (state == ComponentState.DEFAULT) ? // ui // .getDefaultColorScheme() : SubstanceColorSchemeUtilities // .getColorScheme(table, state); if (scheme == null) scheme = SubstanceColorSchemeUtilities.getColorScheme(table, state); if (ui.hasRolloverAnimations() || ui.hasSelectionAnimations()) { super.setForeground(new ColorUIResource(SubstanceColorUtilities .getInterpolatedForegroundColor(table, compId, scheme, state, prevScheme, prevState, FadeKind.SELECTION, FadeKind.ROLLOVER))); } else { super .setForeground(new ColorUIResource(scheme .getForegroundColor())); } SubstanceStripingUtils.applyStripedBackground(table, row, this); this.setFont(table.getFont()); TableCellId cellFocusId = new TableCellId(row, column); // set indication to make exact comparison (since // focus can be only on one cell). cellFocusId.setExactComparison(true); FadeState focusState = SubstanceFadeUtilities.getFadeState(table, cellFocusId, FadeKind.FOCUS); Insets regInsets = ui.getCellRendererInsets(); if (hasFocus || (focusState != null)) { SubstanceBorder border = new SubstanceBorder(regInsets); // System.out.println("[" + row + ":" + column + "] hasFocus : " // + hasFocus + ", focusState : " + focusState); if (focusState != null) { border.setAlpha(focusState.getFadePosition()); } // special case for tables with no grids if (!table.getShowHorizontalLines() && !table.getShowVerticalLines()) { this.setBorder(new CompoundBorder(new EmptyBorder(table .getRowMargin() / 2, 0, table.getRowMargin() / 2, 0), border)); } else { this.setBorder(border); } } else { this.setBorder(new EmptyBorder(regInsets.top, regInsets.left, regInsets.bottom, regInsets.right)); } this.setValue(value); this.setOpaque(false); this.setEnabled(table.isEnabled()); return this; } /* * (non-Javadoc) * * @see javax.swing.JComponent#paint(java.awt.Graphics) */ @Override public final void paint(Graphics g) { super.paint(g); } /* * (non-Javadoc) * * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) */ @Override protected final void paintComponent(Graphics g) { super.paintComponent(g); } @Override protected final void paintBorder(Graphics g) { } @Override public final void paintComponents(Graphics g) { } } substance-5.3.orig/src/org/jvnet/substance/api/combo/0000755000175000017500000000000011256731146022554 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/api/combo/WidestComboPopupPrototype.java0000644000175000017500000000555011136475560030617 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.combo; import java.awt.Component; import javax.swing.JComboBox; import javax.swing.JList; import org.jvnet.substance.SubstanceComboBoxUI; /** * Sample core implementation of {@link ComboPopupPrototypeCallback} interface * that returns the widest combo entry. This class is part of officially * supported API. * * @author Kirill Grouchnikov */ public class WidestComboPopupPrototype implements ComboPopupPrototypeCallback { /* * (non-Javadoc) * * @seeorg.jvnet.substance.combo.ComboPopupPrototypeCallback# * getPopupPrototypeDisplayValue(javax.swing.JComboBox) */ public Object getPopupPrototypeDisplayValue(JComboBox jc) { int maxWidth = -1; Object prototype = null; JList list = ((SubstanceComboBoxUI) jc.getUI()).getPopup().getList(); for (int i = 0; i < jc.getModel().getSize(); i++) { Object elem = jc.getModel().getElementAt(i); Component renderer = jc.getRenderer().getListCellRendererComponent( list, elem, i, false, false); if (renderer != null) { int rWidth = renderer.getPreferredSize().width; if (rWidth > maxWidth) { maxWidth = rWidth; prototype = elem; } } } return prototype; } } substance-5.3.orig/src/org/jvnet/substance/api/combo/ComboPopupPrototypeCallback.java0000644000175000017500000000427111136475560031053 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.combo; import javax.swing.JComboBox; /** * Interface for specifying a prototype entry for a combo popup. This class is * part of officially supported API. * * @author Kirill Grouchnikov */ public interface ComboPopupPrototypeCallback { /** * Returns the prototype entry for combo popup of the specified combobox. * * @param jc * Combo box. * @return Prototype entry for combo popup of the specified combobox. */ public Object getPopupPrototypeDisplayValue(JComboBox jc); } substance-5.3.orig/src/org/jvnet/substance/api/SchemeDerivedColors.java0000644000175000017500000000711211213147714026205 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api; import java.awt.Color; /** * Interface for derived color scheme colors. * * @author Kirill Grouchnikov */ @SubstanceApi public interface SchemeDerivedColors { /** * Returns the watermark stamp color for this scheme. * * @return Watermark stamp color for this scheme. */ public Color getWatermarkStampColor(); /** * Returns the watermark light color for this scheme. * * @return Watermark light color for this scheme. */ public Color getWatermarkLightColor(); /** * Returns the watermark dark color for this scheme. * * @return Watermark dark color for this scheme. */ public Color getWatermarkDarkColor(); /** * Returns the line color for this scheme. * * @return The line color for this scheme. */ public Color getLineColor(); /** * Returns the selection background color for this scheme. * * @return The selection background color for this scheme. */ public Color getSelectionBackgroundColor(); /** * Returns the selection foreground color for this scheme. * * @return The selection foreground color for this scheme. */ public Color getSelectionForegroundColor(); /** * Returns the background fill color for this scheme. * * @return The background fill color for this scheme. */ public Color getBackgroundFillColor(); /** * Returns the text background fill color for this scheme. * * @return The text background fill color for this scheme. */ public Color getTextBackgroundFillColor(); /** * Returns the focus ring color for this scheme. * * @return The focus ring color for this scheme. */ public Color getFocusRingColor(); } substance-5.3.orig/src/org/jvnet/substance/api/ComponentState.java0000644000175000017500000002676311246715042025275 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api; import java.util.LinkedList; import java.util.List; import javax.swing.*; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.substance.colorscheme.*; /** *

* This enum is used in order to provide uniform transition effects on mouse * events. The effects include different visual appearance of the corresponding * control when the mouse hovers over it (rollover), when it's pressed or * selected, disabled etc. *

* *

* Each enum value represents a single state and contains information that is * used by the UI delegates in order to correctly paint the corresponding * controls. *

* * @author Kirill Grouchnikov */ @SubstanceApi public enum ComponentState { /** * Disabled active. Used for disabled buttons that have been marked as * default. */ DISABLED_ACTIVE(ColorSchemeKind.DISABLED, 0.0f), /** * Active. Used for enabled buttons that have been marked as * default. */ ACTIVE(ColorSchemeKind.CURRENT, 0.0f, FadeKind.ENABLE), /** * Disabled selected. */ DISABLED_SELECTED(ColorSchemeKind.DISABLED, 1.0f, FadeKind.SELECTION), /** * Disabled and not selected. */ DISABLED_UNSELECTED(ColorSchemeKind.DISABLED, 0.0f), /** * Pressed selected. */ PRESSED_SELECTED(ColorSchemeKind.CURRENT, 0.5f, FadeKind.ENABLE, FadeKind.SELECTION, FadeKind.PRESS), /** * Pressed and not selected. */ PRESSED_UNSELECTED(ColorSchemeKind.CURRENT, 0.8f, FadeKind.ENABLE, FadeKind.PRESS), /** * Selected. */ SELECTED(ColorSchemeKind.CURRENT, 0.8f, FadeKind.ENABLE, FadeKind.SELECTION), /** * Selected and rolled over. */ ROLLOVER_SELECTED(ColorSchemeKind.CURRENT, 0.4f, FadeKind.ENABLE, FadeKind.ROLLOVER, FadeKind.SELECTION), /** * Armed. */ ARMED(ColorSchemeKind.CURRENT, 0.5f, FadeKind.ENABLE, FadeKind.ARM), /** * Armed and rolled over. */ ROLLOVER_ARMED(ColorSchemeKind.CURRENT, 0.7f, FadeKind.ENABLE, FadeKind.ROLLOVER, FadeKind.ARM), /** * Not selected and rolled over. */ ROLLOVER_UNSELECTED(ColorSchemeKind.CURRENT, 0.3f, FadeKind.ENABLE, FadeKind.ROLLOVER), /** * Default state. */ DEFAULT(ColorSchemeKind.REGULAR, 0.0f, FadeKind.ENABLE); /** * Enum for color scheme kind. Is used in order to decouple the actual * current color scheme and the decision on whether to use it. * * @author Kirill Grouchnikov */ public static enum ColorSchemeKind { /** * Current color scheme (e.g. {@link AquaColorScheme}). */ CURRENT, /** * Regular color scheme (usually {@link MetallicColorScheme}). */ REGULAR, /** * Disabled color scheme (usually {@link LightGrayColorScheme}). */ DISABLED } /** * The corresponding color scheme kind. */ private ColorSchemeKind colorSchemeKind; /** * The corresponding cycle count. Should be a number between 0.0 and 1.0. * This number is used to compute the foreground color of some component. * The color is interpolated between two values (0.0 corresponds to usual * color, 1.0 corresponds to very light version of the usual color). */ private float cyclePos; /** * Active fade kinds for this state. For example, {@link #ROLLOVER_SELECTED} * contains {@link FadeKind#ROLLOVER} and {@link FadeKind#SELECTION}. */ private transient FadeKind[] activeKinds; /** * Simple constructor. * * @param kind * The corresponding color scheme kind. * @param cyclePos * The corresponding cycle count. * @param activeKinds * Indicates active fade kinds for this state. For example, * {@link #ROLLOVER_SELECTED} should pass both * {@link FadeKind#ROLLOVER} and {@link FadeKind#SELECTION}. */ ComponentState(ColorSchemeKind kind, float cyclePos, FadeKind... activeKinds) { colorSchemeKind = kind; this.cyclePos = cyclePos; this.activeKinds = activeKinds; } /** * Returns the corresponding color scheme kind * * @return Corresponding color scheme kind */ public ColorSchemeKind getColorSchemeKind() { return colorSchemeKind; } /** * Returns the corresponding cycle count. * * @return Corresponding cycle count. */ public float getCyclePosition() { return this.cyclePos; } /** * Returns indication whether this component state is "active" * under the specified fade kind. For example, {@link #ROLLOVER_SELECTED} * will return true for both {@link FadeKind#ROLLOVER} and * {@link FadeKind#SELECTION}. * * @param fadeKind * Fade kind. * @return true if this component state is * "active" under the specified fade kind (for example, * {@link #ROLLOVER_SELECTED} will return true for both * {@link FadeKind#ROLLOVER} and {@link FadeKind#SELECTION}), * false otherwise. */ public boolean isKindActive(FadeKind fadeKind) { if (activeKinds == null) return false; for (FadeKind fk : activeKinds) if (fadeKind == fk) return true; return false; } /** * Returns all active component states. * * @return All active component states. */ public static ComponentState[] getActiveStates() { List states = new LinkedList(); for (ComponentState state : ComponentState.values()) { if (state == ComponentState.DEFAULT) continue; if (!state.isKindActive(FadeKind.ENABLE)) continue; states.add(state); } return states.toArray(new ComponentState[0]); } /** * Retrieves component state based on the button model (required parameter) * and component itself (optional parameter). * * @param model * Button model (required). * @param component * Component (optional). * @return The matching component state. */ public static ComponentState getState(ButtonModel model, JComponent component) { return getState(model, component, false); } /** * Returns the state of the specified button. * * @param button * Button. * @return The state of the specified button. */ public static ComponentState getState(AbstractButton button) { return getState(button.getModel(), button, false); } /** * Retrieves component state based on the button model (required parameter) * and button itself (optional parameter). * * @param model * Button model (required). * @param component * Component (optional). * @param toIgnoreSelection * If true, the {@link ButtonModel#isSelected()} * will not be checked. This can be used for tracking transitions * on menu items that use armed state instead, when * we don't want to use different rollover themes for selected * and unselected checkbox and radio button menu items (to * preserve consistent visual appearence of highlights). * @return The matching component state. */ public static ComponentState getState(ButtonModel model, JComponent component, boolean toIgnoreSelection) { // if (!SwingUtilities.isEventDispatchThread()) // throw new IllegalArgumentException("Accessing outside EDT"); boolean isRollover = model.isRollover(); // fix for defect 103 - no rollover effects on menu items // that are not in the selected menu path if (component instanceof MenuElement) { MenuElement[] selectedMenuPath = MenuSelectionManager .defaultManager().getSelectedPath(); for (MenuElement elem : selectedMenuPath) { if (elem == component) { isRollover = true; break; } } } if (component != null) { if (component instanceof JButton) { JButton jb = (JButton) component; if (jb.isDefaultButton()) { if (model.isEnabled()) { // check for rollover if (jb.isRolloverEnabled() && jb.getModel().isRollover()) { if (model.isSelected()) return ROLLOVER_SELECTED; else return ROLLOVER_UNSELECTED; } if ((!model.isPressed()) && (!model.isArmed())) return ACTIVE; } else return DISABLED_ACTIVE; } } } boolean isRolloverEnabled = true; if (component instanceof AbstractButton) isRolloverEnabled = ((AbstractButton) component) .isRolloverEnabled(); if (!model.isEnabled()) { if (model.isSelected()) return DISABLED_SELECTED; return DISABLED_UNSELECTED; } else if (model.isArmed() && model.isPressed()) { if (model.isSelected()) return PRESSED_SELECTED; return PRESSED_UNSELECTED; } else if (!toIgnoreSelection && model.isSelected()) { if (((component == null) || isRolloverEnabled) && isRollover) return ROLLOVER_SELECTED; return SELECTED; } else if (model.isArmed()) { if (((component == null) || isRolloverEnabled) && isRollover) return ROLLOVER_ARMED; return ARMED; } else if (((component == null) || isRolloverEnabled) && isRollover) return ROLLOVER_UNSELECTED; return DEFAULT; } /** * Returns the component state that matches the specified parameters. * * @param isEnabled * Enabled flag. * @param isRollover * Rollover flag. * @param isSelected * Selected flag. * @return The component state that matches the specified parameters. */ public static ComponentState getState(boolean isEnabled, boolean isRollover, boolean isSelected) { if (!isEnabled) { if (isSelected) return DISABLED_SELECTED; return DISABLED_UNSELECTED; } if (isSelected) { if (isRollover) return ROLLOVER_SELECTED; return SELECTED; } if (isRollover) return ROLLOVER_UNSELECTED; return DEFAULT; } } substance-5.3.orig/src/org/jvnet/substance/api/SchemeBaseColors.java0000644000175000017500000000533011136475560025504 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api; import java.awt.Color; import org.jvnet.substance.api.trait.SubstanceTrait; /** * Interface for base color scheme colors. * * @author Kirill Grouchnikov */ @SubstanceApi public interface SchemeBaseColors extends SubstanceTrait { /** * Retrieves the foreground color. * * @return Foreground color. */ public Color getForegroundColor(); /** * Retrieves the ultra-light color. * * @return Ultra-light color. */ public Color getUltraLightColor(); /** * Retrieves the extra color. * * @return Extra color. */ public Color getExtraLightColor(); /** * Retrieves the light color. * * @return Light color. */ public Color getLightColor(); /** * Retrieves the medium color. * * @return Medium color. */ public Color getMidColor(); /** * Retrieves the dark color. * * @return Dark color. */ public Color getDarkColor(); /** * Retrieves the ultra-dark color. * * @return Ultra-dark color. */ public Color getUltraDarkColor(); } substance-5.3.orig/src/org/jvnet/substance/api/SubstanceSkin.java0000644000175000017500000013631011247655126025103 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api; import java.awt.Component; import java.awt.Graphics2D; import java.net.URL; import java.util.*; import javax.swing.JTabbedPane; import javax.swing.UIDefaults; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.ComponentState.ColorSchemeKind; import org.jvnet.substance.api.painter.overlay.SubstanceOverlayPainter; import org.jvnet.substance.api.painter.overlay.TopShadowOverlayPainter; import org.jvnet.substance.api.trait.SubstanceTrait; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.decoration.SubstanceDecorationPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; import org.jvnet.substance.painter.highlight.SubstanceHighlightPainter; import org.jvnet.substance.shaper.SubstanceButtonShaper; import org.jvnet.substance.utils.SkinUtilities; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; import org.jvnet.substance.watermark.SubstanceWatermark; /** * Base abstract class for Substance skins. * * @author Kirill Grouchnikov */ @SubstanceApi public abstract class SubstanceSkin implements SubstanceTrait, Cloneable { /** * Maps decoration area type to the color scheme bundles. Must contain an * entry for {@link DecorationAreaType#NONE}. */ protected Map colorSchemeBundleMap; /** * Maps decoration area type to the background color schemes. */ protected Map backgroundColorSchemeMap; /** * Maps decoration area type to the registered overlay painters. Each * decoration area type can have more than one overlay painter. */ protected Map> overlayPaintersMap; /** * The watermark of this skin. May be null if * this skin doesn't define a custom watermark. */ protected SubstanceWatermark watermark; /** * The button shaper of this skin. Must be non- * null. */ protected SubstanceButtonShaper buttonShaper; /** * The gradient painter of this skin. Must be non- * null. */ protected SubstanceGradientPainter gradientPainter; /** * The border painter of this skin. Must be non- * null. */ protected SubstanceBorderPainter borderPainter; /** * The highlight border painter of this skin. Can be * null. */ protected SubstanceBorderPainter highlightBorderPainter; /** * The highlight painter of this skin. Must be non- * null. */ protected SubstanceHighlightPainter highlightPainter; /** * The decoration painter of this skin. Must be non- * null. */ protected SubstanceDecorationPainter decorationPainter; /** * Set of all decoration area types that are not explicitly registered in * {@link #colorSchemeBundleMap} but still are considered as decoration * areas in this skin. Controls lying in such areas will have their * background painted by * {@link SubstanceDecorationPainter#paintDecorationArea(Graphics2D, Component, DecorationAreaType, int, int, SubstanceSkin)} * instead of a simple background fill. */ protected Set decoratedAreaSet; /** * The start of fade effect on the selected tabs in {@link JTabbedPane}s. * * @see #selectedTabFadeEnd */ protected double selectedTabFadeStart; /** * The end of fade effect on the selected tabs in {@link JTabbedPane}s. * * @see #selectedTabFadeStart */ protected double selectedTabFadeEnd; /** * Contains the types of decoration areas that show a drop shadow on the few * top pixels. */ // protected Set dropShadowsSet; /** * Color scheme for watermarks. */ protected SubstanceColorScheme watermarkScheme; /** * All component states that have associated non-trivial alpha values. */ Set statesWithAlpha; /** * Constructs the basic data structures for a skin. */ protected SubstanceSkin() { this.colorSchemeBundleMap = new EnumMap( DecorationAreaType.class); this.backgroundColorSchemeMap = new EnumMap( DecorationAreaType.class); this.overlayPaintersMap = new EnumMap>( DecorationAreaType.class); this.decoratedAreaSet = EnumSet.of( DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE); // this.dropShadowsSet = EnumSet.noneOf(DecorationAreaType.class); this.selectedTabFadeStart = 0.1; this.selectedTabFadeEnd = 0.3; this.statesWithAlpha = EnumSet.noneOf(ComponentState.class); } /** * Returns the main active color scheme for this skin. The result is the * active color scheme for controls that do not lie in any decoration area. * Custom painting code that needs to consult the colors of the specific * component should use {@link #getColorScheme(Component, ComponentState)} * method and various {@link SubstanceColorScheme} methods. * * @return The main active color scheme for this skin. * @see #getColorScheme(Component, ComponentState) * @see #getMainActiveColorScheme(DecorationAreaType) */ public final SubstanceColorScheme getMainActiveColorScheme() { return this.colorSchemeBundleMap.get(DecorationAreaType.NONE) .getActiveColorScheme(); } /** * Returns the main default color scheme for this skin. The result is the * default color scheme for controls that do not lie in any decoration area. * Custom painting code that needs to consult the colors of the specific * component should use {@link #getColorScheme(Component, ComponentState)} * method and various {@link SubstanceColorScheme} methods. * * @return The main default color scheme for this skin. * @see #getColorScheme(Component, ComponentState) * @see #getMainDefaultColorScheme(DecorationAreaType) */ public final SubstanceColorScheme getMainDefaultColorScheme() { return this.colorSchemeBundleMap.get(DecorationAreaType.NONE) .getDefaultColorScheme(); } /** * Returns the main disabled color scheme for this skin. The result is the * disabled color scheme for controls that do not lie in any decoration * area. Custom painting code that needs to consult the colors of the * specific component should use * {@link #getColorScheme(Component, ComponentState)} method and various * {@link SubstanceColorScheme} methods. * * @return The main disabled color scheme for this skin. * @see #getColorScheme(Component, ComponentState) * @see #getMainDisabledColorScheme(DecorationAreaType) */ public final SubstanceColorScheme getMainDisabledColorScheme() { return this.colorSchemeBundleMap.get(DecorationAreaType.NONE) .getDisabledColorScheme(); } /** * Returns the watermark of this skin. * * @return The watermark of this skin. May be null. */ public final SubstanceWatermark getWatermark() { return this.watermark; } /** * Returns the border painter of this skin. * * @return The border painter of this skin. A valid skin cannot have a * null value returned from this method. Call * {@link #isValid() * } to verify that the skin is valid. * @see #isValid() */ public final SubstanceBorderPainter getBorderPainter() { return this.borderPainter; } /** * Returns the highlight border painter of this skin. * * @return The highlight border painter of this skin. The return value of * this method may be null. In this case, call * {@link #getBorderPainter()}. */ public final SubstanceBorderPainter getHighlightBorderPainter() { return this.highlightBorderPainter; } /** * Returns the button shaper of this skin. * * @return The button shaper of this skin. A valid skin cannot have a * null value returned from this method. Call * {@link #isValid() * } to verify that the skin is valid. * @see #isValid() */ public final SubstanceButtonShaper getButtonShaper() { return this.buttonShaper; } /** * Returns the gradient painter of this skin. * * @return The gradient painter of this skin. A valid skin cannot have a * null value returned from this method. Call * {@link #isValid() * } to verify that the skin is valid. * @see #isValid() */ public final SubstanceGradientPainter getGradientPainter() { return this.gradientPainter; } /** * Returns the highlight painter of this skin. * * @return The highlight painter of this skin. A valid skin cannot have a * null value returned from this method. Call * {@link #isValid() * } to verify that the skin is valid. * @see #isValid() */ public final SubstanceHighlightPainter getHighlightPainter() { return this.highlightPainter; } /** * Returns the decoration painter of this skin. * * @return The decoration painter of this skin. A valid skin cannot have a * null value returned from this method. Call * {@link #isValid() * } to verify that the skin is valid. * @see #isValid() */ public final SubstanceDecorationPainter getDecorationPainter() { return this.decorationPainter; } /** * Adds skin-specific entries to the UI defaults table. * * @param table * UI defaults table. */ public void addCustomEntriesToTable(UIDefaults table) { // Apparently this function is called with null table // when the application is run with -Dswing.defaultlaf // setting. In this case, this function will be called // second time with correct table. if (table == null) { return; } SkinUtilities.addCustomEntriesToTable(table, this); } /** * Returns the color scheme of the specified component in the specified * component state. * * @param comp * Component. * @param componentState * Component state. * @return The color scheme of the component in the specified component * state. */ public final SubstanceColorScheme getColorScheme(Component comp, ComponentState componentState) { // small optimization - lookup the decoration area only if there // are decoration-specific scheme bundles. if (this.colorSchemeBundleMap.size() > 1) { DecorationAreaType decorationAreaType = SubstanceLookAndFeel .getDecorationType(comp); // if ((decorationAreaType == DecorationAreaType.NONE) // && (componentState == ComponentState.DEFAULT)) { // return this.defaultColorScheme; // } if (this.colorSchemeBundleMap.containsKey(decorationAreaType)) { SubstanceColorScheme registered = this.colorSchemeBundleMap .get(decorationAreaType).getColorScheme(componentState); if (registered != null) return registered; } } // if (componentState == ComponentState.DEFAULT) // return this.defaultColorScheme; SubstanceColorScheme registered = this.colorSchemeBundleMap.get( DecorationAreaType.NONE).getColorScheme(componentState); if (registered != null) return registered; if (componentState == ComponentState.DEFAULT) return this.getMainDefaultColorScheme(); if (componentState.getColorSchemeKind() == ColorSchemeKind.DISABLED) return this.getMainDisabledColorScheme(); return this.getMainActiveColorScheme(); } /** * Returns the highlight color scheme of the component. * * @param comp * Component. * @param componentState * Component state. * @return Component highlight color scheme. * @deprecated Use * {@link #getColorScheme(Component, ColorSchemeAssociationKind, ComponentState)} * with {@link ColorSchemeAssociationKind#HIGHLIGHT} instead. * This method will be removed in version 6.0. */ @Deprecated public SubstanceColorScheme getHighlightColorScheme(Component comp, ComponentState componentState) { return this.getColorScheme(comp, ColorSchemeAssociationKind.HIGHLIGHT, componentState); } /** * Returns the alpha channel of the highlight color scheme of the component. * * @param comp * Component. * @param componentState * Component state. * @return Highlight color scheme alpha channel. */ public final float getHighlightAlpha(Component comp, ComponentState componentState) { // small optimization - lookup the decoration area only if there // are decoration-specific scheme bundles. if (this.colorSchemeBundleMap.size() > 1) { DecorationAreaType decorationAreaType = SubstanceLookAndFeel .getDecorationType(comp); if (this.colorSchemeBundleMap.containsKey(decorationAreaType)) { Float registered = this.colorSchemeBundleMap.get( decorationAreaType).getHighlightAlpha(comp, componentState); if (registered >= 0.0) return registered; } } Float registered = this.colorSchemeBundleMap.get( DecorationAreaType.NONE) .getHighlightAlpha(comp, componentState); if (registered >= 0.0) return registered; boolean isRollover = componentState.isKindActive(FadeKind.ROLLOVER); boolean isSelected = componentState.isKindActive(FadeKind.SELECTION); boolean isArmed = componentState.isKindActive(FadeKind.ARM); if (isRollover && isSelected) return 0.9f; if (isRollover && isArmed) return 0.8f; if (isSelected) return 0.7f; if (isArmed) return 0.6f; if (isRollover) return 0.4f; return 0.0f; } /** * Returns the alpha channel of the color scheme of the component. * * @param comp * Component. * @param componentState * Component state. * @return Color scheme alpha channel. */ public final float getAlpha(Component comp, ComponentState componentState) { // optimization - if the state is not registered in any // scheme bundle with custom alpha, return 1.0 if (!this.statesWithAlpha.contains(componentState)) return 1.0f; // small optimization - lookup the decoration area only if there // are decoration-specific scheme bundles. if (this.colorSchemeBundleMap.size() > 1) { DecorationAreaType decorationAreaType = SubstanceLookAndFeel .getDecorationType(comp); if (this.colorSchemeBundleMap.containsKey(decorationAreaType)) { Float registered = this.colorSchemeBundleMap.get( decorationAreaType).getAlpha(comp, componentState); if (registered >= 0.0) return registered; } } Float registered = this.colorSchemeBundleMap.get( DecorationAreaType.NONE).getAlpha(comp, componentState); if (registered >= 0.0) return registered; return 1.0f; } /** * Registers the specified color scheme bundle and background color scheme * to be used on controls in decoration areas. * * @param bundle * The color scheme bundle to use on controls in decoration * areas. * @param backgroundColorScheme * The color scheme to use for background of controls in * decoration areas. * @param areaTypes * Enumerates the area types that are affected by the parameters. */ public void registerDecorationAreaSchemeBundle( SubstanceColorSchemeBundle bundle, SubstanceColorScheme backgroundColorScheme, DecorationAreaType... areaTypes) { if (bundle == null) return; if (backgroundColorScheme == null) { throw new IllegalArgumentException( "Cannot pass null background color scheme"); } for (DecorationAreaType areaType : areaTypes) { this.decoratedAreaSet.add(areaType); this.colorSchemeBundleMap.put(areaType, bundle); this.backgroundColorSchemeMap.put(areaType, backgroundColorScheme); // if (areaType == DecorationAreaType.NONE) { // this.defaultColorScheme = bundle.getDefaultColorScheme(); // } } this.statesWithAlpha.addAll(bundle.getStatesWithAlpha()); } /** * Registers the specified color scheme bundle to be used on controls in * decoration areas. * * @param bundle * The color scheme bundle to use on controls in decoration * areas. * @param areaTypes * Enumerates the area types that are affected by the parameters. */ public void registerDecorationAreaSchemeBundle( SubstanceColorSchemeBundle bundle, DecorationAreaType... areaTypes) { this.registerDecorationAreaSchemeBundle(bundle, bundle .getDefaultColorScheme(), areaTypes); } /** * Registers the specified background color scheme to be used on controls in * decoration areas. * * @param backgroundColorScheme * The color scheme to use for background of controls in * decoration areas. * @param areaTypes * Enumerates the area types that are affected by the parameters. * Each decoration area type will be painted by * {@link SubstanceDecorationPainter#paintDecorationArea(Graphics2D, Component, DecorationAreaType, int, int, SubstanceSkin)} * . */ public void registerAsDecorationArea( SubstanceColorScheme backgroundColorScheme, DecorationAreaType... areaTypes) { if (backgroundColorScheme == null) { throw new IllegalArgumentException( "Cannot pass null background color scheme"); } for (DecorationAreaType areaType : areaTypes) { this.decoratedAreaSet.add(areaType); this.backgroundColorSchemeMap.put(areaType, backgroundColorScheme); } } /** * Returns indication whether the specified decoration area type should have * their background painted by * {@link SubstanceDecorationPainter#paintDecorationArea(Graphics2D, Component, DecorationAreaType, int, int, SubstanceSkin)} * instead of a simple background fill. * * @param decorationType * Decoration area type. * @return true if specified decoration area type should have * their background painted by * {@link SubstanceDecorationPainter#paintDecorationArea(Graphics2D, Component, DecorationAreaType, int, int, SubstanceSkin)} * , false otherwise. */ public boolean isRegisteredAsDecorationArea( DecorationAreaType decorationType) { return this.decoratedAreaSet.contains(decorationType); } /** * Returns the color scheme to be used for painting the watermark. If no * custom watermark color scheme is specified ({@link #watermarkScheme} is * null), the main default color scheme of this skin is used. * * @return The color scheme to be used for painting the watermark. */ public SubstanceColorScheme getWatermarkColorScheme() { if (this.watermarkScheme != null) { return this.watermarkScheme; } return this.getMainDefaultColorScheme(); } /** * Returns the main active color scheme for the specific decoration area * type. Custom painting code that needs to consult the colors of the * specific component should use * {@link #getColorScheme(Component, ComponentState)} method and various * {@link SubstanceColorScheme} methods. * * @param decorationAreaType * Decoration area type. * @return The main active color scheme for this skin. * @see #getColorScheme(Component, ComponentState) * @see #getMainActiveColorScheme() */ public final SubstanceColorScheme getMainActiveColorScheme( DecorationAreaType decorationAreaType) { if (this.colorSchemeBundleMap.containsKey(decorationAreaType)) return this.colorSchemeBundleMap.get(decorationAreaType) .getActiveColorScheme(); return this.colorSchemeBundleMap.get(DecorationAreaType.NONE) .getActiveColorScheme(); } /** * Returns the main default color scheme for the specific decoration area * type. Custom painting code that needs to consult the colors of the * specific component should use * {@link #getColorScheme(Component, ComponentState)} method and various * {@link SubstanceColorScheme} methods. * * @param decorationAreaType * Decoration area type. * @return The main default color scheme for this skin. * @see #getColorScheme(Component, ComponentState) * @see #getMainDefaultColorScheme() */ public final SubstanceColorScheme getMainDefaultColorScheme( DecorationAreaType decorationAreaType) { if (this.colorSchemeBundleMap.containsKey(decorationAreaType)) return this.colorSchemeBundleMap.get(decorationAreaType) .getDefaultColorScheme(); return this.colorSchemeBundleMap.get(DecorationAreaType.NONE) .getDefaultColorScheme(); } /** * Returns the main disabled color scheme for the specific decoration area * type. Custom painting code that needs to consult the colors of the * specific component should use * {@link #getColorScheme(Component, ComponentState)} method and various * {@link SubstanceColorScheme} methods. * * @param decorationAreaType * Decoration area type. * @return The main disabled color scheme for this skin. * @see #getColorScheme(Component, ComponentState) * @see #getMainDisabledColorScheme() */ public final SubstanceColorScheme getMainDisabledColorScheme( DecorationAreaType decorationAreaType) { if (this.colorSchemeBundleMap.containsKey(decorationAreaType)) return this.colorSchemeBundleMap.get(decorationAreaType) .getDisabledColorScheme(); return this.colorSchemeBundleMap.get(DecorationAreaType.NONE) .getDisabledColorScheme(); } /** * Returns the start of fade effect on the selected tabs in * {@link JTabbedPane}s. This value can be used to create XP-like "headers" * on the selected tabs. * * @return The start of fade effect on the selected tabs in * {@link JTabbedPane}s. * @see #getSelectedTabFadeEnd() */ public final double getSelectedTabFadeStart() { return this.selectedTabFadeStart; } /** * Returns the end of fade effect on the selected tabs in * {@link JTabbedPane * }s. This value can be used to create XP-like "headers" * on the selected tabs. * * @return The end of fade effect on the selected tabs in * {@link JTabbedPane * }s. * @see #getSelectedTabFadeStart() */ public final double getSelectedTabFadeEnd() { return this.selectedTabFadeEnd; } /** * Sets the end of fade effect on the selected tabs in {@link JTabbedPane}s. * The value should be in 0.0-1.0 range. * * @param selectedTabFadeEnd * The end of fade effect on the selected tabs in * {@link JTabbedPane}s. Should be in 0.0-1.0 range. */ public void setSelectedTabFadeEnd(double selectedTabFadeEnd) { if ((selectedTabFadeEnd < 0.0) || (selectedTabFadeEnd > 1.0)) { throw new IllegalArgumentException( "Value for selected tab fade end should be in 0.0-1.0 range"); } this.selectedTabFadeEnd = selectedTabFadeEnd; } /** * Sets the start of fade effect on the selected tabs in {@link JTabbedPane} * s. The value should be in 0.0-1.0 range. * * @param selectedTabFadeStart * The start of fade effect on the selected tabs in * {@link JTabbedPane} s. Should be in 0.0-1.0 range. */ public void setSelectedTabFadeStart(double selectedTabFadeStart) { if ((selectedTabFadeStart < 0.0) || (selectedTabFadeStart > 1.0)) { throw new IllegalArgumentException( "Value for selected tab fade start should be in 0.0-1.0 range"); } this.selectedTabFadeStart = selectedTabFadeStart; } /** * Adds the specified overlay painter to the end of the list of overlay * painters associated with the specified decoration area types. * * @param overlayPainter * Overlay painter to add to the end of the list of overlay * painters associated with the specified decoration area types. * @param areaTypes * Decoration area types. */ public void addOverlayPainter(SubstanceOverlayPainter overlayPainter, DecorationAreaType... areaTypes) { for (DecorationAreaType areaType : areaTypes) { if (!this.overlayPaintersMap.containsKey(areaType)) this.overlayPaintersMap.put(areaType, new ArrayList()); this.overlayPaintersMap.get(areaType).add(overlayPainter); } } /** * Removes the specified overlay painter from the list of overlay painters * associated with the specified decoration area types. * * @param overlayPainter * Overlay painter to remove from the list of overlay painters * associated with the specified decoration area types. * @param areaTypes * Decoration area types. */ public void removeOverlayPainter(SubstanceOverlayPainter overlayPainter, DecorationAreaType... areaTypes) { for (DecorationAreaType areaType : areaTypes) { if (!this.overlayPaintersMap.containsKey(areaType)) return; this.overlayPaintersMap.get(areaType).remove(overlayPainter); if (this.overlayPaintersMap.get(areaType).size() == 0) this.overlayPaintersMap.remove(areaType); } } /** * Returns a non-null, non-modifiable list of overlay painters associated * with the specified decoration area type. * * @param decorationAreaType * Decoration area type. * @return A non-null, non-modifiable list of overlay painters associated * with the specified decoration area type. */ public List getOverlayPainters( DecorationAreaType decorationAreaType) { if (!this.overlayPaintersMap.containsKey(decorationAreaType)) return Collections.emptyList(); return Collections.unmodifiableList(this.overlayPaintersMap .get(decorationAreaType)); } /** * Returns indication whether the specified decoration area type should * paint drop shadows on the top few pixels. * * @param decorationAreaType * Decoration area type. * @return true if the specified decoration area type should * paint drop shadows on the top few pixels, false * otherwise. * @see #setPaintingDropShadows(DecorationAreaType) * @see #unsetPaintingDropShadows(DecorationAreaType) * @deprecated Use {@link #getOverlayPainters(DecorationAreaType)} and test * for presence of {@link TopShadowOverlayPainter}. This method * will be removed in version 6.0. */ @Deprecated public boolean isPaintingDropShadows(DecorationAreaType decorationAreaType) { List overlayPainters = this .getOverlayPainters(decorationAreaType); return overlayPainters.contains(TopShadowOverlayPainter.getInstance()); } /** * Marks the specified area type to have drop shadows on the top few pixels. * * @param decorationAreaType * Decoration areas of this type will have drop shadows on the * top few pixels. * @see #unsetPaintingDropShadows(DecorationAreaType) * @see #isPaintingDropShadows(DecorationAreaType) * @deprecated Use * {@link #addOverlayPainter(SubstanceOverlayPainter, DecorationAreaType...)} * with an instance of {@link TopShadowOverlayPainter}. This * method will be removed in version 6.0. */ @Deprecated public void setPaintingDropShadows(DecorationAreaType decorationAreaType) { this.addOverlayPainter(TopShadowOverlayPainter.getInstance(), decorationAreaType); } /** * Marks the specified area type to not have drop shadows on the top few * pixels. * * @param decorationAreaType * Decoration areas of this type will not have drop shadows on * the top few pixels. * @see #setPaintingDropShadows(DecorationAreaType) * @see #isPaintingDropShadows(DecorationAreaType) * @deprecated Use * {@link #removeOverlayPainter(SubstanceOverlayPainter, DecorationAreaType...)} * with an instance of {@link TopShadowOverlayPainter}. This * method will be removed in version 6.0. */ @Deprecated public void unsetPaintingDropShadows(DecorationAreaType decorationAreaType) { this.removeOverlayPainter(TopShadowOverlayPainter.getInstance(), decorationAreaType); } /** * Returns the color scheme to be used for painting the specified visual * area of components in the specified decoration area. * * @param decorationAreaType * Decoration area type. * @param associationKind * Color scheme association kind. * @param componentState * Component state. * @return Color scheme to be used for painting the specified visual area of * components in the specified decoration area. * @since version 5.3 */ public final SubstanceColorScheme getColorScheme( DecorationAreaType decorationAreaType, ColorSchemeAssociationKind associationKind, ComponentState componentState) { if (this.colorSchemeBundleMap.size() > 1) { if (this.colorSchemeBundleMap.containsKey(decorationAreaType)) { return this.colorSchemeBundleMap.get(decorationAreaType) .getColorScheme(associationKind, componentState); } } return this.colorSchemeBundleMap.get(DecorationAreaType.NONE) .getColorScheme(associationKind, componentState); } /** * Returns the color scheme to be used for painting the specified visual * area of the component under the specified component state. * * @param comp * Component. * @param associationKind * Color scheme association kind. * @param componentState * Component state. * @return Color scheme to be used for painting the specified visual area of * the component under the specified component state. * @since version 5.1 */ public final SubstanceColorScheme getColorScheme(Component comp, ColorSchemeAssociationKind associationKind, ComponentState componentState) { // small optimization - lookup the decoration area only if there // are decoration-specific scheme bundles. if (this.colorSchemeBundleMap.size() > 1) { DecorationAreaType decorationAreaType = SubstanceLookAndFeel .getDecorationType(comp); if (this.colorSchemeBundleMap.containsKey(decorationAreaType)) { return this.colorSchemeBundleMap.get(decorationAreaType) .getColorScheme(associationKind, componentState); } } return this.colorSchemeBundleMap.get(DecorationAreaType.NONE) .getColorScheme(associationKind, componentState); } /** * Returns the border color scheme of the component. * * @param comp * Component. * @param componentState * Component state. * @return Component border color scheme. * @deprecated Use * {@link #getColorScheme(Component, ColorSchemeAssociationKind, ComponentState)} * with {@link ColorSchemeAssociationKind#BORDER} instead. This * method will be removed in version 6.0. */ @Deprecated public SubstanceColorScheme getBorderColorScheme(Component comp, ComponentState componentState) { // small optimization - lookup the decoration area only if there // are decoration-specific scheme bundles. if (this.colorSchemeBundleMap.size() > 1) { DecorationAreaType decorationAreaType = SubstanceLookAndFeel .getDecorationType(comp); if (this.colorSchemeBundleMap.containsKey(decorationAreaType)) { return this.colorSchemeBundleMap.get(decorationAreaType) .getColorScheme(ColorSchemeAssociationKind.BORDER, componentState); } } return this.colorSchemeBundleMap.get(DecorationAreaType.NONE) .getColorScheme(ColorSchemeAssociationKind.BORDER, componentState); } @Override protected Object clone() throws CloneNotSupportedException { final String myName = this.getDisplayName(); SubstanceSkin clone = new SubstanceSkin() { @Override public String getDisplayName() { return "Clone " + myName; } }; clone.borderPainter = this.borderPainter; clone.buttonShaper = this.buttonShaper; clone.decorationPainter = this.decorationPainter; clone.gradientPainter = this.gradientPainter; clone.highlightBorderPainter = this.highlightBorderPainter; clone.highlightPainter = this.highlightPainter; clone.watermark = this.watermark; clone.watermarkScheme = this.watermarkScheme; // clone.defaultColorScheme = this.defaultColorScheme; clone.selectedTabFadeEnd = this.selectedTabFadeEnd; clone.selectedTabFadeStart = this.selectedTabFadeStart; if (this.colorSchemeBundleMap != null) { clone.colorSchemeBundleMap = new EnumMap( DecorationAreaType.class); for (Map.Entry bundleEntry : this.colorSchemeBundleMap .entrySet()) { clone.colorSchemeBundleMap.put(bundleEntry.getKey(), (SubstanceColorSchemeBundle) bundleEntry.getValue() .clone()); } } if (this.decoratedAreaSet != null) { clone.decoratedAreaSet = EnumSet.copyOf(this.decoratedAreaSet); } // if (this.dropShadowsSet != null) { // clone.dropShadowsSet = EnumSet.copyOf(this.dropShadowsSet); // } if (this.backgroundColorSchemeMap != null) { clone.backgroundColorSchemeMap = new EnumMap( this.backgroundColorSchemeMap); } if (this.overlayPaintersMap != null) { clone.overlayPaintersMap = new EnumMap>( this.overlayPaintersMap); } return clone; } /** * Creates a new skin that has the same settings as this skin with the * addition of applying the specified color scheme transformation on all the * relevant color schemes. * * @param transform * Color scheme transformation. * @param name * The name of the new skin. * @return The new skin. */ @SubstanceApi public SubstanceSkin transform(ColorSchemeTransform transform, final String name) { SubstanceSkin result = new SubstanceSkin() { @Override public String getDisplayName() { return name; } }; // same painters result.borderPainter = this.borderPainter; result.buttonShaper = this.buttonShaper; result.decorationPainter = this.decorationPainter; result.gradientPainter = this.gradientPainter; result.highlightPainter = this.highlightPainter; result.highlightBorderPainter = this.highlightBorderPainter; // same watermark and transformed scheme result.watermark = this.watermark; if (this.watermarkScheme != null) result.watermarkScheme = transform.transform(this.watermarkScheme); // issue 428 - transform the default color scheme // result.defaultColorScheme = transform // .transform(this.defaultColorScheme); // same misc settings result.selectedTabFadeEnd = this.selectedTabFadeEnd; result.selectedTabFadeStart = this.selectedTabFadeStart; // transform the scheme bundles if (this.colorSchemeBundleMap != null) { result.colorSchemeBundleMap = new EnumMap( DecorationAreaType.class); for (Map.Entry bundleEntry : this.colorSchemeBundleMap .entrySet()) { result.colorSchemeBundleMap.put(bundleEntry.getKey(), bundleEntry.getValue().transform(transform)); } } // same set of decoration areas if (this.decoratedAreaSet != null) { result.decoratedAreaSet = EnumSet.copyOf(this.decoratedAreaSet); } // // same set of drop shadow decorated areas // if (this.dropShadowsSet != null) { // result.dropShadowsSet = EnumSet.copyOf(this.dropShadowsSet); // } // transform the background schemes if (this.backgroundColorSchemeMap != null) { result.backgroundColorSchemeMap = new EnumMap( DecorationAreaType.class); for (Map.Entry entry : this.backgroundColorSchemeMap .entrySet()) { result.backgroundColorSchemeMap.put(entry.getKey(), transform .transform(entry.getValue())); } } // same map of overlay painters result.overlayPaintersMap = new EnumMap>( this.overlayPaintersMap); return result; } /** * Creates a clone of this skin with the specified watermark. This is mainly * targeting sample applications and docrobot. Applications are encouraged * to create a custom skin by either extending one of the core Substance * skins, or by extending the {@link SubstanceSkin} directly. * * @param watermark * Watermark for the new skin. * @return A clone of this skin with the specified watermark. */ @SubstanceApi public SubstanceSkin withWatermark(SubstanceWatermark watermark) { try { SubstanceSkin clone = (SubstanceSkin) this.clone(); clone.watermark = watermark; return clone; } catch (CloneNotSupportedException cnse) { return null; } } /** * Returns the background color scheme for the specified decoration area * type. This method is mainly for the internal use of * {@link SubstanceDecorationPainter#paintDecorationArea(Graphics2D, Component, DecorationAreaType, int, int, SubstanceSkin)} * , but can be used in applications that wish to provide custom overlay * background painting (such as watermarks, for example). * * @param decorationAreaType * Decoration area type. * @return The background color scheme for the specified decoration area * type. */ public final SubstanceColorScheme getBackgroundColorScheme( DecorationAreaType decorationAreaType) { // 1 - check the registered background scheme for this specific area // type. if (this.backgroundColorSchemeMap.containsKey(decorationAreaType)) return this.backgroundColorSchemeMap.get(decorationAreaType); // 2 - check the registered scheme bundle for this specific area type. if (this.colorSchemeBundleMap.containsKey(decorationAreaType)) { SubstanceColorScheme registered = this.colorSchemeBundleMap.get( decorationAreaType).getDefaultColorScheme(); if (registered != null) return registered; } // 3 - return the background scheme for the default area type return this.backgroundColorSchemeMap.get(DecorationAreaType.NONE); } /** * Checks whether this skin is valid. A valid skin must have a color scheme * bundle for {@link DecorationAreaType#NONE} and non-null * button shaper, gradient painter, border painter, highlight painter and * decoration painter. If call to * {@link SubstanceLookAndFeel#setSkin(String)} or * {@link SubstanceLookAndFeel#setSkin(SubstanceSkin)} does not seem to have * any visible effect (returning false), call this method to * verify that your skin is valid. * * @return true if this skin is valid, false * otherwise. */ public boolean isValid() { if (!this.colorSchemeBundleMap.containsKey(DecorationAreaType.NONE)) return false; if (this.getButtonShaper() == null) { return false; } if (this.getGradientPainter() == null) { return false; } if (this.getBorderPainter() == null) { return false; } if (this.getHighlightPainter() == null) { return false; } if (this.getDecorationPainter() == null) { return false; } return true; } /** * Contains information on color schemes loaded by the * {@link SubstanceSkin#getColorSchemes(URL)} API. Note that the custom * skins should only use the {@link #get(String)} API. The rest of the API * is currently internal and is used in the Jitterbug * visual editor. * * @author Kirill Grouchnikov */ public static class ColorSchemes { /** * List of color schemes of this object. */ private List schemes; /** * Creates an object with empty list of color schemes. This method is * for internal use only and should not be used in custom application * skins. */ public ColorSchemes() { this.schemes = new ArrayList(); } /** * Creates an object based on the specified list of color schemes. This * method is for internal use only and should not be used in custom * application skins. * * @param schemes * List of color schemes. */ public ColorSchemes(List schemes) { this(); this.schemes.addAll(schemes); } /** * Returns the number of color schemes in this object. This method is * for internal use only and should not be used in custom application * skins. * * @return The number of color schemes in this object. */ public int size() { return this.schemes.size(); } /** * Returns the color scheme at the specified index. This method is for * internal use only and should not be used in custom application skins. * * @param index * Index. * @return Color scheme at the specified index. */ public SubstanceColorScheme get(int index) { return this.schemes.get(index); } /** * Returns the color scheme based on its display name. This method is * the only API that is published for use in custom application skins. * * @param displayName * Display name of a color scheme. * @return The color scheme with the matching display name. */ public SubstanceColorScheme get(String displayName) { for (SubstanceColorScheme scheme : this.schemes) { if (scheme.getDisplayName().equals(displayName)) { return scheme; } } return null; } /** * Returns the index of the color scheme that has the specified display * name. This method is for internal use only and should not be used in * custom application skins. * * @param displayName * Display name of a color scheme. * @return The index of the color scheme that has the specified display * name. */ private int indexOf(String displayName) { for (int i = 0; i < this.schemes.size(); i++) { SubstanceColorScheme curr = this.schemes.get(i); if (curr.getDisplayName().equals(displayName)) { return i; } } return -1; } /** * Finds the index of the color scheme that has the specified display * name and replaces it with (possibly another) color scheme. This * method is for internal use only and should not be used in custom * application skins. * * @param displayName * Display name of a color scheme. * @param scheme * Color scheme that will replace the existing color scheme * (based on the display name) at the same index in the list. */ public void replace(String displayName, SubstanceColorScheme scheme) { int index = this.indexOf(displayName); if (index >= 0) { this.schemes.remove(index); this.schemes.add(index, scheme); } } /** * Deletes the color scheme that has the specified display name. This * method is for internal use only and should not be used in custom * application skins. * * @param displayName * Display name of the color scheme to delete from the list. */ public void delete(String displayName) { int index = this.indexOf(displayName); if (index >= 0) { this.schemes.remove(index); } } /** * Adds the specified color scheme to the end of the list. This method * is for internal use only and should not be used in custom application * skins. * * @param scheme * Color scheme to add to the end of the list. */ public void add(SubstanceColorScheme scheme) { this.schemes.add(scheme); } /** * Moves the color scheme with the specified display name one position * towards the beginning of the list. This method is for internal use * only and should not be used in custom application skins. * * @param displayName * Display name of the color scheme to move one position * towards the beginning of the list. */ public void switchWithPrevious(String displayName) { int index = this.indexOf(displayName); if (index >= 0) { SubstanceColorScheme scheme = this.schemes.remove(index); this.schemes.add(index - 1, scheme); } } /** * Moves the color scheme with the specified display name one position * towards the end of the list. This method is for internal use only and * should not be used in custom application skins. * * @param displayName * Display name of the color scheme to move one position * towards the end of the list. */ public void switchWithNext(String displayName) { int index = this.indexOf(displayName); if (index >= 0) { SubstanceColorScheme scheme = this.schemes.remove(index); this.schemes.add(index + 1, scheme); } } } /** * Returns the collection of color schemes in the specified URL. * * @param url * URL that points to a resource containing the description of * Substance color schemes. * @return The collection of color schemes in the specified URL. * @since version 5.2 */ public static ColorSchemes getColorSchemes(URL url) { return SubstanceColorSchemeUtilities.getColorSchemes(url); } } substance-5.3.orig/src/org/jvnet/substance/api/trait/0000755000175000017500000000000011256731146022600 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/api/trait/SubstanceTraitInfo.java0000644000175000017500000000534311136475560027221 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.trait; /** * Base interface for Substance traits info, like {@link ThemeInfo}, * {@link WatermarkInfo} etc. * * @author Kirill Grouchnikov */ public interface SubstanceTraitInfo { /** * Returns the display name of the associated trait. This method is part of * officially supported API. * * @return The display name of the associated trait. */ public String getDisplayName(); /** * Returns the class name of the associated trait. * * @return The class name of the associated trait. This method is part of * officially supported API. */ public String getClassName(); /** * Returns indication whether the associated trait is default. * * @return true if the associated trait is default, * false otherwise. */ public boolean isDefault(); /** * Sets indication whether the associated trait is default. * * @param isDefault * New indication whether the associated trait is default. */ public void setDefault(boolean isDefault); } substance-5.3.orig/src/org/jvnet/substance/api/trait/SubstanceTrait.java0000644000175000017500000000431011136475560026376 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.trait; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.watermark.SubstanceWatermark; /** * Base interface for Substance traits, like {@link SubstanceColorScheme}, * {@link SubstanceWatermark} etc. * * @author Kirill Grouchnikov */ public interface SubstanceTrait { /** * Returns the display name of this trait. This method is part * of officially supported API. * * @return The display name of this trait. */ public String getDisplayName(); } substance-5.3.orig/src/org/jvnet/substance/api/SubstanceConstants.java0000644000175000017500000005713211172042176026147 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api; import java.awt.*; import java.awt.geom.GeneralPath; import javax.swing.*; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.lafwidget.animation.FadeTracker; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.shaper.SubstanceButtonShaper; import org.jvnet.substance.utils.*; /** * Substance constants. * * @author Kirill Grouchnikov */ @SubstanceApi public class SubstanceConstants { /** * Enumerates available sides. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#BUTTON_OPEN_SIDE_PROPERTY * @see SubstanceLookAndFeel#BUTTON_SIDE_PROPERTY */ public static enum Side { /** * Left side. */ LEFT, /** * Right side. */ RIGHT, /** * Top side. */ TOP, /** * Bottom side. */ BOTTOM; } /** * Enumerates focus indication kinds. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#FOCUS_KIND */ public enum FocusKind { /** * No focus indication. */ NONE { /* * (non-Javadoc) * * @see * org.jvnet.substance.utils.SubstanceConstants.FocusKind#paintFocus * (java.awt.Component, java.awt.Component, java.awt.Graphics2D, * java.awt.Shape, java.awt.Rectangle, int) */ @Override public void paintFocus(Component mainComp, Component focusedComp, Graphics2D graphics, Shape focusShape, Rectangle textRect, int extraPadding) { } }, /** * Focus indication around the text. */ TEXT { /* * (non-Javadoc) * * @see * org.jvnet.substance.utils.SubstanceConstants.FocusKind#paintFocus * (java.awt.Component, java.awt.Component, java.awt.Graphics2D, * java.awt.Shape, java.awt.Rectangle, int) */ @Override public void paintFocus(Component mainComp, Component focusedComp, Graphics2D graphics, Shape focusShape, Rectangle textRect, int extraPadding) { if (textRect == null) return; if ((textRect.width == 0) || (textRect.height == 0)) return; float dashPhase = 0.0f; int fontSize = SubstanceSizeUtils .getComponentFontSize(mainComp); float dashLength = getDashLength(fontSize); float dashGap = getDashGap(fontSize); FadeTracker fadeTracker = FadeTracker.getInstance(); if (fadeTracker.isTracked(focusedComp, FadeKind.FOCUS_LOOP_ANIMATION)) { dashPhase = (dashLength + dashGap) * (1.0f - fadeTracker.getFade(focusedComp, FadeKind.FOCUS_LOOP_ANIMATION)); } graphics.setStroke(new BasicStroke(SubstanceSizeUtils .getFocusStrokeWidth(fontSize), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 0.0f, new float[] { dashLength, dashGap }, dashPhase)); int delta = ((mainComp instanceof JComboBox) || (mainComp instanceof JSpinner)) ? 0 : 1; GeneralPath contour = SubstanceOutlineUtilities.getBaseOutline( textRect.width + 2 * delta, textRect.height, SubstanceSizeUtils .getClassicButtonCornerRadius(fontSize), null); graphics.translate(textRect.x - delta, textRect.y); graphics.draw(contour); } /* * (non-Javadoc) * * @see * org.jvnet.substance.utils.SubstanceConstants.FocusKind#isAnimated * () */ @Override public boolean isAnimated() { return true; } }, /** * Focus indication around the whole component. */ ALL { /* * (non-Javadoc) * * @see * org.jvnet.substance.utils.SubstanceConstants.FocusKind#paintFocus * (java.awt.Component, java.awt.Component, java.awt.Graphics2D, * java.awt.Shape, java.awt.Rectangle, int) */ @Override public void paintFocus(Component mainComp, Component focusedComp, Graphics2D graphics, Shape focusShape, Rectangle textRect, int extraPadding) { if ((focusShape == null) && ((mainComp instanceof AbstractButton) && !(mainComp instanceof JCheckBox) && !(mainComp instanceof JRadioButton))) { SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(mainComp); if (shaper == null) return; // Shape currClip = graphics.getClip(); // if (!shaper.isProportionate()) { float dashPhase = 0.0f; int fontSize = SubstanceSizeUtils .getComponentFontSize(mainComp); float dashLength = getDashLength(fontSize); float dashGap = getDashGap(fontSize); FadeTracker fadeTracker = FadeTracker.getInstance(); if (fadeTracker.isTracked(focusedComp, FadeKind.FOCUS_LOOP_ANIMATION)) { dashPhase = (dashLength + dashGap) * (1.0f - fadeTracker.getFade(focusedComp, FadeKind.FOCUS_LOOP_ANIMATION)); } graphics.setStroke(new BasicStroke(SubstanceSizeUtils .getFocusStrokeWidth(fontSize), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 0.0f, new float[] { dashLength, dashGap }, dashPhase)); Shape contour = shaper.getButtonOutline( (AbstractButton) mainComp, null, mainComp .getWidth(), mainComp.getHeight(), false); graphics.draw(contour); // } } else { // graphics.translate(textRect.x - 1, textRect.y - 1); graphics.translate(1, 1); Shape contour = (focusShape != null) ? focusShape : SubstanceOutlineUtilities .getBaseOutline( mainComp.getWidth() - 2, mainComp.getHeight() - 2, SubstanceSizeUtils .getClassicButtonCornerRadius(SubstanceSizeUtils .getComponentFontSize(mainComp)), null); float dashPhase = 0.0f; int fontSize = SubstanceSizeUtils .getComponentFontSize(mainComp); float dashLength = getDashLength(fontSize); float dashGap = getDashGap(fontSize); FadeTracker fadeTracker = FadeTracker.getInstance(); if (fadeTracker.isTracked(focusedComp, FadeKind.FOCUS_LOOP_ANIMATION)) { dashPhase = (dashLength + dashGap) * (1.0f - fadeTracker.getFade(focusedComp, FadeKind.FOCUS_LOOP_ANIMATION)); } graphics.setStroke(new BasicStroke(SubstanceSizeUtils .getFocusStrokeWidth(fontSize), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 0.0f, new float[] { dashLength, dashGap }, dashPhase)); graphics.draw(contour); } } /* * (non-Javadoc) * * @see * org.jvnet.substance.utils.SubstanceConstants.FocusKind#isAnimated * () */ @Override public boolean isAnimated() { return true; } }, /** * Focus indication around the whole component, but moved 1 pixel inside * the component. */ ALL_INNER { /* * (non-Javadoc) * * @see * org.jvnet.substance.utils.SubstanceConstants.FocusKind#paintFocus * (java.awt.Component, java.awt.Component, java.awt.Graphics2D, * java.awt.Shape, java.awt.Rectangle, int) */ @Override public void paintFocus(Component mainComp, Component focusedComp, Graphics2D graphics, Shape focusShape, Rectangle textRect, int extraPadding) { if ((focusShape == null) && ((mainComp instanceof AbstractButton) && !(mainComp instanceof JCheckBox) && !(mainComp instanceof JRadioButton))) { SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(mainComp); if (shaper == null) return; if (shaper.isProportionate()) { float dashPhase = 0.0f; int fontSize = SubstanceSizeUtils .getComponentFontSize(mainComp); float dashLength = getDashLength(fontSize); float dashGap = getDashGap(fontSize); FadeTracker fadeTracker = FadeTracker.getInstance(); if (fadeTracker.isTracked(focusedComp, FadeKind.FOCUS_LOOP_ANIMATION)) { dashPhase = (dashLength + dashGap) * (1.0f - fadeTracker.getFade(focusedComp, FadeKind.FOCUS_LOOP_ANIMATION)); } float focusStrokeWidth = SubstanceSizeUtils .getFocusStrokeWidth(fontSize); graphics.setStroke(new BasicStroke(focusStrokeWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 0.0f, new float[] { dashLength, dashGap }, dashPhase)); int insetsPix = extraPadding; Insets insets = new Insets(insetsPix, insetsPix, insetsPix, insetsPix); Shape contour = shaper.getButtonOutline( (AbstractButton) mainComp, insets, mainComp .getWidth(), mainComp.getHeight(), false); graphics.draw(contour); } } else { graphics.translate(extraPadding / 2, extraPadding / 2); int fontSize = SubstanceSizeUtils .getComponentFontSize(mainComp); Shape contour = (focusShape != null) ? focusShape : SubstanceOutlineUtilities.getBaseOutline(mainComp .getWidth() - extraPadding, mainComp.getHeight() - extraPadding, SubstanceSizeUtils .getClassicButtonCornerRadius(fontSize), null); float dashPhase = 0.0f; float dashLength = getDashLength(fontSize); float dashGap = getDashGap(fontSize); FadeTracker fadeTracker = FadeTracker.getInstance(); if (fadeTracker.isTracked(focusedComp, FadeKind.FOCUS_LOOP_ANIMATION)) { dashPhase = (dashLength + dashGap) * (1.0f - fadeTracker.getFade(focusedComp, FadeKind.FOCUS_LOOP_ANIMATION)); } graphics.setStroke(new BasicStroke(SubstanceSizeUtils .getFocusStrokeWidth(fontSize), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 0.0f, new float[] { dashLength, dashGap }, dashPhase)); graphics.draw(contour); } } /* * (non-Javadoc) * * @see * org.jvnet.substance.utils.SubstanceConstants.FocusKind#isAnimated * () */ @Override public boolean isAnimated() { return true; } }, /** * Focus indication around the whole component, but moved 1 pixel inside * the component. */ ALL_STRONG_INNER { /* * (non-Javadoc) * * @see * org.jvnet.substance.utils.SubstanceConstants.FocusKind#paintFocus * (java.awt.Component, java.awt.Component, java.awt.Graphics2D, * java.awt.Shape, java.awt.Rectangle, int) */ @Override public void paintFocus(Component mainComp, Component focusedComp, Graphics2D graphics, Shape focusShape, Rectangle textRect, int extraPadding) { if ((focusShape == null) && ((mainComp instanceof AbstractButton) && !(mainComp instanceof JCheckBox) && !(mainComp instanceof JRadioButton))) { SubstanceButtonShaper shaper = SubstanceCoreUtilities .getButtonShaper(mainComp); if (shaper == null) return; if (shaper.isProportionate()) { Insets insets = new Insets(extraPadding, extraPadding, extraPadding, extraPadding); Shape contour = shaper.getButtonOutline( (AbstractButton) mainComp, insets, mainComp .getWidth(), mainComp.getHeight(), false); graphics.draw(contour); } } else { graphics.translate(extraPadding / 2, extraPadding / 2); Shape contour = (focusShape != null) ? focusShape : SubstanceOutlineUtilities .getBaseOutline( mainComp.getWidth() - extraPadding, mainComp.getHeight() - extraPadding, SubstanceSizeUtils .getClassicButtonCornerRadius(SubstanceSizeUtils .getComponentFontSize(mainComp)), null); graphics.draw(contour); } } }, /** * Focus indication under the component text. */ UNDERLINE { /* * (non-Javadoc) * * @see * org.jvnet.substance.utils.SubstanceConstants.FocusKind#paintFocus * (java.awt.Component, java.awt.Component, java.awt.Graphics2D, * java.awt.Shape, java.awt.Rectangle, int) */ @Override public void paintFocus(Component mainComp, Component focusedComp, Graphics2D graphics, Shape focusShape, Rectangle textRect, int extraPadding) { if (textRect == null) return; float dashPhase = 0.0f; int fontSize = SubstanceSizeUtils .getComponentFontSize(mainComp); float dashLength = getDashLength(fontSize); float dashGap = getDashGap(fontSize); FadeTracker fadeTracker = FadeTracker.getInstance(); if (fadeTracker.isTracked(focusedComp, FadeKind.FOCUS_LOOP_ANIMATION)) { dashPhase = (dashLength + dashGap) * (1.0f - fadeTracker.getFade(mainComp, FadeKind.FOCUS_LOOP_ANIMATION)); } graphics.setStroke(new BasicStroke(SubstanceSizeUtils .getFocusStrokeWidth(fontSize), BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 0.0f, new float[] { dashLength, dashGap }, dashPhase)); graphics.translate(textRect.x - 1, textRect.y); graphics.drawLine(0, textRect.height - 1, textRect.width, textRect.height - 1); graphics.dispose(); } /* * (non-Javadoc) * * @see * org.jvnet.substance.utils.SubstanceConstants.FocusKind#isAnimated * () */ @Override public boolean isAnimated() { return true; } }, /** * Strong focus indication under the component text. */ STRONG_UNDERLINE { /* * (non-Javadoc) * * @see * org.jvnet.substance.utils.SubstanceConstants.FocusKind#paintFocus * (java.awt.Component, java.awt.Component, java.awt.Graphics2D, * java.awt.Shape, java.awt.Rectangle, int) */ @Override public void paintFocus(Component mainComp, Component focusedComp, Graphics2D graphics, Shape focusShape, Rectangle textRect, int extraPadding) { if (textRect == null) return; graphics.translate(textRect.x - 1, textRect.y); graphics.drawLine(0, textRect.height - 1, textRect.width, textRect.height - 1); } }; /** * Paints the focus ring on the specified component. * * @param mainComp * The main component for the focus painting. * @param focusedComp * The actual component that has the focus. For example, the * main component can be a {@link JSpinner}, while the * focused component is a text field inside the the spinner * editor. * @param graphics * Graphics context. * @param focusShape * Focus shape. May be null - in this case, the * bounds of mainComp will be used. * @param textRect * Text rectangle (if relevant). * @param extraPadding * Extra padding between the component bounds and the focus * ring painting. */ public abstract void paintFocus(Component mainComp, Component focusedComp, Graphics2D graphics, Shape focusShape, Rectangle textRect, int extraPadding); /** * Paints the focus ring on the specified component. * * @param comp * Component. * @param graphics * Graphics context. * @param textRect * Text rectangle (if relevant). */ public void paintFocus(Component comp, Graphics2D graphics, Rectangle textRect) { this.paintFocus(comp, comp, graphics, null, textRect, 0); } /** * Returns DPI-aware dash length for dash-based focus painting. * * @param fontSize * The font size of the component for focus painting. * @return DPI-aware dash length for dash-based focus painting. */ protected static float getDashLength(int fontSize) { return 2.0f + SubstanceSizeUtils.getExtraPadding(fontSize); } /** * Returns DPI-aware dash gap for dash-based focus painting. * * @param fontSize * The font size of the component for focus painting. * @return DPI-aware dash gap for dash-based focus painting. */ protected static float getDashGap(int fontSize) { return getDashLength(fontSize) / 2.0f; } /** * Returns indication whether this focus kind can be * animated. For example, focus rings painted with solid lines are * generally static. * * @return true if this focus kind can be * animated, false otherwise. */ public boolean isAnimated() { return false; } } /** * Enumerates of image-based watermarks kinds. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#setImageWatermarkKind(org.jvnet.substance.utils. * SubstanceConstants.ImageWatermarkKind) * @see SubstanceLookAndFeel#getImageWatermarkKind() */ public enum ImageWatermarkKind { /** * The default behaviour. The image is centered in the screen and scaled * down if necessary. */ SCREEN_CENTER_SCALE, /** * The image is tiled starting from the screen top-left corner and not * scaled. */ SCREEN_TILE, /** * The image is anchored to the top-left corner of the application frame * and not scaled. */ APP_ANCHOR, /** * The image is anchored to the center of the application frame and not * scaled. */ APP_CENTER, /** * The image is tiled starting from the top-left corner of the * application frame and not scaled. */ APP_TILE } /** * Enumerates possible modes of closing tabs. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#TABBED_PANE_CLOSE_CALLBACK */ public enum TabCloseKind { /** * Indicates that no tabs should be closed. */ NONE, /** * Indicates that the specified tab should be closed. */ THIS, /** * Indicates that all tabs should be closed. */ ALL, /** * Indicates that all tabs except the specified should be closed. */ ALL_BUT_THIS } /** * Enumerates possible button policies for scroll panes. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#SCROLL_PANE_BUTTONS_POLICY */ public enum ScrollPaneButtonPolicyKind { /** * The empty button policy - no buttons. */ NONE, /** * The opposite (default) button policy - the decrease * button is on one side of the scroll bar, and the increase button is * on the other side of the scroll bar. */ OPPOSITE, /** * The adjacent button policy - both the decrease button * and the increase button are on the same side of the scroll bar * adjacent to each other (like on Mac). */ ADJACENT, /** * The multiple button policy - there are two decrease * buttons on the opposite side of the scroll bar and the increase * button is adjacent to the second decrease button. This combines the * {@link #OPPOSITE} and the {@link #ADJACENT} policies together. */ MULTIPLE, /** * The multiple both button policy - there are two pairs of * decrease-increase buttons on the opposite sides of the scroll bar. * This extends the {@link #MULTIPLE} policy. */ MULTIPLE_BOTH } /** * Enumerates possible values for menu gutter fill kind. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#MENU_GUTTER_FILL_KIND */ public enum MenuGutterFillKind { /** * The none fill kind - draws no background in the menu * gutter. */ NONE, /** * The soft fill fill kind - draws light fill background in * the menu gutter. */ SOFT_FILL, /** * The hard fill fill kind - draws darker fill background * in the menu gutter. */ HARD_FILL, /** * The soft fill kind - draws gradient ranging from darker * to light in the menu gutter. */ SOFT, /** * The hard (default) fill kind - draws gradient ranging * from darker to light in the menu gutter. */ HARD } /** * Color shift kind for shifting themes in inner border painters. * * @author Kirill Grouchnikov * @deprecated Will be removed in version 6.0 */ @Deprecated public enum ColorShiftKind { /** * Instructs the inner border painter to shade the border theme for the * inner part of the border. * * @see ShadeColorScheme * @see SubstanceColorScheme#shade(double) */ SHADE, /** * Instructs the inner border painter to tint the border theme for the * inner part of the border. * * @see TintColorScheme * @see SubstanceColorScheme#tint(double) */ TINT, /** * Instructs the inner border painter to tone the border theme for the * inner part of the border. * * @see ToneColorScheme * @see SubstanceColorScheme#tone(double) */ TONE, /** * Instructs the inner border painter to shift the border theme for the * inner part of the border towards its light colors. */ THEME_LIGHT } /** * Tab content pane border kind. * * @author Kirill Grouchnikov * @since version 4.1 */ public enum TabContentPaneBorderKind { /** * The content pane has full border on all sides plus an additional line * along the tab placement side (as in Firefox 2.0, Internet Explorer * 7.0 and Nimbus). This is the default kind starting from version 4.1. */ DOUBLE_FULL, /** * The content pane has full single border on all sides. This has been * the default kind prior to version 4.1. */ SINGLE_FULL, /** * The content pane has double border along the tab placement side. */ DOUBLE_PLACEMENT, /** * The content pane has single border along the tab placement side. */ SINGLE_PLACEMENT } /** * Enumerates configurable Substance-specific widget types for * {@link SubstanceLookAndFeel#setWidgetVisible(javax.swing.JRootPane, boolean, SubstanceWidgetType...)} * API. * * @author Kirill Grouchnikov */ public enum SubstanceWidgetType { /** * Menu search widget. */ MENU_SEARCH, /** * Title pane heap status widget. */ TITLE_PANE_HEAP_STATUS } } substance-5.3.orig/src/org/jvnet/substance/api/skin/0000755000175000017500000000000011256731146022421 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/api/skin/GraphiteAquaSkin.java0000644000175000017500000001570211247060210026454 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.skin; import org.jvnet.substance.api.*; import org.jvnet.substance.api.painter.fill.FractionBasedFillPainter; import org.jvnet.substance.api.painter.highlight.FractionBasedHighlightPainter; import org.jvnet.substance.painter.border.*; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.decoration.FlatDecorationPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * Graphite Aqua skin. This class is part of officially supported * API. * * @author Kirill Grouchnikov * @since version 5.3 */ public class GraphiteAquaSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Graphite Aqua"; /** * Creates a new Raven Graphite skin. */ public GraphiteAquaSkin() { SubstanceSkin.ColorSchemes schemes = SubstanceSkin .getColorSchemes(GraphiteAquaSkin.class .getClassLoader() .getResource( "org/jvnet/substance/skin/ravengraphite.colorschemes")); SubstanceColorScheme selectedDisabledScheme = schemes .get("Raven Graphite Selected Disabled"); SubstanceColorScheme disabledScheme = schemes .get("Raven Graphite Disabled"); SubstanceColorScheme defaultScheme = schemes .get("Raven Graphite Default"); SubstanceColorScheme backgroundScheme = schemes .get("Raven Graphite Background"); // use the same color scheme for active and default controls SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( defaultScheme, defaultScheme, disabledScheme); // highlight fill scheme + custom alpha for rollover unselected state SubstanceColorScheme highlightScheme = schemes .get("Raven Graphite Aqua"); defaultSchemeBundle.registerHighlightColorScheme(highlightScheme, 0.75f, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerHighlightColorScheme(highlightScheme, 0.9f, ComponentState.SELECTED); defaultSchemeBundle.registerHighlightColorScheme(highlightScheme, 1.0f, ComponentState.ROLLOVER_SELECTED); defaultSchemeBundle.registerHighlightColorScheme(highlightScheme, 1.0f, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); defaultSchemeBundle.registerColorScheme(highlightScheme, ColorSchemeAssociationKind.BORDER, ComponentState.ROLLOVER_ARMED, ComponentState.ROLLOVER_SELECTED, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerColorScheme(highlightScheme, ColorSchemeAssociationKind.FILL, ComponentState.SELECTED, ComponentState.ROLLOVER_SELECTED); // border schemes SubstanceColorScheme borderScheme = schemes .get("Raven Graphite Border"); SubstanceColorScheme separatorScheme = schemes .get("Raven Graphite Separator"); defaultSchemeBundle.registerColorScheme(highlightScheme, ColorSchemeAssociationKind.HIGHLIGHT_BORDER, ComponentState .getActiveStates()); defaultSchemeBundle.registerColorScheme(borderScheme, ColorSchemeAssociationKind.BORDER); defaultSchemeBundle.registerColorScheme(separatorScheme, ColorSchemeAssociationKind.SEPARATOR); defaultSchemeBundle.registerColorScheme(borderScheme, ColorSchemeAssociationKind.MARK); // text highlight scheme defaultSchemeBundle.registerColorScheme(highlightScheme, ColorSchemeAssociationKind.TEXT_HIGHLIGHT, ComponentState.SELECTED, ComponentState.ROLLOVER_SELECTED); defaultSchemeBundle.registerColorScheme(highlightScheme, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); defaultSchemeBundle.registerColorScheme(disabledScheme, 0.5f, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(selectedDisabledScheme, 0.5f, ComponentState.DISABLED_SELECTED); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, backgroundScheme, DecorationAreaType.NONE); this.setSelectedTabFadeStart(0.15); this.setSelectedTabFadeEnd(0.25); this.buttonShaper = new ClassicButtonShaper(); this.watermark = null; this.gradientPainter = new FractionBasedFillPainter("Graphite Aqua", new float[] { 0.0f, 0.5f, 1.0f }, new ColorSchemeSingleColorQuery[] { ColorSchemeSingleColorQuery.LIGHT, ColorSchemeSingleColorQuery.MID, ColorSchemeSingleColorQuery.MID }); this.decorationPainter = new FlatDecorationPainter(); this.highlightPainter = new FractionBasedHighlightPainter( "Graphite Aqua", new float[] { 0.0f, 0.5f, 1.0f }, new ColorSchemeSingleColorQuery[] { ColorSchemeSingleColorQuery.EXTRALIGHT, ColorSchemeSingleColorQuery.LIGHT, ColorSchemeSingleColorQuery.MID }); this.borderPainter = new CompositeBorderPainter("Graphite Aqua", new ClassicBorderPainter(), new DelegateBorderPainter( "Graphite Aqua Inner", new ClassicBorderPainter(), 0xC0FFFFFF, 0x90FFFFFF, 0x30FFFFFF, new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.tint(0.25f); } })); this.highlightBorderPainter = new ClassicBorderPainter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/api/skin/SubstanceMagellanLookAndFeel.java0000644000175000017500000000467011246144254030724 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Magellan skin from * {@link MagellanSkin}. You can set this look-and-feel by: *
    *
  • * -Dswing.defaultlaf=org.jvnet.substance.api.skin.SubstanceMagellanLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.api.skin.SubstanceMagellanLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceMagellanLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 5.3 */ public class SubstanceMagellanLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Magellan look-and-feel. */ public SubstanceMagellanLookAndFeel() { super(new MagellanSkin()); } } substance-5.3.orig/src/org/jvnet/substance/api/skin/MagellanSkin.java0000644000175000017500000002656611246437210025642 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.skin; import java.awt.Color; import org.jvnet.substance.api.*; import org.jvnet.substance.api.painter.border.FractionBasedBorderPainter; import org.jvnet.substance.api.painter.fill.FractionBasedFillPainter; import org.jvnet.substance.api.painter.overlay.*; import org.jvnet.substance.painter.border.*; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.decoration.MatteDecorationPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * Magellan skin. This class is part of officially supported API. * * @author Kirill Grouchnikov * @since version 5.3 */ public class MagellanSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Magellan"; /** * Overlay painter to paint a dark line along the bottom edge of the * toolbars. */ private BottomLineOverlayPainter toolbarBottomLineOverlayPainter; /** * Overlay painter to paint a light line along the top edge of the toolbars. */ private TopLineOverlayPainter toolbarTopLineOverlayPainter; /** * Overlay painter to paint a bezel line along the top edge of the footer. */ private TopBezelOverlayPainter footerTopBezelOverlayPainter; @Override public String getDisplayName() { return NAME; } /** * Creates a new instance of Magellan skin. */ public MagellanSkin() { SubstanceSkin.ColorSchemes colorSchemes = SubstanceSkin .getColorSchemes(MagellanSkin.class .getClassLoader() .getResource( "org/jvnet/substance/api/skin/magellan.colorschemes")); SubstanceColorScheme blueControlsActive = colorSchemes .get("Magellan Blue Controls Active"); SubstanceColorScheme blueControlsDefault = colorSchemes .get("Magellan Blue Controls Default"); SubstanceColorSchemeBundle defaultColorSchemeBundle = new SubstanceColorSchemeBundle( blueControlsActive, blueControlsDefault, blueControlsDefault); defaultColorSchemeBundle.registerColorScheme(blueControlsDefault, 0.5f, ComponentState.DISABLED_UNSELECTED); defaultColorSchemeBundle.registerColorScheme(blueControlsActive, 0.5f, ComponentState.DISABLED_SELECTED); // color schemes for the active states SubstanceColorScheme blueControlsActiveBorder = colorSchemes .get("Magellan Blue Controls Active Border"); SubstanceColorScheme blueControlsDefaultBorder = colorSchemes .get("Magellan Blue Controls Default Border"); defaultColorSchemeBundle.registerColorScheme(blueControlsActiveBorder, ColorSchemeAssociationKind.BORDER, ComponentState .getActiveStates()); defaultColorSchemeBundle.registerColorScheme(blueControlsActiveBorder, ColorSchemeAssociationKind.BORDER, ComponentState.DISABLED_SELECTED); defaultColorSchemeBundle.registerColorScheme(blueControlsDefaultBorder, ColorSchemeAssociationKind.BORDER, ComponentState.DEFAULT, ComponentState.DISABLED_UNSELECTED); // color schemes for the pressed states SubstanceColorScheme blueControlsPressed = colorSchemes .get("Magellan Blue Controls Pressed"); SubstanceColorScheme blueControlsPressedBorder = colorSchemes .get("Magellan Blue Controls Pressed Border"); defaultColorSchemeBundle.registerColorScheme(blueControlsPressed, ColorSchemeAssociationKind.FILL, ComponentState.PRESSED_SELECTED, ComponentState.PRESSED_UNSELECTED); defaultColorSchemeBundle.registerColorScheme(blueControlsPressedBorder, ColorSchemeAssociationKind.BORDER, ComponentState.PRESSED_SELECTED, ComponentState.PRESSED_UNSELECTED); // color schemes for the rollover / armed states SubstanceColorScheme greenControls = colorSchemes .get("Magellan Green Controls"); SubstanceColorScheme greenControlsMark = colorSchemes .get("Magellan Green Controls Mark"); SubstanceColorScheme greenControlsBorder = colorSchemes .get("Magellan Green Controls Border"); defaultColorSchemeBundle.registerColorScheme(greenControls, ColorSchemeAssociationKind.FILL, ComponentState.ROLLOVER_SELECTED, ComponentState.ROLLOVER_UNSELECTED, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); defaultColorSchemeBundle.registerColorScheme(greenControlsMark, ColorSchemeAssociationKind.MARK, ComponentState.ROLLOVER_SELECTED, ComponentState.ROLLOVER_UNSELECTED, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); defaultColorSchemeBundle.registerColorScheme(greenControlsBorder, ColorSchemeAssociationKind.BORDER, ComponentState.ROLLOVER_SELECTED, ComponentState.ROLLOVER_UNSELECTED, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); // highlight alphas defaultColorSchemeBundle.registerHighlightColorScheme(greenControls, 0.7f, ComponentState.ROLLOVER_UNSELECTED); defaultColorSchemeBundle.registerHighlightColorScheme(greenControls, 0.8f, ComponentState.SELECTED); defaultColorSchemeBundle.registerHighlightColorScheme(greenControls, 0.95f, ComponentState.ROLLOVER_SELECTED); defaultColorSchemeBundle.registerHighlightColorScheme(greenControls, 1.0f, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); SubstanceColorScheme lightBlueBackground = colorSchemes .get("Magellan Light Blue Background"); this.registerDecorationAreaSchemeBundle(defaultColorSchemeBundle, lightBlueBackground, DecorationAreaType.NONE); SubstanceColorScheme mediumBlueBackground = colorSchemes .get("Magellan Medium Blue Background"); SubstanceColorScheme darkBlueBackground = colorSchemes .get("Magellan Dark Blue Background"); this.registerAsDecorationArea(mediumBlueBackground, DecorationAreaType.GENERAL, DecorationAreaType.TOOLBAR); this.registerAsDecorationArea(darkBlueBackground, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER); SubstanceColorScheme lightBlueControlsActive = colorSchemes .get("Magellan Light Blue Controls Active"); SubstanceColorScheme lightBlueControlsDefault = colorSchemes .get("Magellan Light Blue Controls Default"); SubstanceColorSchemeBundle footerColorSchemeBundle = new SubstanceColorSchemeBundle( lightBlueControlsActive, lightBlueControlsDefault, lightBlueControlsDefault); footerColorSchemeBundle.registerColorScheme(lightBlueControlsDefault, 0.5f, ComponentState.DISABLED_UNSELECTED); footerColorSchemeBundle.registerColorScheme(lightBlueControlsActive, 0.5f, ComponentState.DISABLED_SELECTED); SubstanceColorScheme lightBlueSeparator = colorSchemes .get("Magellan Light Blue Separator"); footerColorSchemeBundle.registerColorScheme(lightBlueSeparator, ColorSchemeAssociationKind.SEPARATOR); SubstanceColorScheme ultraLightBlueBackground = colorSchemes .get("Magellan Ultralight Blue Background"); this.registerDecorationAreaSchemeBundle(footerColorSchemeBundle, ultraLightBlueBackground, DecorationAreaType.FOOTER); // Add overlay painter to paint drop shadows along the bottom // edges of toolbars this.addOverlayPainter(BottomShadowOverlayPainter.getInstance(), DecorationAreaType.TOOLBAR); // add an overlay painter to paint a dark line along the bottom // edge of toolbars this.toolbarBottomLineOverlayPainter = new BottomLineOverlayPainter( new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { return scheme.getUltraDarkColor(); } }); this.addOverlayPainter(this.toolbarBottomLineOverlayPainter, DecorationAreaType.TOOLBAR); // add an overlay painter to paint a light line along the top // edge of toolbars this.toolbarTopLineOverlayPainter = new TopLineOverlayPainter( new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { Color fg = scheme.getForegroundColor(); return new Color(fg.getRed(), fg.getGreen(), fg .getBlue(), 40); } }); this.addOverlayPainter(this.toolbarTopLineOverlayPainter, DecorationAreaType.TOOLBAR); // add an overlay painter to paint a bezel line along the top // edge of footer this.footerTopBezelOverlayPainter = new TopBezelOverlayPainter( ColorSchemeSingleColorQuery.FOREGROUND, ColorSchemeSingleColorQuery.ULTRALIGHT); this.addOverlayPainter(this.footerTopBezelOverlayPainter, DecorationAreaType.FOOTER); this.selectedTabFadeStart = 1.0f; this.selectedTabFadeEnd = 1.0f; SubstanceBorderPainter outerBorderPainter = new FractionBasedBorderPainter( "Magellan Outer", new float[] { 0.0f, 0.5f, 1.0f }, new ColorSchemeSingleColorQuery[] { ColorSchemeSingleColorQuery.ULTRADARK, ColorSchemeSingleColorQuery.DARK, ColorSchemeSingleColorQuery.DARK }); SubstanceBorderPainter innerBorderPainter = new DelegateBorderPainter( "Magellan Inner", new ClassicBorderPainter(), 0xA0FFFFFF, 0x60FFFFFF, 0x40FFFFFF, new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.tint(0.5); } }); this.borderPainter = new CompositeBorderPainter("Magellan", outerBorderPainter, innerBorderPainter); this.gradientPainter = new FractionBasedFillPainter("Magellan", new float[] { 0.0f, 0.5f, 1.0f }, new ColorSchemeSingleColorQuery[] { ColorSchemeSingleColorQuery.EXTRALIGHT, ColorSchemeSingleColorQuery.LIGHT, ColorSchemeSingleColorQuery.MID }); this.highlightPainter = new ClassicHighlightPainter(); this.decorationPainter = new MatteDecorationPainter(); this.buttonShaper = new ClassicButtonShaper(); } } substance-5.3.orig/src/org/jvnet/substance/api/skin/SubstanceGeminiLookAndFeel.java0000644000175000017500000000464611246400772030417 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Gemini skin from * {@link GeminiSkin}. You can set this look-and-feel by: *
    *
  • * -Dswing.defaultlaf=org.jvnet.substance.api.skin.SubstanceGeminiLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.api.skin.SubstanceGeminiLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceGeminiLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 5.3 */ public class SubstanceGeminiLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Gemini look-and-feel. */ public SubstanceGeminiLookAndFeel() { super(new GeminiSkin()); } } substance-5.3.orig/src/org/jvnet/substance/api/skin/GeminiSkin.java0000644000175000017500000003170611250321614025315 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.skin; import java.awt.Color; import org.jvnet.substance.api.*; import org.jvnet.substance.api.painter.border.DelegateFractionBasedBorderPainter; import org.jvnet.substance.api.painter.border.FractionBasedBorderPainter; import org.jvnet.substance.api.painter.fill.FractionBasedFillPainter; import org.jvnet.substance.api.painter.overlay.*; import org.jvnet.substance.painter.border.*; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.decoration.MatteDecorationPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * Gemini skin. This class is part of officially supported API. * * @author Kirill Grouchnikov * @since version 5.3 */ public class GeminiSkin extends SubstanceSkin { /** * Display name for this skin. */ public static final String NAME = "Gemini"; /** * Overlay painter to paint a dark line along the bottom edge of the * menubar. */ private BottomLineOverlayPainter menuOverlayPainter; /** * Overlay painter to paint a light line along the top edge of the toolbars. */ private TopLineOverlayPainter toolbarOverlayPainter; /** * Overlay painter to paint a dark line along the bottom edge of the * toolbars. */ private BottomLineOverlayPainter toolbarBottomLineOverlayPainter; /** * Overlay painter to paint a bezel line along the top edge of the footer. */ private TopBezelOverlayPainter footerTopBezelOverlayPainter; /** * Creates a new Gemini skin. */ public GeminiSkin() { SubstanceSkin.ColorSchemes schemes = SubstanceSkin .getColorSchemes(GeminiSkin.class.getClassLoader().getResource( "org/jvnet/substance/api/skin/gemini.colorschemes")); SubstanceColorScheme grayScheme = schemes.get("Gemini Gray"); SubstanceColorScheme lightGrayScheme = schemes.get("Gemini Light Gray"); // use the same color scheme for active and default controls SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( grayScheme, grayScheme, lightGrayScheme); // highlight fill scheme + custom alpha for rollover unselected state SubstanceColorScheme highlightScheme = schemes.get("Gemini Highlight"); SubstanceColorScheme highlightBorderScheme = schemes .get("Gemini Highlight Border"); applyHighlightColorScheme(defaultSchemeBundle, highlightScheme, highlightBorderScheme); // borders, separators, marks SubstanceColorScheme grayBorderScheme = schemes .get("Gemini Gray Border"); SubstanceColorScheme lightGrayBorderScheme = schemes .get("Gemini Light Gray Border"); SubstanceColorScheme lightGraySeparatorScheme = schemes .get("Gemini Light Gray Separator"); defaultSchemeBundle.registerColorScheme(grayBorderScheme, ColorSchemeAssociationKind.BORDER); defaultSchemeBundle.registerColorScheme(lightGrayBorderScheme, ColorSchemeAssociationKind.BORDER, ComponentState.DISABLED_ACTIVE, ComponentState.DISABLED_SELECTED, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(lightGraySeparatorScheme, ColorSchemeAssociationKind.SEPARATOR); defaultSchemeBundle.registerColorScheme(grayScheme, ColorSchemeAssociationKind.MARK); defaultSchemeBundle.registerColorScheme(lightGrayScheme, 0.5f, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(grayScheme, 0.5f, ComponentState.DISABLED_SELECTED); SubstanceColorScheme whiteBackgroundScheme = schemes .get("Gemini White Background"); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, whiteBackgroundScheme, DecorationAreaType.NONE); // general color scheme bundle SubstanceColorSchemeBundle generalSchemeBundle = new SubstanceColorSchemeBundle( grayScheme, grayScheme, lightGrayScheme); generalSchemeBundle.registerColorScheme(grayScheme, ColorSchemeAssociationKind.MARK); generalSchemeBundle.registerColorScheme(grayBorderScheme, ColorSchemeAssociationKind.BORDER); applyHighlightColorScheme(generalSchemeBundle, highlightScheme, highlightBorderScheme); this.registerDecorationAreaSchemeBundle(generalSchemeBundle, grayScheme, DecorationAreaType.GENERAL, DecorationAreaType.FOOTER); // header color scheme bundle SubstanceColorScheme blackColorScheme = schemes.get("Gemini Black"); SubstanceColorSchemeBundle headerSchemeBundle = new SubstanceColorSchemeBundle( blackColorScheme, blackColorScheme, blackColorScheme); headerSchemeBundle.registerColorScheme(blackColorScheme, 0.5f, ComponentState.DISABLED_SELECTED, ComponentState.DISABLED_UNSELECTED); headerSchemeBundle.registerColorScheme(blackColorScheme, ColorSchemeAssociationKind.MARK); headerSchemeBundle.registerColorScheme(blackColorScheme, ColorSchemeAssociationKind.BORDER); applyHighlightColorScheme(headerSchemeBundle, highlightScheme, highlightBorderScheme); this.registerDecorationAreaSchemeBundle(headerSchemeBundle, blackColorScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER); // toolbar color scheme bundle SubstanceColorScheme darkBlueColorScheme = schemes .get("Gemini Dark Blue"); SubstanceColorScheme darkBlueBackgroundColorScheme = schemes .get("Gemini Dark Blue Background"); SubstanceColorSchemeBundle toolbarSchemeBundle = new SubstanceColorSchemeBundle( blackColorScheme, darkBlueColorScheme, darkBlueColorScheme); toolbarSchemeBundle.registerColorScheme(blackColorScheme, 0.5f, ComponentState.DISABLED_SELECTED); toolbarSchemeBundle.registerColorScheme(darkBlueColorScheme, 0.5f, ComponentState.DISABLED_UNSELECTED); toolbarSchemeBundle.registerColorScheme(darkBlueColorScheme, ColorSchemeAssociationKind.MARK); toolbarSchemeBundle.registerColorScheme(darkBlueColorScheme, ColorSchemeAssociationKind.BORDER); applyHighlightColorScheme(toolbarSchemeBundle, highlightScheme, darkBlueColorScheme); this.registerDecorationAreaSchemeBundle(toolbarSchemeBundle, darkBlueBackgroundColorScheme, DecorationAreaType.TOOLBAR); this.setSelectedTabFadeStart(0.15); this.setSelectedTabFadeEnd(0.25); // add an overlay painter to paint a bezel line along the top // edge of footer this.footerTopBezelOverlayPainter = new TopBezelOverlayPainter( ColorSchemeSingleColorQuery.DARK, ColorSchemeSingleColorQuery.ULTRALIGHT); this.addOverlayPainter(this.footerTopBezelOverlayPainter, DecorationAreaType.FOOTER); // add two overlay painters to create a bezel line between // menu bar and toolbars this.menuOverlayPainter = new BottomLineOverlayPainter( new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { return scheme.getUltraDarkColor().darker(); } }); this.toolbarOverlayPainter = new TopLineOverlayPainter( new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { Color fg = scheme.getForegroundColor(); return new Color(fg.getRed(), fg.getGreen(), fg .getBlue(), 32); } }); this.addOverlayPainter(this.menuOverlayPainter, DecorationAreaType.HEADER); this.addOverlayPainter(this.toolbarOverlayPainter, DecorationAreaType.TOOLBAR); // add overlay painter to paint drop shadows along the bottom // edges of toolbars this.addOverlayPainter(BottomShadowOverlayPainter.getInstance(), DecorationAreaType.TOOLBAR); // add overlay painter to paint a dark line along the bottom // edge of toolbars this.toolbarBottomLineOverlayPainter = new BottomLineOverlayPainter( ColorSchemeSingleColorQuery.ULTRADARK); this.addOverlayPainter(this.toolbarBottomLineOverlayPainter, DecorationAreaType.TOOLBAR); this.buttonShaper = new ClassicButtonShaper(); this.watermark = null; this.gradientPainter = new FractionBasedFillPainter("Gemini", new float[] { 0.0f, 0.5f, 1.0f }, new ColorSchemeSingleColorQuery[] { ColorSchemeSingleColorQuery.EXTRALIGHT, ColorSchemeSingleColorQuery.LIGHT, ColorSchemeSingleColorQuery.MID }); this.decorationPainter = new MatteDecorationPainter(); this.highlightPainter = new ClassicHighlightPainter(); FractionBasedBorderPainter outerBorderPainter = new FractionBasedBorderPainter( "Gemini Outer", new float[] { 0.0f, 0.5f, 1.0f }, new ColorSchemeSingleColorQuery[] { ColorSchemeSingleColorQuery.ULTRADARK, ColorSchemeSingleColorQuery.ULTRADARK, ColorSchemeSingleColorQuery.ULTRADARK }); SubstanceBorderPainter innerBorderPainter = new DelegateFractionBasedBorderPainter( "Gemini Inner", outerBorderPainter, new int[] { 0x60FFFFFF, 0x40FFFFFF, 0x20FFFFFF }, new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.tint(0.7f); } }); this.borderPainter = new CompositeBorderPainter("Gemini", outerBorderPainter, innerBorderPainter); this.highlightBorderPainter = new ClassicBorderPainter(); } /** * Applies the specified highlight schemes on the relevant parts of the * specified scheme bundle. * * @param schemeBundle * Scheme bundle. * @param highlightScheme * Highlight scheme. * @param highlightBorderScheme * Highlight border scheme. */ private static void applyHighlightColorScheme( SubstanceColorSchemeBundle schemeBundle, SubstanceColorScheme highlightScheme, SubstanceColorScheme highlightBorderScheme) { // specify custom alpha values for the highlights schemeBundle.registerHighlightColorScheme(highlightScheme, 0.75f, ComponentState.ROLLOVER_UNSELECTED); schemeBundle.registerHighlightColorScheme(highlightScheme, 0.9f, ComponentState.SELECTED); schemeBundle.registerHighlightColorScheme(highlightScheme, 1.0f, ComponentState.ROLLOVER_SELECTED); schemeBundle.registerHighlightColorScheme(highlightScheme, 1.0f, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); // use for borders on rollover controls schemeBundle.registerColorScheme(highlightBorderScheme, ColorSchemeAssociationKind.BORDER, ComponentState.ROLLOVER_ARMED, ComponentState.ROLLOVER_SELECTED, ComponentState.ROLLOVER_UNSELECTED); // use for fill of selected controls schemeBundle.registerColorScheme(highlightScheme, ColorSchemeAssociationKind.FILL, ComponentState.SELECTED, ComponentState.ROLLOVER_SELECTED); // use for borders of highlights schemeBundle.registerColorScheme(highlightScheme, ColorSchemeAssociationKind.HIGHLIGHT_BORDER, ComponentState .getActiveStates()); // use for text highlight schemeBundle.registerColorScheme(highlightScheme, ColorSchemeAssociationKind.TEXT_HIGHLIGHT, ComponentState.SELECTED, ComponentState.ROLLOVER_SELECTED); // use for armed controls schemeBundle.registerColorScheme(highlightScheme, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); } /* * (non-Javadoc) * * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName() */ public String getDisplayName() { return NAME; } } substance-5.3.orig/src/org/jvnet/substance/api/skin/SubstanceGraphiteAquaLookAndFeel.java0000644000175000017500000000474511246400102031545 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.skin; import org.jvnet.substance.SubstanceLookAndFeel; /** * Standalone look-and-feel that uses the Raven Graphite skin from * {@link GraphiteAquaSkin}. You can set this look-and-feel by: *
    *
  • -Dswing.defaultlaf=org.jvnet.substance.api.skin. * SubstanceGraphiteAquaLookAndFeel
  • *
  • UIManager.setLookAndFeel( * "org.jvnet.substance.api.skin.SubstanceGraphiteAquaLookAndFeel" );
  • *
  • UIManager.setLookAndFeel(new SubstanceGraphiteAquaLookAndFeel());
  • *
* * @author Kirill Grouchnikov * @since version 5.3 */ public class SubstanceGraphiteAquaLookAndFeel extends SubstanceLookAndFeel { /** * Creates a new Raven Graphite Aqua look-and-feel. */ public SubstanceGraphiteAquaLookAndFeel() { super(new GraphiteAquaSkin()); } } substance-5.3.orig/src/org/jvnet/substance/api/skin/gemini.colorschemes0000644000175000017500000000455311246414746026313 0ustar drazzibdrazzibGemini Dark Blue Background { kind=Light colorUltraLight=#3B4859 colorExtraLight=#3A475A colorLight=#324158 colorMid=#2E3A50 colorDark=#2C384E colorUltraDark=#28324B colorForeground=#CAD9D2 } Gemini White Background { kind=Light colorUltraLight=#EBF1F1 colorExtraLight=#D2E0E0 colorLight=#D3DEDE colorMid=#CFDEDE colorDark=#CCD8D8 colorUltraDark=#C9D6D6 colorForeground=#7B7B79 } Gemini Dark Blue { kind=Dark colorUltraLight=#424C67 colorExtraLight=#38445C colorLight=#2D3D4D colorMid=#212E41 colorDark=#1B2435 colorUltraDark=#121B22 colorForeground=#B3C3DC } Gemini Black { kind=Dark colorUltraLight=#17242C colorExtraLight=#162125 colorLight=#121C1E colorMid=#111B1D colorDark=#0D1313 colorUltraDark=#0C100F colorForeground=#C9C9CB } Gemini Gray { kind=Light colorUltraLight=#C7CFD1 colorExtraLight=#B6C1C2 colorLight=#B3BDB9 colorMid=#A6ADAC colorDark=#606B69 colorUltraDark=#485250 colorForeground=#000000 } Gemini Gray Border { kind=Dark colorUltraLight=#6E6D72 colorExtraLight=#6C6B70 colorLight=#6A696E colorMid=#585D60 colorDark=#575C5F colorUltraDark=#51595B colorForeground=#F8FFFF } Gemini Light Gray { kind=Light colorUltraLight=#E7ECF0 colorExtraLight=#E3EAF0 colorLight=#DFE8EF colorMid=#DBE4EB colorDark=#C5CED7 colorUltraDark=#AEB5BD colorForeground=#636B6E } Gemini Light Gray Border { kind=Light colorUltraLight=#939997 colorExtraLight=#8D928E colorLight=#8B908C colorMid=#858B87 colorDark=#828886 colorUltraDark=#7F8583 colorForeground=#050704 } Gemini Light Gray Separator { kind=Light colorUltraLight=#F5F9F9 colorExtraLight=#E6F1F2 colorLight=#DCE8EA colorMid=#B3C3BE colorDark=#A6B7B4 colorUltraDark=#9CA8AB colorForeground=#000000 } Gemini Highlight { kind=Light colorUltraLight=#FFEC97 colorExtraLight=#FFE86F colorLight=#FFE34F colorMid=#FFC73C colorDark=#F2A926 colorUltraDark=#E29E0B colorForeground=#70430B } Gemini Highlight Border { kind=Light colorUltraLight=#FFE769 colorExtraLight=#FFE454 colorLight=#FFDF4C colorMid=#FFD747 colorDark=#FCB326 colorUltraDark=#FDA607 colorForeground=#70430B } substance-5.3.orig/src/org/jvnet/substance/api/skin/magellan.colorschemes0000644000175000017500000001100611246134646026610 0ustar drazzibdrazzibMagellan Dark Blue Background { kind=Dark colorUltraLight=#063162 colorExtraLight=#063263 colorLight=#063263 colorMid=#063263 colorDark=#031E42 colorUltraDark=#031A3B colorForeground=#DADADA } Magellan Medium Blue Background { kind=Dark colorUltraLight=#0F5AAF colorExtraLight=#0F58AA colorLight=#0D519E colorMid=#0A478D colorDark=#083D7A colorUltraDark=#053163 colorForeground=#EBEBEB } Magellan Light Blue Background { kind=Light colorUltraLight=#0C5AB0 colorExtraLight=#0C5AB0 colorLight=#0C5AB0 colorMid=#0C5AB1 colorDark=#0C5AB0 colorUltraDark=#0C5AB1 colorForeground=#021C3A } Magellan Ultralight Blue Background { kind=Light colorUltraLight=#B2D6FF colorExtraLight=#AFD4FE colorLight=#AAD1FE colorMid=#A7CFFD colorDark=#A0CBFB colorUltraDark=#9DC9FB colorForeground=#003269 } Magellan Blue Controls Default { kind=Dark colorUltraLight=#0C61AC colorExtraLight=#0B60AA colorLight=#064E92 colorMid=#003977 colorDark=#003977 colorUltraDark=#003977 colorForeground=#8FC1F9 } Magellan Blue Controls Default Border { kind=Dark colorUltraLight=#0B498F colorExtraLight=#0A4487 colorLight=#093F7D colorMid=#083C77 colorDark=#06284D colorUltraDark=#042040 colorForeground=#FFFFFF } Magellan Blue Controls Pressed { kind=Dark colorUltraLight=#033568 colorExtraLight=#033568 colorLight=#053B6E colorMid=#084275 colorDark=#084275 colorUltraDark=#084275 colorForeground=#8FC1F9 } Magellan Blue Controls Pressed Border { kind=Dark colorUltraLight=#062547 colorExtraLight=#062241 colorLight=#062547 colorMid=#062547 colorDark=#042244 colorUltraDark=#042040 colorForeground=#FFFFFF } Magellan Blue Controls Active { kind=Dark colorUltraLight=#1074E4 colorExtraLight=#1072DF colorLight=#0F6FD8 colorMid=#0E67CA colorDark=#0D5FBB colorUltraDark=#0C5AB0 colorForeground=#021C3A } Magellan Blue Controls Active Border { kind=Dark colorUltraLight=#074A8C colorExtraLight=#074787 colorLight=#094480 colorMid=#0C457A colorDark=#093F75 colorUltraDark=#0C3E70 colorForeground=#B7D8FC } Magellan Light Blue Controls Active { kind=Light colorUltraLight=#438EE9 colorExtraLight=#428CE5 colorLight=#4189E0 colorMid=#3F83D4 colorDark=#3C7BC8 colorUltraDark=#3A77C0 colorForeground=#021C3A } Magellan Light Blue Controls Default { kind=Light colorUltraLight=#5B88BF colorExtraLight=#5B87BD colorLight=#5A85BA colorMid=#5982B2 colorDark=#577DAB colorUltraDark=#567BA6 colorForeground=#1B3048 } Magellan Green Controls { kind=Light colorUltraLight=#63CA15 colorExtraLight=#63CA15 colorLight=#5BBD12 colorMid=#51AC0D colorDark=#40750B colorUltraDark=#335E0D colorForeground=#143000 } Magellan Green Controls Mark { kind=Light colorUltraLight=#5FB315 colorExtraLight=#57A314 colorLight=#509C13 colorMid=#44870C colorDark=#1F3806 colorUltraDark=#1B3008 colorForeground=#0D1C00 } Magellan Green Controls Border { kind=Dark colorUltraLight=#1E4600 colorExtraLight=#1E4600 colorLight=#1E4600 colorMid=#1E4600 colorDark=#1E4600 colorUltraDark=#1E4600 colorForeground=#3E7A0D } Magellan Light Green Controls { kind=Light colorUltraLight=#DDFF66 colorExtraLight=#DDFF66 colorLight=#C6E857 colorMid=#9FC23E colorDark=#809630 colorUltraDark=#5D7023 colorForeground=#333333 } Magellan Light Green Controls Border { kind=Light colorUltraLight=#DDFF66 colorExtraLight=#DDFF66 colorLight=#DDFF66 colorMid=#DDFF66 colorDark=#DDFF66 colorUltraDark=#DDFF66 colorForeground=#333333 } Magellan Ochre Controls { kind=Light colorUltraLight=#FEC66F colorExtraLight=#FEC66F colorLight=#FCA445 colorMid=#DD8932 colorDark=#DD8932 colorUltraDark=#DD8932 colorForeground=#010100 } Magellan Ochre Controls Border { kind=Light colorUltraLight=#9A835F colorExtraLight=#9A835F colorLight=#9A835F colorMid=#998058 colorDark=#A1875A colorUltraDark=#A1875A colorForeground=#000000 } Magellan Light Blue Separator { kind=Light colorUltraLight=#B0EFFF colorExtraLight=#A8D0FD colorLight=#A5CEFC colorMid=#7197C2 colorDark=#7197C2 colorUltraDark=#7197C2 colorForeground=#003269 } substance-5.3.orig/src/org/jvnet/substance/api/painter/0000755000175000017500000000000011256731146023117 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/api/painter/border/0000755000175000017500000000000011256731146024374 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/api/painter/border/FractionBasedBorderPainter.java0000644000175000017500000001247311247126010032417 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.painter.border; import java.awt.*; import java.awt.MultipleGradientPaint.CycleMethod; import org.jvnet.substance.api.ColorSchemeSingleColorQuery; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.painter.FractionBasedPainter; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.utils.*; /** * Border painter with fraction-based stops and a color query associated with * each stop. This class allows creating multi-gradient borders with exact * control over which color is used at every gradient control point. * * @author Kirill Grouchnikov */ public class FractionBasedBorderPainter extends FractionBasedPainter implements SubstanceBorderPainter { /** * Creates a new fraction-based border painter. * * @param displayName * The display name of this painter. * @param fractions * The fractions of this painter. Must be strictly increasing, * starting from 0.0 and ending at 1.0. * @param colorQueries * The color queries of this painter. Must have the same size as * the fractions array, and all entries must be non- * null. */ public FractionBasedBorderPainter(String displayName, float[] fractions, ColorSchemeSingleColorQuery[] colorQueries) { super(displayName, fractions, colorQueries); } @Override public void paintBorder(Graphics g, Component c, int width, int height, Shape contour, Shape innerContour, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos, boolean useCyclePosAsInterpolation) { Graphics2D graphics = (Graphics2D) g.create(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); SubstanceColorScheme interpolationScheme1 = colorScheme1; SubstanceColorScheme interpolationScheme2 = useCyclePosAsInterpolation ? colorScheme2 : colorScheme1; double cycleCoef = 1.0 - cyclePos; Color[] fillColors = new Color[this.fractions.length]; for (int i = 0; i < this.fractions.length; i++) { ColorSchemeSingleColorQuery colorQuery = this.colorQueries[i]; Color color1 = colorQuery.query(interpolationScheme1); Color color2 = colorQuery.query(interpolationScheme2); if (!useCyclePosAsInterpolation) { fillColors[i] = color1; } else { fillColors[i] = SubstanceColorUtilities.getInterpolatedColor( color1, color2, cycleCoef); } } // System.out.println("\t" + interpolationScheme1.getDisplayName() // + " -> [" + cyclePos + "] " // + interpolationScheme2.getDisplayName()); float strokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(c)); // issue 433 - the "c" can be null when painting // the border of a tree icon used outside the // JTree context. boolean isSpecialButton = (c == null) ? false : c.getClass() .isAnnotationPresent(SubstanceArrowButton.class); int joinKind = isSpecialButton ? BasicStroke.JOIN_MITER : BasicStroke.JOIN_ROUND; int capKind = isSpecialButton ? BasicStroke.CAP_SQUARE : BasicStroke.CAP_BUTT; graphics.setStroke(new BasicStroke(strokeWidth, capKind, joinKind)); MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0, height, this.fractions, fillColors, CycleMethod.REPEAT); graphics.setPaint(gradient); graphics.draw(contour); graphics.dispose(); } @Override public boolean isPaintingInnerContour() { return false; } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsubstance-5.3.orig/src/org/jvnet/substance/api/painter/border/DelegateFractionBasedBorderPainter.javasubstance-5.3.orig/src/org/jvnet/substance/api/painter/border/DelegateFractionBasedBorderPainter.jav0000644000175000017500000001564011247042510033712 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.painter.border; import java.awt.*; import java.awt.MultipleGradientPaint.CycleMethod; import org.jvnet.substance.api.*; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.utils.*; /** * Delegate border painter that allows tweaking the visual appearance of * borders. * * @author Kirill Grouchnikov */ public class DelegateFractionBasedBorderPainter implements SubstanceBorderPainter { /** * Display name of this border painter. */ protected String displayName; /** * The delegate border painter. */ protected FractionBasedBorderPainter delegate; /** * 8-digit hexadecimal masks applied on the colors painted by * {@link #delegate}. Can be used to apply custom translucency. For example, * value 0x80FFFFFF will result in 50% translucency of the original border * color. */ protected int[] masks; /** * Transformation to be applied on the color schemes prior to compute the * colors to be used for border painting. */ protected ColorSchemeTransform transform; /** * Creates a new delegate border painter * * @param displayName * Display name of this border painter. * @param delegate * The delegate border painter. * @param masks * Array of 8-digit hexadecimal masks applied on the relevant * colors painted by the delegate. * @param transform * Transformation to be applied on the color schemes prior to * compute the colors to be used for border painting. */ public DelegateFractionBasedBorderPainter(String displayName, FractionBasedBorderPainter delegate, int[] masks, ColorSchemeTransform transform) { this.displayName = displayName; this.delegate = delegate; this.masks = new int[masks.length]; System.arraycopy(masks, 0, this.masks, 0, masks.length); this.transform = transform; } /** * Map of transformed color schemes (to speed up the subsequent lookups). */ protected final static LazyResettableHashMap transformMap = new LazyResettableHashMap( "DelegateBorderPainter"); @Override public boolean isPaintingInnerContour() { return false; } @Override public void paintBorder(Graphics g, Component c, int width, int height, Shape contour, Shape innerContour, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos, boolean useCyclePosAsInterpolation) { Graphics2D graphics = (Graphics2D) g.create(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); SubstanceColorScheme interpolationScheme1 = colorScheme1; SubstanceColorScheme interpolationScheme2 = useCyclePosAsInterpolation ? colorScheme2 : colorScheme1; // shift schemes interpolationScheme1 = getShiftScheme(interpolationScheme1); interpolationScheme2 = getShiftScheme(interpolationScheme2); double cycleCoef = 1.0 - cyclePos; float[] fractions = delegate.getFractions(); ColorSchemeSingleColorQuery[] colorQueries = delegate.getColorQueries(); Color[] fillColors = new Color[fractions.length]; for (int i = 0; i < fractions.length; i++) { ColorSchemeSingleColorQuery colorQuery = colorQueries[i]; Color color1 = colorQuery.query(interpolationScheme1); Color color2 = colorQuery.query(interpolationScheme2); // apply masks color1 = new Color(this.masks[i] & color1.getRGB(), true); color2 = new Color(this.masks[i] & color2.getRGB(), true); // and interpolate if (!useCyclePosAsInterpolation) { fillColors[i] = color1; } else { fillColors[i] = SubstanceColorUtilities.getInterpolatedColor( color1, color2, cycleCoef); } } float strokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(c)); // issue 433 - the "c" can be null when painting // the border of a tree icon used outside the // JTree context. boolean isSpecialButton = (c == null) ? false : c.getClass() .isAnnotationPresent(SubstanceArrowButton.class); int joinKind = isSpecialButton ? BasicStroke.JOIN_MITER : BasicStroke.JOIN_ROUND; int capKind = isSpecialButton ? BasicStroke.CAP_SQUARE : BasicStroke.CAP_BUTT; graphics.setStroke(new BasicStroke(strokeWidth, capKind, joinKind)); MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0, height, fractions, fillColors, CycleMethod.REPEAT); graphics.setPaint(gradient); graphics.draw(contour); graphics.dispose(); } @Override public String getDisplayName() { return this.displayName; } /** * Retrieves a transformed color scheme. * * @param orig * Original color scheme. * @return Transformed color scheme. */ private SubstanceColorScheme getShiftScheme(SubstanceColorScheme orig) { HashMapKey key = SubstanceCoreUtilities.getHashKey(orig .getDisplayName(), this.getDisplayName(), this.transform); if (!transformMap.containsKey(key)) { transformMap.put(key, this.transform.transform(orig)); } return transformMap.get(key); } } substance-5.3.orig/src/org/jvnet/substance/api/painter/decoration/0000755000175000017500000000000011256731146025246 5ustar drazzibdrazzib././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsubstance-5.3.orig/src/org/jvnet/substance/api/painter/decoration/FractionBasedDecorationPainter.javasubstance-5.3.orig/src/org/jvnet/substance/api/painter/decoration/FractionBasedDecorationPainter.jav0000644000175000017500000001250511247060030033775 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.painter.decoration; import java.awt.*; import java.awt.MultipleGradientPaint.CycleMethod; import org.jvnet.substance.api.*; import org.jvnet.substance.api.painter.FractionBasedPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.decoration.SubstanceDecorationPainter; import org.jvnet.substance.utils.SubstanceCoreUtilities; /** * Decoration painter with fraction-based stops and a color query associated * with each stop. This class allows creating multi-gradient decorations with * exact control over which color is used at every gradient control point. * * @author Kirill Grouchnikov */ public class FractionBasedDecorationPainter extends FractionBasedPainter implements SubstanceDecorationPainter { /** * Creates a new fraction-based decoration painter. * * @param displayName * The display name of this painter. * @param fractions * The fractions of this painter. Must be strictly increasing, * starting from 0.0 and ending at 1.0. * @param colorQueries * The color queries of this painter. Must have the same size as * the fractions array, and all entries must be non- * null. */ public FractionBasedDecorationPainter(String displayName, float[] fractions, ColorSchemeSingleColorQuery[] colorQueries) { super(displayName, fractions, colorQueries); } @Override public void paintDecorationArea(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { switch (decorationAreaType) { case PRIMARY_TITLE_PANE: case SECONDARY_TITLE_PANE: this.paintTitleBackground(graphics, comp, width, height, skin .getBackgroundColorScheme(decorationAreaType)); break; default: this.paintExtraBackground(graphics, SubstanceCoreUtilities .getHeaderParent(comp), comp, width, height, skin .getBackgroundColorScheme(decorationAreaType)); } } /** * Paints the title background. * * @param graphics * Graphics context. * @param comp * Component. * @param width * Width. * @param height * Height. * @param scheme * Color scheme for painting the title background. */ private void paintTitleBackground(Graphics2D graphics, Component comp, int width, int height, SubstanceColorScheme scheme) { Graphics2D g2d = (Graphics2D) graphics.create(); Color[] fillColors = new Color[this.fractions.length]; for (int i = 0; i < this.fractions.length; i++) { ColorSchemeSingleColorQuery colorQuery = this.colorQueries[i]; fillColors[i] = colorQuery.query(scheme); } MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0, height, this.fractions, fillColors, CycleMethod.REPEAT); g2d.setPaint(gradient); g2d.fillRect(0, 0, width, height); g2d.dispose(); } /** * Paints the background of non-title decoration areas. * * @param graphics * Graphics context. * @param parent * Component ancestor for computing the correct offset of the * background painting. * @param comp * Component. * @param width * Width. * @param height * Height. * @param scheme * Color scheme for painting the title background. */ private void paintExtraBackground(Graphics2D graphics, Container parent, Component comp, int width, int height, SubstanceColorScheme scheme) { graphics.setColor(scheme.getMidColor()); graphics.fillRect(0, 0, width, height); } } substance-5.3.orig/src/org/jvnet/substance/api/painter/FractionBasedPainter.java0000644000175000017500000001307011247043254030006 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.painter; import org.jvnet.substance.api.ColorSchemeSingleColorQuery; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.trait.SubstanceTrait; /** * Base painter with fraction-based stops and a color query associated with each * stop. This class allows creating multi-stop gradients with exact control over * which color is used at every gradient control point. * * @author Kirill Grouchnikov */ public abstract class FractionBasedPainter implements SubstanceTrait { /** * The display name of this painter. */ private String displayName; /** * The fractions of this painter. If the constructor has not thrown an * {@link IllegalArgumentException}, the entries in this array are strictly * increasing, starting from 0.0 and ending at 1.0. */ protected float[] fractions; /** * The color queries of this painter. Each entry in this array corresponds * to the matching index in the {@link #fractions}, specifying which color * will be used at the relevant gradient control point. If the constructor * has not thrown an {@link IllegalArgumentException}, the size of this * array is identical to the size of {@link #fractions}, and there are no * null entries in this array. Note that the application code * can still cause an exception at runtime by throwing it in the * implementation of the * {@link ColorSchemeSingleColorQuery#query(SubstanceColorScheme)} method. */ protected ColorSchemeSingleColorQuery[] colorQueries; /** * Creates a new fraction-based border painter. * * @param displayName * The display name of this painter. * @param fractions * The fractions of this painter. Must be strictly increasing, * starting from 0.0 and ending at 1.0. * @param colorQueries * The color queries of this painter. Must have the same size as * the fractions array, and all entries must be non- * null. */ public FractionBasedPainter(String displayName, float[] fractions, ColorSchemeSingleColorQuery[] colorQueries) { this.displayName = displayName; if ((fractions == null) || (colorQueries == null)) { throw new IllegalArgumentException("Cannot pass null arguments"); } if (fractions.length != colorQueries.length) { throw new IllegalArgumentException("Argument length does not match"); } int length = fractions.length; if ((fractions[0] != 0.0f) || (fractions[length - 1] != 1.0f)) { throw new IllegalArgumentException( "End fractions must be 0.0 and 1.0"); } for (int i = 0; i < length - 1; i++) { if (fractions[i + 1] <= fractions[i]) { throw new IllegalArgumentException( "Fractions must be strictly increasing"); } } for (int i = 0; i < length; i++) { if (colorQueries[i] == null) { throw new IllegalArgumentException("Cannot pass null query"); } } this.colorQueries = new ColorSchemeSingleColorQuery[length]; System.arraycopy(colorQueries, 0, this.colorQueries, 0, length); this.fractions = new float[length]; System.arraycopy(fractions, 0, this.fractions, 0, length); } @Override public String getDisplayName() { return this.displayName; } /** * Returns the fractions of this painter. * * @return Fractions of this painter. */ public float[] getFractions() { float[] result = new float[this.fractions.length]; System.arraycopy(this.fractions, 0, result, 0, this.fractions.length); return result; } /** * Returns the color queries of this painter. * * @return Color queries of this painter. */ public ColorSchemeSingleColorQuery[] getColorQueries() { ColorSchemeSingleColorQuery[] result = new ColorSchemeSingleColorQuery[this.colorQueries.length]; System.arraycopy(this.colorQueries, 0, result, 0, this.colorQueries.length); return result; } } substance-5.3.orig/src/org/jvnet/substance/api/painter/overlay/0000755000175000017500000000000011256731146024600 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/api/painter/overlay/TopLineOverlayPainter.java0000644000175000017500000000775111246440610031704 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.painter.overlay; import java.awt.*; import javax.swing.SwingUtilities; import org.jvnet.substance.api.*; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.utils.DecorationPainterUtils; import org.jvnet.substance.utils.SubstanceSizeUtils; /** * Overlay painter that paints a single line at the bottom edge of the relevant * decoration area. This class is part of officially supported API. * * @author Kirill Grouchnikov * @since version 5.3 */ public final class TopLineOverlayPainter implements SubstanceOverlayPainter { /** * Used to compute the color of the line painted by this overlay painter. */ ColorSchemeSingleColorQuery colorSchemeQuery; /** * Creates a new overlay painter that paints a single line at the top edge * of the relevant decoration area * * @param colorSchemeQuery * Used to compute the color of the line painted by this overlay * painter. */ public TopLineOverlayPainter(ColorSchemeSingleColorQuery colorSchemeQuery) { this.colorSchemeQuery = colorSchemeQuery; } @Override public void paintOverlay(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { Component c = comp; Component topMostWithSameDecorationAreaType = c; while (c != null) { if (DecorationPainterUtils.getImmediateDecorationType(c) == decorationAreaType) { topMostWithSameDecorationAreaType = c; } c = c.getParent(); } Point inTopMost = SwingUtilities.convertPoint(comp, new Point(0, 0), topMostWithSameDecorationAreaType); int dy = inTopMost.y; int fontSize = SubstanceSizeUtils.getComponentFontSize(comp); float borderStrokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(fontSize); graphics.setStroke(new BasicStroke(borderStrokeWidth)); SubstanceColorScheme colorScheme = skin .getBackgroundColorScheme(decorationAreaType); // skin.getColorScheme(comp, // ColorSchemeAssociationKind.SEPARATOR, ComponentState.DEFAULT); graphics.setColor(this.colorSchemeQuery.query(colorScheme)); graphics.drawLine(0, (int) borderStrokeWidth - dy - 1, width, (int) borderStrokeWidth - dy - 1); } @Override public String getDisplayName() { return "Top Line"; } } substance-5.3.orig/src/org/jvnet/substance/api/painter/overlay/BottomShadowOverlayPainter.java0000644000175000017500000001020211245213666032735 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.painter.overlay; import java.awt.*; import javax.swing.SwingUtilities; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.utils.DecorationPainterUtils; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Overlay painter that paints a few pixel-high drop shadow at the bottom edge * of the relevant decoration area. This class is part of officially supported * API. * * @author Kirill Grouchnikov * @since version 5.3 */ public final class BottomShadowOverlayPainter implements SubstanceOverlayPainter { /** * Singleton instance. */ private static BottomShadowOverlayPainter INSTANCE; /** * Returns the single instance of this class. * * @return Single instance of this class. */ public synchronized static BottomShadowOverlayPainter getInstance() { if (INSTANCE == null) INSTANCE = new BottomShadowOverlayPainter(); return INSTANCE; } /** * Private constructor to enforce that {@link #getInstance()} is the only * way an application can get an instance of this class. */ private BottomShadowOverlayPainter() { } @Override public void paintOverlay(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { Color shadowColor = SubstanceColorUtilities .getBackgroundFillColor(comp).darker(); Component c = comp; Component topMostWithSameDecorationAreaType = c; while (c != null) { if (DecorationPainterUtils.getImmediateDecorationType(c) == decorationAreaType) { topMostWithSameDecorationAreaType = c; } c = c.getParent(); } int topHeight = topMostWithSameDecorationAreaType.getHeight(); Point inTopMost = SwingUtilities.convertPoint(comp, new Point(0, 0), topMostWithSameDecorationAreaType); int dy = inTopMost.y; Graphics2D fillGraphics = (Graphics2D) graphics.create(); fillGraphics.translate(0, -dy); int shadowHeight = 4; GradientPaint fillPaint = new GradientPaint(0, topHeight - shadowHeight, SubstanceColorUtilities .getAlphaColor(shadowColor, 0), 0, topHeight, SubstanceColorUtilities.getAlphaColor(shadowColor, 128)); fillGraphics.setPaint(fillPaint); fillGraphics.fillRect(0, topHeight - shadowHeight, width, shadowHeight); fillGraphics.dispose(); } @Override public String getDisplayName() { return "Bottom Shadow"; } } substance-5.3.orig/src/org/jvnet/substance/api/painter/overlay/BottomLineOverlayPainter.java0000644000175000017500000001007611246440572032407 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.painter.overlay; import java.awt.*; import org.jvnet.substance.api.*; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.utils.DecorationPainterUtils; import org.jvnet.substance.utils.SubstanceSizeUtils; /** * Overlay painter that paints a single line at the bottom edge of the relevant * decoration area. This class is part of officially supported API. * * @author Kirill Grouchnikov * @since version 5.3 */ public final class BottomLineOverlayPainter implements SubstanceOverlayPainter { /** * Used to compute the color of the line painted by this overlay painter. */ ColorSchemeSingleColorQuery colorSchemeQuery; /** * Creates a new overlay painter that paints a single line at the bottom * edge of the relevant decoration area * * @param colorSchemeQuery * Used to compute the color of the line painted by this overlay * painter. */ public BottomLineOverlayPainter(ColorSchemeSingleColorQuery colorSchemeQuery) { this.colorSchemeQuery = colorSchemeQuery; } @Override public void paintOverlay(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { Component c = comp; Component topMostWithSameDecorationAreaType = c; while (c != null) { if (DecorationPainterUtils.getImmediateDecorationType(c) == decorationAreaType) { topMostWithSameDecorationAreaType = c; } c = c.getParent(); } // Point inTopMost = SwingUtilities.convertPoint(comp, new Point(0, 0), // topMostWithSameDecorationAreaType); // int dy = inTopMost.y; int fontSize = SubstanceSizeUtils.getComponentFontSize(comp); float borderStrokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(fontSize); graphics.setStroke(new BasicStroke(borderStrokeWidth)); SubstanceColorScheme colorScheme = // skin.getColorScheme(comp, // ColorSchemeAssociationKind.SEPARATOR, ComponentState.DEFAULT); // colorScheme = skin.getBackgroundColorScheme(decorationAreaType); graphics.setColor(this.colorSchemeQuery.query(colorScheme)); graphics.drawLine(0, topMostWithSameDecorationAreaType.getHeight() - (int) borderStrokeWidth, width, topMostWithSameDecorationAreaType.getHeight() - (int) borderStrokeWidth); } @Override public String getDisplayName() { return "Bottom Line"; } } substance-5.3.orig/src/org/jvnet/substance/api/painter/overlay/TopBezelOverlayPainter.java0000644000175000017500000001115511246440622032052 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.painter.overlay; import java.awt.*; import javax.swing.SwingUtilities; import org.jvnet.substance.api.*; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.utils.DecorationPainterUtils; import org.jvnet.substance.utils.SubstanceSizeUtils; /** * Overlay painter that paints a bezel line at the top edge of the relevant * decoration area. This class is part of officially supported API. * * @author Kirill Grouchnikov * @since version 5.3 */ public final class TopBezelOverlayPainter implements SubstanceOverlayPainter { /** * Used to compute the color of the top line painted by this overlay * painter. */ ColorSchemeSingleColorQuery colorSchemeQueryTop; /** * Used to compute the color of the bottom line painted by this overlay * painter. */ ColorSchemeSingleColorQuery colorSchemeQueryBottom; /** * Creates a new overlay painter that paints a bezel line at the top edge of * the relevant decoration area * * @param colorSchemeQueryTop * Used to compute the color of the top line painted by this * overlay painter. * @param colorSchemeQueryBottom * Used to compute the color of the top line painted by this * overlay painter. */ public TopBezelOverlayPainter( ColorSchemeSingleColorQuery colorSchemeQueryTop, ColorSchemeSingleColorQuery colorSchemeQueryBottom) { this.colorSchemeQueryTop = colorSchemeQueryTop; this.colorSchemeQueryBottom = colorSchemeQueryBottom; } @Override public void paintOverlay(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { Component c = comp; Component topMostWithSameDecorationAreaType = c; while (c != null) { if (DecorationPainterUtils.getImmediateDecorationType(c) == decorationAreaType) { topMostWithSameDecorationAreaType = c; } c = c.getParent(); } Point inTopMost = SwingUtilities.convertPoint(comp, new Point(0, 0), topMostWithSameDecorationAreaType); int dy = inTopMost.y; int fontSize = SubstanceSizeUtils.getComponentFontSize(comp); float borderStrokeWidth = SubstanceSizeUtils .getBorderStrokeWidth(fontSize); graphics.setStroke(new BasicStroke(borderStrokeWidth)); SubstanceColorScheme colorScheme = skin .getBackgroundColorScheme(decorationAreaType); // skin.getColorScheme(comp, // ColorSchemeAssociationKind.SEPARATOR, ComponentState.DEFAULT); graphics.setColor(this.colorSchemeQueryTop.query(colorScheme)); graphics.drawLine(0, (int) (borderStrokeWidth) - dy - 1, width, (int) (borderStrokeWidth) - dy - 1); graphics.setColor(this.colorSchemeQueryBottom.query(colorScheme)); graphics.drawLine(0, (int) (2 * borderStrokeWidth) - dy - 1, width, (int) (2 * borderStrokeWidth) - dy - 1); } @Override public String getDisplayName() { return "Top Line Shadow"; } } substance-5.3.orig/src/org/jvnet/substance/api/painter/overlay/TopShadowOverlayPainter.java0000644000175000017500000000766511245213640032246 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.painter.overlay; import java.awt.*; import javax.swing.SwingUtilities; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.utils.DecorationPainterUtils; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Overlay painter that paints a few pixel-high drop shadow at the top edge of * the relevant decoration area. This class is part of officially supported API. * * @author Kirill Grouchnikov * @since version 5.3 */ public final class TopShadowOverlayPainter implements SubstanceOverlayPainter { /** * Singleton instance. */ private static TopShadowOverlayPainter INSTANCE; /** * Returns the single instance of this class. * * @return Single instance of this class. */ public synchronized static TopShadowOverlayPainter getInstance() { if (INSTANCE == null) INSTANCE = new TopShadowOverlayPainter(); return INSTANCE; } /** * Private constructor to enforce that {@link #getInstance()} is the only * way an application can get an instance of this class. */ private TopShadowOverlayPainter() { } @Override public void paintOverlay(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin) { Color shadowColor = SubstanceColorUtilities .getBackgroundFillColor(comp).darker(); // need to handle components "embedded" in other components Component c = comp; Component topMostWithSameDecorationAreaType = c; while (c != null) { if (DecorationPainterUtils.getImmediateDecorationType(c) == decorationAreaType) { topMostWithSameDecorationAreaType = c; } c = c.getParent(); } Point inTopMost = SwingUtilities.convertPoint(comp, new Point(0, 0), topMostWithSameDecorationAreaType); int dy = inTopMost.y; Graphics2D g2d = (Graphics2D) graphics.create(); g2d.translate(0, -dy); g2d.setPaint(new GradientPaint(0, 0, SubstanceColorUtilities .getAlphaColor(shadowColor, 160), 0, 4, SubstanceColorUtilities .getAlphaColor(shadowColor, 16))); g2d.fillRect(0, 0, comp.getWidth(), 4); g2d.dispose(); } @Override public String getDisplayName() { return "Top Shadow"; } } substance-5.3.orig/src/org/jvnet/substance/api/painter/overlay/SubstanceOverlayPainter.java0000644000175000017500000000530511245213540032251 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.painter.overlay; import java.awt.Component; import java.awt.Graphics2D; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.api.trait.SubstanceTrait; import org.jvnet.substance.painter.decoration.DecorationAreaType; /** * Overlay painter interface for Substance look and feel. This class is * part of officially supported API. * * @author Kirill Grouchnikov * @since version 5.3 */ public interface SubstanceOverlayPainter extends SubstanceTrait { /** * Paints the overlay. * * @param graphics * Graphics context. * @param comp * Component. * @param decorationAreaType * Decoration area type. Must not be null. * @param width * Width. * @param height * Height. * @param skin * Skin for painting the overlay. */ public void paintOverlay(Graphics2D graphics, Component comp, DecorationAreaType decorationAreaType, int width, int height, SubstanceSkin skin); } substance-5.3.orig/src/org/jvnet/substance/api/painter/highlight/0000755000175000017500000000000011256731146025066 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/api/painter/highlight/FractionBasedHighlightPainter.java0000644000175000017500000001061511247060006033601 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.painter.highlight; import java.awt.*; import java.awt.MultipleGradientPaint.CycleMethod; import java.util.Set; import org.jvnet.substance.api.ColorSchemeSingleColorQuery; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.SubstanceConstants.Side; import org.jvnet.substance.api.painter.FractionBasedPainter; import org.jvnet.substance.painter.highlight.SubstanceHighlightPainter; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Highlight painter with fraction-based stops and a color query associated with * each stop. This class allows creating multi-gradient highlights with exact * control over which color is used at every gradient control point. * * @author Kirill Grouchnikov */ public class FractionBasedHighlightPainter extends FractionBasedPainter implements SubstanceHighlightPainter { /** * Creates a new fraction-based highlight painter. * * @param displayName * The display name of this painter. * @param fractions * The fractions of this painter. Must be strictly increasing, * starting from 0.0 and ending at 1.0. * @param colorQueries * The color queries of this painter. Must have the same size as * the fractions array, and all entries must be non- * null. */ public FractionBasedHighlightPainter(String displayName, float[] fractions, ColorSchemeSingleColorQuery[] colorQueries) { super(displayName, fractions, colorQueries); } /* * (non-Javadoc) * * @see org.jvnet.substance.painter.highlight.SubstanceHighlightPainter# * paintHighlight(java.awt.Graphics2D, java.awt.Component, int, int, * java.util.Set, org.jvnet.substance.api.SubstanceColorScheme, * org.jvnet.substance.api.SubstanceColorScheme, float) */ @Override public void paintHighlight(Graphics2D graphics, Component comp, int width, int height, Set openSides, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos) { Graphics2D g2d = (Graphics2D) graphics.create(); double cycleCoef = 1.0 - cyclePos; Color[] fillColors = new Color[this.fractions.length]; for (int i = 0; i < this.fractions.length; i++) { ColorSchemeSingleColorQuery colorQuery = this.colorQueries[i]; Color color1 = colorQuery.query(colorScheme1); Color color2 = colorQuery.query(colorScheme2); fillColors[i] = SubstanceColorUtilities.getInterpolatedColor( color1, color2, cycleCoef); } MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0, height, this.fractions, fillColors, CycleMethod.REPEAT); g2d.setPaint(gradient); g2d.fillRect(0, 0, width, height); g2d.dispose(); } } substance-5.3.orig/src/org/jvnet/substance/api/painter/fill/0000755000175000017500000000000011256731146024045 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/api/painter/fill/FractionBasedFillPainter.java0000644000175000017500000001050711247060022031535 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.painter.fill; import java.awt.*; import java.awt.MultipleGradientPaint.CycleMethod; import org.jvnet.substance.api.ColorSchemeSingleColorQuery; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.painter.FractionBasedPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Fill painter with fraction-based stops and a color query associated with each * stop. This class allows creating multi-gradient fills with exact control over * which color is used at every gradient control point. * * @author Kirill Grouchnikov */ public class FractionBasedFillPainter extends FractionBasedPainter implements SubstanceGradientPainter { /** * Creates a new fraction-based fill painter. * * @param displayName * The display name of this painter. * @param fractions * The fractions of this painter. Must be strictly increasing, * starting from 0.0 and ending at 1.0. * @param colorQueries * The color queries of this painter. Must have the same size as * the fractions array, and all entries must be non- * null. */ public FractionBasedFillPainter(String displayName, float[] fractions, ColorSchemeSingleColorQuery[] colorQueries) { super(displayName, fractions, colorQueries); } @Override public void paintContourBackground(Graphics g, Component comp, int width, int height, Shape contour, boolean isFocused, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos, boolean hasShine, boolean useCyclePosAsInterpolation) { Graphics2D graphics = (Graphics2D) g.create(); SubstanceColorScheme interpolationScheme1 = colorScheme1; SubstanceColorScheme interpolationScheme2 = useCyclePosAsInterpolation ? colorScheme2 : colorScheme1; double cycleCoef = 1.0 - cyclePos; Color[] fillColors = new Color[this.fractions.length]; for (int i = 0; i < this.fractions.length; i++) { ColorSchemeSingleColorQuery colorQuery = this.colorQueries[i]; Color color1 = colorQuery.query(interpolationScheme1); Color color2 = colorQuery.query(interpolationScheme2); if (!useCyclePosAsInterpolation) { fillColors[i] = color1; } else { fillColors[i] = SubstanceColorUtilities.getInterpolatedColor( color1, color2, cycleCoef); } } MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0, height, this.fractions, fillColors, CycleMethod.REPEAT); graphics.setPaint(gradient); graphics.fill(contour); graphics.dispose(); } } substance-5.3.orig/src/org/jvnet/substance/api/SubstanceColorScheme.java0000644000175000017500000001412211136475560026375 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api; import java.awt.Color; import org.jvnet.substance.api.trait.SubstanceTrait; /** * General interface for color schemes. * * @author Kirill Grouchnikov */ @SubstanceApi public interface SubstanceColorScheme extends SubstanceTrait, SchemeBaseColors, SchemeDerivedColors { /** * Returns indication whether this color scheme uses dark colors. Note that * this method may be removed in the future. * * @return true if this color scheme uses dark colors, * false otherwise. */ public boolean isDark(); /** * Creates a shift version of this scheme. * * @param backgroundShiftColor * Shift color for background colors. Should have full opacity. * @param backgroundShiftFactor * Value in 0.0...1.0 range. Larger values shift more towards the * specified color. * @param foregroundShiftColor * Shift color for foreground colors. Should have full opacity. * @param foregroundShiftFactor * Value in 0.0...1.0 range. Larger values shift more towards the * specified color. * @return Shift version of this scheme. */ public SubstanceColorScheme shift(Color backgroundShiftColor, double backgroundShiftFactor, Color foregroundShiftColor, double foregroundShiftFactor); /** * Creates a shift version of this scheme. * * @param backgroundShiftColor * Shift color for background colors. Should have full opacity. * @param backgroundShiftFactor * Value in 0.0...1.0 range. Larger values shift more towards the * specified color. * @return Shift version of this scheme that does not change * the foreground color. */ public SubstanceColorScheme shiftBackground(Color backgroundShiftColor, double backgroundShiftFactor); /** * Creates a tinted (shifted towards white) version of this * color scheme. * * @param tintFactor * Value in 0.0...1.0 range. Larger values shift more towards * white color. * @return Tinted version of this scheme. */ public SubstanceColorScheme tint(double tintFactor); /** * Creates a toned (shifted towards gray) version of this color * scheme. * * @param toneFactor * Value in 0.0...1.0 range. Larger values shift more towards * gray color. * @return Toned version of this scheme. */ public SubstanceColorScheme tone(double toneFactor); /** * Creates a shaded (shifted towards black) version of this * color scheme. * * @param shadeFactor * Value in 0.0...1.0 range. Larger values shift more towards * black color. * @return Shaded version of this scheme. */ public SubstanceColorScheme shade(double shadeFactor); /** * Creates a saturated or desaturated version of this scheme. * The value and brightness stay the same. * * @param saturateFactor * Value in -1.0...1.0 range. Positive values create more * saturated colors. Negative values create more desaturated * colors. * @return Saturated version of this scheme. */ public SubstanceColorScheme saturate(double saturateFactor); /** * Creates an inverted version of this scheme. * * @return Inverted version of this scheme. */ public SubstanceColorScheme invert(); /** * Creates a negated version of this scheme. * * @return Negated version of this scheme. */ public SubstanceColorScheme negate(); /** * Creates a hue-shifted (in HSB space) version of this color * scheme. * * @param hueShiftFactor * Value in -1.0...1.0 range. * @return Hue-shifted version of this scheme. */ public SubstanceColorScheme hueShift(double hueShiftFactor); /** * This method is a fluent-interface builder utility for setting the display * name for this color scheme. The implementation must return the same * this instance. * * @param colorSchemeDisplayName * New display name for this color scheme. * @return This color scheme. */ public SubstanceColorScheme named(String colorSchemeDisplayName); } substance-5.3.orig/src/org/jvnet/substance/api/tabbed/0000755000175000017500000000000011256731146022676 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/api/tabbed/VetoableTabCloseListener.java0000644000175000017500000000454311136475560030435 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.tabbed; import java.awt.Component; import javax.swing.JTabbedPane; /** * Vetoable listener on tab closing. This class is part of officially supported * API. * * @author Kirill Grouchnikov */ public interface VetoableTabCloseListener extends TabCloseListener { /** * Called when a tab is about to be closed. Can veto the tab closing. * * @param tabbedPane * Tabbed pane. * @param tabComponent * Tab component to be closed. * @return true if the corresponding tab shouldn't be closed, * false otherwise. */ public boolean vetoTabClosing(JTabbedPane tabbedPane, Component tabComponent); } substance-5.3.orig/src/org/jvnet/substance/api/tabbed/TabCloseCallback.java0000644000175000017500000000661211136475560026661 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.tabbed; import java.awt.event.MouseEvent; import javax.swing.JTabbedPane; import org.jvnet.substance.api.SubstanceConstants.TabCloseKind; /** * Callback for registering app-specific behaviour on tab close buttons. This * class is part of officially supported API. * * @author Kirill Grouchnikov */ public interface TabCloseCallback { /** * Invoked when the tab area (not close button) is clicked. * * @param tabbedPane * Tabbed pane. * @param tabIndex * Index of the tab under the click. * @param mouseEvent * Mouse event. * @return Tab close kind. */ public TabCloseKind onAreaClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent); /** * Invoked when the tab close button is clicked. * * @param tabbedPane * Tabbed pane. * @param tabIndex * Index of the tab under the click. * @param mouseEvent * Mouse event. * @return Tab close kind. */ public TabCloseKind onCloseButtonClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent); /** * Returns the tooltip for the tab area (not close button). * * @param tabbedPane * Tabbed pane. * @param tabIndex * Index of the tab under the mouse. * @return Tooltip for the tab area. */ public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex); /** * Returns the tooltip for the tab close button. * * @param tabbedPane * Tabbed pane. * @param tabIndex * Index of the tab under the mouse. * @return Tooltip for the tab close button. */ public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex); } substance-5.3.orig/src/org/jvnet/substance/api/tabbed/TabCloseListener.java0000644000175000017500000000465311136475560026755 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.tabbed; import java.awt.Component; import javax.swing.JTabbedPane; /** * Listener on tab closing. This class is part of officially supported API. * * @author Kirill Grouchnikov */ public interface TabCloseListener extends BaseTabCloseListener { /** * Called when a tab is about to be closed. * * @param tabbedPane * Tabbed pane. * @param tabComponent * Tab component to be closed. */ public void tabClosing(JTabbedPane tabbedPane, Component tabComponent); /** * Called when a tab is closed. * * @param tabbedPane * Tabbed pane. * @param tabComponent * Tab component closed. */ public void tabClosed(JTabbedPane tabbedPane, Component tabComponent); } substance-5.3.orig/src/org/jvnet/substance/api/tabbed/MultipleTabCloseListener.java0000644000175000017500000000475111136475560030470 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.tabbed; import java.awt.Component; import java.util.Set; import javax.swing.JTabbedPane; /** * Listener on multiple tab closing. This class is part of officially supported * API. * * @author Kirill Grouchnikov */ public interface MultipleTabCloseListener extends BaseTabCloseListener { /** * Called when tabs are about to be closed. * * @param tabbedPane * Tabbed pane. * @param tabComponents * Tab components to be closed. */ public void tabsClosing(JTabbedPane tabbedPane, Set tabComponents); /** * Called when tabs are closed. * * @param tabbedPane * Tabbed pane. * @param tabComponents * Tab components closed. */ public void tabsClosed(JTabbedPane tabbedPane, Set tabComponents); } substance-5.3.orig/src/org/jvnet/substance/api/tabbed/VetoableMultipleTabCloseListener.java0000644000175000017500000000463511136475560032153 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.tabbed; import java.awt.Component; import java.util.Set; import javax.swing.JTabbedPane; /** * Vetoable listener on tabs closing. This class is part of officially supported * API. * * @author Kirill Grouchnikov */ public interface VetoableMultipleTabCloseListener extends MultipleTabCloseListener { /** * Called when tabs are about to be closed. Can veto the tabs closing. * * @param tabbedPane * Tabbed pane. * @param tabComponents * Tab components to be closed. * @return true if the corresponding tabs shouldn't be closed, * false otherwise. */ public boolean vetoTabsClosing(JTabbedPane tabbedPane, Set tabComponents); } substance-5.3.orig/src/org/jvnet/substance/api/tabbed/BaseTabCloseListener.java0000644000175000017500000000356511136475560027551 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api.tabbed; /** * Base interface for the tab close listeners. This class is part of officially * supported API. * * @author Kirill Grouchnikov */ public interface BaseTabCloseListener { } substance-5.3.orig/src/org/jvnet/substance/api/ColorSchemeSingleColorQuery.java0000644000175000017500000001122111246710614027703 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api; import java.awt.Color; /** * Defines a query that returns a single color based on a color scheme. * * @author Kirill Grouchnikov */ @SubstanceApi public interface ColorSchemeSingleColorQuery { /** * Returns a single color based on the specified color scheme. * * @param scheme * The color scheme. * @return The color based on the specified color scheme. */ public Color query(SubstanceColorScheme scheme); /** * Core implementation of the {@link ColorSchemeSingleColorQuery} interface * that returns the ultra light color of the specified color scheme. */ public static final ColorSchemeSingleColorQuery ULTRALIGHT = new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { return scheme.getUltraLightColor(); } }; /** * Core implementation of the {@link ColorSchemeSingleColorQuery} interface * that returns the extra light color of the specified color scheme. */ public static final ColorSchemeSingleColorQuery EXTRALIGHT = new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { return scheme.getExtraLightColor(); } }; /** * Core implementation of the {@link ColorSchemeSingleColorQuery} interface * that returns the light color of the specified color scheme. */ public static final ColorSchemeSingleColorQuery LIGHT = new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { return scheme.getLightColor(); } }; /** * Core implementation of the {@link ColorSchemeSingleColorQuery} interface * that returns the mid color of the specified color scheme. */ public static final ColorSchemeSingleColorQuery MID = new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { return scheme.getMidColor(); } }; /** * Core implementation of the {@link ColorSchemeSingleColorQuery} interface * that returns the dark color of the specified color scheme. */ public static final ColorSchemeSingleColorQuery DARK = new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { return scheme.getDarkColor(); } }; /** * Core implementation of the {@link ColorSchemeSingleColorQuery} interface * that returns the ultra dark color of the specified color scheme. */ public static final ColorSchemeSingleColorQuery ULTRADARK = new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { return scheme.getUltraDarkColor(); } }; /** * Core implementation of the {@link ColorSchemeSingleColorQuery} interface * that returns the foreground color of the specified color scheme. */ public static final ColorSchemeSingleColorQuery FOREGROUND = new ColorSchemeSingleColorQuery() { @Override public Color query(SubstanceColorScheme scheme) { return scheme.getForegroundColor(); } }; } substance-5.3.orig/src/org/jvnet/substance/api/SubstanceColorSchemeBundle.java0000644000175000017500000005065711247654602027543 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.api; import java.awt.Component; import java.util.*; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.substance.colorscheme.BlendBiColorScheme; import org.jvnet.substance.painter.decoration.DecorationAreaType; /** * Color scheme bundle. Defines the visual appearance of a single decoration * area of a skin. * * @author Kirill Grouchnikov * @see DecorationAreaType * @see ColorSchemeAssociationKind * @see SubstanceSkin */ @SubstanceApi public class SubstanceColorSchemeBundle implements Cloneable { /** * The active color scheme of this bundle. */ protected SubstanceColorScheme activeColorScheme; /** * The default color scheme of this bundle. */ protected SubstanceColorScheme defaultColorScheme; /** * The disabled color scheme of this bundle. */ protected SubstanceColorScheme disabledColorScheme; /** * Maps from component state to the alpha channel applied on color scheme. * This map doesn't have to contain entries for all {@link ComponentState} * instances. */ protected Map stateAlphaMap; /** * Maps from component state to the alpha channel applied on highlight color * scheme. This map doesn't have to contain entries for all * {@link ComponentState} instances. */ protected Map stateHighlightSchemeAlphaMap; /** * If there is no explicitly registered color scheme for pressed component * states, this field will contain a synthesized color scheme for a pressed * state. */ protected SubstanceColorScheme pressedScheme; /** * If there is no explicitly registered color scheme for the disabled * selected component states, this field will contain a synthesized color * scheme for the disabled selected state. */ protected SubstanceColorScheme disabledSelectedScheme; /** * Maps from color scheme association kinds to the map of color schemes. * Different visual parts of controls in the specific decoration are can be * painted with different color schemes. For example, a rollover button can * use a light orange scheme for the gradient fill and a dark gray scheme * for the border. In this case, this map will have: * *
    *
  • An entry with key {@link ColorSchemeAssociationKind#FILL}. This entry * has a map entry with key {@link ComponentState#SELECTED} and value that * points to the light orange scheme.
  • *
  • An entry with key {@link ColorSchemeAssociationKind#BORDER}. This * entry has a map entry with key {@link ComponentState#SELECTED} and value * that points to the dark gray scheme.
  • *
*/ protected Map> colorSchemeMap; /** * Creates a new color scheme bundle. * * @param activeColorScheme * The active color scheme of this bundle. * @param defaultColorScheme * The default color scheme of this bundle. * @param disabledColorScheme * The disabled color scheme of this bundle. */ public SubstanceColorSchemeBundle(SubstanceColorScheme activeColorScheme, SubstanceColorScheme defaultColorScheme, SubstanceColorScheme disabledColorScheme) { this.activeColorScheme = activeColorScheme; this.defaultColorScheme = defaultColorScheme; this.disabledColorScheme = disabledColorScheme; this.stateAlphaMap = new EnumMap( ComponentState.class); this.stateHighlightSchemeAlphaMap = new EnumMap( ComponentState.class); this.colorSchemeMap = new HashMap>(); for (ColorSchemeAssociationKind associationKind : ColorSchemeAssociationKind .values()) { this.colorSchemeMap.put(associationKind, new EnumMap( ComponentState.class)); } } /** * Registers a color scheme for the specific component state. * * @param stateColorScheme * Color scheme for the specified component state. * @param alpha * Alpha channel for the color scheme. * @param states * Component states. */ public void registerColorScheme(SubstanceColorScheme stateColorScheme, float alpha, ComponentState... states) { if (states != null) { for (ComponentState state : states) { this.colorSchemeMap.get(ColorSchemeAssociationKind.FILL).put( state, stateColorScheme); this.stateAlphaMap.put(state, alpha); } } } /** * Registers a color scheme for the specific component state. * * @param stateColorScheme * Color scheme for the specified component state. * @param states * Component states. */ public void registerColorScheme(SubstanceColorScheme stateColorScheme, ComponentState... states) { this.registerColorScheme(stateColorScheme, 1.0f, states); } /** * Registers a highlight color scheme for the specific component state if * the component state is not null, or a global highlight color * scheme otherwise. * * @param stateHighlightScheme * Highlight color scheme for the specified component state. * @param states * Component states. If null, the specified color * scheme will be applied for all states left unspecified. */ public void registerHighlightColorScheme( SubstanceColorScheme stateHighlightScheme, ComponentState... states) { if ((states == null) || (states.length == 0)) { for (ComponentState state : ComponentState.values()) { if (this.colorSchemeMap.get( ColorSchemeAssociationKind.HIGHLIGHT) .containsKey(state)) continue; if (!state.isKindActive(FadeKind.ENABLE)) continue; if (state == ComponentState.DEFAULT) continue; // this.stateHighlightColorSchemeMap.put(state, // stateHighlightScheme); this.colorSchemeMap.get(ColorSchemeAssociationKind.HIGHLIGHT) .put(state, stateHighlightScheme); } } else { for (ComponentState state : states) { this.colorSchemeMap.get(ColorSchemeAssociationKind.HIGHLIGHT) .put(state, stateHighlightScheme); } } } /** * Registers a highlight color scheme for the specific component state if * the component state is not null, or a global highlight color * scheme otherwise. * * @param highlightScheme * Highlight color scheme for the specified component states. * @param alpha * Alpha channel for the highlight color scheme. * @param states * Component states. If null, the specified color * scheme will be applied for all states left unspecified. */ public void registerHighlightColorScheme( SubstanceColorScheme highlightScheme, float alpha, ComponentState... states) { if (highlightScheme == null) { throw new IllegalArgumentException("Cannot pass null color scheme"); } if ((states == null) || (states.length == 0)) { for (ComponentState state : ComponentState.values()) { if (!state.isKindActive(FadeKind.ENABLE)) continue; if (state == ComponentState.DEFAULT) continue; if (!this.colorSchemeMap.get( ColorSchemeAssociationKind.HIGHLIGHT) .containsKey(state)) this.colorSchemeMap.get( ColorSchemeAssociationKind.HIGHLIGHT).put(state, highlightScheme); if (!this.stateHighlightSchemeAlphaMap.containsKey(state)) this.stateHighlightSchemeAlphaMap.put(state, alpha); } } else { for (ComponentState state : states) { this.colorSchemeMap.get(ColorSchemeAssociationKind.HIGHLIGHT) .put(state, highlightScheme); this.stateHighlightSchemeAlphaMap.put(state, alpha); } } } /** * Returns the color scheme of the specified component in the specified * component state. * * @param comp * Component. * @param componentState * Component state. * @return The color scheme of the component in the specified component * state. */ public SubstanceColorScheme getColorScheme(ComponentState componentState) { SubstanceColorScheme registered = this.colorSchemeMap.get( ColorSchemeAssociationKind.FILL).get(componentState); if (registered != null) return registered; if (componentState.isKindActive(FadeKind.PRESS)) { if (this.pressedScheme == null) { this.pressedScheme = this.activeColorScheme.shade(0.2) .saturate(0.1); } return this.pressedScheme; } if (componentState == ComponentState.DISABLED_SELECTED) { if (this.disabledSelectedScheme == null) { this.disabledSelectedScheme = new BlendBiColorScheme( this.activeColorScheme, this.disabledColorScheme, 0.25); } return this.disabledSelectedScheme; } if (componentState == ComponentState.DEFAULT) return this.defaultColorScheme; if (!componentState.isKindActive(FadeKind.ENABLE)) return this.disabledColorScheme; return this.activeColorScheme; } /** * Returns the highlight color scheme of the component. * * @param comp * Component. * @param componentState * Component state. * @return Component highlight color scheme. * @deprecated Use * {@link #getColorScheme(Component, ColorSchemeAssociationKind, ComponentState)} * with {@link ColorSchemeAssociationKind#HIGHLIGHT} instead. * This method will be removed in version 6.0. */ @Deprecated public SubstanceColorScheme getHighlightColorScheme(Component comp, ComponentState componentState) { return this.getColorScheme(ColorSchemeAssociationKind.HIGHLIGHT, componentState); // SubstanceColorScheme registered = this.colorSchemeMap.get( // ColorSchemeAssociationKind.HIGHLIGHT).get(componentState); // if (registered != null) // return registered; // // return null; } /** * Returns the alpha channel of the highlight color scheme of the component. * * @param comp * Component. * @param componentState * Component state. * @return Highlight color scheme alpha channel. */ public float getHighlightAlpha(Component comp, ComponentState componentState) { Float registered = this.stateHighlightSchemeAlphaMap .get(componentState); if (registered != null) return registered.floatValue(); return -1.0f; } /** * Returns the alpha channel of the color scheme of the component. * * @param comp * Component. * @param componentState * Component state. * @return Color scheme alpha channel. */ public float getAlpha(Component comp, ComponentState componentState) { Float registered = this.stateAlphaMap.get(componentState); if (registered != null) return registered.floatValue(); return -1.0f; } /** * Returns the active color scheme of this bundle. * * @return The active color scheme of this bundle. */ public SubstanceColorScheme getActiveColorScheme() { return activeColorScheme; } /** * Returns the default color scheme of this bundle. * * @return The default color scheme of this bundle. */ public SubstanceColorScheme getDefaultColorScheme() { return defaultColorScheme; } /** * Returns the disabled color scheme of this bundle. * * @return The disabled color scheme of this bundle. */ public SubstanceColorScheme getDisabledColorScheme() { return disabledColorScheme; } /** * Registers the color scheme to be used for the specified visual area of * controls under the specified states. For example, if the light orange * scheme has to be used for gradient fill of rollover selected and rollover * controls, the parameters would be: * *
    *
  • scheme=light orange scheme
  • *
  • * associationKind={@link ColorSchemeAssociationKind#FILL}
  • *
  • * states={@link ComponentState#ROLLOVER_SELECTED}, * {@link ComponentState#ROLLOVER_UNSELECTED}
  • *
* * @param scheme * Color scheme. * @param associationKind * Color scheme association kind that specifies the visual areas * of controls to be painted with this color scheme. * @param states * Component states that further restrict the usage of the * specified color scheme. * @since version 5.1 */ public void registerColorScheme(SubstanceColorScheme scheme, ColorSchemeAssociationKind associationKind, ComponentState... states) { if (scheme == null) { throw new IllegalArgumentException("Cannot pass null color scheme"); } if ((states == null) || (states.length == 0)) { for (ComponentState state : ComponentState.values()) { if (this.colorSchemeMap.get(associationKind).containsKey(state)) continue; this.colorSchemeMap.get(associationKind).put(state, scheme); } } else { for (ComponentState state : states) { this.colorSchemeMap.get(associationKind).put(state, scheme); } } } /** * Returns the color scheme to be used for painting the specified visual * area of the component under the specified component state. * * @param comp * Component. * @param associationKind * Color scheme association kind. * @param componentState * Component state. * @return Color scheme to be used for painting the specified visual area of * the component under the specified component state. * @see #registerColorScheme(SubstanceColorScheme, ComponentState...) * @since version 5.1 */ public SubstanceColorScheme getColorScheme( ColorSchemeAssociationKind associationKind, ComponentState componentState) { if (associationKind == ColorSchemeAssociationKind.FILL) return this.getColorScheme(componentState); SubstanceColorScheme registered = this.colorSchemeMap.get( associationKind).get(componentState); if (registered != null) return registered; ColorSchemeAssociationKind fallback = associationKind.getFallback(); if (fallback == null) return null; return getColorScheme(fallback, componentState); } /** * Registers a border color scheme for the specific component state if the * component state is not null, or a global highlight color * scheme otherwise. * * @param scheme * Border color scheme for the specified component state. * @param states * Component states. If null, the specified color * scheme will be applied for all states left unspecified. * @deprecated Use * {@link #registerColorScheme(SubstanceColorScheme, ColorSchemeAssociationKind, ComponentState...)} * with {@link ColorSchemeAssociationKind#BORDER} instead. This * method will be removed in version 6.0. */ @Deprecated public void registerBorderColorScheme(SubstanceColorScheme scheme, ComponentState... states) { this.registerColorScheme(scheme, ColorSchemeAssociationKind.BORDER, states); } /** * Returns the border color scheme of the component. * * @param comp * Component. * @param componentState * Component state. * @return Component border color scheme. * @deprecated Use * {@link #getColorScheme(Component, ColorSchemeAssociationKind, ComponentState)} * with {@link ColorSchemeAssociationKind#BORDER} instead. This * method will be removed in version 6.0. */ @Deprecated public SubstanceColorScheme getBorderColorScheme(Component comp, ComponentState componentState) { return this.getColorScheme(ColorSchemeAssociationKind.BORDER, componentState); // SubstanceColorScheme registered = this.colorSchemeMap.get( // ColorSchemeAssociationKind.BORDER).get(componentState); // if (registered != null) // return registered; // // return this.getColorScheme(comp, componentState, true); } @Override protected Object clone() throws CloneNotSupportedException { SubstanceColorSchemeBundle clone = new SubstanceColorSchemeBundle( this.activeColorScheme, this.defaultColorScheme, this.disabledColorScheme); for (Map.Entry> entry : this.colorSchemeMap .entrySet()) { clone.colorSchemeMap.get(entry.getKey()).putAll(entry.getValue()); } if (this.stateAlphaMap != null) { clone.stateAlphaMap = new EnumMap( this.stateAlphaMap); } if (this.stateHighlightSchemeAlphaMap != null) { clone.stateHighlightSchemeAlphaMap = new EnumMap( this.stateHighlightSchemeAlphaMap); } return clone; } /** * Creates a new color scheme bundle that has the same settings as this * color scheme bundle with the addition of applying the specified color * scheme transformation on all the relevant color schemes * * @param transform * Color scheme transformation. * @return The new color scheme bundle. */ public SubstanceColorSchemeBundle transform(ColorSchemeTransform transform) { // transform the basic schemes SubstanceColorSchemeBundle result = new SubstanceColorSchemeBundle( transform.transform(this.activeColorScheme), transform .transform(this.defaultColorScheme), transform .transform(this.disabledColorScheme)); for (Map.Entry> entry : this.colorSchemeMap .entrySet()) { for (Map.Entry subEntry : entry .getValue().entrySet()) { result.colorSchemeMap.get(entry.getKey()).put( subEntry.getKey(), transform.transform(subEntry.getValue())); } } // alphas are the same if (this.stateAlphaMap != null) { result.stateAlphaMap = new EnumMap( this.stateAlphaMap); } // highlight alphas are the same if (this.stateHighlightSchemeAlphaMap != null) { result.stateHighlightSchemeAlphaMap = new EnumMap( this.stateHighlightSchemeAlphaMap); } return result; } /** * Returns the set of all component states that have non-trivial alpha * associated with them. Non-trivial alpha is a value that is strictly less * than 1.0. * * @return All component states that have associated non-trivial alpha * values. */ Set getStatesWithAlpha() { Set result = EnumSet.noneOf(ComponentState.class); for (Map.Entry alphaEntry : this.stateAlphaMap .entrySet()) { if (alphaEntry.getValue() < 1.0f) { result.add(alphaEntry.getKey()); } } return result; } } substance-5.3.orig/src/org/jvnet/substance/SubstanceMenuBarUI.java0000644000175000017500000000717311245202246025206 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.Graphics; import javax.swing.JComponent; import javax.swing.JMenuBar; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicMenuBarUI; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.painter.utils.DecorationPainterUtils; import org.jvnet.substance.utils.SubstanceCoreUtilities; /** * UI for menu bars in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceMenuBarUI extends BasicMenuBarUI { /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceMenuBarUI(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicMenuBarUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); SubstanceLookAndFeel.setDecorationType(this.menuBar, DecorationAreaType.HEADER); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicMenuBarUI#uninstallDefaults() */ @Override protected void uninstallDefaults() { DecorationPainterUtils.clearDecorationType(this.menuBar); super.uninstallDefaults(); } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void update(Graphics g, JComponent c) { boolean isOpaque = TransitionLayout.isOpaque(c); if (isOpaque) { BackgroundPaintingUtils.update(g, c, false); } else { super.update(g, c); } } /** * Returns the menu bar of this UI delegate. This method is for internal use * only. * * @return The menu bar of this UI delegate. */ public JMenuBar getMenuBar() { return this.menuBar; } } substance-5.3.orig/src/org/jvnet/substance/SubstanceSliderUI.java0000644000175000017500000007513111245202246025076 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.geom.AffineTransform; import java.awt.geom.GeneralPath; import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; import javax.swing.*; import javax.swing.plaf.*; import javax.swing.plaf.basic.BasicSliderUI; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.api.*; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.gradient.ClassicGradientPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; import org.jvnet.substance.painter.utils.SeparatorPainterUtils; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.icon.SubstanceIconFactory; /** * UI for sliders in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceSliderUI extends BasicSliderUI implements Trackable { /** * Surrogate button model for tracking the thumb transitions. */ private ButtonModel thumbModel; /** * Listener for fade animations. */ private RolloverControlListener substanceRolloverListener; /** * Listener on property change events. */ private PropertyChangeListener substancePropertyChangeListener; /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /** * Icon for horizontal sliders. */ protected Icon horizontalIcon; /** * Icon for sliders without labels and ticks. */ protected Icon roundIcon; /** * Icon for vertical sliders. */ protected Icon verticalIcon; /** * Cache of track images. */ protected static final LazyResettableHashMap trackCache = new LazyResettableHashMap( "SubstanceSliderUI.track"); /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceSliderUI((JSlider) comp); } /** * Simple constructor. * * @param slider * Slider. */ public SubstanceSliderUI(JSlider slider) { super(null); this.thumbModel = new DefaultButtonModel(); this.thumbModel.setArmed(false); this.thumbModel.setSelected(false); this.thumbModel.setPressed(false); this.thumbModel.setRollover(false); this.thumbModel.setEnabled(slider.isEnabled()); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSliderUI#calculateTrackRect() */ @Override protected void calculateTrackRect() { super.calculateTrackRect(); if (this.slider.getOrientation() == SwingConstants.HORIZONTAL) { this.trackRect.y = 3 + (int) Math.ceil(SubstanceSizeUtils .getFocusStrokeWidth(SubstanceSizeUtils .getComponentFontSize(this.slider))) + this.insetCache.top; } } /** * Returns the rectangle of track for painting. * * @return The rectangle of track for painting. */ private Rectangle getPaintTrackRect() { int trackLeft = 0, trackRight = 0, trackTop = 0, trackBottom = 0; if (this.slider.getOrientation() == SwingConstants.HORIZONTAL) { trackTop = 3 + this.insetCache.top + 2 * this.focusInsets.top; trackBottom = trackTop + this.getTrackWidth() - 1; trackRight = this.trackRect.width; return new Rectangle(this.trackRect.x + trackLeft, trackTop, trackRight - trackLeft, trackBottom - trackTop); } else { if (this.slider.getComponentOrientation().isLeftToRight()) { trackLeft = trackRect.x + this.insetCache.left + this.focusInsets.left; trackRight = trackLeft + this.getTrackWidth() - 1; } else { trackRight = trackRect.x + trackRect.width - this.insetCache.right - this.focusInsets.right; // this.slider.getWidth() - 8 - this.insetCache.right; trackLeft = trackRight - this.getTrackWidth() + 1; } trackBottom = this.trackRect.height - 1; return new Rectangle(trackLeft, this.trackRect.y + trackTop, trackRight - trackLeft, trackBottom - trackTop); } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSliderUI#paintTrack(java.awt.Graphics) */ @Override public void paintTrack(Graphics g) { Graphics2D graphics = (Graphics2D) g.create(); boolean drawInverted = this.drawInverted(); Rectangle paintRect = this.getPaintTrackRect(); // Width and height of the painting rectangle. int width = paintRect.width; int height = paintRect.height; if (this.slider.getOrientation() == JSlider.VERTICAL) { // apply rotation / translate transformation on vertical // sider tracks int temp = width; width = height; height = temp; AffineTransform at = graphics.getTransform(); at.translate(paintRect.x, width + paintRect.y); at.rotate(-Math.PI / 2); graphics.setTransform(at); } else { graphics.translate(paintRect.x, paintRect.y); } ComponentState currState = ComponentState.getState(this.thumbModel, this.slider); ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(this.slider); SubstanceColorScheme trackScheme = SubstanceColorSchemeUtilities .getColorScheme(this.slider, this.slider.isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED); this.paintSliderTrack(graphics, drawInverted, trackScheme, SubstanceColorSchemeUtilities.getColorScheme(this.slider, ColorSchemeAssociationKind.BORDER, currState), width, height); SubstanceColorScheme trackSchemeSelected = SubstanceColorSchemeUtilities .getColorScheme(this.slider, currState); SubstanceColorScheme trackBorderSchemeSelected = SubstanceColorSchemeUtilities .getColorScheme(this.slider, ColorSchemeAssociationKind.BORDER, currState); FadeState fadeState = SubstanceFadeUtilities.getFadeState(this.slider, FadeKind.ROLLOVER, FadeKind.SELECTION, FadeKind.PRESS); if (fadeState != null) { SubstanceColorScheme prevScheme = SubstanceColorSchemeUtilities .getColorScheme(this.slider, prevState); SubstanceColorScheme prevBorderScheme = SubstanceColorSchemeUtilities .getColorScheme(this.slider, ColorSchemeAssociationKind.BORDER, prevState); float cyclePos = fadeState.getFadePosition(); if (!fadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; if (prevState != ComponentState.DEFAULT) { graphics.setComposite(TransitionLayout.getAlphaComposite( this.slider, 1.0f - cyclePos, g)); this.paintSliderTrackSelected(graphics, drawInverted, paintRect, prevScheme, prevBorderScheme, width, height); } if (currState != ComponentState.DEFAULT) { graphics.setComposite(TransitionLayout.getAlphaComposite( this.slider, cyclePos, g)); this.paintSliderTrackSelected(graphics, drawInverted, paintRect, trackSchemeSelected, trackBorderSchemeSelected, width, height); } } else { boolean hasFill = currState.isKindActive(FadeKind.ROLLOVER) || currState.isKindActive(FadeKind.PRESS); if (hasFill) { this.paintSliderTrackSelected(graphics, drawInverted, paintRect, trackSchemeSelected, trackBorderSchemeSelected, width, height); } } graphics.dispose(); } /** * Paints the slider track. * * @param graphics * Graphics. * @param drawInverted * Indicates whether the value-range shown for the slider is * reversed. * @param fillColorScheme * Fill color scheme. * @param borderScheme * Border color scheme. * @param width * Track width. * @param height * Track height. */ private void paintSliderTrack(Graphics2D graphics, boolean drawInverted, SubstanceColorScheme fillColorScheme, SubstanceColorScheme borderScheme, int width, int height) { Graphics2D g2d = (Graphics2D) graphics.create(); SubstanceGradientPainter gradientPainter = ClassicGradientPainter.INSTANCE; SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(this.slider); int componentFontSize = SubstanceSizeUtils .getComponentFontSize(this.slider); int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(componentFontSize) / 2.0); float radius = SubstanceSizeUtils .getClassicButtonCornerRadius(componentFontSize) / 2.0f; int borderThickness = (int) SubstanceSizeUtils .getBorderStrokeWidth(componentFontSize); HashMapKey key = SubstanceCoreUtilities.getHashKey(width, height, radius, borderDelta, borderThickness, fillColorScheme .getDisplayName(), borderScheme.getDisplayName()); if (!trackCache.containsKey(key)) { BufferedImage trackImage = SubstanceCoreUtilities.getBlankImage( width + 1, height + 1); Graphics2D cacheGraphics = trackImage.createGraphics(); Shape contour = SubstanceOutlineUtilities.getBaseOutline(width + 1, height + 1, radius, null, borderDelta); gradientPainter.paintContourBackground(cacheGraphics, slider, width, height, contour, false, fillColorScheme, fillColorScheme, 0, false, false); GeneralPath contourInner = SubstanceOutlineUtilities .getBaseOutline(width + 1, height + 1, radius - borderThickness, null, borderThickness + borderDelta); borderPainter.paintBorder(cacheGraphics, slider, width + 1, height + 1, contour, contourInner, borderScheme, borderScheme, 0, false); trackCache.put(key, trackImage); cacheGraphics.dispose(); } BufferedImage cached = trackCache.get(key); g2d.drawImage(cached, 0, 0, null); g2d.dispose(); } /** * Paints the selected part of the slider track. * * @param graphics * Graphics. * @param drawInverted * Indicates whether the value-range shown for the slider is * reversed. * @param paintRect * Selected portion. * @param fillScheme * Fill color scheme. * @param borderScheme * Border color scheme. * @param width * Track width. * @param height * Track height. */ private void paintSliderTrackSelected(Graphics2D graphics, boolean drawInverted, Rectangle paintRect, SubstanceColorScheme fillScheme, SubstanceColorScheme borderScheme, int width, int height) { Graphics2D g2d = (Graphics2D) graphics.create(); Insets insets = this.slider.getInsets(); insets.top /= 2; insets.left /= 2; insets.bottom /= 2; insets.right /= 2; SubstanceGradientPainter gp = SubstanceCoreUtilities .getGradientPainter(this.slider); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(this.slider); float radius = SubstanceSizeUtils .getClassicButtonCornerRadius(SubstanceSizeUtils .getComponentFontSize(slider)) / 2.0f; int borderDelta = (int) Math.floor(SubstanceSizeUtils .getBorderStrokeWidth(SubstanceSizeUtils .getComponentFontSize(slider)) / 2.0); // fill selected portion if (this.slider.isEnabled()) { if (this.slider.getOrientation() == SwingConstants.HORIZONTAL) { int middleOfThumb = this.thumbRect.x + (this.thumbRect.width / 2) - paintRect.x; int fillMinX; int fillMaxX; if (drawInverted) { fillMinX = middleOfThumb; fillMaxX = width; } else { fillMinX = 0; fillMaxX = middleOfThumb; } int fillWidth = fillMaxX - fillMinX; int fillHeight = height + 1; if ((fillWidth > 0) && (fillHeight > 0)) { Shape contour = SubstanceOutlineUtilities.getBaseOutline( fillWidth, fillHeight, radius, null, borderDelta); g2d.translate(fillMinX, 0); gp.paintContourBackground(g2d, this.slider, fillWidth, fillHeight, contour, false, fillScheme, fillScheme, 0.0f, false, false); borderPainter.paintBorder(g2d, this.slider, fillWidth, fillHeight, contour, null, borderScheme, borderScheme, 0.0f, false); } } else { int middleOfThumb = this.thumbRect.y + (this.thumbRect.height / 2) - paintRect.y; int fillMin; int fillMax; if (this.drawInverted()) { fillMin = 0; fillMax = middleOfThumb; // fix for issue 368 - inverted vertical sliders g2d.translate(width + 2 - middleOfThumb, 0); } else { fillMin = middleOfThumb; fillMax = width + 1; } int fillWidth = fillMax - fillMin; int fillHeight = height + 1; if ((fillWidth > 0) && (fillHeight > 0)) { Shape contour = SubstanceOutlineUtilities.getBaseOutline( fillWidth, fillHeight, radius, null, borderDelta); gp.paintContourBackground(g2d, this.slider, fillWidth, fillHeight, contour, false, fillScheme, fillScheme, 0.0f, false, false); borderPainter.paintBorder(g2d, this.slider, fillWidth, fillHeight, contour, null, borderScheme, borderScheme, 0.0f, false); } } } g2d.dispose(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSliderUI#getThumbSize() */ @Override protected Dimension getThumbSize() { Icon thumbIcon = this.getIcon(); return new Dimension(thumbIcon.getIconWidth(), thumbIcon .getIconHeight()); } /** * Returns the thumb icon for the associated slider. * * @return The thumb icon for the associated slider. */ protected Icon getIcon() { if (this.slider.getOrientation() == JSlider.HORIZONTAL) { if (this.slider.getPaintTicks() || this.slider.getPaintLabels()) return this.horizontalIcon; else return this.roundIcon; } else { if (this.slider.getPaintTicks() || this.slider.getPaintLabels()) return this.verticalIcon; else return this.roundIcon; } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSliderUI#paintThumb(java.awt.Graphics) */ @Override public void paintThumb(Graphics g) { Graphics2D graphics = (Graphics2D) g.create(); // graphics.setComposite(TransitionLayout.getAlphaComposite(slider)); Rectangle knobBounds = this.thumbRect; // System.out.println(thumbRect); graphics.translate(knobBounds.x, knobBounds.y); Icon icon = this.getIcon(); if (this.slider.getOrientation() == JSlider.HORIZONTAL) { if (icon != null) icon.paintIcon(this.slider, graphics, -1, 0); } else { if (this.slider.getComponentOrientation().isLeftToRight()) { if (icon != null) icon.paintIcon(this.slider, graphics, 0, -1); } else { if (icon != null) icon.paintIcon(this.slider, graphics, 0, 1); } } // graphics.translate(-knobBounds.x, -knobBounds.y); graphics.dispose(); } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#paint(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void paint(Graphics g, final JComponent c) { Graphics2D graphics = (Graphics2D) g.create(); ComponentState currState = ComponentState.getState(this.thumbModel, this.slider); float alpha = SubstanceColorSchemeUtilities.getAlpha(this.slider, currState); BackgroundPaintingUtils.updateIfOpaque(graphics, c); recalculateIfInsetsChanged(); recalculateIfOrientationChanged(); final Rectangle clip = graphics.getClipBounds(); if (!clip.intersects(trackRect) && slider.getPaintTrack()) calculateGeometry(); graphics.setComposite(TransitionLayout.getAlphaComposite(this.slider, alpha, g)); if (slider.getPaintTrack() && clip.intersects(trackRect)) { paintTrack(graphics); } if (slider.getPaintTicks() && clip.intersects(tickRect)) { paintTicks(graphics); } if (slider.hasFocus() && clip.intersects(focusRect)) { paintFocus(graphics); } if (clip.intersects(thumbRect)) { paintThumb(graphics); } graphics.setComposite(TransitionLayout.getAlphaComposite(this.slider, 1.0f, g)); if (slider.getPaintLabels() && clip.intersects(labelRect)) { paintLabels(graphics); } if (!this.slider.hasFocus()) { if (FadeTracker.getInstance().isTracked(c, FadeKind.FOCUS)) this.paintFocus(graphics); } // graphics.setColor(Color.red); // graphics.draw(trackRect); // graphics.setColor(Color.green); // graphics.draw(tickRect); // graphics.setColor(Color.blue); // graphics.draw(thumbRect); // graphics.setColor(Color.magenta); // graphics.draw(labelRect); graphics.dispose(); } /** * Returns the button model for tracking the thumb transitions. * * @return Button model for tracking the thumb transitions. */ public ButtonModel getButtonModel() { return this.thumbModel; } /* * (non-Javadoc) * * @see org.jvnet.substance.Trackable#isInside(java.awt.event.MouseEvent) */ public boolean isInside(MouseEvent me) { Rectangle thumbB = this.thumbRect; if (thumbB == null) return false; return thumbB.contains(me.getX(), me.getY()); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicSliderUI#installDefaults(javax.swing.JSlider) */ @Override protected void installDefaults(JSlider slider) { super.installDefaults(slider); Font f = slider.getFont(); if (f == null || f instanceof UIResource) { slider.setFont(new FontUIResource(SubstanceLookAndFeel .getFontPolicy().getFontSet("Substance", null) .getControlFont())); } int size = SubstanceSizeUtils.getSliderIconSize(SubstanceSizeUtils .getComponentFontSize(slider)); // System.out.println("Slider size : " + size); this.horizontalIcon = SubstanceIconFactory.getSliderHorizontalIcon( size, false); this.roundIcon = SubstanceIconFactory.getSliderRoundIcon(size); this.verticalIcon = SubstanceIconFactory.getSliderVerticalIcon(size, false); int focusIns = (int) Math.ceil(2.0 * SubstanceSizeUtils .getFocusStrokeWidth(SubstanceSizeUtils .getComponentFontSize(slider))); this.focusInsets = new Insets(focusIns, focusIns, focusIns, focusIns); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicSliderUI#installListeners(javax.swing.JSlider * ) */ @Override protected void installListeners(final JSlider slider) { super.installListeners(slider); // fix for defect 109 - memory leak on changing skin this.substanceRolloverListener = new RolloverControlListener(this, this.thumbModel); slider.addMouseListener(this.substanceRolloverListener); slider.addMouseMotionListener(this.substanceRolloverListener); this.substancePropertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("enabled".equals(evt.getPropertyName())) { SubstanceSliderUI.this.thumbModel.setEnabled(slider .isEnabled()); } if ("font".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { slider.updateUI(); } }); } } }; this.slider .addPropertyChangeListener(this.substancePropertyChangeListener); this.substanceFadeStateListener = new FadeStateListener(this.slider, this.thumbModel, SubstanceCoreUtilities .getFadeCallback(this.slider, this.thumbModel, false, false, this.slider)); this.substanceFadeStateListener.registerListeners(false); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicSliderUI#uninstallListeners(javax.swing.JSlider * ) */ @Override protected void uninstallListeners(JSlider slider) { super.uninstallListeners(slider); // fix for defect 109 - memory leak on changing skin slider.removeMouseListener(this.substanceRolloverListener); slider.removeMouseMotionListener(this.substanceRolloverListener); this.substanceRolloverListener = null; slider .removePropertyChangeListener(this.substancePropertyChangeListener); this.substancePropertyChangeListener = null; this.substanceFadeStateListener.unregisterListeners(); this.substanceFadeStateListener = null; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSliderUI#paintFocus(java.awt.Graphics) */ @Override public void paintFocus(Graphics g) { SubstanceCoreUtilities.paintFocus(g, this.slider, this.slider, null, null, 1.0f, (int) Math.ceil(SubstanceSizeUtils .getFocusStrokeWidth(SubstanceSizeUtils .getComponentFontSize(this.slider))) / 2); } /** * Returns the amount that the thumb goes past the slide bar. * * @return Amount that the thumb goes past the slide bar. */ protected int getThumbOverhang() { return (int) (this.getThumbSize().getHeight() - this.getTrackWidth()) / 2; } /** * Returns the shorter dimension of the track. * * @return Shorter dimension of the track. */ protected int getTrackWidth() { return SubstanceSizeUtils.getSliderTrackSize(SubstanceSizeUtils .getComponentFontSize(this.slider)); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSliderUI#getTickLength() */ @Override protected int getTickLength() { return SubstanceSizeUtils.getSliderTickSize(SubstanceSizeUtils .getComponentFontSize(this.slider)); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSliderUI#paintTicks(java.awt.Graphics) */ @Override public void paintTicks(Graphics g) { Rectangle tickBounds = this.tickRect; SubstanceColorScheme tickScheme = SubstanceColorSchemeUtilities .getColorScheme(this.slider, ColorSchemeAssociationKind.SEPARATOR, this.slider .isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED); if (this.slider.getOrientation() == JSlider.HORIZONTAL) { int value = this.slider.getMinimum() + this.slider.getMinorTickSpacing(); int xPos = 0; if ((this.slider.getMinorTickSpacing() > 0) && (this.slider.getMajorTickSpacing() > 0)) { // collect x's of the minor ticks java.util.List minorXs = new ArrayList(); while (value < this.slider.getMaximum()) { int delta = value - this.slider.getMinimum(); if (delta % this.slider.getMajorTickSpacing() != 0) { xPos = this.xPositionForValue(value); minorXs.add(xPos - 1); } value += this.slider.getMinorTickSpacing(); } // and paint them in one call SeparatorPainterUtils.paintVerticalLines(g, this.slider, tickScheme, tickBounds.y, minorXs, tickBounds.height / 2, 0.75f); } if (this.slider.getMajorTickSpacing() > 0) { // collect x's of the major ticks java.util.List majorXs = new ArrayList(); value = this.slider.getMinimum() + this.slider.getMajorTickSpacing(); while (value < this.slider.getMaximum()) { xPos = this.xPositionForValue(value); majorXs.add(xPos - 1); value += this.slider.getMajorTickSpacing(); } // and paint them in one call SeparatorPainterUtils.paintVerticalLines(g, this.slider, tickScheme, tickBounds.y, majorXs, tickBounds.height, 0.75f); } } else { g.translate(tickBounds.x, 0); int value = this.slider.getMinimum() + this.slider.getMinorTickSpacing(); int yPos = 0; boolean ltr = this.slider.getComponentOrientation().isLeftToRight(); if (this.slider.getMinorTickSpacing() > 0) { // collect y's of the minor ticks java.util.List minorYs = new ArrayList(); int offset = 0; if (!ltr) { offset = tickBounds.width - tickBounds.width / 2; } while (value < this.slider.getMaximum()) { yPos = this.yPositionForValue(value); minorYs.add(yPos); value += this.slider.getMinorTickSpacing(); } // and paint them in one call SeparatorPainterUtils.paintHorizontalLines(g, this.slider, tickScheme, offset, minorYs, tickBounds.width / 2, ltr ? 0.75f : 0.25f, ltr); } if (this.slider.getMajorTickSpacing() > 0) { // collect y's of the major ticks java.util.List majorYs = new ArrayList(); value = this.slider.getMinimum() + this.slider.getMajorTickSpacing(); while (value < this.slider.getMaximum()) { yPos = this.yPositionForValue(value); majorYs.add(yPos); value += this.slider.getMajorTickSpacing(); } // and paint them in one call SeparatorPainterUtils.paintHorizontalLines(g, this.slider, tickScheme, 0, majorYs, tickBounds.width, ltr ? 0.75f : 0.25f, ltr); } g.translate(-tickBounds.x, 0); } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSliderUI#calculateTickRect() */ @Override protected void calculateTickRect() { if (this.slider.getOrientation() == JSlider.HORIZONTAL) { this.tickRect.x = this.trackRect.x; this.tickRect.y = this.trackRect.y + this.trackRect.height; this.tickRect.width = this.trackRect.width; this.tickRect.height = (this.slider.getPaintTicks()) ? this .getTickLength() : 0; } else { this.tickRect.width = (this.slider.getPaintTicks()) ? this .getTickLength() : 0; if (this.slider.getComponentOrientation().isLeftToRight()) { this.tickRect.x = this.trackRect.x + this.trackRect.width; } else { this.tickRect.x = this.trackRect.x - this.tickRect.width; } this.tickRect.y = this.trackRect.y; this.tickRect.height = this.trackRect.height; } if (this.slider.getPaintTicks()) { if (this.slider.getOrientation() == JSlider.HORIZONTAL) { this.tickRect.y -= 3; } else { if (this.slider.getComponentOrientation().isLeftToRight()) { this.tickRect.x -= 2; } else { this.tickRect.x += 2; } } } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSliderUI#calculateLabelRect() */ @Override protected void calculateLabelRect() { super.calculateLabelRect(); if ((this.slider.getOrientation() == JSlider.VERTICAL) && !this.slider.getPaintTicks() && this.slider.getComponentOrientation().isLeftToRight()) { this.labelRect.x += 3; } if (this.slider.getOrientation() == JSlider.VERTICAL) { this.labelRect.width = getHeightOfTallestLabel(); } } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSliderUI#calculateThumbLocation() */ @Override protected void calculateThumbLocation() { super.calculateThumbLocation(); Rectangle trackRect = this.getPaintTrackRect(); if (slider.getOrientation() == JSlider.HORIZONTAL) { int valuePosition = xPositionForValue(slider.getValue()); double centerY = trackRect.y + trackRect.height / 2.0; thumbRect.y = (int) (centerY - thumbRect.height / 2.0) + 1; thumbRect.x = valuePosition - thumbRect.width / 2; } else { int valuePosition = yPositionForValue(slider.getValue()); double centerX = trackRect.x + trackRect.width / 2.0; thumbRect.x = (int) (centerX - thumbRect.width / 2.0) + 1; thumbRect.y = valuePosition - (thumbRect.height / 2); } } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicSliderUI#getPreferredSize(javax.swing.JComponent * ) */ @Override public Dimension getPreferredSize(JComponent c) { this.recalculateIfInsetsChanged(); Dimension d; if (this.slider.getOrientation() == JSlider.VERTICAL) { d = new Dimension(this.getPreferredVerticalSize()); d.width = this.insetCache.left + this.insetCache.right; d.width += this.focusInsets.left + this.focusInsets.right; d.width += this.trackRect.width; if (this.slider.getPaintTicks()) d.width += getTickLength(); if (this.slider.getPaintLabels()) d.width += getWidthOfWidestLabel(); d.width += 3; } else { d = new Dimension(this.getPreferredHorizontalSize()); d.height = this.insetCache.top + this.insetCache.bottom; d.height += this.focusInsets.top + this.focusInsets.bottom; d.height += this.trackRect.height; if (this.slider.getPaintTicks()) d.height += getTickLength(); if (this.slider.getPaintLabels()) d.height += getHeightOfTallestLabel(); d.height += 3; } return d; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSliderUI#setThumbLocation(int, int) */ @Override public void setThumbLocation(int x, int y) { super.setThumbLocation(x, y); this.slider.repaint(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSliderUI#getPreferredHorizontalSize() */ @Override public Dimension getPreferredHorizontalSize() { return new Dimension(SubstanceSizeUtils.getAdjustedSize( SubstanceSizeUtils.getComponentFontSize(this.slider), 200, 1, 20, false), 21); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSliderUI#getPreferredVerticalSize() */ @Override public Dimension getPreferredVerticalSize() { return new Dimension(21, SubstanceSizeUtils.getAdjustedSize( SubstanceSizeUtils.getComponentFontSize(this.slider), 200, 1, 20, false)); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceRadioButtonMenuItemUI.java0000644000175000017500000002102611247214702027546 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.awt.event.MouseEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicRadioButtonMenuItemUI; import org.jvnet.lafwidget.animation.FadeStateListener; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.icon.RadioButtonMenuItemIcon; import org.jvnet.substance.utils.menu.MenuUtilities; import org.jvnet.substance.utils.menu.SubstanceMenu; import org.jvnet.substance.utils.menu.MenuUtilities.MenuPropertyListener; /** * UI for radio button menu items in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceRadioButtonMenuItemUI extends BasicRadioButtonMenuItemUI implements SubstanceMenu, Trackable { /** * Rollover listener. */ protected RolloverMenuItemListener substanceRolloverListener; /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /** * Property change listener. Listens on changes to * {@link AbstractButton#MODEL_CHANGED_PROPERTY} property. */ protected PropertyChangeListener substancePropertyListener; /** * Listens on all changes to the underlying menu item. */ protected MenuPropertyListener substanceMenuPropertyListener; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); JRadioButtonMenuItem item = (JRadioButtonMenuItem) comp; item.setRolloverEnabled(true); return new SubstanceRadioButtonMenuItemUI(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicMenuItemUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); // Improving performance on big menus. this.substanceMenuPropertyListener = new MenuPropertyListener( this.menuItem); this.substanceMenuPropertyListener.install(); // fix for defect 109 - storing reference to rollover listener this.substanceRolloverListener = new RolloverMenuItemListener( this.menuItem); this.menuItem.addMouseListener(this.substanceRolloverListener); this.substanceFadeStateListener = new FadeStateListener(this.menuItem, this.menuItem.getModel(), SubstanceCoreUtilities .getFadeCallback(this.menuItem, this.menuItem .getModel(), true, false, this.menuItem)); this.substanceFadeStateListener.registerListeners(); this.substancePropertyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (AbstractButton.MODEL_CHANGED_PROPERTY.equals(evt .getPropertyName())) { if (substanceFadeStateListener != null) substanceFadeStateListener.unregisterListeners(); substanceFadeStateListener = new FadeStateListener( menuItem, menuItem.getModel(), SubstanceCoreUtilities.getFadeCallback(menuItem, menuItem.getModel(), true, false, menuItem)); substanceFadeStateListener.registerListeners(); } if ("font".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (menuItem != null) { menuItem.updateUI(); } } }); } } }; this.menuItem.addPropertyChangeListener(this.substancePropertyListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicMenuItemUI#uninstallListeners() */ @Override protected void uninstallListeners() { super.uninstallListeners(); // Improving performance on big menus. this.substanceMenuPropertyListener.uninstall(); this.substanceMenuPropertyListener = null; // fix for defect 109 - unregistering rollover listener this.menuItem.removeMouseListener(this.substanceRolloverListener); this.substanceRolloverListener = null; this.menuItem .removePropertyChangeListener(this.substancePropertyListener); this.substancePropertyListener = null; this.substanceFadeStateListener.unregisterListeners(); this.substanceFadeStateListener = null; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicMenuItemUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); if (this.checkIcon == null || this.checkIcon instanceof UIResource) { this.checkIcon = new RadioButtonMenuItemIcon(this.menuItem, SubstanceSizeUtils.getMenuCheckMarkSize(SubstanceSizeUtils .getComponentFontSize(this.menuItem))); } this.defaultTextIconGap = SubstanceSizeUtils .getTextIconGap(SubstanceSizeUtils .getComponentFontSize(this.menuItem)); } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getAssociatedMenuItem() */ public JMenuItem getAssociatedMenuItem() { return this.menuItem; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getAcceleratorFont() */ public Font getAcceleratorFont() { return this.acceleratorFont; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getArrowIcon() */ public Icon getArrowIcon() { return this.arrowIcon; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getCheckIcon() */ public Icon getCheckIcon() { return this.checkIcon; } /* * (non-Javadoc) * * @see org.jvnet.substance.SubstanceMenu#getDefaultTextIconGap() */ public int getDefaultTextIconGap() { return this.defaultTextIconGap; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicMenuItemUI#getPreferredMenuItemSize(javax * .swing.JComponent, javax.swing.Icon, javax.swing.Icon, int) */ @Override protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { Dimension superDim = super.getPreferredMenuItemSize(c, checkIcon, arrowIcon, defaultTextIconGap); return new Dimension(MenuUtilities.getPreferredWidth(menuItem), superDim.height); } /* * (non-Javadoc) * * @see * org.jvnet.substance.utils.Trackable#isInside(java.awt.event.MouseEvent) */ public boolean isInside(MouseEvent me) { return this.menuItem.getBounds().contains(me.getX(), me.getY()); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicMenuItemUI#paintMenuItem(java.awt.Graphics, * javax.swing.JComponent, javax.swing.Icon, javax.swing.Icon, * java.awt.Color, java.awt.Color, int) */ @Override protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { MenuUtilities.paintMenuItem(g, menuItem, checkIcon, arrowIcon, defaultTextIconGap); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceTreeUI.java0000644000175000017500000010475311246717644024574 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.awt.event.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.*; import javax.swing.*; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.IconUIResource; import javax.swing.plaf.basic.BasicTreeUI; import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreePath; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.lafwidget.utils.LookUtils; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.renderers.SubstanceDefaultTreeCellRenderer; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.painter.utils.HighlightPainterUtils; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.icon.SubstanceIconFactory; /** * UI for lists in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceTreeUI extends BasicTreeUI { /** * Holds the list of currently selected paths. */ protected Map selectedPaths; /** * Holds the currently rolled-over path or null if none such. */ protected TreePathId currRolloverPathId; /** * Listener that listens to changes on tree properties. */ protected PropertyChangeListener substancePropertyChangeListener; /** * Listener for selection animations. */ protected TreeSelectionListener substanceSelectionFadeListener; /** * Listener for fade animations on tree rollovers. */ protected RolloverFadeListener substanceFadeRolloverListener; /** * Listener for selection of an entire row. */ protected MouseListener substanceRowSelectionListener; /** * Map of previous fade states (for state-aware color scheme transitions). */ private Map prevStateMap; /** * Map of next fade states (for state-aware color scheme transitions). */ private Map nextStateMap; /** * The current default color scheme. Is computed in * {@link #update(Graphics, JComponent)} and reused in * {@link SubstanceDefaultTreeCellRenderer#getTreeCellRendererComponent(JTree, Object, boolean, boolean, boolean, int, boolean)} * for performance optimizations. */ private SubstanceColorScheme currDefaultColorScheme; /** * Cell renderer insets. Is computed in {@link #installDefaults()} and * reused in * {@link SubstanceDefaultTreeCellRenderer#getTreeCellRendererComponent(JTree, Object, boolean, boolean, boolean, int, boolean)} * for performance optimizations. */ private Insets cellRendererInsets; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceTreeUI(); } /** * Creates a UI delegate for tree. */ public SubstanceTreeUI() { super(); this.selectedPaths = new HashMap(); this.prevStateMap = new HashMap(); this.nextStateMap = new HashMap(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTreeUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); if (SubstanceCoreUtilities.toDrawWatermark(this.tree)) this.tree.setOpaque(false); if (this.tree.getSelectionPaths() != null) { for (TreePath selectionPath : this.tree.getSelectionPaths()) { TreePathId pathId = new TreePathId(selectionPath); selectedPaths.put(pathId, selectionPath.getLastPathComponent()); prevStateMap.put(pathId, ComponentState.SELECTED); } } setExpandedIcon(new IconUIResource(SubstanceIconFactory.getTreeIcon( this.tree, false))); setCollapsedIcon(new IconUIResource(SubstanceIconFactory.getTreeIcon( this.tree, true))); this.tree.putClientProperty(SubstanceCoreUtilities.USE_HIGHLIGHT, Boolean.TRUE); // instead of computing the cell renderer insets on // every cell rendering, compute it once and expose to the // SubstanceDefaultTreeCellRenderer this.cellRendererInsets = SubstanceSizeUtils .getTreeCellRendererInsets(SubstanceSizeUtils .getComponentFontSize(tree)); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTreeUI#uninstallDefaults() */ @Override protected void uninstallDefaults() { this.selectedPaths.clear(); super.uninstallDefaults(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTreeUI#paintRow(java.awt.Graphics, * java.awt.Rectangle, java.awt.Insets, java.awt.Rectangle, * javax.swing.tree.TreePath, int, boolean, boolean, boolean) */ @Override protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) { // Don't paint the renderer if editing this row. if ((this.editingComponent != null) && (this.editingRow == row)) { // fix for issue 446 - paint the expand control // on the editing row if (shouldPaintExpandControl(path, row, isExpanded, hasBeenExpanded, isLeaf)) { if (!this.tree.getComponentOrientation().isLeftToRight() && LookUtils.IS_JAVA_5) { bounds.x -= 4; } paintExpandControlEnforce(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf); } } int leadIndex; if (this.tree.hasFocus()) { TreePath leadPath = this.tree.getLeadSelectionPath(); leadIndex = this.getRowForPath(this.tree, leadPath); } else { leadIndex = -1; } Component renderer = this.currentCellRenderer .getTreeCellRendererComponent(this.tree, path .getLastPathComponent(), this.tree.isRowSelected(row), isExpanded, isLeaf, row, (leadIndex == row)); if (!(renderer instanceof SubstanceDefaultTreeCellRenderer)) { // if it's not Substance renderer - ask the Basic delegate to paint // it. super.paintRow(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf); if (shouldPaintExpandControl(path, row, isExpanded, hasBeenExpanded, isLeaf)) { paintExpandControlEnforce(g, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf); } return; } TreePathId pathId = new TreePathId(path); // Respect the current composite set on the graphics - for // JXPanel alpha channel float currFactor = 1.0f; Composite currComposite = ((Graphics2D) g).getComposite(); if (currComposite instanceof AlphaComposite) { AlphaComposite ac = (AlphaComposite) currComposite; if (ac.getRule() == AlphaComposite.SRC_OVER) currFactor = ac.getAlpha(); } Graphics2D g2d = (Graphics2D) g.create(); // fix for issue 183 - passing the original Graphics context // to compute the alpha composite. If the tree is in a JXPanel // (component from SwingX) and it has custom alpha value set, // then the original graphics context will have a SRC_OVER // alpha composite applied to it. g2d.setComposite(TransitionLayout.getAlphaComposite(this.tree, currFactor)); // Color background = renderer.getBackground(); // if (background == null) // background = tree.getBackground(); ComponentState prevState = this.getPrevPathState(pathId); ComponentState currState = this.getPathState(pathId); // Compute the alpha values for the animation. float startAlpha = SubstanceColorSchemeUtilities.getHighlightAlpha( this.tree, prevState); float endAlpha = SubstanceColorSchemeUtilities.getHighlightAlpha( this.tree, currState); FadeState state = SubstanceFadeUtilities.getFadeState(this.tree, pathId, FadeKind.SELECTION, FadeKind.ROLLOVER); float totalAlpha = endAlpha; float fadeCoef = 0.0f; if (state != null) { fadeCoef = state.getFadePosition(); // compute the total alpha of the overlays. if (state.isFadingIn()) { totalAlpha = startAlpha + (endAlpha - startAlpha) * fadeCoef; } else { totalAlpha = startAlpha + (endAlpha - startAlpha) * (1.0f - fadeCoef); } if (state.isFadingIn()) fadeCoef = 1.0f - fadeCoef; } // System.out.println(row + ":" + prevTheme.getDisplayName() + "[" // + alphaForPrevBackground + "]:" + currTheme.getDisplayName() // + "[" + alphaForCurrBackground + "]"); // At this point the renderer is an instance of // SubstanceDefaultTreeCellRenderer if (totalAlpha > 0.0f) { g2d.setComposite(TransitionLayout.getAlphaComposite(this.tree, currFactor * totalAlpha, g)); // Fix for defect 180 - painting the // highlight beneath the entire row HighlightPainterUtils .paintHighlight(g2d, this.rendererPane, renderer, new Rectangle(this.tree.getInsets().left, bounds.y, this.tree.getWidth() - this.tree.getInsets().right - this.tree.getInsets().left, bounds.height), 0.8f, null, currState, prevState, fadeCoef); g2d.setComposite(TransitionLayout.getAlphaComposite(this.tree, currFactor)); } // System.out.println("Painting row " + row); // Play with opacity to make our own gradient background // on selected elements to show - safe to cast and set opacity // since at this point the renderer can only by the // SubstanceDefaultTreeCellRenderer JComponent jRenderer = (JComponent) renderer; boolean newOpaque = !this.tree.isRowSelected(row); if (SubstanceCoreUtilities.toDrawWatermark(this.tree)) newOpaque = false; Map opacity = new HashMap(); if (!newOpaque) SubstanceCoreUtilities.makeNonOpaque(jRenderer, opacity); this.rendererPane.paintComponent(g2d, renderer, this.tree, bounds.x, bounds.y, Math.max(this.tree.getWidth() - this.tree.getInsets().right - this.tree.getInsets().left - bounds.x, bounds.width), bounds.height, true); if (!newOpaque) SubstanceCoreUtilities.restoreOpaque(jRenderer, opacity); // Paint the expand control now after the row background has been // overlayed by the highlight background on selected and rolled over // rows. See comments on paintExpandControl(). if (shouldPaintExpandControl(path, row, isExpanded, hasBeenExpanded, isLeaf)) { if (!this.tree.getComponentOrientation().isLeftToRight() && LookUtils.IS_JAVA_5) { bounds.x -= 4; } paintExpandControlEnforce(g2d, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf); } g2d.dispose(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTreeUI#paintExpandControl(java.awt.Graphics, * java.awt.Rectangle, java.awt.Insets, java.awt.Rectangle, * javax.swing.tree.TreePath, int, boolean, boolean, boolean) */ @Override protected void paintExpandControl(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) { // This does nothing. The base implementation of paint() paints // the tree lines and tree expand controls *before* painting the // renderer. In Substance, the highlights are painted in the // paintRow, and thus would overlay the expand controls. This results // in expand controls being much less visible under most of the skins. // So, Substance paints the expand controls *after* painting the // highlights (and the renderer which doesn't overlap with the expand // controls in any case). This is done in paintRow() by calling // the paintExpandControlEnforce() instead (that eventually calls the // super implementation of paintExpandControl(). } /** * Paints the expand control of the specified row. * * @param g * Graphics context. * @param clipBounds * Clip bounds. * @param insets * Insets. * @param bounds * Row bounds. * @param path * Tree path. * @param row * Tree row. * @param isExpanded * Expand indication. * @param hasBeenExpanded * Indication whether this row has ever been expanded. * @param isLeaf * Indication whether this row is a leaf. */ protected void paintExpandControlEnforce(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) { // boolean toPaint = (!this.tree.isEnabled()) || this.isInside; float alpha = SubstanceColorSchemeUtilities.getAlpha(this.tree, this.tree.isEnabled() ? ComponentState.DEFAULT : ComponentState.DISABLED_UNSELECTED); Graphics2D graphics = (Graphics2D) g.create(); // if (toPaint) { graphics.setComposite(TransitionLayout.getAlphaComposite(this.tree, alpha, g)); super.paintExpandControl(graphics, clipBounds, insets, bounds, path, row, isExpanded, hasBeenExpanded, isLeaf); // } graphics.dispose(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTreeUI#paintHorizontalPartOfLeg(java.awt. * Graphics, java.awt.Rectangle, java.awt.Insets, java.awt.Rectangle, * javax.swing.tree.TreePath, int, boolean, boolean, boolean) */ @Override protected void paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) { } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTreeUI#paintVerticalPartOfLeg(java.awt.Graphics * , java.awt.Rectangle, java.awt.Insets, javax.swing.tree.TreePath) */ @Override protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path) { } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTreeUI#createDefaultCellRenderer() */ @Override protected TreeCellRenderer createDefaultCellRenderer() { return new SubstanceDefaultTreeCellRenderer(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTreeUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); this.substancePropertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (SubstanceLookAndFeel.WATERMARK_VISIBLE.equals(evt .getPropertyName())) { tree.setOpaque(!SubstanceCoreUtilities .toDrawWatermark(tree)); } if ("font".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { tree.updateUI(); } }); } } }; this.tree .addPropertyChangeListener(this.substancePropertyChangeListener); this.substanceSelectionFadeListener = new MyTreeSelectionListener(); this.tree.getSelectionModel().addTreeSelectionListener( this.substanceSelectionFadeListener); this.substanceRowSelectionListener = new RowSelectionListener(); this.tree.addMouseListener(this.substanceRowSelectionListener); // Add listener for the fade animation this.substanceFadeRolloverListener = new RolloverFadeListener(); this.tree.addMouseMotionListener(this.substanceFadeRolloverListener); this.tree.addMouseListener(this.substanceFadeRolloverListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTreeUI#uninstallListeners() */ @Override protected void uninstallListeners() { this.tree.removeMouseListener(this.substanceRowSelectionListener); this.substanceRowSelectionListener = null; this.tree.getSelectionModel().removeTreeSelectionListener( this.substanceSelectionFadeListener); this.substanceSelectionFadeListener = null; this.tree .removePropertyChangeListener(this.substancePropertyChangeListener); this.substancePropertyChangeListener = null; // Remove listener for the fade animation this.tree.removeMouseMotionListener(this.substanceFadeRolloverListener); this.tree.removeMouseListener(this.substanceFadeRolloverListener); this.substanceFadeRolloverListener = null; super.uninstallListeners(); } /** * ID of a single tree path. * * @author Kirill Grouchnikov */ @SuppressWarnings("unchecked") public static class TreePathId implements Comparable { /** * Tree path. */ protected TreePath path; /** * Creates a tree path ID. * * @param path * Tree path. */ public TreePathId(TreePath path) { this.path = path; } /* * (non-Javadoc) * * @see java.lang.Comparable#compareTo(java.lang.Object) */ public int compareTo(Object o) { if (o instanceof TreePathId) { TreePathId otherId = (TreePathId) o; if ((this.path == null) && (otherId.path != null)) return 1; if ((otherId.path == null) && (this.path != null)) return -1; Object[] path1Objs = this.path.getPath(); Object[] path2Objs = otherId.path.getPath(); if (path1Objs.length != path2Objs.length) return 1; for (int i = 0; i < path1Objs.length; i++) if (!path1Objs[i].equals(path2Objs[i])) return 1; return 0; } return -1; } /* * (non-Javadoc) * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { return this.compareTo(obj) == 0; } /* * (non-Javadoc) * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { if (this.path == null) return 0; Object[] pathObjs = this.path.getPath(); int result = pathObjs[0].hashCode(); for (int i = 1; i < pathObjs.length; i++) result = result ^ pathObjs[i].hashCode(); return result; } } /** * Selection listener for selection animation effects. * * @author Kirill Grouchnikov */ protected class MyTreeSelectionListener implements TreeSelectionListener { /* * (non-Javadoc) * * @see * javax.swing.event.TreeSelectionListener#valueChanged(javax.swing. * event.TreeSelectionEvent) */ public void valueChanged(TreeSelectionEvent e) { // Map currSelected = (Map) // tree // .getClientProperty(SELECTED_INDICES); if (tree.getSelectionPaths() != null) { for (TreePath selectionPath : tree.getSelectionPaths()) { TreePathId pathId = new TreePathId(selectionPath); // check if was selected before if (!selectedPaths.containsKey(pathId)) { // start fading in // System.out.println("Fade in on index " + i); FadeTracker.getInstance().trackFadeIn( FadeKind.SELECTION, tree, pathId, false, new PathRepaintCallback(tree, selectionPath)); selectedPaths.put(pathId, selectionPath .getLastPathComponent()); } } } for (Iterator> it = selectedPaths .entrySet().iterator(); it.hasNext();) { Map.Entry entry = it.next(); if (tree.getSelectionModel() .isPathSelected(entry.getKey().path)) continue; // fade out for deselected path FadeTracker.getInstance().trackFadeOut(FadeKind.SELECTION, tree, entry.getKey(), false, new PathRepaintCallback(tree, entry.getKey().path)); it.remove(); } } } /** * Repaints a single path during the fade animation cycle. * * @author Kirill Grouchnikov */ protected class PathRepaintCallback extends UIThreadFadeTrackerAdapter { /** * Associated tree. */ protected JTree tree; /** * Associated (animated) path. */ protected TreePath treePath; /** * Creates a new animation repaint callback. * * @param tree * Associated tree. * @param treePath * Associated (animated) path. */ public PathRepaintCallback(JTree tree, TreePath treePath) { super(); this.tree = tree; this.treePath = treePath; } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.utils.FadeTracker$FadeTrackerCallback#fadeEnded * (org.jvnet.lafwidget.utils.FadeTracker.FadeKind) */ @Override public void fadeEnded(FadeKind fadeKind) { if (SubstanceTreeUI.this.tree == tree) { TreePathId pathId = new TreePathId(treePath); ComponentState currState = getPathState(pathId); if (currState == ComponentState.DEFAULT) { prevStateMap.remove(pathId); nextStateMap.remove(pathId); } else { prevStateMap.put(pathId, currState); nextStateMap.put(pathId, currState); } // System.out.println(tabIndex + "->" // + prevStateMap.get(tabIndex).name()); } this.repaintPath(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.utils.FadeTracker$FadeTrackerCallback#fadePerformed * (org.jvnet.lafwidget.utils.FadeTracker.FadeKind, float) */ @Override public void fadePerformed(FadeKind fadeKind, float fade) { if (SubstanceTreeUI.this.tree == tree) { TreePathId pathId = new TreePathId(treePath); nextStateMap.put(pathId, getPathState(pathId)); } this.repaintPath(); } /* * (non-Javadoc) * * @see * org.jvnet.lafwidget.animation.FadeTrackerAdapter#fadeReversed(org * .jvnet.lafwidget.animation.FadeKind, boolean, float) */ @Override public void fadeReversed(FadeKind fadeKind, boolean isFadingIn, float fadeCycle10) { if (SubstanceTreeUI.this.tree == tree) { TreePathId pathId = new TreePathId(treePath); ComponentState nextState = nextStateMap.get(pathId); if (nextState == null) { prevStateMap.remove(pathId); } else { prevStateMap.put(pathId, nextState); } // System.out.println(tabIndex + "->" // + prevStateMap.get(tabIndex).name()); } this.repaintPath(); } /** * Repaints the associated path. */ private void repaintPath() { SwingUtilities.invokeLater(new Runnable() { public void run() { if (SubstanceTreeUI.this.tree == null) { // may happen if the LAF was switched in the meantime return; } Rectangle boundsBuffer = new Rectangle(); Rectangle bounds = treeState.getBounds(treePath, boundsBuffer); if (bounds != null) { // still visible // fix for defect 180 - refresh the entire row bounds.x = 0; bounds.width = tree.getWidth(); // fix for defect 188 - rollover effects for trees // with insets Insets insets = tree.getInsets(); bounds.x += insets.left; bounds.y += insets.top; tree.repaint(bounds); } } }); } } /** * Listener for rollover animation effects. * * @author Kirill Grouchnikov */ private class RolloverFadeListener implements MouseListener, MouseMotionListener { public void mouseClicked(MouseEvent e) { } public void mouseEntered(MouseEvent e) { if (!tree.isEnabled()) return; // isInside = true; } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } public void mouseExited(MouseEvent e) { if (!tree.isEnabled()) return; // isInside = false; this.fadeOut(); // System.out.println("Nulling RO index"); currRolloverPathId = null; } public void mouseMoved(MouseEvent e) { if (!tree.isEnabled()) return; // isInside = true; handleMove(e); } public void mouseDragged(MouseEvent e) { if (!tree.isEnabled()) return; handleMove(e); } /** * Handles various mouse move events and initiates the fade animation if * necessary. * * @param e * Mouse event. */ private void handleMove(MouseEvent e) { TreePath closestPath = tree.getClosestPathForLocation(e.getX(), e .getY()); Rectangle bounds = tree.getPathBounds(closestPath); if (bounds == null) { this.fadeOut(); currRolloverPathId = null; return; } if ((e.getY() < bounds.y) || (e.getY() > (bounds.y + bounds.height))) { this.fadeOut(); currRolloverPathId = null; return; } // check if this is the same index TreePathId newPathId = new TreePathId(closestPath); if ((currRolloverPathId != null) && newPathId.equals(currRolloverPathId)) { // System.out.println("Same location " + // System.currentTimeMillis()); // System.out.print("Current : "); // for (Object o1 : currPathId.path.getPath()) { // System.out.print(o1); // } // System.out.println(""); // System.out.print("Closest : "); // for (Object o2 : newPathId.path.getPath()) { // System.out.print(o2); // } // System.out.println(""); return; } this.fadeOut(); FadeTracker.getInstance().trackFadeIn(FadeKind.ROLLOVER, tree, newPathId, false, new PathRepaintCallback(tree, closestPath)); // System.out.println("Setting RO index to " + roIndex); currRolloverPathId = newPathId; } /** * Initiates the fade out effect. */ private void fadeOut() { if (currRolloverPathId == null) return; FadeTracker.getInstance().trackFadeOut(FadeKind.ROLLOVER, tree, currRolloverPathId, false, new PathRepaintCallback(tree, currRolloverPathId.path)); } } /** * Listener for selecting the entire rows. * * @author Kirill Grouchnikov */ private class RowSelectionListener extends MouseAdapter { /* * (non-Javadoc) * * @see * java.awt.event.MouseAdapter#mousePressed(java.awt.event.MouseEvent) */ @Override public void mousePressed(MouseEvent e) { if (!tree.isEnabled()) return; TreePath closestPath = tree.getClosestPathForLocation(e.getX(), e .getY()); if (closestPath == null) return; Rectangle bounds = tree.getPathBounds(closestPath); // Process events outside the immediate bounds - fix for defect // 19 on substance-netbeans. This properly handles Ctrl and Shift // selections on trees. if ((e.getY() >= bounds.y) && (e.getY() < (bounds.y + bounds.height)) && ((e.getX() < bounds.x) || (e.getX() > (bounds.x + bounds.width)))) { // tree.setSelectionPath(closestPath); // fix - don't select a node if the click was on the // expand control if (isLocationInExpandControl(closestPath, e.getX(), e.getY())) return; selectPathForEvent(closestPath, e); } } } /** * Returns the pivot X for the cells rendered in the specified area. Used * for the smart tree scroll ( * {@link SubstanceLookAndFeel#TREE_SMART_SCROLL_ANIMATION_KIND}). * * @param paintBounds * Area bounds. * @return Pivot X for the cells rendered in the specified area */ public int getPivotRendererX(Rectangle paintBounds) { TreePath initialPath = getClosestPathForLocation(tree, 0, paintBounds.y); Enumeration paintingEnumerator = treeState .getVisiblePathsFrom(initialPath); int endY = paintBounds.y + paintBounds.height; int totalY = 0; int count = 0; if (initialPath != null && paintingEnumerator != null) { boolean done = false; Rectangle boundsBuffer = new Rectangle(); Rectangle bounds; TreePath path; Insets insets = tree.getInsets(); while (!done && paintingEnumerator.hasMoreElements()) { path = (TreePath) paintingEnumerator.nextElement(); if (path != null) { bounds = treeState.getBounds(path, boundsBuffer); bounds.x += insets.left; bounds.y += insets.top; int currMedianX = bounds.x;// + bounds.width / 2; totalY += currMedianX; count++; if ((bounds.y + bounds.height) >= endY) done = true; } else { done = true; } } } if (count == 0) return -1; return totalY / count - 2 * SubstanceSizeUtils.getTreeIconSize(SubstanceSizeUtils .getComponentFontSize(tree)); } /** * Returns the previous state for the specified path. * * @param pathId * Path index. * @return The previous state for the specified path. */ public ComponentState getPrevPathState(TreePathId pathId) { if (this.prevStateMap.containsKey(pathId)) return this.prevStateMap.get(pathId); return this.getPathState(pathId); } /** * Returns the current state for the specified path. * * @param pathId * Path index. * @return The current state for the specified path. */ public ComponentState getPathState(TreePathId pathId) { int rowIndex = this.tree.getRowForPath(pathId.path); boolean isEnabled = this.tree.isEnabled(); boolean isRollover = (this.currRolloverPathId != null) && pathId.equals(this.currRolloverPathId); boolean isSelected = this.tree.isRowSelected(rowIndex); return ComponentState.getState(isEnabled, isRollover, isSelected); } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void update(Graphics g, JComponent c) { BackgroundPaintingUtils.updateIfOpaque(g, c); // Should never happen if installed for a UI if (treeState == null) { return; } // compute the default color scheme - to optimize the performance // SubstanceColorScheme scheme = SubstanceColorSchemeUtilities // .getColorScheme(this.tree, // this.tree.isEnabled() ? ComponentState.DEFAULT // : ComponentState.DISABLED_UNSELECTED); // this.currHashColor = scheme.getLineColor(); this.currDefaultColorScheme = SubstanceColorSchemeUtilities .getColorScheme(tree, ComponentState.DEFAULT); Rectangle paintBounds = g.getClipBounds(); Insets insets = tree.getInsets(); TreePath initialPath = getClosestPathForLocation(tree, 0, paintBounds.y); Enumeration paintingEnumerator = treeState .getVisiblePathsFrom(initialPath); int row = treeState.getRowForPath(initialPath); int endY = paintBounds.y + paintBounds.height; // second part - fix for defect 214 (rollover effects on non-opaque // trees resulted in inconsistent behaviour) boolean isWatermarkBleed = SubstanceCoreUtilities.toDrawWatermark(tree) || !tree.isOpaque(); Graphics2D g2d = (Graphics2D) g.create(); SubstanceStripingUtils.setup(c); if (initialPath != null && paintingEnumerator != null) { boolean done = false; Rectangle boundsBuffer = new Rectangle(); Rectangle bounds; TreePath path; while (!done && paintingEnumerator.hasMoreElements()) { path = (TreePath) paintingEnumerator.nextElement(); if (path != null) { // respect the background color of the renderer. boolean isLeaf = treeModel.isLeaf(path .getLastPathComponent()); boolean isExpanded = isLeaf ? false : treeState .getExpandedState(path); Component renderer = this.currentCellRenderer .getTreeCellRendererComponent(this.tree, path .getLastPathComponent(), this.tree .isRowSelected(row), isExpanded, isLeaf, row, tree.hasFocus() ? (tree .getLeadSelectionRow() == row) : false); Color background = renderer.getBackground(); if (background == null) background = tree.getBackground(); bounds = treeState.getBounds(path, boundsBuffer); bounds.x += insets.left; bounds.y += insets.top; if (!isWatermarkBleed) { g2d.setColor(background); g2d.fillRect(paintBounds.x, bounds.y, paintBounds.width, bounds.height); } else { if (this.tree.getComponentOrientation().isLeftToRight()) { BackgroundPaintingUtils.fillAndWatermark(g2d, this.tree, background, new Rectangle( paintBounds.x, bounds.y, paintBounds.width, bounds.height)); } else { BackgroundPaintingUtils.fillAndWatermark(g2d, this.tree, background, new Rectangle( paintBounds.x, bounds.y, paintBounds.width, bounds.height)); } } if ((bounds.y + bounds.height) >= endY) done = true; } else { done = true; } row++; } } this.paint(g2d, c); SubstanceStripingUtils.tearDown(c); g2d.dispose(); } // /* // * (non-Javadoc) // * // * @see javax.swing.plaf.basic.BasicTreeUI#getHashColor() // */ // @Override // protected Color getHashColor() { // return this.currHashColor; // } /** * Returns the default color scheme of this tree. Is for internal use only. * * @return The default color scheme of this tree. */ public SubstanceColorScheme getDefaultColorScheme() { return this.currDefaultColorScheme; } /** * Returns the cell renderer insets of this tree. Is for internal use only. * * @return The cell renderer insets of this tree. */ public Insets getCellRendererInsets() { return cellRendererInsets; } } substance-5.3.orig/src/org/jvnet/substance/SubstanceRadioButtonUI.java0000644000175000017500000003216311253517614026113 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.*; import javax.swing.text.View; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.api.*; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.utils.*; /** * UI for radio buttons in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceRadioButtonUI extends BasicRadioButtonUI { /** * Property change listener. Listens on changes to * {@link AbstractButton#MODEL_CHANGED_PROPERTY} property. */ protected PropertyChangeListener substancePropertyListener; /** * Associated toggle button. */ protected JToggleButton button; /** * Icons for all component states */ private static LazyResettableHashMap icons = new LazyResettableHashMap( "SubstanceRadioButtonUI"); /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /* * (non-Javadoc) * * @seejavax.swing.plaf.basic.BasicButtonUI#installListeners(javax.swing. * AbstractButton) */ @Override protected void installListeners(final AbstractButton b) { super.installListeners(b); substanceFadeStateListener = new FadeStateListener(b, b.getModel(), SubstanceCoreUtilities.getFadeCallback(b, false)); substanceFadeStateListener.registerListeners(); substancePropertyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (AbstractButton.MODEL_CHANGED_PROPERTY.equals(evt .getPropertyName())) { if (substanceFadeStateListener != null) substanceFadeStateListener.unregisterListeners(); substanceFadeStateListener = new FadeStateListener(b, b .getModel(), SubstanceCoreUtilities .getFadeCallback(b, false)); substanceFadeStateListener.registerListeners(); } // if ("opaque".equals(evt.getPropertyName())) { // if (!Boolean.TRUE.equals(b // .getClientProperty(SubstanceButtonUI.LOCK_OPACITY))) { // b.putClientProperty(SubstanceButtonUI.OPACITY_ORIGINAL, // evt.getNewValue()); // // System.out // // .println("PCL: " // // + b.getText() // // + "->" // // + b // // .getClientProperty(SubstanceButtonUI.OPACITY_ORIGINAL // // )); // } // } if ("font".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { b.updateUI(); } }); } } }; b.addPropertyChangeListener(substancePropertyListener); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicRadioButtonUI#installDefaults(javax.swing * .AbstractButton) */ @Override protected void installDefaults(AbstractButton b) { super.installDefaults(b); Border border = b.getBorder(); if (border == null || border instanceof UIResource) { b.setBorder(SubstanceSizeUtils .getRadioButtonBorder(SubstanceSizeUtils .getComponentFontSize(b))); } button.setRolloverEnabled(true); LookAndFeel.installProperty(b, "iconTextGap", SubstanceSizeUtils .getTextIconGap(SubstanceSizeUtils.getComponentFontSize(b))); } /* * (non-Javadoc) * * @seejavax.swing.plaf.basic.BasicButtonUI#uninstallListeners(javax.swing. * AbstractButton) */ @Override protected void uninstallListeners(AbstractButton b) { substanceFadeStateListener.unregisterListeners(); substanceFadeStateListener = null; b.removePropertyChangeListener(substancePropertyListener); substancePropertyListener = null; super.uninstallListeners(b); } /** * Returns the icon that matches the current and previous states of the * radio button. * * @param button * Button (should be {@link JRadioButton}). * @param currState * Current state of the checkbox. * @param prevState * Previous state of the checkbox. * @return Matching icon. */ private static Icon getIcon(JToggleButton button, ComponentState currState, ComponentState prevState) { float visibility = currState.isKindActive(FadeKind.SELECTION) ? 10 : 0; SubstanceColorScheme currFillColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.FILL, currState); SubstanceColorScheme prevFillColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.FILL, prevState); SubstanceColorScheme currMarkColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.MARK, currState); SubstanceColorScheme prevMarkColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.MARK, prevState); SubstanceColorScheme currBorderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.BORDER, currState); SubstanceColorScheme prevBorderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.BORDER, prevState); float cyclePos = 0; FadeState fadeState = SubstanceFadeUtilities.getFadeState(button, FadeKind.SELECTION, FadeKind.ROLLOVER, FadeKind.PRESS); if (fadeState != null) { cyclePos = fadeState.getFadePosition(); if (fadeState.isFadingIn()) cyclePos = 1.0f - cyclePos; if (fadeState.fadeKind == FadeKind.SELECTION) { visibility = fadeState.getFadePosition(); } } int fontSize = SubstanceSizeUtils.getComponentFontSize(button); int checkMarkSize = SubstanceSizeUtils.getRadioButtonMarkSize(fontSize); SubstanceGradientPainter fillPainter = SubstanceCoreUtilities .getGradientPainter(button); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(button); HashMapKey key = SubstanceCoreUtilities.getHashKey(fontSize, checkMarkSize, currState.name(), currState.name(), fillPainter .getDisplayName(), borderPainter.getDisplayName(), currFillColorScheme.getDisplayName(), prevFillColorScheme .getDisplayName(), currMarkColorScheme.getDisplayName(), prevMarkColorScheme .getDisplayName(), currBorderColorScheme .getDisplayName(), prevBorderColorScheme .getDisplayName(), cyclePos, visibility); Icon result = SubstanceRadioButtonUI.icons.get(key); if (result != null) return result; result = new ImageIcon(SubstanceImageCreator.getRadioButton(button, fillPainter, borderPainter, checkMarkSize, currState, prevState, 0, currFillColorScheme, prevFillColorScheme, currMarkColorScheme, prevMarkColorScheme, currBorderColorScheme, prevBorderColorScheme, cyclePos, visibility / 10.f)); SubstanceRadioButtonUI.icons.put(key, result); return result; } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceRadioButtonUI((JToggleButton) comp); } /** * Simple constructor. * * @param button * Associated radio button. */ public SubstanceRadioButtonUI(JToggleButton button) { this.button = button; button.setRolloverEnabled(true); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicButtonUI#createButtonListener(javax.swing * .AbstractButton) */ @Override protected BasicButtonListener createButtonListener(AbstractButton b) { return new RolloverButtonListener(b); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicRadioButtonUI#getDefaultIcon() */ @Override public Icon getDefaultIcon() { ComponentState currState = ComponentState.getState(button); ComponentState prevState = SubstanceCoreUtilities .getPrevComponentState(button); return SubstanceRadioButtonUI.getIcon(button, currState, prevState); } @Override public void paint(Graphics g, JComponent c) { AbstractButton b = (AbstractButton) c; // boolean isOpaque = b.isOpaque(); // b.putClientProperty(SubstanceButtonUI.LOCK_OPACITY, Boolean.TRUE); // b.setOpaque(false); if (// isOpaque || TransitionLayout.isOpaque(c)) { BackgroundPaintingUtils.update(g, c, false); } // b.setOpaque(isOpaque); // b.putClientProperty(SubstanceButtonUI.LOCK_OPACITY, null); FontMetrics fm = g.getFontMetrics(); Insets i = b.getInsets(); Rectangle viewRect = new Rectangle(); Rectangle iconRect = new Rectangle(); final Rectangle textRect = new Rectangle(); viewRect.x = i.left; viewRect.y = i.top; viewRect.width = b.getWidth() - (i.right + viewRect.x); viewRect.height = b.getHeight() - (i.bottom + viewRect.y); textRect.x = textRect.y = textRect.width = textRect.height = 0; iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0; Font f = b.getFont(); g.setFont(f); Icon icon = SubstanceCoreUtilities.getIcon(b, this.getDefaultIcon(), null, false); // layout the text and icon String text = SwingUtilities.layoutCompoundLabel(c, fm, b.getText(), icon, b.getVerticalAlignment(), b.getHorizontalAlignment(), b .getVerticalTextPosition(), b .getHorizontalTextPosition(), viewRect, iconRect, textRect, b.getText() == null ? 0 : b.getIconTextGap()); Graphics2D g2d = (Graphics2D) g.create(); if (text != null && !text.equals("")) { final View v = (View) b.getClientProperty(BasicHTML.propertyKey); if (v != null) { v.paint(g2d, textRect); } else { this.paintButtonText(g2d, b, textRect, text); } } // Paint the Icon if (icon != null) { icon.paintIcon(c, g2d, iconRect.x, iconRect.y); } if (b.isFocusPainted()) { if (b.hasFocus() || FadeTracker.getInstance().isTracked(c, FadeKind.FOCUS)) { // make sure that the focus ring is not clipped int focusRingPadding = SubstanceSizeUtils .getFocusRingPadding(SubstanceSizeUtils .getComponentFontSize(button)) / 2; SubstanceCoreUtilities.paintFocus(g2d, button, button, null, textRect, 1.0f, focusRingPadding); } } // g2d.setColor(Color.red); // g2d.draw(iconRect); // g2d.draw(viewRect); // g2d.draw(textRect); // g2d.setColor(Color.blue); // g2d.drawRect(0, 0, button.getWidth() - 1, button.getHeight() - 1); g2d.dispose(); } /** * Returns memory usage string. * * @return Memory usage string. */ public static String getMemoryUsage() { StringBuffer sb = new StringBuffer(); sb.append("SubstanceRadioButtonUI: \n"); sb.append("\t" + SubstanceRadioButtonUI.icons.size() + " icons"); return sb.toString(); } /** * Paints the text. * * @param g * Graphic context * @param button * Button * @param textRect * Text rectangle * @param text * Text to paint */ protected void paintButtonText(Graphics g, AbstractButton button, Rectangle textRect, String text) { SubstanceTextUtilities.paintText(g, button, textRect, text, button .getDisplayedMnemonicIndex()); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceFormattedTextFieldUI.java0000644000175000017500000001270411136475560027421 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.Color; import java.awt.Graphics; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.border.Border; import javax.swing.plaf.*; import javax.swing.plaf.basic.BasicBorders; import javax.swing.plaf.basic.BasicFormattedTextFieldUI; import org.jvnet.lafwidget.animation.FadeStateListener; import org.jvnet.substance.utils.*; import org.jvnet.substance.utils.border.SubstanceBorder; /** * UI for formatted text fields in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceFormattedTextFieldUI extends BasicFormattedTextFieldUI { /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /** * The associated formatted text field. */ protected JFormattedTextField textField; /** * Property change listener. */ protected PropertyChangeListener substancePropertyChangeListener; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceFormattedTextFieldUI(comp); } /** * Simple constructor. * * @param c * Component (formatted text field). */ public SubstanceFormattedTextFieldUI(JComponent c) { super(); this.textField = (JFormattedTextField) c; } @Override protected void installListeners() { super.installListeners(); this.substanceFadeStateListener = new FadeStateListener(this.textField, null, null); this.substanceFadeStateListener.registerListeners(false); this.substancePropertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("font".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { // remember the caret location - issue 404 int caretPos = textField.getCaretPosition(); textField.updateUI(); textField.setCaretPosition(caretPos); } }); } } }; this.textField .addPropertyChangeListener(this.substancePropertyChangeListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTextUI#uninstallListeners() */ @Override protected void uninstallListeners() { this.substanceFadeStateListener.unregisterListeners(); this.substanceFadeStateListener = null; this.textField .removePropertyChangeListener(this.substancePropertyChangeListener); this.substancePropertyChangeListener = null; super.uninstallListeners(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTextUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); Border b = this.textField.getBorder(); if (b == null || b instanceof UIResource) { Border newB = new BorderUIResource.CompoundBorderUIResource( new SubstanceBorder(SubstanceSizeUtils .getTextBorderInsets(SubstanceSizeUtils .getComponentFontSize(this.textField))), new BasicBorders.MarginBorder()); this.textField.setBorder(newB); } // support for per-window skins Color foregr = this.textField.getForeground(); if ((foregr == null) || (foregr instanceof UIResource)) { this.textField.setForeground(SubstanceColorUtilities .getForegroundColor(SubstanceLookAndFeel.getCurrentSkin( this.textField).getMainDefaultColorScheme())); } } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTextUI#paintBackground(java.awt.Graphics) */ @Override protected void paintBackground(Graphics g) { SubstanceTextUtilities.paintTextCompBackground(g, this.textField); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceInternalFrameUI.java0000644000175000017500000001576311136475560026422 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.Color; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.JComponent; import javax.swing.JInternalFrame; import javax.swing.JInternalFrame.JDesktopIcon; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicInternalFrameUI; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.SubstanceInternalFrameTitlePane; /** * UI for internal frames in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceInternalFrameUI extends BasicInternalFrameUI { /** * Title pane */ private SubstanceInternalFrameTitlePane titlePane; /** * Property listener on the associated internal frame. */ protected PropertyChangeListener substancePropertyListener; /** * Simple constructor. * * @param b * Associated internal frame. */ public SubstanceInternalFrameUI(JInternalFrame b) { super(b); } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceInternalFrameUI((JInternalFrame) comp); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicInternalFrameUI#createNorthPane(javax.swing * .JInternalFrame) */ @Override protected JComponent createNorthPane(JInternalFrame w) { this.titlePane = new SubstanceInternalFrameTitlePane(w); // f.putClientProperty(INTERNAL_FRAME_PINNED, Boolean.TRUE); return this.titlePane; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicInternalFrameUI#uninstallComponents() */ @Override protected void uninstallComponents() { this.titlePane.uninstall(); super.uninstallComponents(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicInternalFrameUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); this.substancePropertyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (JInternalFrame.IS_CLOSED_PROPERTY.equals(evt .getPropertyName())) { titlePane.uninstall(); JDesktopIcon jdi = frame.getDesktopIcon(); SubstanceDesktopIconUI ui = (SubstanceDesktopIconUI) jdi .getUI(); ui.uninstallIfNecessary(jdi); } if ("background".equals(evt.getPropertyName())) { Color newBackgr = (Color) evt.getNewValue(); if (!(newBackgr instanceof UIResource)) { getTitlePane().setBackground(newBackgr); frame.getDesktopIcon().setBackground(newBackgr); } } if ("ancestor".equals(evt.getPropertyName())) { // fix for issue 344 - reopening an internal frame // that has been closed. JDesktopIcon jdi = frame.getDesktopIcon(); SubstanceDesktopIconUI ui = (SubstanceDesktopIconUI) jdi .getUI(); ui.installIfNecessary(jdi); } } }; this.frame.addPropertyChangeListener(this.substancePropertyListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicInternalFrameUI#uninstallListeners() */ @Override protected void uninstallListeners() { this.frame.removePropertyChangeListener(this.substancePropertyListener); this.substancePropertyListener = null; super.uninstallListeners(); } // private class BorderListener1 extends BorderListener implements // SwingConstants { // // Rectangle getIconBounds() { // int xOffset = 5; // Rectangle rect = null; // // Icon icon = SubstanceInternalFrameUI.this.frame.getFrameIcon(); // if (icon != null) { // int iconY = ((SubstanceInternalFrameUI.this.titlePane.getHeight() / 2) - // (icon // .getIconHeight() / 2)); // rect = new Rectangle(xOffset, iconY, icon.getIconWidth(), icon // .getIconHeight()); // } // return rect; // } // // @Override // public void mouseClicked(MouseEvent e) { // if ((e.getClickCount() == 2) && (e.getSource() == // SubstanceInternalFrameUI.this.getNorthPane()) // && SubstanceInternalFrameUI.this.frame.isClosable() && // !SubstanceInternalFrameUI.this.frame.isIcon()) { // Rectangle rect = this.getIconBounds(); // if ((rect != null) && rect.contains(e.getX(), e.getY())) { // SubstanceInternalFrameUI.this.frame.doDefaultCloseAction(); // } else { // super.mouseClicked(e); // } // } else { // super.mouseClicked(e); // } // } // } // / End BorderListener Class // // /** // * Returns the MouseInputAdapter that will be installed // * on the TitlePane. // * // * @param w the JInternalFrame // * @return the MouseInputAdapter that will be installed // * on the TitlePane. // * @since 1.6 // */ // @Override // protected MouseInputAdapter createBorderListener(JInternalFrame w) { // return new BorderListener1(); // } // /** * Returns the title pane of the associated internal frame. This method is * for internal use only. * * @return Title pane of the associated internal frame. */ public SubstanceInternalFrameTitlePane getTitlePane() { return titlePane; } // @Override // public void update(Graphics g, JComponent c) { // super.update(g, c); // } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/0000755000175000017500000000000011256731150023202 5ustar drazzibdrazzibsubstance-5.3.orig/src/org/jvnet/substance/colorscheme/BaseLightColorScheme.java0000644000175000017500000000406211136475560030044 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; /** * Base class for light color schemes. * * @author Kirill Grouchnikov */ public abstract class BaseLightColorScheme extends BaseColorScheme { /** * Creates a new light color scheme. * * @param displayName * Display name for the color scheme. */ protected BaseLightColorScheme(String displayName) { super(displayName, false); } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/MetallicColorScheme.java0000644000175000017500000001023111136475562027731 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Metallic color scheme. The primary use of this color scheme is for * default controls of light skins. * * @author Kirill Grouchnikov */ public class MetallicColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(250, 252, 255); /** * The main extra light color. */ private static final Color mainExtraLightColor = new Color(240, 245, 250); /** * The main light color. */ private static final Color mainLightColor = new Color(200, 210, 220); /** * The main medium color. */ private static final Color mainMidColor = new Color(180, 185, 190); /** * The main dark color. */ private static final Color mainDarkColor = new Color(80, 85, 90); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(32, 37, 42); /** * The foreground color. */ private static final Color foregroundColor = new Color(15, 20, 25); /** * Creates a new Metallic color scheme. */ public MetallicColorScheme() { super("Metallic"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return MetallicColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return MetallicColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return MetallicColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return MetallicColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return MetallicColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return MetallicColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return MetallicColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/LightAquaColorScheme.java0000644000175000017500000001012011136475560030051 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Light aqua color scheme. * * @author Kirill Grouchnikov */ public class LightAquaColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(215, 238, 250); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(194, 224, 237); /** * The main light color. */ private static final Color mainLightColor = new Color(164, 227, 243); /** * The main medium color. */ private static final Color mainMidColor = new Color(112, 206, 239); /** * The main dark color. */ private static final Color mainDarkColor = new Color(32, 180, 226); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(44, 47, 140); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Light Aqua color scheme. */ public LightAquaColorScheme() { super("Light Aqua"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return LightAquaColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return LightAquaColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return LightAquaColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return LightAquaColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return LightAquaColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return LightAquaColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return LightAquaColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/BarbyPinkColorScheme.java0000644000175000017500000001011711136475560030061 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Barby pink color scheme. * * @author Kirill Grouchnikov */ public class BarbyPinkColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(240, 159, 242); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(239, 153, 235); /** * The main light color. */ private static final Color mainLightColor = new Color(238, 139, 230); /** * The main medium color. */ private static final Color mainMidColor = new Color(231, 95, 193); /** * The main dark color. */ private static final Color mainDarkColor = new Color(150, 30, 101); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(111, 29, 78); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Barby Pink color scheme. */ public BarbyPinkColorScheme() { super("Barby Pink"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return BarbyPinkColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return BarbyPinkColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return BarbyPinkColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return BarbyPinkColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return BarbyPinkColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return BarbyPinkColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return BarbyPinkColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/DerivedColorsResolverLight.java0000644000175000017500000001162511213147760031331 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; import org.jvnet.substance.api.SchemeDerivedColors; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Resolver of derived colors for light color schemes. This class is not * accessible outside the package and is for internal use only. * * @author Kirill Grouchnikov */ public class DerivedColorsResolverLight implements SchemeDerivedColors { /** * The original color scheme. */ SubstanceColorScheme scheme; /** * Creates the resolver of derived colors for the specified light color * scheme. * * @param scheme * The original color scheme. */ public DerivedColorsResolverLight(SubstanceColorScheme scheme) { if (scheme.isDark()) { throw new IllegalArgumentException("The scheme must be light: " + scheme.getDisplayName()); } this.scheme = scheme; } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getWatermarkStampColor() */ @Override public Color getWatermarkStampColor() { return SubstanceColorUtilities.getAlphaColor(this.scheme.getMidColor(), 50); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getWatermarkLightColor() */ public Color getWatermarkLightColor() { return this.scheme.getLightColor(); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getWatermarkDarkColor() */ public Color getWatermarkDarkColor() { return SubstanceColorUtilities.getAlphaColor( this.scheme.getDarkColor(), 15); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getLineColor() */ public Color getLineColor() { return SubstanceColorUtilities.getInterpolatedColor(this.scheme .getMidColor(), this.scheme.getDarkColor(), 0.7); } /* * (non-Javadoc) * * @see * org.jvnet.substance.api.SchemeDerivedColors#getSelectionForegroundColor() */ @Override public Color getSelectionForegroundColor() { return this.scheme.getUltraDarkColor().darker().darker(); } /* * (non-Javadoc) * * @see * org.jvnet.substance.api.SchemeDerivedColors#getSelectionBackgroundColor() */ @Override public Color getSelectionBackgroundColor() { return this.scheme.getExtraLightColor(); } /* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { return this.scheme.getDisplayName(); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getBackgroundFillColor() */ @Override public Color getBackgroundFillColor() { return this.scheme.getExtraLightColor(); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getFocusRingColor() */ @Override public Color getFocusRingColor() { return this.scheme.getDarkColor(); } /* * (non-Javadoc) * * @see * org.jvnet.substance.api.SchemeDerivedColors#getTextBackgroundFillColor() */ @Override public Color getTextBackgroundFillColor() { return SubstanceColorUtilities.getInterpolatedColor(this.scheme .getUltraLightColor(), this.scheme.getExtraLightColor(), 0.8); } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/JadeForestColorScheme.java0000644000175000017500000001011311136475560030222 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Jade Forest color scheme. * * @author Kirill Grouchnikov */ public class JadeForestColorScheme extends BaseDarkColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(40, 124, 22); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(45, 113, 19); /** * The main light color. */ private static final Color mainLightColor = new Color(39, 104, 17); /** * The main medium color. */ private static final Color mainMidColor = new Color(6, 53, 27); /** * The main dark color. */ private static final Color mainDarkColor = new Color(7, 38, 1); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(10, 23, 1); /** * The foreground color. */ private static final Color foregroundColor = Color.white; /** * Creates a new Jade Forest color scheme. */ public JadeForestColorScheme() { super("Jade Forest"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return JadeForestColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return JadeForestColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return JadeForestColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return JadeForestColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return JadeForestColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return JadeForestColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return JadeForestColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/BaseColorScheme.java0000644000175000017500000002074311243711500027042 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; import org.jvnet.substance.api.SchemeDerivedColors; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Base class for Substance color schemes. * * @author kirillg */ public abstract class BaseColorScheme implements SubstanceColorScheme { /** * Indicates whether this color scheme is dark. */ protected boolean isDark; /** * Display name of this color scheme. */ protected String displayName; /** * Resolver for the derived colors. */ protected SchemeDerivedColors derivedColorsResolver; /** * Constructs the basic functionality of a color scheme. * * @param displayName * Display name. * @param isDark * Indication whether the color scheme is dark. */ protected BaseColorScheme(String displayName, boolean isDark) { this.displayName = displayName; this.isDark = isDark; this.derivedColorsResolver = this.isDark ? new DerivedColorsResolverDark( this) : new DerivedColorsResolverLight(this); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.trait.SubstanceTrait#getDisplayName() */ @Override public String getDisplayName() { return this.displayName; } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SubstanceColorScheme#isDark() */ @Override public boolean isDark() { return this.isDark; } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SubstanceColorScheme#shift(java.awt.Color, * double, java.awt.Color, double) */ public SubstanceColorScheme shift(Color backgroundShiftColor, double backgroundShiftFactor, Color foregroundShiftColor, double foregroundShiftFactor) { return new ShiftColorScheme(this, backgroundShiftColor, backgroundShiftFactor, foregroundShiftColor, foregroundShiftFactor, true); } /* * (non-Javadoc) * * @see * org.jvnet.substance.api.SubstanceColorScheme#shiftBackground(java.awt * .Color, double) */ @Override public SubstanceColorScheme shiftBackground(Color backgroundShiftColor, double backgroundShiftFactor) { return this.shift(backgroundShiftColor, backgroundShiftFactor, null, 0.0); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SubstanceColorScheme#tint(double) */ public SubstanceColorScheme tint(double tintFactor) { return new TintColorScheme(this, tintFactor); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SubstanceColorScheme#tone(double) */ public SubstanceColorScheme tone(double toneFactor) { return new ToneColorScheme(this, toneFactor); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SubstanceColorScheme#shade(double) */ public SubstanceColorScheme shade(double shadeFactor) { return new ShadeColorScheme(this, shadeFactor); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SubstanceColorScheme#saturate(double) */ public SubstanceColorScheme saturate(double saturateFactor) { return new SaturatedColorScheme(this, saturateFactor); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SubstanceColorScheme#invert() */ public SubstanceColorScheme invert() { return new InvertedColorScheme(this); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SubstanceColorScheme#negate() */ public SubstanceColorScheme negate() { return new NegatedColorScheme(this); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SubstanceColorScheme#hueShift(double) */ public SubstanceColorScheme hueShift(double hueShiftFactor) { return new HueShiftColorScheme(this, hueShiftFactor); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getBackgroundFillColor() */ public Color getBackgroundFillColor() { return derivedColorsResolver.getBackgroundFillColor(); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getFocusRingColor() */ @Override public Color getFocusRingColor() { return derivedColorsResolver.getFocusRingColor(); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getLineColor() */ public Color getLineColor() { return derivedColorsResolver.getLineColor(); } /* * (non-Javadoc) * * @see * org.jvnet.substance.api.SchemeDerivedColors#getSelectionForegroundColor() */ public Color getSelectionForegroundColor() { return derivedColorsResolver.getSelectionForegroundColor(); } /* * (non-Javadoc) * * @see * org.jvnet.substance.api.SchemeDerivedColors#getSelectionBackgroundColor() */ @Override public Color getSelectionBackgroundColor() { return derivedColorsResolver.getSelectionBackgroundColor(); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getWatermarkDarkColor() */ public Color getWatermarkDarkColor() { return derivedColorsResolver.getWatermarkDarkColor(); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getWatermarkLightColor() */ public Color getWatermarkLightColor() { return derivedColorsResolver.getWatermarkLightColor(); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getWatermarkStampColor() */ @Override public Color getWatermarkStampColor() { return derivedColorsResolver.getWatermarkStampColor(); } /* * (non-Javadoc) * * @see * org.jvnet.substance.api.SchemeDerivedColors#getTextBackgroundFillColor() */ @Override public Color getTextBackgroundFillColor() { return derivedColorsResolver.getTextBackgroundFillColor(); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SubstanceColorScheme#named(java.lang.String) */ @Override public SubstanceColorScheme named(String colorSchemeDisplayName) { this.displayName = colorSchemeDisplayName; return this; } /* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { return this.getDisplayName() + " {\n kind=" + (this.isDark() ? "Dark" : "Light") + "\n colorUltraLight=" + SubstanceColorUtilities.encode(this.getUltraLightColor()) + "\n colorExtraLight=" + SubstanceColorUtilities.encode(this.getExtraLightColor()) + "\n colorLight=" + SubstanceColorUtilities.encode(this.getLightColor()) + "\n colorMid=" + SubstanceColorUtilities.encode(this.getMidColor()) + "\n colorDark=" + SubstanceColorUtilities.encode(this.getDarkColor()) + "\n colorUltraDark=" + SubstanceColorUtilities.encode(this.getUltraDarkColor()) + "\n colorForeground=" + SubstanceColorUtilities.encode(this.getForegroundColor()) + "\n}"; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/DesertSandColorScheme.java0000644000175000017500000001013311136475560030232 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Desert Sand color scheme. * * @author Kirill Grouchnikov */ public class DesertSandColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(204, 226, 135); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(187, 204, 170); /** * The main light color. */ private static final Color mainLightColor = new Color(182, 200, 119); /** * The main medium color. */ private static final Color mainMidColor = new Color(147, 157, 105); /** * The main dark color. */ private static final Color mainDarkColor = new Color(113, 120, 81); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(80, 96, 48); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Desert Sand color scheme. */ public DesertSandColorScheme() { super("Desert Sand"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return DesertSandColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return DesertSandColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return DesertSandColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return DesertSandColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return DesertSandColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return DesertSandColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return DesertSandColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/DerivedColorsResolverDark.java0000644000175000017500000001121111213150360031120 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; import org.jvnet.substance.api.SchemeDerivedColors; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Resolver of derived colors for dark color schemes. This class is not * accessible outside the package and is for internal use only. * * @author Kirill Grouchnikov */ class DerivedColorsResolverDark implements SchemeDerivedColors { /** * The original color scheme. */ SubstanceColorScheme scheme; /** * Creates the resolver of derived colors for the specified dark color * scheme. * * @param scheme * The original color scheme. */ public DerivedColorsResolverDark(SubstanceColorScheme scheme) { if (!scheme.isDark()) { throw new IllegalArgumentException("The scheme must be dark: " + scheme.getDisplayName()); } this.scheme = scheme; } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getWatermarkStampColor() */ @Override public Color getWatermarkStampColor() { return SubstanceColorUtilities.getAlphaColor(this.scheme .getUltraLightColor(), 30); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getWatermarkDarkColor() */ @Override public Color getWatermarkDarkColor() { return this.scheme.getLightColor(); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getWatermarkLightColor() */ public Color getWatermarkLightColor() { return this.scheme.getUltraLightColor(); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getLineColor() */ @Override public Color getLineColor() { return this.scheme.getMidColor(); } /* * (non-Javadoc) * * @see * org.jvnet.substance.api.SchemeDerivedColors#getSelectionForegroundColor() */ @Override public Color getSelectionForegroundColor() { return this.scheme.getUltraDarkColor().darker(); } /* * (non-Javadoc) * * @see * org.jvnet.substance.api.SchemeDerivedColors#getSelectionBackgroundColor() */ @Override public Color getSelectionBackgroundColor() { return this.scheme.getUltraLightColor().brighter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getBackgroundFillColor() */ @Override public Color getBackgroundFillColor() { return this.scheme.getDarkColor().brighter(); } /* * (non-Javadoc) * * @see org.jvnet.substance.api.SchemeDerivedColors#getFocusRingColor() */ @Override public Color getFocusRingColor() { return this.scheme.getUltraDarkColor(); } /* * (non-Javadoc) * * @see * org.jvnet.substance.api.SchemeDerivedColors#getTextBackgroundFillColor() */ @Override public Color getTextBackgroundFillColor() { return SubstanceColorUtilities.getInterpolatedColor(this.scheme .getMidColor(), this.scheme.getLightColor(), 0.4); } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/LimeGreenColorScheme.java0000644000175000017500000001010611136475562030047 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Lime green color scheme. * * @author Kirill Grouchnikov */ public class LimeGreenColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(205, 255, 85); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(172, 255, 54); /** * The main light color. */ private static final Color mainLightColor = new Color(169, 248, 57); /** * The main medium color. */ private static final Color mainMidColor = new Color(117, 232, 39); /** * The main dark color. */ private static final Color mainDarkColor = new Color(18, 86, 0); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(8, 62, 0); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Lime Green color scheme. */ public LimeGreenColorScheme() { super("Lime Green"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return LimeGreenColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return LimeGreenColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return LimeGreenColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return LimeGreenColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return LimeGreenColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return LimeGreenColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return LimeGreenColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/CharcoalColorScheme.java0000644000175000017500000001006011136475560027711 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Charcoal color scheme. * * @author Kirill Grouchnikov */ public class CharcoalColorScheme extends BaseDarkColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(110, 21, 27); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(94, 27, 36); /** * The main light color. */ private static final Color mainLightColor = new Color(61, 19, 29); /** * The main medium color. */ private static final Color mainMidColor = new Color(50, 20, 22); /** * The main dark color. */ private static final Color mainDarkColor = new Color(35, 15, 10); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(13, 8, 4); /** * The foreground color. */ private static final Color foregroundColor = Color.white; /** * Creates a new Charcoal color scheme. */ public CharcoalColorScheme() { super("Charcoal"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return CharcoalColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return CharcoalColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return CharcoalColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return CharcoalColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return CharcoalColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return CharcoalColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return CharcoalColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/ShiftColorScheme.java0000644000175000017500000002710611246717102027254 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.*; /** * Base class for shifted color schemes. A shifted color scheme is based on some * original color scheme, a shift color and a shift factor. All colors of the * original color scheme are shifted towards the shift color based on the shift * factor. The closer the shift factor value is to 1.0, the closer the colors of * the shifted color scheme will be to the shift color. * * @author Kirill Grouchnikov */ public class ShiftColorScheme extends BaseColorScheme { /** * Shift factor for background colors. */ private double backgroundShiftFactor; /** * Shift factor for foreground colors. */ private double foregroundShiftFactor; /** * Shift color for background colors. */ private Color backgroundShiftColor; /** * Shift color for foreground color. */ private Color foregroundShiftColor; /** * The main ultra-light color. */ private Color mainUltraLightColor; /** * The main extra-light color. */ private Color mainExtraLightColor; /** * The main light color. */ private Color mainLightColor; /** * The main medium color. */ private Color mainMidColor; /** * The main dark color. */ private Color mainDarkColor; /** * The main ultra-dark color. */ private Color mainUltraDarkColor; /** * The foreground color. */ private Color foregroundColor; /** * The original color scheme. */ private SubstanceColorScheme origScheme; /** * Cache of shifted schemes. */ protected final static LazyResettableHashMap shiftedCache = new LazyResettableHashMap( "ShiftColorScheme.shiftedSchemes"); /** * Creates a new shifted color scheme. * * @param origScheme * The original color scheme. * @param shiftColor * Shift color for the colors. * @param shiftFactor * Shift factor for the colors. Should be in 0.0-1.0 range. */ public ShiftColorScheme(SubstanceColorScheme origScheme, Color shiftColor, double shiftFactor) { this(origScheme, shiftColor, shiftFactor, shiftColor, shiftFactor / 2.0, false); } /** * Creates a new shifted color scheme. * * @param origScheme * The original color scheme. * @param backgroundShiftColor * Shift color for the background colors. * @param backgroundShiftFactor * Shift factor for the background colors. Should be in 0.0-1.0 * range. * @param foregroundShiftColor * Shift color for the foreground colors. * @param foregroundShiftFactor * Shift factor for the foreground colors. Should be in 0.0-1.0 * range. * @param shiftByBrightness * If true, the shift will account for the * brightness of the original color scheme colors. */ public ShiftColorScheme(SubstanceColorScheme origScheme, Color backgroundShiftColor, double backgroundShiftFactor, Color foregroundShiftColor, double foregroundShiftFactor, boolean shiftByBrightness) { super("Shift " + origScheme.getDisplayName() + " to backgr [" + backgroundShiftColor + "] " + (int) (100 * backgroundShiftFactor) + "%, foregr [" + foregroundShiftColor + "]" + (int) (100 * foregroundShiftFactor) + "%", origScheme .isDark()); this.backgroundShiftColor = backgroundShiftColor; this.backgroundShiftFactor = backgroundShiftFactor; this.foregroundShiftColor = foregroundShiftColor; this.foregroundShiftFactor = foregroundShiftFactor; this.origScheme = origScheme; this.foregroundColor = (this.foregroundShiftColor != null) ? SubstanceColorUtilities .getInterpolatedColor(this.foregroundShiftColor, origScheme .getForegroundColor(), this.foregroundShiftFactor) : origScheme.getForegroundColor(); shiftByBrightness = shiftByBrightness && (this.backgroundShiftColor != null); Color ultraDarkToShiftTo = shiftByBrightness ? SubstanceColorUtilities .deriveByBrightness(this.backgroundShiftColor, origScheme .getUltraDarkColor()) : this.backgroundShiftColor; this.mainUltraDarkColor = (this.backgroundShiftColor != null) ? SubstanceColorUtilities .getInterpolatedColor(ultraDarkToShiftTo, origScheme .getUltraDarkColor(), this.backgroundShiftFactor) : origScheme.getUltraDarkColor(); Color darkToShiftTo = shiftByBrightness ? SubstanceColorUtilities .deriveByBrightness(this.backgroundShiftColor, origScheme .getDarkColor()) : this.backgroundShiftColor; this.mainDarkColor = (this.backgroundShiftColor != null) ? SubstanceColorUtilities .getInterpolatedColor(darkToShiftTo, origScheme.getDarkColor(), this.backgroundShiftFactor) : origScheme.getDarkColor(); Color midToShiftTo = shiftByBrightness ? SubstanceColorUtilities .deriveByBrightness(this.backgroundShiftColor, origScheme .getMidColor()) : this.backgroundShiftColor; this.mainMidColor = (this.backgroundShiftColor != null) ? SubstanceColorUtilities .getInterpolatedColor(midToShiftTo, origScheme.getMidColor(), this.backgroundShiftFactor) : origScheme.getMidColor(); Color lightToShiftTo = shiftByBrightness ? SubstanceColorUtilities .deriveByBrightness(this.backgroundShiftColor, origScheme .getLightColor()) : this.backgroundShiftColor; this.mainLightColor = (this.backgroundShiftColor != null) ? SubstanceColorUtilities .getInterpolatedColor(lightToShiftTo, origScheme .getLightColor(), this.backgroundShiftFactor) : origScheme.getLightColor(); Color extraLightToShiftTo = shiftByBrightness ? SubstanceColorUtilities .deriveByBrightness(this.backgroundShiftColor, origScheme .getExtraLightColor()) : this.backgroundShiftColor; this.mainExtraLightColor = (this.backgroundShiftColor != null) ? SubstanceColorUtilities .getInterpolatedColor(extraLightToShiftTo, origScheme .getExtraLightColor(), this.backgroundShiftFactor) : origScheme.getExtraLightColor(); Color ultraLightToShiftTo = shiftByBrightness ? SubstanceColorUtilities .deriveByBrightness(this.backgroundShiftColor, origScheme .getUltraLightColor()) : this.backgroundShiftColor; this.mainUltraLightColor = (this.backgroundShiftColor != null) ? SubstanceColorUtilities .getInterpolatedColor(ultraLightToShiftTo, origScheme .getUltraLightColor(), this.backgroundShiftFactor) : origScheme.getUltraLightColor(); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return this.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return this.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return this.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return this.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return this.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return this.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return this.mainUltraDarkColor; } /** * Returns the original color scheme. * * @return The original color scheme. */ public SubstanceColorScheme getOrigScheme() { return this.origScheme; } /** * Returns the shift factor. * * @return Shift factor. */ public double getShiftFactor() { return this.backgroundShiftFactor; } /** * Returns a shifted color scheme. This method is for internal use only. * * @param orig * The original color scheme. * @param backgroundShiftColor * Shift color for the background color scheme colors. May be * null - in this case, the background color scheme * colors will not be shifted. * @param backgroundShiftFactor * Shift factor for the background color scheme colors. If the * shift color for the background color scheme colors is * null, this value is ignored. * @param foregroundShiftColor * Shift color for the foreground color scheme colors. May be * null - in this case, the foreground color scheme * colors will not be shifted. * @param foregroundShiftFactor * Shift factor for the foreground color scheme colors. If the * shift color for the foreground color scheme colors is * null, this value is ignored. * @return Shifted scheme. */ public static SubstanceColorScheme getShiftedScheme( SubstanceColorScheme orig, Color backgroundShiftColor, double backgroundShiftFactor, Color foregroundShiftColor, double foregroundShiftFactor) { HashMapKey key = SubstanceCoreUtilities.getHashKey(orig .getDisplayName(), backgroundShiftColor == null ? "" : backgroundShiftColor.getRGB(), backgroundShiftFactor, foregroundShiftColor == null ? "" : foregroundShiftColor .getRGB(), foregroundShiftFactor); SubstanceColorScheme result = shiftedCache.get(key); if (result == null) { result = orig.shift(backgroundShiftColor, backgroundShiftFactor, foregroundShiftColor, foregroundShiftFactor); shiftedCache.put(key, result); } return result; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/BottleGreenColorScheme.java0000644000175000017500000001013611136475560030413 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Bottle green color scheme. * * @author Kirill Grouchnikov */ public class BottleGreenColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(145, 209, 131); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(115, 197, 99); /** * The main light color. */ private static final Color mainLightColor = new Color(63, 181, 59); /** * The main medium color. */ private static final Color mainMidColor = new Color(6, 139, 58); /** * The main dark color. */ private static final Color mainDarkColor = new Color(11, 75, 38); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(0, 14, 14); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Bottle Green color scheme. */ public BottleGreenColorScheme() { super("Bottle Green"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return BottleGreenColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return BottleGreenColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return BottleGreenColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return BottleGreenColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return BottleGreenColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return BottleGreenColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return BottleGreenColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/NegatedColorScheme.java0000644000175000017500000001202511136475562027551 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Implementation of negated color scheme. Negated color scheme is based on some * original color scheme, negating all the colors. * * @author Kirill Grouchnikov */ public class NegatedColorScheme extends BaseColorScheme { /** * The main ultra-light color. */ private Color mainUltraLightColor; /** * The main extra-light color. */ private Color mainExtraLightColor; /** * The main light color. */ private Color mainLightColor; /** * The main medium color. */ private Color mainMidColor; /** * The main dark color. */ private Color mainDarkColor; /** * The main ultra-dark color. */ private Color mainUltraDarkColor; /** * The foreground color. */ private Color foregroundColor; /** * The original color scheme. */ private SubstanceColorScheme origScheme; /** * Creates a new inverted scheme. * * @param origScheme * The original color scheme. */ public NegatedColorScheme(SubstanceColorScheme origScheme) { super("Negated " + origScheme.getDisplayName(), !origScheme.isDark()); this.origScheme = origScheme; this.foregroundColor = SubstanceColorUtilities.invertColor(origScheme .getForegroundColor()); this.mainUltraDarkColor = SubstanceColorUtilities .invertColor(origScheme.getUltraDarkColor()); this.mainDarkColor = SubstanceColorUtilities.invertColor(origScheme .getDarkColor()); this.mainMidColor = SubstanceColorUtilities.invertColor(origScheme .getMidColor()); this.mainLightColor = SubstanceColorUtilities.invertColor(origScheme .getLightColor()); this.mainExtraLightColor = SubstanceColorUtilities .invertColor(origScheme.getExtraLightColor()); this.mainUltraLightColor = SubstanceColorUtilities .invertColor(origScheme.getUltraLightColor()); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return this.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return this.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return this.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return this.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return this.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return this.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return this.mainUltraDarkColor; } /** * Returns the original color scheme. * * @return The original color scheme. */ public SubstanceColorScheme getOrigScheme() { return this.origScheme; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/DarkGrayColorScheme.java0000644000175000017500000001017411136475560027707 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Dark gray color scheme. The primary use of this color scheme is for * disabled controls of dark skins. * * @author Kirill Grouchnikov */ public class DarkGrayColorScheme extends BaseDarkColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraDarkColor = new Color(5, 5, 5); /** * The main extra light color. */ private static final Color mainDarkColor = new Color(15, 15, 15); /** * The main light color. */ private static final Color mainMidColor = new Color(30, 30, 30); /** * The main medium color. */ private static final Color mainLightColor = new Color(45, 45, 45); /** * The main dark color. */ private static final Color mainExtraLightColor = new Color(75, 75, 75); /** * The main ultra-dark color. */ private static final Color mainUltraLightColor = new Color(155, 155, 155); /** * The foreground color. */ private static final Color foregroundColor = Color.white; /** * Creates a new color scheme. */ public DarkGrayColorScheme() { super("Dark Gray"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return DarkGrayColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return DarkGrayColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return DarkGrayColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return DarkGrayColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return DarkGrayColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return DarkGrayColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return DarkGrayColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/SunsetColorScheme.java0000644000175000017500000001004311136475562027461 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Sunset color scheme. * * @author Kirill Grouchnikov */ public class SunsetColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(255, 196, 56); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(255, 162, 45); /** * The main light color. */ private static final Color mainLightColor = new Color(255, 137, 41); /** * The main medium color. */ private static final Color mainMidColor = new Color(254, 97, 30); /** * The main dark color. */ private static final Color mainDarkColor = new Color(197, 19, 55); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(115, 38, 80); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Sunset color scheme. */ public SunsetColorScheme() { super("Sunset"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return SunsetColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return SunsetColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return SunsetColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return SunsetColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return SunsetColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return SunsetColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return SunsetColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/ShadeColorScheme.java0000644000175000017500000000454311136475562027234 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; /** * Shaded color scheme. A shaded color scheme is a color scheme that is shifted * to black color. * * @author Kirill Grouchnikov * @see ShiftColorScheme */ public class ShadeColorScheme extends ShiftColorScheme { /** * Creates a new shaded color scheme. * * @param origColorScheme * The original color scheme. * @param shadeFactor * The shade factor. Should be in 0.0-1.0 range. */ public ShadeColorScheme(SubstanceColorScheme origColorScheme, double shadeFactor) { super(origColorScheme, Color.black, shadeFactor); } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/SunGlareColorScheme.java0000644000175000017500000001007611136475562027726 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Sun Glare color scheme. * * @author Kirill Grouchnikov */ public class SunGlareColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(255, 255, 209); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(248, 249, 160); /** * The main light color. */ private static final Color mainLightColor = new Color(255, 255, 80); /** * The main medium color. */ private static final Color mainMidColor = new Color(252, 226, 55); /** * The main dark color. */ private static final Color mainDarkColor = new Color(106, 29, 0); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(67, 18, 0); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Sun Glare color scheme. */ public SunGlareColorScheme() { super("Sun Glare"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return SunGlareColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return SunGlareColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return SunGlareColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return SunGlareColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return SunGlareColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return SunGlareColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return SunGlareColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/EbonyColorScheme.java0000644000175000017500000001001511136475560027251 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Ebony color scheme. * * @author Kirill Grouchnikov */ public class EbonyColorScheme extends BaseDarkColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(85, 85, 85); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(75, 75, 75); /** * The main light color. */ private static final Color mainLightColor = new Color(60, 60, 60); /** * The main medium color. */ private static final Color mainMidColor = new Color(40, 40, 40); /** * The main dark color. */ private static final Color mainDarkColor = new Color(20, 20, 20); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(10, 10, 10); /** * The foreground color. */ private static final Color foregroundColor = Color.white; /** * Creates a new Ebony color scheme. */ public EbonyColorScheme() { super("Ebony"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return EbonyColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return EbonyColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return EbonyColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return EbonyColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return EbonyColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return EbonyColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return EbonyColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/SteelBlueColorScheme.java0000644000175000017500000001011611136475562030065 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Steel Blue color scheme. * * @author Kirill Grouchnikov */ public class SteelBlueColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(149, 193, 219); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(130, 181, 212); /** * The main light color. */ private static final Color mainLightColor = new Color(118, 165, 195); /** * The main medium color. */ private static final Color mainMidColor = new Color(108, 149, 178); /** * The main dark color. */ private static final Color mainDarkColor = new Color(38, 79, 111); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(47, 75, 99); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Steel Blue color scheme. */ public SteelBlueColorScheme() { super("Steel Blue"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return SteelBlueColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return SteelBlueColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return SteelBlueColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return SteelBlueColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return SteelBlueColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return SteelBlueColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return SteelBlueColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/BaseDarkColorScheme.java0000644000175000017500000000405511136475560027660 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; /** * Base class for dark color schemes. * * @author Kirill Grouchnikov */ public abstract class BaseDarkColorScheme extends BaseColorScheme { /** * Creates a new dark color scheme. * * @param displayName * Display name for the color scheme. */ protected BaseDarkColorScheme(String displayName) { super(displayName, true); } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/SepiaColorScheme.java0000644000175000017500000001003611136475562027243 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Sepia color scheme. * * @author Kirill Grouchnikov */ public class SepiaColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(220, 182, 150); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(205, 168, 135); /** * The main light color. */ private static final Color mainLightColor = new Color(195, 153, 128); /** * The main medium color. */ private static final Color mainMidColor = new Color(187, 151, 102); /** * The main dark color. */ private static final Color mainDarkColor = new Color(157, 102, 72); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(154, 106, 84); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Sepia color scheme. */ public SepiaColorScheme() { super("Sepia"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return SepiaColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return SepiaColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return SepiaColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return SepiaColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return SepiaColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return SepiaColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return SepiaColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/InvertedColorScheme.java0000644000175000017500000001211711136475560027762 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Implementation of inverted color scheme. Inverted color scheme is based on * some original color scheme, switching the dark colors by light colors and * inverting the foreground color. * * @author Kirill Grouchnikov */ public class InvertedColorScheme extends BaseColorScheme { /** * The main ultra-light color. */ private Color mainUltraLightColor; /** * The main extra-light color. */ private Color mainExtraLightColor; /** * The main light color. */ private Color mainLightColor; /** * The main medium color. */ private Color mainMidColor; /** * The main dark color. */ private Color mainDarkColor; /** * The main ultra-dark color. */ private Color mainUltraDarkColor; /** * The foreground color. */ private Color foregroundColor; /** * The original color scheme. */ private SubstanceColorScheme origScheme; /** * Creates a new inverted scheme. * * @param origScheme * The original color scheme. */ public InvertedColorScheme(SubstanceColorScheme origScheme) { super("Inverted " + origScheme.getDisplayName(), !origScheme.isDark()); this.origScheme = origScheme; this.foregroundColor = SubstanceColorUtilities.invertColor(origScheme .getForegroundColor()); this.mainUltraDarkColor = SubstanceColorUtilities .invertColor(origScheme.getUltraLightColor()); this.mainDarkColor = SubstanceColorUtilities.invertColor(origScheme .getExtraLightColor()); this.mainMidColor = SubstanceColorUtilities.invertColor(origScheme .getLightColor()); this.mainLightColor = SubstanceColorUtilities.invertColor(origScheme .getMidColor()); this.mainExtraLightColor = SubstanceColorUtilities .invertColor(origScheme.getDarkColor()); this.mainUltraLightColor = SubstanceColorUtilities .invertColor(origScheme.getUltraDarkColor()); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return this.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return this.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return this.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return this.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return this.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return this.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return this.mainUltraDarkColor; } /** * Returns the original color scheme. * * @return The original color scheme. */ public SubstanceColorScheme getOrigScheme() { return this.origScheme; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/BlendBiColorScheme.java0000644000175000017500000001553011162714534027477 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Blended color scheme. * * @author Kirill Grouchnikov */ public class BlendBiColorScheme extends BaseColorScheme { /** * The main ultra-light color. */ private Color mainUltraLightColor; /** * The main extra-light color. */ private Color mainExtraLightColor; /** * The main light color. */ private Color mainLightColor; /** * The main medium color. */ private Color mainMidColor; /** * The main dark color. */ private Color mainDarkColor; /** * The main ultra-dark color. */ private Color mainUltraDarkColor; /** * The foreground color. */ private Color foregroundColor; /** * The main original color scheme. */ private SubstanceColorScheme firstScheme; /** * The secondary original color scheme. */ private SubstanceColorScheme secondScheme; /** * Likeness to the first scheme. Values close to 0.0 will create scheme that * closely matches the second original scheme. Values close to 1.0 will * create scheme that closely matches the second original scheme. */ private double firstSchemeLikeness; /** * Creates a new blended color scheme. * * @param firstScheme * The first original color scheme. * @param secondScheme * The second original color scheme. * @param firstSchemeLikeness * Likeness to the first scheme. Values close to 0.0 will create * scheme that closely matches the second original scheme. Values * close to 1.0 will create scheme that closely matches the * second original scheme. */ public BlendBiColorScheme(SubstanceColorScheme firstScheme, SubstanceColorScheme secondScheme, double firstSchemeLikeness) { super("Blended " + firstScheme.getDisplayName() + " & " + secondScheme.getDisplayName() + " " + firstSchemeLikeness, firstScheme.isDark()); this.firstScheme = firstScheme; this.secondScheme = secondScheme; this.firstSchemeLikeness = firstSchemeLikeness; this.foregroundColor = new Color(SubstanceColorUtilities .getInterpolatedRGB(firstScheme.getForegroundColor(), secondScheme.getForegroundColor(), firstSchemeLikeness)); this.mainUltraDarkColor = new Color(SubstanceColorUtilities .getInterpolatedRGB(firstScheme.getUltraDarkColor(), secondScheme.getUltraDarkColor(), firstSchemeLikeness)); this.mainDarkColor = new Color(SubstanceColorUtilities .getInterpolatedRGB(firstScheme.getDarkColor(), secondScheme .getDarkColor(), firstSchemeLikeness)); this.mainMidColor = new Color(SubstanceColorUtilities .getInterpolatedRGB(firstScheme.getMidColor(), secondScheme .getMidColor(), firstSchemeLikeness)); this.mainLightColor = new Color(SubstanceColorUtilities .getInterpolatedRGB(firstScheme.getLightColor(), secondScheme .getLightColor(), firstSchemeLikeness)); this.mainExtraLightColor = new Color(SubstanceColorUtilities .getInterpolatedRGB(firstScheme.getExtraLightColor(), secondScheme.getExtraLightColor(), firstSchemeLikeness)); this.mainUltraLightColor = new Color(SubstanceColorUtilities .getInterpolatedRGB(firstScheme.getUltraLightColor(), secondScheme.getUltraLightColor(), firstSchemeLikeness)); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return this.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return this.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return this.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return this.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return this.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return this.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return this.mainUltraDarkColor; } /** * Returns the likeness to the first scheme. * * @return Likeness to the first scheme */ public double getFirstSchemeLikeness() { return this.firstSchemeLikeness; } /** * Returns the main original color scheme. * * @return The main original color scheme. */ public SubstanceColorScheme getFirstScheme() { return this.firstScheme; } /** * Returns the secondary original color scheme. * * @return The secondary original color scheme. */ public SubstanceColorScheme getSecondScheme() { return this.secondScheme; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/HueShiftColorScheme.java0000644000175000017500000001320111136475560027714 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Hue-shifted color scheme. A hue-shifted color scheme is a color scheme that * is hue-shifted in HSB space. * * @author Kirill Grouchnikov */ public class HueShiftColorScheme extends BaseColorScheme { /** * Hue-shift factor. */ private double hueShiftFactor; /** * The main ultra-light color. */ private Color mainUltraLightColor; /** * The main extra-light color. */ private Color mainExtraLightColor; /** * The main light color. */ private Color mainLightColor; /** * The main medium color. */ private Color mainMidColor; /** * The main dark color. */ private Color mainDarkColor; /** * The main ultra-dark color. */ private Color mainUltraDarkColor; /** * The foreground color. */ private Color foregroundColor; /** * The original color scheme. */ private SubstanceColorScheme origScheme; /** * Creates a new hue-shifted color scheme. * * @param origScheme * The original color scheme. * @param hueShiftFactor * Shift factor. Should be in -1.0-1.0 range. */ public HueShiftColorScheme(SubstanceColorScheme origScheme, double hueShiftFactor) { super("Hue-shift " + origScheme.getDisplayName() + " " + (int) (100 * hueShiftFactor) + "%", origScheme.isDark()); this.hueShiftFactor = hueShiftFactor; this.origScheme = origScheme; this.foregroundColor = SubstanceColorUtilities.getHueShiftedColor( origScheme.getForegroundColor(), this.hueShiftFactor / 2.0); this.mainUltraDarkColor = SubstanceColorUtilities.getHueShiftedColor( origScheme.getUltraDarkColor(), this.hueShiftFactor); this.mainDarkColor = SubstanceColorUtilities.getHueShiftedColor( origScheme.getDarkColor(), this.hueShiftFactor); this.mainMidColor = SubstanceColorUtilities.getHueShiftedColor( origScheme.getMidColor(), this.hueShiftFactor); this.mainLightColor = SubstanceColorUtilities.getHueShiftedColor( origScheme.getLightColor(), this.hueShiftFactor); this.mainExtraLightColor = SubstanceColorUtilities.getHueShiftedColor( origScheme.getExtraLightColor(), this.hueShiftFactor); this.mainUltraLightColor = SubstanceColorUtilities.getHueShiftedColor( origScheme.getUltraLightColor(), this.hueShiftFactor); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return this.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return this.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return this.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return this.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return this.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return this.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return this.mainUltraDarkColor; } /** * Returns the original color scheme. * * @return The original color scheme. */ public SubstanceColorScheme getOrigScheme() { return this.origScheme; } /** * Returns the hue-shift factor. * * @return Hue-shift factor. */ public double getHueShiftFactor() { return this.hueShiftFactor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/TintColorScheme.java0000644000175000017500000000453511136475562027127 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; /** * Tinted color scheme. A tinted color scheme is a color scheme that is shifted * to white color. * * @author Kirill Grouchnikov * @see ShiftColorScheme */ public class TintColorScheme extends ShiftColorScheme { /** * Creates a new tinted color scheme. * * @param origColorScheme * The original color scheme. * @param tintFactor * The tint factor. Should be in 0.0-1.0 range. */ public TintColorScheme(SubstanceColorScheme origColorScheme, double tintFactor) { super(origColorScheme, Color.white, tintFactor); } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/OrangeColorScheme.java0000644000175000017500000001003311136475562027412 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Orange color scheme. * * @author Kirill Grouchnikov */ public class OrangeColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ public static final Color mainUltraLightColor = new Color(255, 250, 235); /** * The main light color. */ public static final Color mainExtraLightColor = new Color(255, 220, 180); /** * The main light color. */ public static final Color mainLightColor = new Color(245, 200, 128); /** * The main medium color. */ public static final Color mainMidColor = new Color(240, 170, 50); /** * The main dark color. */ public static final Color mainDarkColor = new Color(229, 151, 0); /** * The main ultra-dark color. */ public static final Color mainUltraDarkColor = new Color(180, 100, 0); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Orange color scheme. */ public OrangeColorScheme() { super("Orange"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return OrangeColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return OrangeColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return OrangeColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return OrangeColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return OrangeColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return OrangeColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return OrangeColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/DarkMetallicColorScheme.java0000644000175000017500000001026111136475560030534 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Dark metallic color scheme. The primary use of this color scheme is * for default controls of dark skins. * * @author Kirill Grouchnikov */ public class DarkMetallicColorScheme extends BaseDarkColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraDarkColor = new Color(5, 3, 0); /** * The main extra light color. */ private static final Color mainDarkColor = new Color(15, 10, 5); /** * The main light color. */ private static final Color mainMidColor = new Color(55, 45, 35); /** * The main medium color. */ private static final Color mainLightColor = new Color(75, 70, 65); /** * The main dark color. */ private static final Color mainExtraLightColor = new Color(90, 85, 80); /** * The main ultra-dark color. */ private static final Color mainUltraLightColor = new Color(100, 90, 85); /** * The foreground color. */ private static final Color foregroundColor = Color.white; /** * Creates a new Dark Metallic color scheme. */ public DarkMetallicColorScheme() { super("Dark Metallic"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return DarkMetallicColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return DarkMetallicColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return DarkMetallicColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return DarkMetallicColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return DarkMetallicColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return DarkMetallicColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return DarkMetallicColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/LightGrayColorScheme.java0000644000175000017500000001026211136475562030075 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Light gray color scheme. The primary use of this color scheme is for * disabled controls of light skins. * * @author Kirill Grouchnikov */ public class LightGrayColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(250, 251, 252); /** * The main extra light color. */ private static final Color mainExtraLightColor = new Color(240, 242, 244); /** * The main light color. */ private static final Color mainLightColor = new Color(225, 228, 231); /** * The main medium color. */ private static final Color mainMidColor = new Color(210, 214, 218); /** * The main dark color. */ private static final Color mainDarkColor = new Color(180, 185, 190); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(100, 106, 112); /** * The foreground color. */ private static final Color foregroundColor = new Color(120, 125, 130); /** * Creates a new Light Gray color scheme. */ public LightGrayColorScheme() { super("Light Gray"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return LightGrayColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return LightGrayColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return LightGrayColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return LightGrayColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return LightGrayColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return LightGrayColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return LightGrayColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/PurpleColorScheme.java0000644000175000017500000001005111136475562027446 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Purple color scheme. * * @author Kirill Grouchnikov */ public class PurpleColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(240, 220, 245); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(218, 209, 233); /** * The main light color. */ private static final Color mainLightColor = new Color(203, 175, 237); /** * The main medium color. */ private static final Color mainMidColor = new Color(201, 135, 226); /** * The main dark color. */ private static final Color mainDarkColor = new Color(140, 72, 170); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(94, 39, 114); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Purple color scheme. */ public PurpleColorScheme() { super("Purple"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return PurpleColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return PurpleColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return PurpleColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return PurpleColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return PurpleColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return PurpleColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return PurpleColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/SunfireRedColorScheme.java0000644000175000017500000001012711136475562030251 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Sunfire Red color scheme. * * @author Kirill Grouchnikov */ public class SunfireRedColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(225, 139, 166); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(218, 110, 130); /** * The main light color. */ private static final Color mainLightColor = new Color(215, 42, 23); /** * The main medium color. */ private static final Color mainMidColor = new Color(224, 20, 10); /** * The main dark color. */ private static final Color mainDarkColor = new Color(170, 28, 23); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(129, 23, 15); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Sunfire Red color scheme. */ public SunfireRedColorScheme() { super("Sunfire Red"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return SunfireRedColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return SunfireRedColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return SunfireRedColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return SunfireRedColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return SunfireRedColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return SunfireRedColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return SunfireRedColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/AquaColorScheme.java0000644000175000017500000001001711136475560027066 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Aqua color scheme. * * @author Kirill Grouchnikov */ public class AquaColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(194, 224, 237); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(164, 227, 243); /** * The main light color. */ private static final Color mainLightColor = new Color(112, 206, 239); /** * The main medium color. */ private static final Color mainMidColor = new Color(32, 180, 226); /** * The main dark color. */ private static final Color mainDarkColor = new Color(44, 47, 140); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(30, 40, 100); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Aqua color scheme. */ public AquaColorScheme() { super("Aqua"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return AquaColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return AquaColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return AquaColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return AquaColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return AquaColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return AquaColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return AquaColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/DarkVioletColorScheme.java0000644000175000017500000001012311136475560030241 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Dark violet color scheme. * * @author Kirill Grouchnikov */ public class DarkVioletColorScheme extends BaseDarkColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(107, 22, 124); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(89, 19, 113); /** * The main light color. */ private static final Color mainLightColor = new Color(83, 17, 104); /** * The main medium color. */ private static final Color mainMidColor = new Color(53, 6, 31); /** * The main dark color. */ private static final Color mainDarkColor = new Color(33, 1, 38); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(15, 1, 23); /** * The foreground color. */ private static final Color foregroundColor = Color.white;// new /** * Creates a new Dark Violet color scheme. */ public DarkVioletColorScheme() { super("Dark Violet"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return DarkVioletColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return DarkVioletColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return DarkVioletColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return DarkVioletColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return DarkVioletColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return DarkVioletColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return DarkVioletColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/BrownColorScheme.java0000644000175000017500000001003111136475560027262 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Brown color scheme. * * @author Kirill Grouchnikov */ public class BrownColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(240, 230, 170); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(230, 219, 142); /** * The main light color. */ private static final Color mainLightColor = new Color(217, 179, 89); /** * The main medium color. */ private static final Color mainMidColor = new Color(190, 137, 27); /** * The main dark color. */ private static final Color mainDarkColor = new Color(162, 90, 26); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(94, 71, 57); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Brown color scheme. */ public BrownColorScheme() { super("Brown"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return BrownColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return BrownColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return BrownColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return BrownColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return BrownColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return BrownColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return BrownColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/RaspberryColorScheme.java0000644000175000017500000001010611136475562030151 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Raspberry color scheme. * * @author Kirill Grouchnikov */ public class RaspberryColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(254, 166, 189); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(255, 152, 177); /** * The main light color. */ private static final Color mainLightColor = new Color(251, 110, 144); /** * The main medium color. */ private static final Color mainMidColor = new Color(225, 52, 98); /** * The main dark color. */ private static final Color mainDarkColor = new Color(84, 28, 41); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(40, 0, 9); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Raspberry color scheme. */ public RaspberryColorScheme() { super("Raspberry"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return RaspberryColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return RaspberryColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return RaspberryColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return RaspberryColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return RaspberryColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return RaspberryColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return RaspberryColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/TerracottaColorScheme.java0000644000175000017500000001013011136475562030305 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Terracotta color scheme. * * @author Kirill Grouchnikov */ public class TerracottaColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(250, 203, 125); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(248, 191, 114); /** * The main light color. */ private static final Color mainLightColor = new Color(239, 176, 105); /** * The main medium color. */ private static final Color mainMidColor = new Color(227, 147, 88); /** * The main dark color. */ private static final Color mainDarkColor = new Color(195, 113, 63); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(163, 87, 64); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Terracotta color scheme. */ public TerracottaColorScheme() { super("Terracotta"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return TerracottaColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return TerracottaColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return TerracottaColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return TerracottaColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return TerracottaColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return TerracottaColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return TerracottaColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/UltramarineColorScheme.java0000644000175000017500000001012411136475562030463 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Ultramarine color scheme. * * @author Kirill Grouchnikov */ public class UltramarineColorScheme extends BaseDarkColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(46, 22, 124); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(33, 19, 113); /** * The main light color. */ private static final Color mainLightColor = new Color(31, 17, 104); /** * The main medium color. */ private static final Color mainMidColor = new Color(47, 6, 53); /** * The main dark color. */ private static final Color mainDarkColor = new Color(11, 1, 38); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(2, 1, 23); /** * The foreground color. */ private static final Color foregroundColor = Color.white; /** * Creates a new Ultramarine color scheme. */ public UltramarineColorScheme() { super("Ultramarine"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return UltramarineColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return UltramarineColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return UltramarineColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return UltramarineColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return UltramarineColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return UltramarineColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return UltramarineColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/SaturatedColorScheme.java0000644000175000017500000001311611136475562030140 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorUtilities; /** * Saturated color scheme. A saturated color scheme is a color scheme that is * saturated / desaturated (using HSV). * * @author Kirill Grouchnikov * @see ShiftColorScheme */ public class SaturatedColorScheme extends BaseColorScheme { /** * Shift factor. */ private double saturationFactor; /** * The main ultra-light color. */ private Color mainUltraLightColor; /** * The main extra-light color. */ private Color mainExtraLightColor; /** * The main light color. */ private Color mainLightColor; /** * The main medium color. */ private Color mainMidColor; /** * The main dark color. */ private Color mainDarkColor; /** * The main ultra-dark color. */ private Color mainUltraDarkColor; /** * The foreground color. */ private Color foregroundColor; /** * The original color scheme. */ private SubstanceColorScheme origScheme; /** * Creates a new saturated color scheme. * * @param origScheme * The original color scheme. * @param saturationFactor * Saturation factor. Should be in -1.0..1.0 range. */ public SaturatedColorScheme(SubstanceColorScheme origScheme, double saturationFactor) { super("Saturated (" + (int) (100 * saturationFactor) + "%) " + origScheme.getDisplayName(), origScheme.isDark()); this.saturationFactor = saturationFactor; this.origScheme = origScheme; this.foregroundColor = origScheme.getForegroundColor(); this.mainUltraDarkColor = SubstanceColorUtilities.getSaturatedColor( origScheme.getUltraDarkColor(), saturationFactor); this.mainDarkColor = SubstanceColorUtilities.getSaturatedColor( origScheme.getDarkColor(), saturationFactor); this.mainMidColor = SubstanceColorUtilities.getSaturatedColor( origScheme.getMidColor(), saturationFactor); this.mainLightColor = SubstanceColorUtilities.getSaturatedColor( origScheme.getLightColor(), saturationFactor); this.mainExtraLightColor = SubstanceColorUtilities.getSaturatedColor( origScheme.getExtraLightColor(), saturationFactor); this.mainUltraLightColor = SubstanceColorUtilities.getSaturatedColor( origScheme.getUltraLightColor(), saturationFactor); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return this.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return this.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return this.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return this.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return this.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return this.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return this.mainUltraDarkColor; } /** * Returns the original color scheme. * * @return The original color scheme. */ public SubstanceColorScheme getOrigScheme() { return this.origScheme; } /** * Returns the saturation factor. * * @return Saturation factor. */ public double getSaturationFactor() { return this.saturationFactor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/OliveColorScheme.java0000644000175000017500000001003711136475562027261 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Olive color scheme. * * @author Kirill Grouchnikov */ public class OliveColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(205, 212, 182); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(189, 192, 165); /** * The main light color. */ private static final Color mainLightColor = new Color(175, 183, 142); /** * The main medium color. */ private static final Color mainMidColor = new Color(165, 174, 129); /** * The main dark color. */ private static final Color mainDarkColor = new Color(135, 142, 102); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(104, 111, 67); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Olive color scheme. */ public OliveColorScheme() { super("Olive"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return OliveColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return OliveColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return OliveColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return OliveColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return OliveColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return OliveColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return OliveColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/CremeColorScheme.java0000644000175000017500000001004011136475560027226 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; /** * Brown color scheme. * * @author Kirill Grouchnikov */ public class CremeColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(254, 254, 252); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(238, 243, 230); /** * The main light color. */ private static final Color mainLightColor = new Color(235, 234, 225); /** * The main medium color. */ private static final Color mainMidColor = new Color(227, 228, 219); /** * The main dark color. */ private static final Color mainDarkColor = new Color(179, 182, 176); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(178, 168, 153); /** * The foreground color. */ private static final Color foregroundColor = Color.black; /** * Creates a new Creme color scheme. */ public CremeColorScheme() { super("Creme"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return CremeColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return CremeColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return CremeColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return CremeColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return CremeColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return CremeColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return CremeColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/org/jvnet/substance/colorscheme/ToneColorScheme.java0000644000175000017500000000453011136475562027111 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance.colorscheme; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; /** * Toned color scheme. A toned color scheme is a color scheme that is shifted to * gray color. * * @author Kirill Grouchnikov * @see ShiftColorScheme */ public class ToneColorScheme extends ShiftColorScheme { /** * Creates a new toned color scheme. * * @param origColorScheme * The original color scheme. * @param toneFactor * The tone factor. Should be in 0.0-1.0 range. */ public ToneColorScheme(SubstanceColorScheme origColorScheme, double toneFactor) { super(origColorScheme, Color.gray, toneFactor); } } substance-5.3.orig/src/org/jvnet/substance/SubstanceDesktopIconUI.java0000644000175000017500000002132311136475560026102 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import javax.swing.JComponent; import javax.swing.UIManager; import javax.swing.JInternalFrame.JDesktopIcon; import javax.swing.event.MouseInputListener; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; import javax.swing.plaf.basic.BasicDesktopIconUI; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.utils.*; /** * UI for desktop icons in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceDesktopIconUI extends BasicDesktopIconUI { /** * Listener on the title label (for the dragging purposes). */ private MouseInputListener substanceLabelMouseInputListener; /** * Width of minimized component (desktop icon). */ private int width; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceDesktopIconUI(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicDesktopIconUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); Font f = this.desktopIcon.getFont(); if ((f == null) || (f instanceof UIResource)) { this.desktopIcon.setFont(UIManager.getFont("DesktopIcon.font")); } this.width = UIManager.getInt("DesktopIcon.width"); this.desktopIcon.setBackground(SubstanceColorSchemeUtilities .getColorScheme(this.desktopIcon.getInternalFrame(), ComponentState.ACTIVE).getBackgroundFillColor()); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicDesktopIconUI#installComponents() */ @Override protected void installComponents() { this.frame = this.desktopIcon.getInternalFrame(); // this.frame.setOpaque(false); // Icon icon = this.frame.getFrameIcon(); this.iconPane = new SubstanceInternalFrameTitlePane(this.frame); this.iconPane.setOpaque(false); this.desktopIcon.setLayout(new BorderLayout()); this.desktopIcon.add(this.iconPane, BorderLayout.CENTER); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicDesktopIconUI#uninstallComponents() */ @Override protected void uninstallComponents() { ((SubstanceInternalFrameTitlePane) this.iconPane).uninstall(); this.desktopIcon.setLayout(null); this.desktopIcon.remove(this.iconPane); this.frame = null; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicDesktopIconUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); this.substanceLabelMouseInputListener = this.createMouseInputListener(); this.iconPane .addMouseMotionListener(this.substanceLabelMouseInputListener); this.iconPane.addMouseListener(this.substanceLabelMouseInputListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicDesktopIconUI#uninstallListeners() */ @Override protected void uninstallListeners() { ((SubstanceInternalFrameTitlePane) this.iconPane).uninstallListeners(); this.iconPane .removeMouseMotionListener(this.substanceLabelMouseInputListener); this.iconPane .removeMouseListener(this.substanceLabelMouseInputListener); this.substanceLabelMouseInputListener = null; super.uninstallListeners(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.ComponentUI#getPreferredSize(javax.swing.JComponent) */ @Override public Dimension getPreferredSize(JComponent c) { // Desktop icons can not be resized. Their dimensions should // always be the minimum size. See getMinimumSize(JComponent c). return this.getMinimumSize(c); } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#getMinimumSize(javax.swing.JComponent) */ @Override public Dimension getMinimumSize(JComponent c) { // For the desktop icon we will use the layout maanger to // determine the correct height of the component, but we want to keep // the width consistent according to the jlf spec. return new Dimension(this.width, this.desktopIcon.getLayout() .minimumLayoutSize(this.desktopIcon).height); } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#getMaximumSize(javax.swing.JComponent) */ @Override public Dimension getMaximumSize(JComponent c) { // Desktop icons can not be resized. Their dimensions should // always be the minimum size. See getMinimumSize(JComponent c). return this.getMinimumSize(c); } // /* // * (non-Javadoc) // * // * @see javax.swing.plaf.ComponentUI#paint(java.awt.Graphics, // * javax.swing.JComponent) // */ // @Override // public void paint(Graphics g, JComponent c) { // JInternalFrame.JDesktopIcon di = (JInternalFrame.JDesktopIcon) c; // di.setOpaque(false); // // int width = di.getWidth(); // int height = di.getHeight(); // // Graphics2D graphics = (Graphics2D) g.create(); // // the background is translucent // // graphics.setComposite(AlphaComposite.getInstance( // // AlphaComposite.SRC_ATOP, 0.6f)); // // // // SubstanceImageCreator.paintRectangularBackground(graphics, 0, 0, // // width, // // height, SubstanceCoreUtilities.getActiveScheme(this.desktopIcon // // .getInternalFrame()), false, false); // // di.paintComponents(graphics); // // graphics.dispose(); // } // // /* // * (non-Javadoc) // * // * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, // * javax.swing.JComponent) // */ // @Override // public void update(Graphics g, JComponent c) { // this.paint(g, c); // } // /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicDesktopIconUI#installUI(javax.swing.JComponent * ) */ @Override public void installUI(JComponent c) { super.installUI(c); c.setOpaque(false); } @Override public void uninstallUI(JComponent c) { // desktopIcon.remove(this.titleLabel); // super.uninstallUI(c); SubstanceInternalFrameTitlePane thePane = (SubstanceInternalFrameTitlePane) this.iconPane; super.uninstallUI(c); thePane.uninstallListeners(); } /** * Returns the component for desktop icon hover (internal frame preview) * functionality. * * @return The component for desktop icon hover (internal frame preview) * functionality. */ public JComponent getComponentForHover() { return this.iconPane; } /** * Installs the UI delegate on the desktop icon if necessary. * * @param jdi * Desktop icon. */ public void installIfNecessary(JDesktopIcon jdi) { // fix for issue 344 - reopening an internal frame // that has been closed. if (this.desktopIcon == null) { this.installUI(jdi); } } /** * Uninstalls the UI delegate from the desktop icon if necessary. * * @param jdi * Desktop icon. */ public void uninstallIfNecessary(JDesktopIcon jdi) { // fix for issue 345 - an internal frame used in inner option pane // gets closed twice if (this.desktopIcon == jdi) { this.uninstallUI(jdi); } } } substance-5.3.orig/src/org/jvnet/substance/SubstanceToolBarUI.java0000644000175000017500000001005111245202246025204 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.Component; import java.awt.Graphics; import javax.swing.JComponent; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicToolBarUI; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.utils.BackgroundPaintingUtils; import org.jvnet.substance.painter.utils.DecorationPainterUtils; import org.jvnet.substance.utils.SubstanceCoreUtilities; /** * UI for tool bars in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceToolBarUI extends BasicToolBarUI { /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceToolBarUI(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicToolBarUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); SubstanceLookAndFeel.setDecorationType(this.toolBar, DecorationAreaType.TOOLBAR); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicToolBarUI#uninstallDefaults() */ @Override protected void uninstallDefaults() { DecorationPainterUtils.clearDecorationType(this.toolBar); super.uninstallDefaults(); } /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#update(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void update(Graphics g, JComponent c) { boolean isOpaque = TransitionLayout.isOpaque(c); if (isOpaque) { BackgroundPaintingUtils.update(g, c, false); } else { super.update(g, c); } } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicToolBarUI#setBorderToRollover(java.awt.Component * ) */ @Override protected void setBorderToRollover(Component c) { } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicToolBarUI#setBorderToNonRollover(java.awt * .Component) */ @Override protected void setBorderToNonRollover(Component c) { } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicToolBarUI#setBorderToNormal(java.awt.Component * ) */ @Override protected void setBorderToNormal(Component c) { } } substance-5.3.orig/src/org/jvnet/substance/SubstanceToolBarSeparatorUI.java0000644000175000017500000000721211162645550027101 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.*; import javax.swing.*; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicToolBarSeparatorUI; import org.jvnet.substance.painter.utils.SeparatorPainterUtils; import org.jvnet.substance.utils.SubstanceCoreUtilities; /** * UI for toolbar separators in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceToolBarSeparatorUI extends BasicToolBarSeparatorUI { public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceToolBarSeparatorUI(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicSeparatorUI#paint(java.awt.Graphics, * javax.swing.JComponent) */ @Override public void paint(Graphics g, JComponent c) { Graphics2D graphics = (Graphics2D) g.create(); SeparatorPainterUtils.paintSeparator(c, graphics, c.getWidth(), c .getHeight(), ((JSeparator) c).getOrientation()); graphics.dispose(); } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicToolBarSeparatorUI#getPreferredSize(javax * .swing.JComponent) */ @Override public Dimension getPreferredSize(JComponent c) { Dimension size = ((JToolBar.Separator) c).getSeparatorSize(); if (size != null) { size = size.getSize(); } else { size = new Dimension(6, 6); if (((JSeparator) c).getOrientation() == SwingConstants.VERTICAL) { size.height = 0; } else { size.width = 0; } } return size; } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicSeparatorUI#getMaximumSize(javax.swing.JComponent * ) */ @Override public Dimension getMaximumSize(JComponent c) { Dimension pref = getPreferredSize(c); if (((JSeparator) c).getOrientation() == SwingConstants.VERTICAL) { return new Dimension(pref.width, Short.MAX_VALUE); } else { return new Dimension(Short.MAX_VALUE, pref.height); } } } substance-5.3.orig/src/org/jvnet/substance/SubstanceEditorPaneUI.java0000644000175000017500000001275411167404326025716 0ustar drazzibdrazzib/* * Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.jvnet.substance; import java.awt.Color; import java.awt.Graphics; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.plaf.*; import javax.swing.plaf.basic.BasicBorders; import javax.swing.plaf.basic.BasicEditorPaneUI; import org.jvnet.lafwidget.animation.FadeStateListener; import org.jvnet.substance.utils.*; /** * UI for editor panes in Substance look and feel. * * @author Kirill Grouchnikov */ public class SubstanceEditorPaneUI extends BasicEditorPaneUI { /** * Listener for fade animations. */ protected FadeStateListener substanceFadeStateListener; /** * The associated editor pane. */ protected JEditorPane editorPane; /** * Property change listener. */ protected PropertyChangeListener substancePropertyChangeListener; /* * (non-Javadoc) * * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent) */ public static ComponentUI createUI(JComponent comp) { SubstanceCoreUtilities.testComponentCreationThreadingViolation(comp); return new SubstanceEditorPaneUI(comp); } /** * Simple constructor. * * @param c * Component (editor pane). */ public SubstanceEditorPaneUI(JComponent c) { super(); this.editorPane = (JEditorPane) c; } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTextUI#installListeners() */ @Override protected void installListeners() { super.installListeners(); super.installListeners(); this.substanceFadeStateListener = new FadeStateListener( this.editorPane, null, null); this.substanceFadeStateListener.registerListeners(false); this.substancePropertyChangeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("font".equals(evt.getPropertyName())) { SwingUtilities.invokeLater(new Runnable() { public void run() { // remember the caret location - issue 404 int caretPos = editorPane.getCaretPosition(); editorPane.updateUI(); editorPane.setCaretPosition(caretPos); } }); } } }; this.editorPane .addPropertyChangeListener(this.substancePropertyChangeListener); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTextUI#uninstallListeners() */ @Override protected void uninstallListeners() { this.substanceFadeStateListener.unregisterListeners(); this.substanceFadeStateListener = null; this.editorPane .removePropertyChangeListener(this.substancePropertyChangeListener); this.substancePropertyChangeListener = null; super.uninstallListeners(); } /* * (non-Javadoc) * * @see javax.swing.plaf.basic.BasicTextUI#installDefaults() */ @Override protected void installDefaults() { super.installDefaults(); Border b = this.editorPane.getBorder(); if (b == null || b instanceof UIResource) { Border newB = new BorderUIResource.CompoundBorderUIResource( new EmptyBorder(SubstanceSizeUtils .getTextBorderInsets(SubstanceSizeUtils .getComponentFontSize(this.editorPane))), new BasicBorders.MarginBorder()); this.editorPane.setBorder(newB); } // support for per-window skins Color foregr = this.editorPane.getForeground(); if ((foregr == null) || (foregr instanceof UIResource)) { this.editorPane.setForeground(SubstanceColorUtilities .getForegroundColor(SubstanceLookAndFeel.getCurrentSkin( this.editorPane).getMainDefaultColorScheme())); } } /* * (non-Javadoc) * * @see * javax.swing.plaf.basic.BasicTextUI#paintBackground(java.awt.Graphics) */ @Override protected void paintBackground(Graphics g) { SubstanceTextUtilities.paintTextCompBackground(g, this.editorPane); } } substance-5.3.orig/src/resource/0000755000175000017500000000000011256731152016624 5ustar drazzibdrazzibsubstance-5.3.orig/src/resource/drive-harddisk.png0000644000175000017500000000113310623727444022236 0ustar drazzibdrazzibPNG  IHDRabKGD pHYs  tIME5|wtEXtCommentMenu-sized icon ========== (c) 2003 Jakub 'jimmac' Steiner, http://jimmac.musichall.cz created with the GIMP, http://www.gimp.orggGPIDAT8˥Mn0@ &j$p7$ ސ'@,Al"(U{~3E6O'Zc9lU(ձL@Cf3bE!}@ *H'D>S=Ы TeYFuLAEQ . 땪0Ɛ)Ʉc@$ btk-{vPv;mmKa<m[=㑪PUT$I8c97*"|2N#hLE ,ZKYwj\2gzվU&l IENDB`substance-5.3.orig/src/resource/folder-new.png0000644000175000017500000000117310623730324021373 0ustar drazzibdrazzibPNG  IHDRabKGDC pHYs B(xtIME UO-IDAT8˥=hSaޖ{SI۴$ V\JEAM]AP['qpE.@%-A-Bh!?!!AŇ܍L&s5hkU_z>MP\g/[}C(˧=}$?  il ci1 l22v\ޛБl*gH֡(UmSk繼Pa3. rf_>cvMl/~p0Urs0~d4Ydi1S(e`6H<%A4jF')εbm;M  T -v[7H0t]|TtZ|}OT#[mm:%b@VXF"R AbH 0"duE\6%,V4_=EP ԅ0Z`={QmAP pkk/Ggs]H"/\7ᚩIENDB`substance-5.3.orig/src/resource/32/0000755000175000017500000000000011256731152017050 5ustar drazzibdrazzibsubstance-5.3.orig/src/resource/32/dialog-information.png0000644000175000017500000000356610623714516023354 0ustar drazzibdrazzibPNG  IHDR szzbKGD pHYs  tIME38fIDATXŖ[lTgnό_0cCp 8$&R,RUmU+%@ EMUZE}$C%6JmriJۤb<_>s݇ <U}_3y੧B 2ܦ&r=j6yg{ZWS]V:4F=tqibV+/z BΘNiش6D9"!7Bٲ_ɹ?|p:3k՚칳 kO㤋7{(iM:41rAA2"D(/PWٜ9sd }ntscړ$HD0N6'KdrFVXxC(NlKslMun? l\U,l)@A9D9#1f2N,3s2U:^Δ}ݧ;߄Z E.É9Ĕd 3RW]cDŠ UV4u(E5S6LsBsal`A O|WT W7]|?Z71e'^Z!͈,8#sA*_Yӝw ""1ֽXESTw -Ze6ld&dh Gz%%̚U˛ZX&<.W67z\#b5D*ϕtN-V쉹9\1qY6b27h@h3 mTr_={jl i]koY昮,'BH%#-Mn\% Cx/Yр}bW^͟o՗u|H6u6 FJ  k_8t=ӆ7ėXXT-gIbL2];ڞ5Qڮ\&yv)sR\e ՆS}ᱯ]{.~rt'VJpb=N}>XJnm{۳cU%/L 8vn5+E:Uuzq;nX籇lAOZ4F#\# [;oС;6ڲنxO.J A>7/xMKY@z?]+= d YvՓ3 z@G"C])8qcSp]{;00ch\G….B[ugrwwӚaL\6ALCX蹏05y\RbPg29|Y q@EpzdNNf;;{essw?6mze;8rdj喝׃jPK Btz㞱Q?Ϗ?~yuT_s%^E Dhooo}g2bM`B`l [՜^PJqˍoMJAXke<z h·!\(OՌ_"8ap$MǟY^:9|O>[O8ΆXm}UOIX~7i<ۍ4$!R )/Zk,(d-WS:'X_},>V|hSep'{K!Lba`)1 iHCr)dҨ,+Jpɖk['>@.7ܒn=ʞaibYnpmƤIe0${E\[15ˊ3}sCC-L V˛vT2di PQ GnV:}aZ?A(V V$lݛr .^eûGw47߼zÐyL,Ϫٜj'.IIa8]0rM x]meʻm<8Ri;@LO(  3? ,ebY&4ؽ#4pk 4Z6[^],9K'A<s4 [q|?5; s{Mi \|?$!m\ttssʢk-n^[C1N 7I0xy,,ٮA)1KI, ƕ>!ŎhU45d*,$4ncY N"`͒TZs?ek֠¥!*K Z/ gN_n=Wrf*2 NsRJc8 4?2@m<\tkO nhg0iN`%1lO$ Ȝ̴Td7H!RLc8Ջ(PJa6u^1;NoLR 3S-HM( @ χ8I).+I/+82DWedR/G X8/Թ@ "UfRӍJ)"):{yGHy"CݱWt.MhLB<c4⟲ce=)HH5<thMɲX;'5^>֏Ra$va|FC~Ebu47Ԇ /uMuBיS{4VXXұDMV([9SwI۶d>c|?XWN՝pS">1ĄM"amlN=ZSFia.}wl8KMMhN3\ܪ, M=(ZH"kJs&a;>h&a+D%l]]JV`W}%훪7҄j`sH)q[fZ 7.%h` /5շ63 8 fW[FUK .+ 8o(@v'<#a,([+*0>a_k:v=>>gYHx|ƧW~^<ʩ~Z O0# 'K/\8s0?hSw{p_t-D ~Aov;7,~k+W^Qˣ2k-Lu׿"J5VWN78e&+K6s;FB8 EM5{}Ǟ勅)֟n 3R.}{90+kl3>?~֓P@Z_84m]F0JdD%}X&QG>{'dRb!',ucq[> KUĽO|V<7х H Sv F1uZ!:=Ċ0P /1X!V u; 5JnJ)|Gk镰!ˠBێo{T7;6ΟǫV;+!656[J%7[G5*=kCGc6N_.]qJ={:46hs<hKG2=MS*Vۯ ɱ61z\ج[O1[-nDd 2$۲!85![}cxu[󅢸o͡^CC_ޘW./&F䳷E>U`\3SZGDF,#kWxx& `oQP'NӝzG*lE'`Yzoյ)}c`k v0_(Gƿv$朿Rm-:<K9gyoZ[nƒ[}ny{M}8e. QNs0k8Mjr_?nzn{ O>խ|m{1xU b~ymѺSV.Ml,[:wůZp$ 42LNÏH2PٱB*YbxNVA{ukMmYpMpNd  G=0$\;b8JeoOI3iaPwBW< AiqnqqJ<-ͺw|s:boG)`[QDXu5d RP4T{C((?OYJmt *+ۤAg/18#Ѐс/'.p*~8|z2ʬYhaԹs]J6ߕBt¡ PԔmm-[~?B\.WbBLIUTD&'K7 B5kx[UpwLyqՑ Nm᫤ٳsܦ)څLJJ8r8((躞ĵw/OR&M]C8 TSav G/,L8IdӉ|o^sSi#+'GSwg [`k)={xb4\$`4nɏw0 M@ k耝}@L i( p M/IENDB`substance-5.3.orig/src/resource/user-home.png0000644000175000017500000000102010623730252021224 0ustar drazzibdrazzibPNG  IHDRabKGDC pHYs B(xtIME 89rIDAT8˥=hSQJ@AABU1vEQukt("hE "mP߽&i^[.{9\uVr:>km,K@=zPkzi Ju ׭!|xXzZIO]݁dyR(HM=k-Z{p"$|?!=[5f.'r> !=~w=tbucGwGq<ϫ&h\!HTvЪĩA-o>|99%c H#iq +}9:@@"PB RFlxma?.O]9 ʷ oIENDB`substance-5.3.orig/src/resource/application_view_list.png0000644000175000017500000000073110623734204023721 0ustar drazzibdrazzibPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<kIDAT8˥JcQ\El/#(!E6Bl$ VV>.bmHL#bak8g泸QQ6d``΁9S,QYܬ=Uw䎹!.Gf0w~̇ۇ_'imv'sMFHpO ePLᴙ#wLS=%5e013bo*&HQϲh|:yBY_U1 1ˏ [??DbarQ&>!B !|BCj n?BQpw;ln:n%ܐ{NyPufW:* -IENDB`substance-5.3.orig/src/resource/go-up.png0000644000175000017500000000121410623730274020360 0ustar drazzibdrazzibPNG  IHDRasBIT|dtEXtSoftwarewww.inkscape.org<IDAT8OhAƿ73ٍzhLт@*ՊhDbE-rkJIbREOBM*^DPC)*4&Q!|ߛ!5ɛ|fvn<IuL:.O <WLFfG ฼ʼns֖ǖ% Ep74HK: ]"GJ a2Wk =<؎Ql*eh :}6.N_ +XR"K(u@AVqE؟~ԋ+U?cjJZۆ25|I=/b1 lܺ?n%&Fs'0۶К"IENDB`substance-5.3.orig/src/resource/media-floppy.png0000644000175000017500000000106110623727422021720 0ustar drazzibdrazzibPNG  IHDRasBIT|dtEXtSoftwarewww.inkscape.org<IDAT8A?34F,\#("Vbg(XɝXX\\an2"w!'/3Ã --wYtɁa39&FdjN)'=OBkǰ1CXcp'/7}mqO:86N*S^l0rr=* yDehjLU>HG" dn. N-v{4(-Howf~.Gbʛ<6Vk/vH,AԐ$4<oQAYIENDB`substance-5.3.orig/src/resource/text-x-generic.png0000644000175000017500000000051510623727630022201 0ustar drazzibdrazzibPNG  IHDRabKGD pHYs  tIME8`&BIDAT8˭=n0H[!!l"A!QsL$^Xj,{|3m1 Z;騬8xt/5ǒ4MW(w=ιURW/P&AH৞"Lxx3}Z=B)pS @0y.?iv2̥gn:RHaf'us1RC}X?<5_8 &3 \ _KM`e "(DZah}H,C+ \t]D#1Y~uڜ>{_w"a/_8hyʛ,‡ʧIENDB`substance-5.3.orig/src/resource/brushed.gif0000644000175000017500000004714310337722774020771 0ustar drazzibdrazzibGIF89aοξн!,o?~0B|PAEԧ!Ǐ#8?}᳧ɴބ "DpbǾ|F2"ӅB80$(PȂI˗٬GջldӞE{m۷jǐcT2Ws0,/곷a;s Ŏ>1bDa.xMG֌/ŀ5"ֽ,ڲ K68[pMT+D~&Bp"g* JQg/bJ_N{ܳo7 H0n@+Xc 0F! v6v )Dji$G$E#5uTjǞRZGg,[4x&5Ey)qmhE$W`oSN]J*WOo%|p?m #4d"J(@Y[WƦ^ [p\AHTrYVAfVјs UMhV}&xi%nwi\ZPtqU5oH 'J%pht$eEӟ'8&[,NM| iQZu=*rśk!nVEl: ~>4 twbUCWaYwۛe צъm9uDeѣ:!dF֙bdAU`31*\=5t=+]rFt4B:AȐ{֞hkMEPH[]vK*6SLlYG& /s~XoxƦpLru$K\مSـ.v"rKY.-JdC>Y+.A.-~;WqK ZEFGj;>Uyը@A<`ݎ"ڿܞaXS"@\GcI6(,ژWd*0AhR$FM"FJ -8f&32bͰDXߠA d[wD'?1'.u{J§|T/?UR2-# `D( ?Ap`H < !"huc~YI`q'PMYt:df$cE<$M 7dflsi΄2i cfo#8#<$ Ƣ>|KK͒,I IP;61龜!w>4]ޞE1 PjbO%:@OxmRS'Cp Ѫ|TqRX'zQ0 *Q:.MDRJdΌ[v2W-9 ":lk[9mm> 8p'  2e0[ t.]QE;q3B+D`&=Nnt 5!{kL9f%0c3:}ҟE0H'y)1ˡqwo$A?8!@B }PYagZ` ũ੦I1J_=Hy, `aȾYo^yR%{s\vTC pHi05P/`q&q&)D&=,"};2}u-g-w-SwB%BWAFmE6q34nRg5%`F@F VOұcIs!K%0cfusFB>Sąay+<,}C i0Y0e`OfD6c3RPQxcCdD;3_g}| @[Sb+:r23 / L:;S&e~I!SU7"7un'E%fGlalj.ƒ`H 6F!d#Z6P^6OKKdK#xN :QDBaK`}#C!&e$S@=Wsߣ\aQ/"?0Rc.r#61gg5jR+g %= " kP" tAq"\GD+X$s)IbJD'S9t2jxv?1MxLyLw8XpRcmW0S1C c  !8-:#O$OdA:TMEeMCOә`S)AEy)/tQ>!ō1njHQgYva/-PP-P/KIHap$zhsLN+hm3I/M!>MS4MDSeGPfMT$ϔeB~}p lj v$@IRbQNVM63?!]hvM&]`e7aI$i`"TTW?Z3\{Rh^`#AMFMg p2p 2P=!jvɅ02j$xl6)= &3Ha(<ϷB<ҧ8gO%6.rrhqbla1P1H`&%( Kt9cdE2sSF22GWDh(B52%RC1Xr='ta2E [v^fr% C Y`j@n wpNB8:&eWɥ,ѐUaa 7>0?&VAG)'{uyu7B&/Ólg;$\`YD jp8ppCm.'W$g"1b\bwx'WW20f$zٗ'AJ#r/*}]PYY}w},}`yDZ_! lt1'Kh/|~ezPaAZ>n"aY$$2!e&<t▕d9 @06`0`cLWK*{">'AQd-aM[OerXG>9=t!)7r4"w5fy@-3UO6KG/|!Sa+ڨy֤#\Ohޒ7ބ5A`U R)c}2>">x{hyzr-PO @[!JÑ?Cwcoya -ROB,ӑf5''GrLֱ6Db@68Կ6l:0JFࡎ?A[qb#͡p#yDF,TF>u1UB8[+S)Ksqu͚yaU\P;r-%> q8`qQs"2D:*s E8#ŁdyS9AG* ƗfSp`US)HF0ŅFAռ"Qif _a :i\[D3(Au3;up?\1F$چ"#(G)1q\1%3)͇{ ?nB3QP29\\v2VL%jdւ񲏦g^&o*=fEMnJTeDƌea33c'<; w=W'%s@Oj٢#iE021U=u/PG/-#lL.xB)hI2!R;}34B$ C_#0X}81$r'P%K&#JQElP1T-F2QKeݒѦ0/I`:H7'wl=@Q'1-e'ِNmxpv+9g^š;rl"9yRC3S'oxW2Llyt#߇ qbh[Z4\W G$Xdzzw^ /z@)P{$;'1̆(bt,-CL' |z[io[2t@b>NPbhޢ_-IfM,7ߒO!e7P׍!-3v}B>ǝlZ|\\Am1%:", =%P'@,Gً0rmh(R4m13Du,>l5B1loߣe=$tbaN5!Yܤ:dJH4GC7ZevoXv0`8`^.`g PcXܑf6+j+tIhR7hssfjlDʹ^g,z'|ǣw[DGϞ>}ÇRIz$cGO={0eҟKׯ`}SUӥFo_MRdK(UT_ڧo:{թ?BK*uĄD.$y%(0<ǛtČ}"40$7/ߤ OSWI&'??ŊmIْ8K̉eKVyΒ&I3xmߢʹ)MJMD([Xo,P8!#]NA |pb 2<*i!؛ 񠃺B \BӘ8 ¾n6jrR2/ 2Ѩ4G(*ʩB%.M` &) P뵽iJ* $ʥ«΂HB /,!4q短QE$*^M. +rkmž($<*DRP}K%Nup". -CB"5Bsn"!$sI;^s+H8B)BZB Hk U-)!GN/IUEJހn .@}Kg_'NbiR }F .;y$Zp$4E*+ @Rnzk,Z)SVs$ ‚J* 5CF[(sKt $Vb~agqaѾ'pjkǦML` f{-y<Ү5e.߈Ɲe);ߜ$rn .X|tX rçR$ /‹u;hMZQ4qOa5Uٷ8`bͼ^XkNa{@\Hbe)s -VywXV! 0Kf U8h9Y䴣)-IW\J3.FuVTļ>@,`> m>`("yD ``# Y1BIw֒(7]f8 RreJ:NNdWϊT2JW.%EMZz}qT!SbI+qҞpt+0A"B -`" EDy T9; P܎L;=FJNjڇ¨ = Q6'u-p`vVs&ߐ`C8Z2p&J @G !)AE77I ozT{aNڶ-nAMU*+yS=PJȎ@Q xӥ&2Q- .HA8H.thG;eJEB$J &t"ьK]M܃:%F)N]VXHqPQ%d:0$D\9"fn4I kNgPl|aTJ,)`InA̼Əش"q(ZlϚ$ XT_M 嬷_L&eVM/rl d@|%@ D7ibI*ԁP_QO)2h RS];J,s 1|ty^_-6ر]I@<1$BC$؈Ӗ5(Ji)lMկ5j _4 |0iVm֟8n˦ 'Q(xD고)'/WII X%: @.ÒR Sw\B#%ϥѮ,5ed#Q9l8B$; [}Vg=9a}ܣBFQb.1%[?#zxn=1\^z(VEMqvxz^wt= l3&oX-]ښIf9*#V)lS vnZiXsZcEw\XV۹HQ!;mHr_qsW^Zj=OΈ7 *D*  *9 ]{ha>JpJa1Z 8 ' (-L !K2Pzi 4,3/ a;3_2mj?n*cH Lಞ(#٠Jƴ` r,lY>Az$ 3ܐ0Ѐ62V a8+DF0;*3ڎ`8) j3n4(EԜoR=h#\%੡"6␙ &^2 q.U0:+ȃ6z+P{R908`G%sP2 j Hȷ3x;h5yG1k4x 39 8h) K3Lmz'XD>~CBA@@ASB2K7&}K`6tsWAY>±knyPgVDSTԵ:F%@;7LM}|mJl )#􌎘gc̲Paٕ\C}$cƑ%̮VL]8>m(S"Y@81#QX9q.B tqa_\w MA,Q TVb 3S>+í1 *!Zp* <@ cUjhJ+eph|*a")/(Խ8 w\u|&p(u] !x ȏwu̡U({`b rPc sX˶lT]Xb*#Y4/;R:77 ``c8 ,c`]l5qx%V^ğyXdfufkUVX\uyM*_P6`cQ=:G) 2J7JOfA갉P |-zH]J1oi$"A ڐZĖ4SyA 0`PRBrDwku k&U2;XS:`j c"9>*"BLF"ĝpܞ 8" Sb?!%pZ!6琡>|iW|$H~e{dПErh=:Ϟ=zJM0ҡC"-ZƉ tȏC26F!QE^4`MJG948R Y-cW|-Lx_>AХct)Rą3*p.skc>Y5z(XhNQ!s )oH?=&0nTFܩpn-z_=׋|~H]Ps\`v  Y>C]e曇A6C^UWg-&X.G 'ՉᔘzvTqIaݴbQ=ReQV9KNtQ_Xnoao2)'A=vN7JWf$\ 1">C4_xh=ǚkfj2MjQF"$X 'C5єa=o  v*=dbZc{^tAQRUO.Z|#brRF!K'FȚd%!IBf&4| %RJaK]Pf_KIԓfTlSzP4vEP2S 0=à/( ;îuq\ gWLUPyͅ^FF^ҪY{<a/Firٝ/R)b+L{頪5(0B >8a`,DN5

CP1CXppB_9N,seD_wOP~aMr*=9愛E}p$#P_Pb,.Rq|"aRh|xB˔Dbj OtiX'&ëP~d$HBC 6 z2,fa9[v(K-exZ  p-4B/?@x`%H2UgPČeIA",@tPyS% Tth" 95ӿ!jE>UlÓ0BL:?TG"\ЁC AA0,+ 9?ж >,WmU\*NВH0HIdaf2vzƖS+6nlp[TY VB`A?  0B `%+5 '(x!݌TC5b ? J¯Tl6 ES@4>y&\z]Q8 V,U0#VN2Ũa]QќZ 6 џ/i+IK#cU:֞F23 ʝr5o>8 2BbrPL# jF4efF0Jnw9=1§^x,dNb!Y P@Fy{Ybe/R'rDF{}%!ӡpq`‰rpd^ fOBkٲzS&zϝ\F8PdH8D!4Gō؏ߞ1U[bd=]]\'Q "螛Ӭ&^@t,+e?q8Nv3HGY@J MBc/rWwXR.v(TS]pB֢% `(WSZ,VguCxD%0GnP? 'J:] 1n:͌.,`,dSM@dh摘HYR4ʦaN\kIhۦhi̙Շ A}5 lԪ:׾ ĭ5BujL!y8 Q#Ѓ9D,CeqUYK=^ю*K1R2¤D1S*6 =#9Fl詑I]? ZZC>()Jl g $}U: e =(wquIZB c@أLw&MpRIM4l?5hneT,$C1#7 C)rU:v [ Xܡ?,5Bn4"3)A؀)dJ.A Ԝm:~:j׬U&kO,ebu􌝻 ˡ=YA?WO$ MTMl%d@U <OpDS E-MP@=ud@m`Aa3` vD(ʡ\t ZD>@ Ly ŞrċSmYKzh\Si ]ѵMU\: Pψ @M, G 蘊 5Qj,=dĀL=h=@A=p<LdrhdM+MiNtpe-GPM_ih ^c.bSUlIVԥ!f遑` R|\υqșF@tu@L?|~X ߲,L@? ADRgؖ̈J,!IəlPjD⑘s}،HKgt׆>A!iL? ]N=RIҕ)dBXIHEP1] Lz,R >abtД0S-ZňK@4A&< 8lQX e~* n?ڦ-ՎpEQ`z ;!be HԴ罉'=` C Ax2@ܪMOOM4S} qqUH29Ķ$GlMDOM KʨK A>  @W ~,ubGst_l8N̍t\hdm11ǀYKh>I`QQdtbd[pDlXdhF#\p~ bnhfip`adbPE,My` 4E|j_rQJ!"Ip`F Ē,]ԏU T8Eh ."Q xZqnN{cp:S BTB'E~ Y ,Bh̀?de)+- ex" H_fؔ(CE}1\.MV@P3`DxD?n @ CA8O  g1D$(&F'-[zʉ̟fP~(ΗL!YUA Ă  D, =U@kJ, r Yь%auK$"">UTJٍg]}@A,Ah=8@ЭB@/M0ESD*՘`:mX\癀ZɌ xǩ id!M,!1= T"=0A dQوdCJ<.H2E@$UJ^dEVDm;2Ϧ1Q(.}dP懴mٗΚ sb*D@Ap@m pzM-b ݪQLp3ڄs ^i~QymWĥPL܌o$@ fh 8V\e$xWWOX1]=lIzqrl17ë*_kX򐬿?Q>Ĉ'(02ґfK43\ EqNT.E St(T0EJd`$*qRܨܒ낢}*1[̨\ܥ <6! s8e+pUt ۾ChE^Io++=rN?t@?p@?DbхǨx-yLouM*\O+](MPUݓܲUf^m5s**]_u5QDPLg`Ipep+H"!JfP*.P j"ͮUPHL2Uiʖ)_ӥկi[~FK8\i%EfN`*%l|UkyX8ϙh]FikUBI (*IP\̋9ic(0^I\9JHM%JH') ܆PpUaja?Ȁ(A+?X\ɻ: W&|x4!B-g=*:ɛ,B2KxJ ,Ị8/l!E dy )@Ե_܅baT7kƀLazUX)l >ˈ1&jat G5.SNV֕]L\Iɮ[9ɔи9\,хhѶ}~ 2L ֡Ez5HBX(Xoq#]$z5EՀ3ry7P{zR䜽9G=޾|˷d{H7yՓ0^z3W3>qȑG_ϋ55ZԨ $={O jgG-{Qi?:6ݩVgE~L9,H,Id =$BR^A?15dQ=zj^\V5hW~ALoeY+GL@əYO<4U ғxSC;ޏvƽj[<)3L#?Vp#,RDQg̍nH  *&s 5" j" ٌʏj맟jN.: -6,|0$g:3xI:NMl.TԨy뢞MdAB{&খJ*;2#I8dax >t@1$@ϝ<.iN!ц.di; "예Z-ېvӝ^xH|%h " ~1,IY˛P'LwF ֲ BN.P hJ>RЄ!.֔E  r;o\&Y$*95l۔^Pg dWPx5i*qZѴ!E"4ĬX4Oª{ضdB fcJ`e\0|ed$g(1JNy}R~t@h<~ )3ML,UAƌr*-* \`]ZM&>^S90wMlc9>hȰ]b5 dqW'ֵiiNA>8Er/Em`(F0U p?d #B5G0,Zf\;}I4Q|dk*d1t`Jc]'"1Y o\"L$?o5"wȨ5> L|_Ó+p@ 25m5 0ê'6) KdٲeϏ;0 &!8@30 rl`ne2t`jTg\n+l9[VWxzSM%'iR`]BKma+f&f@;oG{rf5Ѐ,hB Qy)|*y(&īqGH,,lNin"vi*^`LRbddF-bdΪUga ?ȵ ,㠨Yb-*"42D;dc^o@pG^d'r-|iޤ`Vd5.*R&p8\ V&VDSV "N& ;substance-5.3.orig/src/resource/TangoFamfamIcons.license0000644000175000017500000003522410623732014023345 0ustar drazzibdrazzibAttribution-ShareAlike 2.5 CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM ITS USE. License THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. 1. Definitions 1. "Collective Work" means a work, such as a periodical issue, anthology or encyclopedia, in which the Work in its entirety in unmodified form, along with a number of other contributions, constituting separate and independent works in themselves, are assembled into a collective whole. A work that constitutes a Collective Work will not be considered a Derivative Work (as defined below) for the purposes of this License. 2. "Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which the Work may be recast, transformed, or adapted, except that a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this License. For the avoidance of doubt, where the Work is a musical composition or sound recording, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered a Derivative Work for the purpose of this License. 3. "Licensor" means the individual or entity that offers the Work under the terms of this License. 4. "Original Author" means the individual or entity who created the Work. 5. "Work" means the copyrightable work of authorship offered under the terms of this License. 6. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. 7. "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike. 2. Fair Use Rights. Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws. 3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: 1. to reproduce the Work, to incorporate the Work into one or more Collective Works, and to reproduce the Work as incorporated in the Collective Works; 2. to create and reproduce Derivative Works; 3. to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission the Work including as incorporated in Collective Works; 4. to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission Derivative Works. 5. For the avoidance of doubt, where the work is a musical composition: 1. Performance Royalties Under Blanket Licenses. Licensor waives the exclusive right to collect, whether individually or via a performance rights society (e.g. ASCAP, BMI, SESAC), royalties for the public performance or public digital performance (e.g. webcast) of the Work. 2. Mechanical Rights and Statutory Royalties. Licensor waives the exclusive right to collect, whether individually or via a music rights society or designated agent (e.g. Harry Fox Agency), royalties for any phonorecord You create from the Work ("cover version") and distribute, subject to the compulsory license created by 17 USC Section 115 of the US Copyright Act (or the equivalent in other jurisdictions). 6. Webcasting Rights and Statutory Royalties. For the avoidance of doubt, where the Work is a sound recording, Licensor waives the exclusive right to collect, whether individually or via a performance-rights society (e.g. SoundExchange), royalties for the public digital performance (e.g. webcast) of the Work, subject to the compulsory license created by 17 USC Section 114 of the US Copyright Act (or the equivalent in other jurisdictions). The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. All rights not expressly granted by Licensor are hereby reserved. 4. Restrictions.The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: 1. You may distribute, publicly display, publicly perform, or publicly digitally perform the Work only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy or phonorecord of the Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Work that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Work itself to be made subject to the terms of this License. If You create a Collective Work, upon notice from any Licensor You must, to the extent practicable, remove from the Collective Work any credit as required by clause 4(c), as requested. If You create a Derivative Work, upon notice from any Licensor You must, to the extent practicable, remove from the Derivative Work any credit as required by clause 4(c), as requested. 2. You may distribute, publicly display, publicly perform, or publicly digitally perform a Derivative Work only under the terms of this License, a later version of this License with the same License Elements as this License, or a Creative Commons iCommons license that contains the same License Elements as this License (e.g. Attribution-ShareAlike 2.5 Japan). You must include a copy of, or the Uniform Resource Identifier for, this License or other license specified in the previous sentence with every copy or phonorecord of each Derivative Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Derivative Works that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder, and You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Derivative Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Derivative Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Derivative Work itself to be made subject to the terms of this License. 3. If you distribute, publicly display, publicly perform, or publicly digitally perform the Work or any Derivative Works or Collective Works, You must keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or (ii) if the Original Author and/or Licensor designate another party or parties (e.g. a sponsor institute, publishing entity, journal) for attribution in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; the title of the Work if supplied; to the extent reasonably practicable, the Uniform Resource Identifier, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and in the case of a Derivative Work, a credit identifying the use of the Work in the Derivative Work (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). Such credit may be implemented in any reasonable manner; provided, however, that in the case of a Derivative Work or Collective Work, at a minimum such credit will appear where any other comparable authorship credit appears and in a manner at least as prominent as such other comparable authorship credit. 5. Representations, Warranties and Disclaimer UNLESS OTHERWISE AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE MATERIALS, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 7. Termination 1. This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Derivative Works or Collective Works from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. 2. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. 8. Miscellaneous 1. Each time You distribute or publicly digitally perform the Work or a Collective Work, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. 2. Each time You distribute or publicly digitally perform a Derivative Work, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. 3. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. 4. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. 5. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. Creative Commons is not a party to this License, and makes no warranty whatsoever in connection with the Work. Creative Commons will not be liable to You or any party on any legal theory for any damages whatsoever, including without limitation any general, special, incidental or consequential damages arising in connection to this license. Notwithstanding the foregoing two (2) sentences, if Creative Commons has expressly identified itself as the Licensor hereunder, it shall have all rights and obligations of Licensor. Except for the limited purpose of indicating to the public that the Work is licensed under the CCPL, neither party will use the trademark "Creative Commons" or any related trademark or logo of Creative Commons without the prior written consent of Creative Commons. Any permitted use will be in compliance with Creative Commons' then-current trademark usage guidelines, as may be published on its website or otherwise made available upon request from time to time. Creative Commons may be contacted at http://creativecommons.org/. substance-5.3.orig/src/resource/computer.png0000644000175000017500000000067310623727444021204 0ustar drazzibdrazzibPNG  IHDRabKGDC pHYs  ~tIME 3HIDAT8˥AKQowKx",AAPo}$E)]A5&l Tv؝${3OS| $2[V$VDvE题4Ny4ິ} F,.!cjah_|LaAPxX  ȩx|xQL =[PXoaxVD ({9$~@_o0ϭOMPո:ߛHh4Fe9=e+gT.vw}ubCu8{%srz R|V6frʕٌӜx;#IENDB`substance-5.3.orig/src/test/0000755000175000017500000000000011256731152015754 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/TestPlaceholder.java0000644000175000017500000000371711036213200021672 0ustar drazzibdrazzibpackage test; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.utils.LafConstants.AnimationKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessSkin; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; public class TestPlaceholder extends JFrame { public TestPlaceholder() { super("Some simple text"); this.setLayout(new BorderLayout()); JDesktopPane jdp = new JDesktopPane(); this.add(jdp, BorderLayout.CENTER); final JInternalFrame jif = new JInternalFrame("Test"); jif.setClosable(true); jif.setMaximizable(true); jif.setIconifiable(true); jif.setVisible(true); jif.setBounds(20, 20, 300, 200); jdp.add(jif); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton changeSkin = new JButton("change skin"); changeSkin.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SubstanceLookAndFeel.setSkin(new BusinessSkin()); } }); controls.add(changeSkin); JButton isClosable = new JButton("is closable?"); isClosable.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println(jif.isClosable()); } }); controls.add(isClosable); this.add(controls, BorderLayout.SOUTH); this.setSize(650, 400); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) throws Exception { JFrame.setDefaultLookAndFeelDecorated(true); //System.out.println(UIManager.get("MenuBarUI")); UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); SwingUtilities.invokeLater(new Runnable() { public void run() { new TestPlaceholder().setVisible(true); } }); } } substance-5.3.orig/src/test/NoiseFrame.java0000644000175000017500000001175110776621666020672 0ustar drazzibdrazzibpackage test; import java.awt.Graphics; import java.awt.image.BufferedImage; import javax.swing.JFrame; import org.jvnet.substance.painter.noise.*; import org.jvnet.substance.painter.noise.FabricFilter.FabricFilterLink; import org.jvnet.substance.painter.noise.NoiseFilter.TrigKind; import org.jvnet.substance.skin.BusinessBlackSteelSkin; public class NoiseFrame extends JFrame { public NoiseFrame() { } @Override public void paint(Graphics g) { int width = this.getWidth(); int height = this.getHeight(); // // double[][] noise = new // // PerlinNoiseGenerator().getSparseNormalizedNoise( // // width, height, 0); // ColorScheme cs = new BrownColorScheme(); // Color c1 = SubstanceCoreUtilities.getInterpolatedColor( // cs.getMidColor(), cs.getLightColor(), 0.9); // Color c2 = cs.getLightColor(); // Color c3 = cs.getUltraLightColor(); // // BufferedImage bi = new BufferedImage(width, height, // BufferedImage.TYPE_INT_ARGB); // Graphics2D g2d = (Graphics2D) bi.getGraphics(); // // for (int i = 0; i < width; i++) { // double ii = (double) (i - width / 2) / 10.0; // for (int j = 0; j < height; j++) { // double jj = (double) (j - height / 2) / 10.0; // double zz2 = 1.0;// 100 - ii * ii - 4 * jj * jj; // if (zz2 > 0.0) { // double noise = 0.5 + 0.5 * PerlinNoiseGenerator.noise(ii, // jj, Math.sqrt(zz2)); // // noise = 0.5 + 0.5 * Math.cos(i + 20*noise); // // noise = 0.5 + 0.5*Math.sin(i + j + 20*noise); // // noise = (0.5 + 0.5 * Math.sin(i + 20 * noise) // // * Math.cos(-i + j + 20 * noise)); // fabric // // noise = 0.5 + 0.5 * Math.cos(i / 10. + noise); // marble // // noise = Math.sqrt(Math.abs(2*noise-1)); // maze // // double noise2 = 0.5 + 0.5 * PerlinNoiseGenerator.noise( // i / 100.0, j / 100.0, zz2); // // noise = 20 * noise - (int) (20 * noise); // wood // // // double bumps = PerlinNoiseGenerator.PerlinNoise_2D(ii, // // jj / 10.0); // // if (bumps < .5) // // bumps = 0; // // else // // bumps = 1; // // noise += (1-noise)*bumps*0.5; // // FabricFilter.FabricFilterLink fabricLink1 = FabricFilterLink // .getXLink(1.0, 20.0, TrigKind.SINE); // FabricFilter.FabricFilterLink fabricLink2 = FabricFilterLink // .getYLink(1.0, 20.0, TrigKind.COSINE); // NoiseFilter fabricFilter = new FabricFilter(fabricLink1, // fabricLink2); // NoiseFilter marbleFilter = MarbleFilter.getXFilter(0.1, // TrigKind.COSINE); // NoiseFilter mazeFilter = new MazeFilter(); // NoiseFilter woodFilter = new WoodFilter(30.0); // // CompoundNoiseFilter compoundFilter = new CompoundNoiseFilter( // woodFilter); // noise = compoundFilter.apply(i, j, zz2, noise2); // // if (noise < 0.5) // g2d.setColor(SubstanceCoreUtilities // .getInterpolatedColor(c2, c1, 2.0 * noise)); // else // g2d.setColor(SubstanceCoreUtilities // .getInterpolatedColor(c3, c2, // 2.0 * (noise - .5))); // g2d.fillRect(i, j, 1, 1); // } else { // g2d.setColor(Color.black); // g2d.fillRect(i, j, 1, 1); // } // } // } // ConvolveOp convolve = new ConvolveOp(new Kernel(3, 3, new float[] { // .08f, .08f, .08f, .08f, .38f, .08f, .08f, .08f, .08f }), // ConvolveOp.EDGE_NO_OP, null); // bi = convolve.filter(bi, null); FabricFilter.FabricFilterLink fabricLink1 = FabricFilterLink.getXLink( 1.0, 10.0, TrigKind.SINE); FabricFilter.FabricFilterLink fabricLink2 = FabricFilterLink.getYLink( 1.0, 10.0, TrigKind.COSINE); NoiseFilter fabricFilter = new FabricFilter(fabricLink1, fabricLink2); NoiseFilter marbleFilter = MarbleFilter .getXFilter(0.1, TrigKind.COSINE); NoiseFilter mazeFilter = new MedianBeakFilter(); NoiseFilter woodFilter = new WoodFilter(30.0); // CompoundNoiseFilter compoundFilter = new CompoundNoiseFilter( // fabricFilter); // long start = System.currentTimeMillis(); // BufferedImage bi = NoiseFactory.getNoiseImage( // new SubstanceCharcoalTheme(), new SubstanceCharcoalTheme(), // width, height, 0.01, 0.01, true, compoundFilter, true, false); // long end = System.currentTimeMillis(); // System.out.println("Time0 " + (end - start)); // // CompoundNoiseFilter compoundFilter2 = new CompoundNoiseFilter( // fabricFilter); long start = System.currentTimeMillis(); BufferedImage bi2 = NoiseFactory.getNoiseImage( new BusinessBlackSteelSkin(), 400, 400, 0.8, 0.8, false, null, true, true); // bi2 = LafWidgetUtilities.createThumbnail(bi2, 200); long end = System.currentTimeMillis(); System.out.println("Time1 " + (end - start)); // g.setColor(new SubstanceCharcoalTheme().getDefaultTheme() // .getColorScheme().getDarkColor().brighter()); // g.fillRect(0, 0, 1000, 1000); g.drawImage(bi2, 0, 0, null); } public static void main(String[] args) { NoiseFrame nf = new NoiseFrame(); nf.setSize(400, 400); nf.setLocationRelativeTo(null); nf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); nf.setVisible(true); } } substance-5.3.orig/src/test/META-INF/0000755000175000017500000000000010614155542017114 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/check/0000755000175000017500000000000011256731152017031 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/check/CombosPanel.java0000644000175000017500000004562511212462656022114 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.awt.event.*; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.*; import org.jvnet.substance.*; import org.jvnet.substance.api.combo.ComboPopupPrototypeCallback; import org.jvnet.substance.api.combo.WidestComboPopupPrototype; import test.check.command.*; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; /** * Test application panel for testing {@link JComboBox} component. * * @author Kirill Grouchnikov */ public class CombosPanel extends ControllablePanel implements Deferrable { private boolean isInitialized; @Override public boolean isInitialized() { return this.isInitialized; } /** * A configure command that allows editing the specified combobox. * * @author Kirill Grouchnikov */ public static class EditAllowCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(JComboBox combo) { combo.setEditable(true); } } /** * A configure command that disallows editing the specified combobox. * * @author Kirill Grouchnikov */ public static class EditDisallowCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(JComboBox combo) { combo.setEditable(false); } } /** * Applies the specified configuration command on all combobox children of * the specified component. * * @param comp * Component. * @param command * Configuration command to apply. */ public static void run(Component comp, ConfigurationCommand command) { if (comp instanceof JComboBox) { command.configure((JComboBox) comp); return; } if (comp instanceof Container) { Container cont = (Container) comp; for (int i = 0; i < cont.getComponentCount(); i++) { run(cont.getComponent(i), command); } } } /** * Text editor for a combobox that checks fix for defect 151. * * @author Kirill Grouchnikov */ private class ComboBoxTextEditor151 extends JTextField implements ComboBoxEditor { /** * Document. */ javax.swing.text.Document doc; /** * Creates the text editor. */ public ComboBoxTextEditor151() { super(); doc = super.getDocument(); } /* * (non-Javadoc) * * @see javax.swing.ComboBoxEditor#getEditorComponent() */ public java.awt.Component getEditorComponent() { return this; } /* * (non-Javadoc) * * @see javax.swing.ComboBoxEditor#setItem(java.lang.Object) */ public void setItem(Object anObject) { if (anObject instanceof EditableDocument151) { super.setCaretPosition(0); super.setDocument((javax.swing.text.Document) anObject); } else { super.setCaretPosition(0); super.setDocument(doc); super.setText(anObject.toString()); } } /* * (non-Javadoc) * * @see javax.swing.ComboBoxEditor#getItem() */ public Object getItem() { return super.getText(); } /* * (non-Javadoc) * * @see java.awt.Component#toString() */ @Override public String toString() { return super.getText(); } } /** * The document for checking fix for defect 151. * * @author Kirill Grouchnikov */ private class EditableDocument151 extends javax.swing.text.PlainDocument { /** * Creates the document. */ public EditableDocument151() { this.setText("Long text to show the bug"); } /* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { try { return super.getText(0, super.getLength()); } catch (javax.swing.text.BadLocationException ex) { return "bad location"; } } /** * @param newText */ public void setText(String newText) { try { super.remove(0, super.getLength()); super.insertString(0, newText, new javax.swing.text.SimpleAttributeSet()); } catch (javax.swing.text.BadLocationException ex) { ex.printStackTrace(); } } } /** * Returns the left panel with comboboxes. * * @return The left panel with comboboxes. */ private JPanel getLeftComboPanel() { FormLayout lm = new FormLayout("right:pref, 4dlu, fill:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); builder.setDefaultDialogBorder(); builder.appendSeparator("Simple combos"); JComboBox comboRegular = new JComboBox(new Object[] { "entry1", "entry2", "entry3", "entry4", "entry5", "entry6" }); comboRegular.setToolTipText("This is my combo 1"); comboRegular.setMaximumRowCount(4); builder.append("Regular", comboRegular); JComboBox comboDisabled = new JComboBox(new Object[] { "entry1", "entry2", "entry3" }); comboDisabled.setEnabled(false); builder.append("Disabled", comboDisabled); JComboBox comboColored = new JComboBox(new Object[] { "entry31", "entry32", "entry33", "entry34", "entry35", "entry36", "aaa", "abb", "abc" }); comboColored.setName("Colored combo"); comboColored.setBackground(new Color(255, 128, 128)); comboColored.setForeground(new Color(0, 0, 128)); builder.append("Pink background", comboColored); JComboBox comboColors = new FlexiComboBox(new Color(255, 128, 128), new Color(128, 255, 128), new Color(128, 128, 255), new Color(255, 255, 128), new Color(255, 128, 255), new Color( 128, 255, 255)) { @Override public String getCaption(Color item) { return item.getRed() + ":" + item.getGreen() + ":" + item.getBlue(); } @Override public Color getItemColor(Color item) { return item; } }; comboColors.setName("Colors combo"); builder.append("Colors", comboColors); JComboBox comboFlat = new JComboBox(new Object[] { "entry1", "entry2", "entry3", "entry4", "entry5", "entry6" }); comboFlat.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); builder.append("Flat button", comboFlat); JComboBox comboDefaultCoreRenderer = new JComboBox(new Object[] { "entry1", "entry2", "entry3", "entry4", "entry5", "entry6" }); comboDefaultCoreRenderer.setRenderer(new DefaultListCellRenderer()); builder.append("Default core renderer", comboDefaultCoreRenderer); JComboBox comboEditable = new JComboBox(new Object[] { "Ester", "Jordi", "Jordina", "Jorge", "Sergi" }); comboEditable.setEditable(true); builder.append("Editable", comboEditable); builder.appendSeparator("Miscellaneous"); JComboBox colorCombo = new ColorComboBox(); builder.append("Color chooser", colorCombo); JComboBox comboHebrew = new JComboBox(new Object[] { "\u05e8\u05d0\u05e9\u05d9 1", "\u05e8\u05d0\u05e9\u05d9 2", "\u05e8\u05d0\u05e9\u05d9 3", "\u05e8\u05d0\u05e9\u05d9 4", "\u05e8\u05d0\u05e9\u05d9 5", "\u05e8\u05d0\u05e9\u05d9 6", "\u05e8\u05d0\u05e9\u05d9 7", "\u05e8\u05d0\u05e9\u05d9 8", "\u05e8\u05d0\u05e9\u05d9 9" }); comboHebrew.setToolTipText("RTL combo"); comboHebrew.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); comboHebrew.setMaximumRowCount(6); builder.append("RTL (Hebrew)", comboHebrew); try { final Icon israelFlag = new ImageIcon(ImageIO.read(getClass() .getResource("/test/check/icons/flag_israel.png"))); JComboBox comboHebrewCustomRenderer = new FlexiComboBox( "\u05e8\u05d0\u05e9\u05d9 1", "\u05e8\u05d0\u05e9\u05d9 2", "\u05e8\u05d0\u05e9\u05d9 3", "\u05e8\u05d0\u05e9\u05d9 4", "\u05e8\u05d0\u05e9\u05d9 5", "\u05e8\u05d0\u05e9\u05d9 6", "\u05e8\u05d0\u05e9\u05d9 7", "\u05e8\u05d0\u05e9\u05d9 8", "\u05e8\u05d0\u05e9\u05d9 9") { @Override public String getCaption(String item) { return item; } @Override public Icon getItemIcon(String item) { return israelFlag; } }; comboHebrewCustomRenderer.setToolTipText("RTL combo"); comboHebrewCustomRenderer .setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); comboHebrewCustomRenderer.setMaximumRowCount(6); builder.append("RTL (Hebrew) with icon", comboHebrewCustomRenderer); } catch (IOException ioe) { } final JComboBox combo151 = new JComboBox(); final ComboBoxTextEditor151 editor = new ComboBoxTextEditor151(); combo151.setEditor(editor); combo151.addItem(new EditableDocument151()); combo151.addItem("Default"); combo151.addItem("No Sound"); combo151.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { editor.setCaretPosition(0); if (combo151.getSelectedItem() instanceof String) { combo151.setEditable(false); } else { combo151.setEditable(true); } editor.setCaretPosition(0); } }); builder.append("Defect 151", combo151); return builder.getPanel(); } /** * Returns the right panel with comboboxes. * * @return The right panel with comboboxes. */ private JPanel getRightComboPanel() { FormLayout lm = new FormLayout("right:pref, 4dlu, left:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); builder.setDefaultDialogBorder(); builder.appendSeparator("Popup flyout"); JComboBox comboFlyoutDefault = new JComboBox(new Object[] { "entry1", "entry2", "entry3", "entry4", "entry5", "entry6" }); comboFlyoutDefault.setMaximumRowCount(4); builder.append("Default", comboFlyoutDefault); JComboBox comboFlyoutNorth = new JComboBox(new Object[] { "entry1", "entry2", "entry3", "entry4", "entry5", "entry6" }); comboFlyoutNorth.setMaximumRowCount(4); comboFlyoutNorth.putClientProperty( SubstanceLookAndFeel.COMBO_BOX_POPUP_FLYOUT_ORIENTATION, SwingConstants.NORTH); builder.append("North", comboFlyoutNorth); JComboBox comboFlyoutEast = new JComboBox(new Object[] { "entry1", "entry2", "entry3", "entry4", "entry5", "entry6" }); comboFlyoutEast.setMaximumRowCount(4); comboFlyoutEast.putClientProperty( SubstanceLookAndFeel.COMBO_BOX_POPUP_FLYOUT_ORIENTATION, SwingConstants.EAST); builder.append("East", comboFlyoutEast); JComboBox comboFlyoutSouth = new JComboBox(new Object[] { "entry1", "entry2", "entry3", "entry4", "entry5", "entry6" }); comboFlyoutSouth.setMaximumRowCount(4); comboFlyoutSouth.putClientProperty( SubstanceLookAndFeel.COMBO_BOX_POPUP_FLYOUT_ORIENTATION, SwingConstants.SOUTH); builder.append("South", comboFlyoutSouth); JComboBox comboFlyoutWest = new JComboBox(new Object[] { "entry1", "entry2", "entry3", "entry4", "entry5", "entry6" }); comboFlyoutWest.setMaximumRowCount(4); comboFlyoutWest.putClientProperty( SubstanceLookAndFeel.COMBO_BOX_POPUP_FLYOUT_ORIENTATION, SwingConstants.WEST); builder.append("West", comboFlyoutWest); JComboBox comboFlyoutCenter = new JComboBox(new Object[] { "entry1", "entry2", "entry3", "entry4", "entry5", "entry6" }); comboFlyoutCenter.setMaximumRowCount(4); comboFlyoutCenter.putClientProperty( SubstanceLookAndFeel.COMBO_BOX_POPUP_FLYOUT_ORIENTATION, SwingConstants.CENTER); builder.append("Center", comboFlyoutCenter); builder.appendSeparator("Popup prototype"); JComboBox comboProto1 = new JComboBox(new Object[] { "aa", "aaaaa", "aaaaaaaaaa", "this one is the one", "abcdefghijklmnopqrstuvwxyz" }); comboProto1.setPrototypeDisplayValue("aaaaa"); comboProto1.putClientProperty( SubstanceLookAndFeel.COMBO_POPUP_PROTOTYPE, "this one is the one"); builder.append("Hard-coded value", comboProto1); JComboBox comboProto2 = new JComboBox(new Object[] { "aa", "aaaaa", "aaaaaaaaaa", "another one (not it)", "abcdefghijklmnopqrstuvwxyz" }); comboProto2.setPrototypeDisplayValue("aaaaa"); comboProto2.putClientProperty( SubstanceLookAndFeel.COMBO_POPUP_PROTOTYPE, new WidestComboPopupPrototype()); builder.append("Widest core callback", comboProto2); JComboBox comboProto3 = new JComboBox(new Object[] { "aa", "aaaaa", "this is not", "this one is not it", "this one is it that is for the popup" }); comboProto3.setPrototypeDisplayValue("aaaaa"); comboProto3.putClientProperty( SubstanceLookAndFeel.COMBO_POPUP_PROTOTYPE, new ComboPopupPrototypeCallback() { public Object getPopupPrototypeDisplayValue(JComboBox jc) { return jc.getModel().getElementAt( jc.getModel().getSize() - 1); } }); builder.append("Custom callback", comboProto3); builder.appendSeparator("Empty combos"); JComboBox emptyModelCombo = new JComboBox(new String[] {}); builder.append("Empty model", emptyModelCombo); JComboBox emptyStringCombo = new JComboBox(new String[] { "" }); builder.append("Empty string", emptyStringCombo); JComboBox spaceCombo = new JComboBox(new String[] { " " }); builder.append("Space string", spaceCombo); JComboBox emptyEditableCombo = new JComboBox(new String[] {}); emptyEditableCombo.setEditable(true); builder.append("Empty model + editable", emptyEditableCombo); JComboBox emptyStringEditableCombo = new JComboBox(new String[] { "" }); emptyStringEditableCombo.setEditable(true); builder.append("Empty string + editable", emptyStringEditableCombo); JComboBox spaceEditableCombo = new JComboBox(new String[] { " " }); spaceEditableCombo.setEditable(true); builder.append("Space string + editable", spaceEditableCombo); return builder.getPanel(); } /** * Creates the combobox panel. */ public CombosPanel() { this.setLayout(new BorderLayout()); } @Override public synchronized void initialize() { JPanel gridPanel = new ScrollablePanel(); gridPanel.setLayout(new GridLayout(1, 2)); gridPanel.add(getLeftComboPanel()); gridPanel.add(getRightComboPanel()); this.add(new JScrollPane(gridPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER); FormLayout lm = new FormLayout("fill:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); JButton checkEscape = new JButton("Check ESC key"); checkEscape.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final JDialog dialog = new JDialog(); dialog.setTitle("Press ESC key when combo is focused"); dialog.setLayout(new FlowLayout()); JComboBox sampleCombo = new JComboBox(new Object[] { "Ester", "Jordi", "Jordina", "Jorge", "Sergi" }); sampleCombo.setEditable(true); dialog.add(sampleCombo); dialog.add(new JCheckBox("Sample checkbox")); dialog.add(new JButton("Sample button")); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); JRootPane rootPane = dialog.getRootPane(); InputMap iMap = rootPane .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); iMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "escape"); ActionMap aMap = rootPane.getActionMap(); aMap.put("escape", new AbstractAction() { public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); dialog.pack(); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); // center the dialog in the physical screen dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2); dialog.setVisible(true); } }); JButton disableCombosButton = new JButton("Disable all"); disableCombosButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { CombosPanel.run(CombosPanel.this, new DisableCommand()); } }); } }); JButton enableCombosButton = new JButton("Enable all"); enableCombosButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { CombosPanel.run(CombosPanel.this, new EnableCommand()); } }); } }); JButton makeAllEditableButton = new JButton("Make all editable"); makeAllEditableButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { CombosPanel.run(CombosPanel.this, new EditAllowCommand()); } }); } }); JButton makeAllNonEditableButton = new JButton("Make all non-editable"); makeAllNonEditableButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { CombosPanel.run(CombosPanel.this, new EditDisallowCommand()); } }); } }); builder.append(disableCombosButton); builder.append(enableCombosButton); builder.append(makeAllNonEditableButton); builder.append(makeAllEditableButton); builder.append(checkEscape); this.controlPanel = builder.getPanel(); this.isInitialized = true; } } substance-5.3.orig/src/test/check/AnimateProgressBar.java0000644000175000017500000000226610731171170023425 0ustar drazzibdrazzibpackage test.check; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; public class AnimateProgressBar extends JFrame { public AnimateProgressBar() { this.setLayout(new BorderLayout()); final JProgressBar jpb = new JProgressBar(0, 15); this.add(jpb, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton forw = new JButton("Increment"); forw.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jpb.setValue(jpb.getValue() + 1); } }); controls.add(forw); this.add(controls, BorderLayout.SOUTH); this.setSize(300, 100); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); SwingUtilities.invokeLater(new Runnable() { public void run() { new AnimateProgressBar().setVisible(true); } }); } } substance-5.3.orig/src/test/check/SliderPanel.java0000644000175000017500000003733511212462606022106 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Hashtable; import javax.swing.*; import test.check.command.ConfigurationCommand; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; /** * Test application panel for testing {@link JSlider} component. * * @author Kirill Grouchnikov */ public class SliderPanel extends ControllablePanel implements Deferrable { private boolean isInitialized; @Override public boolean isInitialized() { return this.isInitialized; } /** * A configure command that sets a titled border on the specified slider. * * @author Kirill Grouchnikov */ public static class SetTitleBorderCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(JSlider slider) { slider.setBorder(BorderFactory.createTitledBorder("Title")); } } /** * A configure command that clears the border of the specified slider. * * @author Kirill Grouchnikov */ public static class ClearBorderCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(JSlider slider) { slider.setBorder(null); } } /** * A configure command that configures the specified slider to snap to the * ticks. * * @author Kirill Grouchnikov */ public static class SnapToTicksCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(JSlider slider) { slider.setSnapToTicks(true); } } /** * A configure command that configures the specified slider to not snap to * the ticks. * * @author Kirill Grouchnikov */ public static class UnsnapToTicksCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(JSlider slider) { slider.setSnapToTicks(false); } } /** * Creates the test panel with sliders. */ public SliderPanel() { this.setLayout(new BorderLayout()); } public synchronized void initialize() { JPanel mainPanel = new ScrollablePanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.setOpaque(false); this.add(new JScrollPane(mainPanel), BorderLayout.CENTER); JPanel horPanel = new JPanel(); BoxLayout horLayout = new BoxLayout(horPanel, BoxLayout.Y_AXIS); horPanel.setLayout(horLayout); JSlider horizontalLTR3 = new JSlider(0, 100, 50); horizontalLTR3.setSnapToTicks(true); horizontalLTR3.setMajorTickSpacing(20); horizontalLTR3.setMinorTickSpacing(5); horPanel.add(horizontalLTR3); JSlider horizontalLTR2 = new JSlider(0, 100, 50); horizontalLTR2.setSnapToTicks(true); horizontalLTR2.setMajorTickSpacing(20); horizontalLTR2.setMinorTickSpacing(5); horizontalLTR2.setPaintTicks(true); horPanel.add(horizontalLTR2); JSlider horizontalLTR1 = new JSlider(0, 100, 50); horizontalLTR1.setSnapToTicks(true); horizontalLTR1.setMajorTickSpacing(20); horizontalLTR1.setMinorTickSpacing(5); horizontalLTR1.setPaintLabels(true); horPanel.add(horizontalLTR1); JSlider horizontalLTR = new JSlider(0, 100, 50); horizontalLTR.setSnapToTicks(true); horizontalLTR.setMajorTickSpacing(20); horizontalLTR.setMinorTickSpacing(5); horizontalLTR.setPaintTicks(true); horizontalLTR.setPaintLabels(true); horPanel.add(horizontalLTR); JSlider disHorizontalLTR3 = new JSlider(0, 100, 50); disHorizontalLTR3.setSnapToTicks(true); disHorizontalLTR3.setMajorTickSpacing(20); disHorizontalLTR3.setMinorTickSpacing(5); disHorizontalLTR3.setEnabled(false); horPanel.add(disHorizontalLTR3); JSlider disHorizontalLTR2 = new JSlider(0, 100, 50); disHorizontalLTR2.setSnapToTicks(true); disHorizontalLTR2.setMajorTickSpacing(20); disHorizontalLTR2.setMinorTickSpacing(5); disHorizontalLTR2.setPaintTicks(true); disHorizontalLTR2.setEnabled(false); horPanel.add(disHorizontalLTR2); JSlider disHorizontalLTR1 = new JSlider(0, 100, 50); disHorizontalLTR1.setSnapToTicks(true); disHorizontalLTR1.setMajorTickSpacing(20); disHorizontalLTR1.setMinorTickSpacing(5); disHorizontalLTR1.setPaintLabels(true); disHorizontalLTR1.setEnabled(false); horPanel.add(disHorizontalLTR1); JSlider disHorizontalLTR = new JSlider(0, 100, 50); disHorizontalLTR.setSnapToTicks(true); disHorizontalLTR.setMajorTickSpacing(20); disHorizontalLTR.setMinorTickSpacing(5); disHorizontalLTR.setPaintTicks(true); disHorizontalLTR.setPaintLabels(true); disHorizontalLTR.setEnabled(false); horPanel.add(disHorizontalLTR); JSlider invertedHorizontalLTR = new JSlider(0, 100, 30); invertedHorizontalLTR.setSnapToTicks(true); invertedHorizontalLTR.setMajorTickSpacing(20); invertedHorizontalLTR.setMinorTickSpacing(5); invertedHorizontalLTR.setPaintTicks(true); invertedHorizontalLTR.setPaintLabels(true); invertedHorizontalLTR.setInverted(true); horPanel.add(invertedHorizontalLTR); JSlider horizontalRTL = new JSlider(0, 100, 50); horizontalRTL.setSnapToTicks(true); horizontalRTL.setMajorTickSpacing(20); horizontalRTL.setMinorTickSpacing(5); horizontalRTL.setPaintTicks(true); horizontalRTL.setPaintLabels(true); horizontalRTL .applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); horPanel.add(horizontalRTL); JSlider disHorizontalRTL = new JSlider(0, 100, 50); disHorizontalRTL.setSnapToTicks(true); disHorizontalRTL.setMajorTickSpacing(20); disHorizontalRTL.setMinorTickSpacing(5); disHorizontalRTL.setPaintTicks(true); disHorizontalRTL.setPaintLabels(true); disHorizontalRTL.setEnabled(false); disHorizontalRTL .applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); horPanel.add(disHorizontalRTL); JSlider titledHorizontal = new JSlider(0, 100, 50); titledHorizontal.setBorder(BorderFactory.createTitledBorder("Title")); horPanel.add(titledHorizontal); JSlider coloredLabels = getSliderWithColoredLabels(); horPanel.add(coloredLabels); JSlider htmlLabels = getSliderWithHTMLLabels(); horPanel.add(htmlLabels); mainPanel.add(horPanel, BorderLayout.WEST); JPanel verPanel = new JPanel(new FlowLayout()); mainPanel.add(verPanel, BorderLayout.CENTER); JSlider verticalLTR3 = new JSlider(JSlider.VERTICAL, 0, 100, 50); verticalLTR3.setSnapToTicks(true); verticalLTR3.setMajorTickSpacing(20); verticalLTR3.setMinorTickSpacing(5); // verticalLTR3.setPaintTicks(true); // verticalLTR3.setPaintLabels(true); verPanel.add(verticalLTR3); JSlider verticalLTR1 = new JSlider(JSlider.VERTICAL, 0, 100, 50); verticalLTR1.setSnapToTicks(true); verticalLTR1.setMajorTickSpacing(20); verticalLTR1.setMinorTickSpacing(5); verticalLTR1.setPaintTicks(true); // verticalLTR1.setPaintLabels(true); verPanel.add(verticalLTR1); JSlider verticalLTR2 = new JSlider(JSlider.VERTICAL, 0, 100, 50); verticalLTR2.setSnapToTicks(true); verticalLTR2.setMajorTickSpacing(20); verticalLTR2.setMinorTickSpacing(5); // verticalLTR2.setPaintTicks(true); verticalLTR2.setPaintLabels(true); verPanel.add(verticalLTR2); JSlider verticalLTR = new JSlider(JSlider.VERTICAL, 0, 100, 50); verticalLTR.setSnapToTicks(true); verticalLTR.setMajorTickSpacing(20); verticalLTR.setMinorTickSpacing(5); verticalLTR.setPaintTicks(true); verticalLTR.setPaintLabels(true); verPanel.add(verticalLTR); JSlider disVerticalLTR = new JSlider(JSlider.VERTICAL, 0, 100, 50); disVerticalLTR.setSnapToTicks(true); disVerticalLTR.setMajorTickSpacing(20); disVerticalLTR.setMinorTickSpacing(5); disVerticalLTR.setPaintTicks(true); disVerticalLTR.setPaintLabels(true); disVerticalLTR.setEnabled(false); verPanel.add(disVerticalLTR); JSlider invertedVerticalLTR = new JSlider(JSlider.VERTICAL, 0, 100, 30); invertedVerticalLTR.setSnapToTicks(true); invertedVerticalLTR.setMajorTickSpacing(20); invertedVerticalLTR.setMinorTickSpacing(5); invertedVerticalLTR.setPaintTicks(true); invertedVerticalLTR.setPaintLabels(true); invertedVerticalLTR.setInverted(true); verPanel.add(invertedVerticalLTR); JSlider verticalRTL3 = new JSlider(JSlider.VERTICAL, 0, 100, 50); verticalRTL3.setSnapToTicks(true); verticalRTL3.setMajorTickSpacing(20); verticalRTL3.setMinorTickSpacing(5); // verticalRTL3.setPaintTicks(true); // verticalRTL3.setPaintLabels(true); verticalRTL3 .applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); verPanel.add(verticalRTL3); JSlider verticalRTL1 = new JSlider(JSlider.VERTICAL, 0, 100, 50); verticalRTL1.setSnapToTicks(true); verticalRTL1.setMajorTickSpacing(20); verticalRTL1.setMinorTickSpacing(5); verticalRTL1.setPaintTicks(true); // verticalRTL1.setPaintLabels(true); verticalRTL1 .applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); verPanel.add(verticalRTL1); JSlider verticalRTL2 = new JSlider(JSlider.VERTICAL, 0, 100, 50); verticalRTL2.setSnapToTicks(true); verticalRTL2.setMajorTickSpacing(20); verticalRTL2.setMinorTickSpacing(5); // verticalRTL2.setPaintTicks(true); verticalRTL2.setPaintLabels(true); verticalRTL2 .applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); verPanel.add(verticalRTL2); JSlider verticalRTL = new JSlider(JSlider.VERTICAL, 0, 100, 50); verticalRTL.setSnapToTicks(true); verticalRTL.setMajorTickSpacing(20); verticalRTL.setMinorTickSpacing(5); verticalRTL.setPaintTicks(true); verticalRTL.setPaintLabels(true); verticalRTL .applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); verPanel.add(verticalRTL); JSlider disVerticalRTL = new JSlider(JSlider.VERTICAL, 0, 100, 50); disVerticalRTL.setSnapToTicks(true); disVerticalRTL.setMajorTickSpacing(20); disVerticalRTL.setMinorTickSpacing(5); disVerticalRTL.setPaintTicks(true); disVerticalRTL.setPaintLabels(true); disVerticalRTL.setEnabled(false); disVerticalRTL .applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); verPanel.add(disVerticalRTL); FormLayout lm = new FormLayout("fill:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); JButton setTitledBorderButton = new JButton("Set titled border"); setTitledBorderButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { SliderPanel.run(SliderPanel.this, new SetTitleBorderCommand()); } }); } }); JButton clearBorderButton = new JButton("Clear border"); clearBorderButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { SliderPanel.run(SliderPanel.this, new ClearBorderCommand()); } }); } }); JButton snapToTicksButton = new JButton("Snap to ticks"); snapToTicksButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { SliderPanel.run(SliderPanel.this, new SnapToTicksCommand()); } }); } }); JButton unsnapToTicksButton = new JButton("Unsnap to ticks"); unsnapToTicksButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { SliderPanel.run(SliderPanel.this, new UnsnapToTicksCommand()); } }); } }); builder.append(setTitledBorderButton); builder.append(clearBorderButton); builder.append(snapToTicksButton); builder.append(unsnapToTicksButton); this.controlPanel = builder.getPanel(); this.isInitialized = true; } private JSlider getSliderWithColoredLabels() { JSlider coloredLabels = new JSlider(); coloredLabels.setMinimum(0); coloredLabels.setMaximum(2); coloredLabels.setMajorTickSpacing(1); coloredLabels.setPaintLabels(true); Hashtable labels = new Hashtable(); JLabel l0 = new JLabel("Red"); l0.setForeground(new Color(255, 0, 0)); labels.put(new Integer(0), l0); JLabel l1 = new JLabel("Green"); l1.setForeground(new Color(0, 255, 0)); labels.put(new Integer(1), l1); JLabel l2 = new JLabel("Blue"); l2.setForeground(new Color(0, 0, 255)); labels.put(new Integer(2), l2); coloredLabels.setLabelTable(labels); return coloredLabels; } private JSlider getSliderWithHTMLLabels() { JSlider htmlLabels = new JSlider(); htmlLabels.setMinimum(0); htmlLabels.setMaximum(2); htmlLabels.setMajorTickSpacing(1); htmlLabels.setPaintLabels(true); Hashtable labels = new Hashtable(); JLabel l0 = new JLabel( "0
0
0"); l0.setForeground(new Color(255, 0, 0)); labels.put(new Integer(0), l0); JLabel l1 = new JLabel( "1
1
1"); labels.put(new Integer(1), l1); JLabel l2 = new JLabel( "2
2
2"); labels.put(new Integer(2), l2); htmlLabels.setLabelTable(labels); return htmlLabels; } /** * Runs the specified configuration command on all sliders in the specified * component. * * @param comp * Component. * @param command * Configuration command to run. */ public static void run(Component comp, ConfigurationCommand command) { if (comp instanceof JSlider) { command.configure((JSlider) comp); return; } if (comp instanceof Container) { Container cont = (Container) comp; for (int i = 0; i < cont.getComponentCount(); i++) { run(cont.getComponent(i), command); } } } }substance-5.3.orig/src/test/check/TabPanel.java0000644000175000017500000001071311022155444021357 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.BorderLayout; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.SkinChangeListener; import org.jvnet.substance.utils.SubstanceImageCreator; import test.Check; /** * Test application panel for testing {@link JTabbedPane} component. * * @author Kirill Grouchnikov */ public class TabPanel extends ControllablePanel { /** * Tabbed pane. */ public JTabbedPane jtp; /** * Creates a test panel with tabbed pane. */ public TabPanel() { this.setLayout(new BorderLayout()); jtp = new JTabbedPane(); NumberedPanel tnp1 = new NumberedPanel(1); jtp.addTab("tab0", null, new JPanel()); jtp.addTab("tab1", Check.getIcon("flag_mexico"), tnp1); jtp.addTab("tab 2", Check.getIcon("flag_sweden"), new NumberedPanel(2)); NumberedPanel tnp3 = new NumberedPanel(3); jtp.addTab("tab 3", Check.getIcon("flag_russia"), tnp3); final NumberedPanel np4 = new NumberedPanel(4); boolean isSubstance = (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel); jtp.addTab("tab 4", isSubstance ? new ImageIcon(SubstanceImageCreator .getBigHexaMarker(4, SubstanceLookAndFeel.getCurrentSkin(jtp) .getMainActiveColorScheme())) : null, np4); final NumberedPanel np5 = new NumberedPanel(5); jtp.addTab("tab 5", isSubstance ? new ImageIcon( SubstanceImageCreator.getBigHexaMarker(5, SubstanceLookAndFeel .getCurrentSkin(jtp).getMainActiveColorScheme())) : null, np5); SubstanceLookAndFeel .registerSkinChangeListener(new SkinChangeListener() { @Override public void skinChanged() { int index4 = jtp.indexOfComponent(np4); if (index4 >= 0) { jtp.setIconAt(index4, SubstanceImageCreator .getHexaMarker(4, SubstanceLookAndFeel .getCurrentSkin(jtp) .getMainActiveColorScheme())); } int index5 = jtp.indexOfComponent(np5); if (index5 >= 0) { jtp.setIconAt(index5, SubstanceImageCreator .getHexaMarker(5, SubstanceLookAndFeel .getCurrentSkin(jtp) .getMainActiveColorScheme())); } } }); jtp.setEnabledAt(2, false); jtp.setEnabledAt(3, false); this.add(jtp, BorderLayout.CENTER); try { MyTabPreviewPainter previewPainter = new MyTabPreviewPainter(); jtp.putClientProperty(LafWidget.TABBED_PANE_PREVIEW_PAINTER, previewPainter); this.controlPanel = new TabControlPanel(jtp, previewPainter); } catch (NoClassDefFoundError ncdfe) { this.controlPanel = new TabControlPanel(jtp, null); } catch (Throwable e) { } // this.setPreferredSize(new Dimension(400, 400)); // this.setSize(this.getPreferredSize()); // this.setMinimumSize(this.getPreferredSize()); } }substance-5.3.orig/src/test/check/Controllable.java0000644000175000017500000000400510734705420022312 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import javax.swing.JPanel; /** * Base interface for test application panels that wish to contribute a control * panel to the control task pane container. * * @author Kirill Grouchnikov */ public interface Controllable { /** * Returns the control panel. * * @return The control panel. */ public JPanel getControlPanel(); } substance-5.3.orig/src/test/check/SubstanceVerticalGradientWatermark.java0000644000175000017500000001027411022224010026632 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; import org.jvnet.substance.watermark.SubstanceWatermark; /** * Implementation of {@link org.jvnet.substance.watermark.SubstanceWatermark}, * drawing vertical gradient. * * @author Kirill Grouchnikov */ public class SubstanceVerticalGradientWatermark implements SubstanceWatermark { /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#drawWatermarkImage(java.awt.Graphics, * int, int, int, int) */ public void drawWatermarkImage(Graphics g, Component c, int x, int y, int width, int height) { if (c != null) if (!c.isDisplayable() || !c.isShowing()) return; Component parent = c; if (parent != null) { while (parent.getParent() != null) parent = parent.getParent(); } if (!parent.isShowing()) return; int dx = (parent != null) ? c.getLocationOnScreen().x - parent.getLocationOnScreen().x : 0; int dy = (parent != null) ? c.getLocationOnScreen().y - parent.getLocationOnScreen().y : 0; // int dw = (parent != null) ? parent.getWidth() : width; int dh = (parent != null) ? parent.getHeight() : height; Graphics2D graphics = (Graphics2D) g.create(); graphics.setPaint(new GradientPaint(x - dx, y - dy, Color.gray, x - dx, y - dy + dh, SubstanceColorSchemeUtilities.getColorScheme(c, ComponentState.DEFAULT).getMidColor())); graphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.8f)); graphics.fillRect(x, y, width, height); graphics.dispose(); } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#updateWatermarkImage(org.jvnet.substance.skin.SubstanceSkin) */ public boolean updateWatermarkImage(SubstanceSkin skin) { return true; } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#previewWatermark(java.awt.Graphics, * int, int, int, int) */ public void previewWatermark(Graphics g, int x, int y, int width, int height) { this.drawWatermarkImage(g, null, x, y, width, height); } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#getDisplayName() */ public String getDisplayName() { return "Vertical Gradient"; } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#dispose() */ public void dispose() { } } substance-5.3.orig/src/test/check/ColorizedControlsPanel.java0000644000175000017500000012110411212460756024332 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.text.DecimalFormat; import java.util.Enumeration; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.tree.*; import org.jvnet.substance.SubstanceLookAndFeel; import test.Check; import test.check.command.*; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; /** * Test application panel for testing colorized components. * * @author Kirill Grouchnikov */ public class ColorizedControlsPanel extends JPanel implements Deferrable { /** * The default button. */ public JButton defaultButton; private boolean isInitialized; @Override public boolean isInitialized() { return this.isInitialized; } /** * Returns a row of buttons, consisting of {@link JButton}, * {@link JToggleButton}, {@link JCheckBox} and {@link JRadioButton} in * default states. * * @return A row of buttons, consisting of {@link JButton}, * {@link JToggleButton}, {@link JCheckBox} and {@link JRadioButton} * in default states. */ private AbstractButton[] getRow() { AbstractButton[] result = new AbstractButton[4]; result[0] = new JButton("sample"); result[1] = new JToggleButton("sample"); result[2] = new JCheckBox("sample"); result[3] = new JRadioButton("sample"); return result; } /** * Adds a row of buttons configured with the specified text, icon and * configuration command. * * @param builder * Form builder. * @param label * Text to set. * @param icon * Icon to set. * @param configurationCmd * Configuration command to apply. */ private void addButtonRow(DefaultFormBuilder builder, String label, Icon icon, ConfigurationCommand configurationCmd) { AbstractButton[] row = this.getRow(); if (configurationCmd != null) { for (AbstractButton ab : row) { configurationCmd.configure(ab); ab.setName(label + " " + ab.getClass().getSimpleName()); } } JLabel jl = new JLabel(label); if (icon != null) jl.setIcon(icon); builder.append(jl); for (AbstractButton ab : row) builder.append(ab); } /** * Adds a row of components configured with the specified configuration * command. * * @param builder * Form builder. * @param label * Text to set. * @param creationCmd * Creation command. * @param configurationCmd * Configuration command to apply. */ private void addControlRow(DefaultFormBuilder builder, String label, CreationCommand creationCmd, ConfigurationCommand configurationCmd) { Component[] row = new Component[4]; row[0] = creationCmd.create(); row[0].setBackground(Color.yellow); row[0].setName(row[0].getName() + ": yellow backgr"); row[1] = creationCmd.create(); row[1].setBackground(Color.blue); row[1].setForeground(Color.red); row[1].setName(row[1].getName() + ": blue backgr, red foregr"); row[2] = creationCmd.create(); row[2].setBackground(Color.green); row[2].setName(row[2].getName() + ": green backgr"); row[3] = creationCmd.create(); row[3].setBackground(Color.green.darker()); row[3].setName(row[3].getName() + ": darker green backgr"); if (configurationCmd != null) { for (Component comp : row) { configurationCmd.configure(comp); } } JLabel jl = new JLabel(label); builder.append(jl); for (Component comp : row) builder.append(comp); } private void addInternalFrame(JDesktopPane desktopPane, CreationCommand creationCommand, ConfigurationCommand configCommand) { JInternalFrame jif = (JInternalFrame) creationCommand.create(); desktopPane.add(jif); configCommand.configure(jif); } /** * Creates a new button panel. */ @SuppressWarnings("unchecked") public ColorizedControlsPanel() { this.setLayout(new BorderLayout()); } @Override public synchronized void initialize() { FormLayout lmButtons = new FormLayout( "right:pref, 10dlu, left:pref:grow(1), 4dlu," + "left:pref:grow(1), 4dlu, left:pref:grow(1), " + "4dlu, left:pref:grow(1)", ""); lmButtons.setColumnGroups(new int[][] { { 3, 5, 7, 9 } }); DefaultFormBuilder builderButtons = new DefaultFormBuilder(lmButtons, new ScrollablePanel()); builderButtons.setDefaultDialogBorder(); builderButtons.append(""); JLabel bLabel = new JLabel("Buttons"); bLabel.setIcon(Check.getIcon("JButtonColor16")); JLabel tbLabel = new JLabel("Toggle buttons"); tbLabel.setIcon(Check.getIcon("JToggleButtonColor16")); JLabel cbLabel = new JLabel("Check boxes"); cbLabel.setIcon(Check.getIcon("JCheckBoxColor16")); JLabel rbLabel = new JLabel("Radio buttons"); rbLabel.setIcon(Check.getIcon("JRadioButtonColor16")); builderButtons.append(bLabel, tbLabel); builderButtons.append(cbLabel, rbLabel); builderButtons.appendSeparator("Regular settings"); this.addButtonRow(builderButtons, "Enabled", null, null); this.addButtonRow(builderButtons, "Flat", null, new ClientPropertyCommand(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE)); this.addButtonRow(builderButtons, "Disabled", null, new DisableCommand()); this .addButtonRow(builderButtons, "Selected", null, new SelectCommand()); this.addButtonRow(builderButtons, "Disabled selected", null, new ChainCommand(new DisableCommand(), new SelectCommand())); builderButtons.appendSeparator("Background settings"); this.addButtonRow(builderButtons, "Yellow", null, new BackgroundColorCommand(Color.yellow)); this.addButtonRow(builderButtons, "Yellow flat", null, new ChainCommand(new BackgroundColorCommand( Color.yellow), new ClientPropertyCommand( SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE))); this.addButtonRow(builderButtons, "Yellow disabled", null, new ChainCommand(new BackgroundColorCommand( Color.yellow), new DisableCommand())); this.addButtonRow(builderButtons, "Yellow selected", null, new ChainCommand(new BackgroundColorCommand( Color.yellow), new SelectCommand())); this.addButtonRow(builderButtons, "Yellow disabled selected", null, new ChainCommand(new BackgroundColorCommand( Color.yellow), new SelectCommand(), new DisableCommand())); this.addButtonRow(builderButtons, "Red", null, new BackgroundColorCommand(Color.red)); this.addButtonRow(builderButtons, "Red disabled", null, new ChainCommand(new BackgroundColorCommand( Color.red), new DisableCommand())); this.addButtonRow(builderButtons, "Red selected", null, new ChainCommand(new BackgroundColorCommand( Color.red), new SelectCommand())); this.addButtonRow(builderButtons, "Red disabled selected", null, new ChainCommand(new BackgroundColorCommand( Color.red), new SelectCommand(), new DisableCommand())); this.addButtonRow(builderButtons, "Green", null, new BackgroundColorCommand(Color.green)); this.addButtonRow(builderButtons, "Green disabled", null, new ChainCommand(new BackgroundColorCommand( Color.green), new DisableCommand())); this.addButtonRow(builderButtons, "Green selected", null, new ChainCommand(new BackgroundColorCommand( Color.green), new SelectCommand())); this .addButtonRow(builderButtons, "Green disabled selected", null, new ChainCommand(new BackgroundColorCommand( Color.green), new SelectCommand(), new DisableCommand())); this.addButtonRow(builderButtons, "Dark Green", null, new BackgroundColorCommand(Color.green.darker())); this.addButtonRow(builderButtons, "Dark Green disabled", null, new ChainCommand(new BackgroundColorCommand( Color.green.darker()), new DisableCommand())); this.addButtonRow(builderButtons, "Dark Green selected", null, new ChainCommand(new BackgroundColorCommand( Color.green.darker()), new SelectCommand())); this.addButtonRow(builderButtons, "Dark Green disabled selected", null, new ChainCommand(new BackgroundColorCommand( Color.green.darker()), new SelectCommand(), new DisableCommand())); builderButtons.appendSeparator("Foreground settings"); this.addButtonRow(builderButtons, "Yellow", null, new ForegroundColorCommand(Color.yellow)); this.addButtonRow(builderButtons, "Yellow disabled", null, new ChainCommand(new ForegroundColorCommand( Color.yellow), new DisableCommand())); this.addButtonRow(builderButtons, "Yellow selected", null, new ChainCommand(new ForegroundColorCommand( Color.yellow), new SelectCommand())); this.addButtonRow(builderButtons, "Yellow disabled selected", null, new ChainCommand(new ForegroundColorCommand( Color.yellow), new SelectCommand(), new DisableCommand())); this.addButtonRow(builderButtons, "Red", null, new ForegroundColorCommand(Color.red)); this.addButtonRow(builderButtons, "Red disabled", null, new ChainCommand(new ForegroundColorCommand( Color.red), new DisableCommand())); this.addButtonRow(builderButtons, "Red selected", null, new ChainCommand(new ForegroundColorCommand( Color.red), new SelectCommand())); this.addButtonRow(builderButtons, "Red disabled selected", null, new ChainCommand(new ForegroundColorCommand( Color.red), new SelectCommand(), new DisableCommand())); this.addButtonRow(builderButtons, "Green", null, new ForegroundColorCommand(Color.green)); this.addButtonRow(builderButtons, "Green disabled", null, new ChainCommand(new ForegroundColorCommand( Color.green), new DisableCommand())); this.addButtonRow(builderButtons, "Green selected", null, new ChainCommand(new ForegroundColorCommand( Color.green), new SelectCommand())); this .addButtonRow(builderButtons, "Green disabled selected", null, new ChainCommand(new ForegroundColorCommand( Color.green), new SelectCommand(), new DisableCommand())); this.addButtonRow(builderButtons, "Dark Green", null, new ForegroundColorCommand(Color.green.darker())); this.addButtonRow(builderButtons, "Dark Green disabled", null, new ChainCommand(new ForegroundColorCommand( Color.green.darker()), new DisableCommand())); this.addButtonRow(builderButtons, "Dark Green selected", null, new ChainCommand(new ForegroundColorCommand( Color.green.darker()), new SelectCommand())); this.addButtonRow(builderButtons, "Dark Green disabled selected", null, new ChainCommand(new ForegroundColorCommand( Color.green.darker()), new SelectCommand(), new DisableCommand())); builderButtons.appendSeparator("Combined settings"); this.addButtonRow(builderButtons, "Blue/yellow", null, new ChainCommand(new ForegroundColorCommand( Color.blue), new BackgroundColorCommand(Color.yellow))); this.addButtonRow(builderButtons, "Blue/yellow disabled", null, new ChainCommand(new ForegroundColorCommand( Color.blue), new BackgroundColorCommand(Color.yellow), new DisableCommand())); this.addButtonRow(builderButtons, "Blue/yellow selected", null, new ChainCommand(new ForegroundColorCommand( Color.blue), new BackgroundColorCommand(Color.yellow), new SelectCommand())); this.addButtonRow(builderButtons, "Blue/yellow disabled selected", null, new ChainCommand(new ForegroundColorCommand( Color.blue), new BackgroundColorCommand(Color.yellow), new SelectCommand(), new DisableCommand())); this.addButtonRow(builderButtons, "Red/light green", null, new ChainCommand(new ForegroundColorCommand( Color.red), new BackgroundColorCommand(Color.green .brighter()))); this.addButtonRow(builderButtons, "Red/light green disabled", null, new ChainCommand(new ForegroundColorCommand( Color.red), new BackgroundColorCommand(Color.green .brighter()), new DisableCommand())); this.addButtonRow(builderButtons, "Red/light green selected", null, new ChainCommand(new ForegroundColorCommand( Color.red), new BackgroundColorCommand(Color.green .brighter()), new SelectCommand())); this .addButtonRow(builderButtons, "Red/light green disabled selected", null, new ChainCommand(new ForegroundColorCommand( Color.red), new BackgroundColorCommand( Color.green.brighter()), new SelectCommand(), new DisableCommand())); this.addButtonRow(builderButtons, "Dark yellow/blue", null, new ChainCommand(new ForegroundColorCommand( Color.yellow.darker()), new BackgroundColorCommand( Color.blue))); this.addButtonRow(builderButtons, "Dark yellow/blue disabled", null, new ChainCommand(new ForegroundColorCommand( Color.yellow.darker()), new BackgroundColorCommand( Color.blue), new DisableCommand())); this.addButtonRow(builderButtons, "Dark yellow/blue selected", null, new ChainCommand(new ForegroundColorCommand( Color.yellow.darker()), new BackgroundColorCommand( Color.blue), new SelectCommand())); this .addButtonRow(builderButtons, "Dark yellow/blue disabled selected", null, new ChainCommand(new ForegroundColorCommand( Color.yellow.darker()), new BackgroundColorCommand(Color.blue), new SelectCommand(), new DisableCommand())); this.addButtonRow(builderButtons, "Dark green/magenta", null, new ChainCommand(new ForegroundColorCommand( Color.green.darker()), new BackgroundColorCommand( Color.magenta))); this.addButtonRow(builderButtons, "Dark green/magenta disabled", null, new ChainCommand(new ForegroundColorCommand( Color.green.darker()), new BackgroundColorCommand( Color.magenta), new DisableCommand())); this.addButtonRow(builderButtons, "Dark green/magenta selected", null, new ChainCommand(new ForegroundColorCommand( Color.green.darker()), new BackgroundColorCommand( Color.magenta), new SelectCommand())); this.addButtonRow(builderButtons, "Dark green/magenta disabled selected", null, new ChainCommand(new ForegroundColorCommand( Color.green.darker()), new BackgroundColorCommand( Color.magenta), new SelectCommand(), new DisableCommand())); JPanel panelButtons = builderButtons.getPanel(); JScrollPane jspButtons = new JScrollPane(panelButtons); panelButtons.setOpaque(false); jspButtons.setOpaque(false); jspButtons.getViewport().setOpaque(false); FormLayout lmOther = new FormLayout( "right:pref, 10dlu, left:pref:grow(1), 4dlu," + "left:pref:grow(1), 4dlu, left:pref:grow(1), " + "4dlu, left:pref:grow(1)", ""); lmOther.setColumnGroups(new int[][] { { 3, 5, 7, 9 } }); DefaultFormBuilder builderOther = new DefaultFormBuilder(lmOther, new ScrollablePanel()); builderOther.setDefaultDialogBorder(); builderOther.append(""); builderOther.append(new JLabel("Yellow"), new JLabel( "Blue + red foreground")); builderOther.append(new JLabel("Green"), new JLabel("Dark green")); builderOther.appendSeparator("Labels"); addControlRow(builderOther, "Regular", new CreationCommand() { public Component create() { return new JLabel("label"); } }, null); addControlRow(builderOther, "Disabled", new CreationCommand() { public Component create() { return new JLabel("label"); } }, new DisableCommand()); addControlRow(builderOther, "HTML", new CreationCommand() { public Component create() { return new JLabel( "text text text"); } }, null); builderOther.appendSeparator("Sliders"); addControlRow(builderOther, "Regular", new CreationCommand() { public Component create() { return new JSlider(0, 100, 50); } }, null); addControlRow(builderOther, "Disabled", new CreationCommand() { public Component create() { return new JSlider(0, 100, 50); } }, new DisableCommand()); builderOther.appendSeparator("Progress bars"); addControlRow(builderOther, "Regular", new CreationCommand() { public Component create() { JProgressBar jpb = new JProgressBar(0, 100); jpb.setIndeterminate(false); jpb.setValue(50); jpb.setStringPainted(true); return jpb; } }, null); addControlRow(builderOther, "Disabled", new CreationCommand() { public Component create() { JProgressBar jpb = new JProgressBar(0, 100); jpb.setIndeterminate(false); jpb.setValue(50); jpb.setStringPainted(true); return jpb; } }, new DisableCommand()); addControlRow(builderOther, "Custom foreground", new CreationCommand() { public Component create() { JProgressBar jpb = new JProgressBar(0, 100); jpb.setIndeterminate(false); jpb.setValue(50); jpb.setStringPainted(true); return jpb; } }, new ForegroundColorCommand(Color.red)); addControlRow(builderOther, "Disabled with foreground", new CreationCommand() { public Component create() { JProgressBar jpb = new JProgressBar(0, 100); jpb.setIndeterminate(false); jpb.setValue(50); jpb.setStringPainted(true); return jpb; } }, new ChainCommand(new DisableCommand(), new ForegroundColorCommand(Color.red))); addControlRow(builderOther, "Indeterminate", new CreationCommand() { public Component create() { JProgressBar jpb = new JProgressBar(0, 100); jpb.setIndeterminate(true); return jpb; } }, null); addControlRow(builderOther, "Indeterminate disabled", new CreationCommand() { public Component create() { JProgressBar jpb = new JProgressBar(0, 100); jpb.setIndeterminate(true); return jpb; } }, new DisableCommand()); builderOther.appendSeparator("Combo boxes"); addControlRow(builderOther, "Regular", new CreationCommand() { public Component create() { JComboBox jcb = new JComboBox(new Object[] { "Ester", "Jordi", "Jordina", "Jorge", "Sergi" }); return jcb; } }, null); addControlRow(builderOther, "Flat", new CreationCommand() { public Component create() { JComboBox jcb = new JComboBox(new Object[] { "Ester", "Jordi", "Jordina", "Jorge", "Sergi" }); return jcb; } }, new ClientPropertyCommand(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE)); addControlRow(builderOther, "Disabled", new CreationCommand() { public Component create() { JComboBox jcb = new JComboBox(new Object[] { "Ester", "Jordi", "Jordina", "Jorge", "Sergi" }); return jcb; } }, new DisableCommand()); addControlRow(builderOther, "Editable", new CreationCommand() { public Component create() { JComboBox jcb = new JComboBox(new Object[] { "Ester", "Jordi", "Jordina", "Jorge", "Sergi" }); jcb.setEditable(true); return jcb; } }, null); addControlRow(builderOther, "Disabled editable", new CreationCommand() { public Component create() { JComboBox jcb = new JComboBox(new Object[] { "Ester", "Jordi", "Jordina", "Jorge", "Sergi" }); jcb.setEditable(true); return jcb; } }, new DisableCommand()); CreationCommand spinnerCreationCmd = new CreationCommand() { public Component create() { JSpinner s = new JSpinner(new SpinnerListModel(new Object[] { "sample0", "sample", "sample2" })); s.getModel().setValue("sample"); return s; } }; builderOther.appendSeparator("Spinners"); addControlRow(builderOther, "Regular", spinnerCreationCmd, null); addControlRow(builderOther, "Flat", spinnerCreationCmd, new ClientPropertyCommand(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE)); addControlRow(builderOther, "Disabled", spinnerCreationCmd, new DisableCommand()); JPanel panelOther = builderOther.getPanel(); JScrollPane jspOther = new JScrollPane(panelOther); panelOther.setOpaque(false); jspOther.setOpaque(false); jspOther.getViewport().setOpaque(false); FormLayout lmText = new FormLayout( "right:pref, 10dlu, left:pref:grow(1), 4dlu," + "left:pref:grow(1), 4dlu, left:pref:grow(1), " + "4dlu, left:pref:grow(1)", ""); lmText.setColumnGroups(new int[][] { { 3, 5, 7, 9 } }); DefaultFormBuilder builderText = new DefaultFormBuilder(lmText, new ScrollablePanel()); builderText.setDefaultDialogBorder(); builderText.append(""); builderText.append(new JLabel("Yellow"), new JLabel( "Blue + red foreground")); builderText.append(new JLabel("Green"), new JLabel("Dark green")); builderText.appendSeparator("Text fields"); addControlRow(builderText, "Regular", new CreationCommand() { public Component create() { JTextField field = new JTextField("test", 15); return field; } }, null); addControlRow(builderText, "Watermark", new CreationCommand() { public Component create() { JTextField field = new JTextField("test", 15); return field; } }, new ClientPropertyCommand( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE)); addControlRow(builderText, "Disabled", new CreationCommand() { public Component create() { JTextField field = new JTextField("test", 15); return field; } }, new DisableCommand()); addControlRow(builderText, "Not editable", new CreationCommand() { public Component create() { JTextField field = new JTextField("test", 15); field.setEditable(false); return field; } }, null); builderText.appendSeparator("Formatted text fields"); addControlRow(builderText, "Regular", new CreationCommand() { public Component create() { JFormattedTextField field = new JFormattedTextField( new DecimalFormat("#,##0.0000")); field.setText("2,430.0000"); return field; } }, null); addControlRow(builderText, "Watermark", new CreationCommand() { public Component create() { JFormattedTextField field = new JFormattedTextField( new DecimalFormat("#,##0.0000")); field.setText("2,430.0000"); return field; } }, new ClientPropertyCommand( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE)); addControlRow(builderText, "Disabled", new CreationCommand() { public Component create() { JFormattedTextField field = new JFormattedTextField( new DecimalFormat("#,##0.0000")); field.setText("2,430.0000"); return field; } }, new DisableCommand()); addControlRow(builderText, "Not editable", new CreationCommand() { public Component create() { JFormattedTextField field = new JFormattedTextField( new DecimalFormat("#,##0.0000")); field.setText("2,430.0000"); field.setEditable(false); return field; } }, null); builderText.appendSeparator("Password fields"); addControlRow(builderText, "Regular", new CreationCommand() { public Component create() { JPasswordField field = new JPasswordField("password", 15); return field; } }, null); addControlRow(builderText, "Watermark", new CreationCommand() { public Component create() { JPasswordField field = new JPasswordField("password", 15); return field; } }, new ClientPropertyCommand( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE)); addControlRow(builderText, "Disabled", new CreationCommand() { public Component create() { JPasswordField field = new JPasswordField("password", 15); return field; } }, new DisableCommand()); addControlRow(builderText, "Not editable", new CreationCommand() { public Component create() { JPasswordField field = new JPasswordField("password", 15); field.setEditable(false); return field; } }, null); builderText.appendSeparator("Editor panes"); addControlRow(builderText, "Regular", new CreationCommand() { public Component create() { JEditorPane pane = new JEditorPane("text/html;", "Sample content
text"); return pane; } }, null); addControlRow(builderText, "Watermark", new CreationCommand() { public Component create() { JEditorPane pane = new JEditorPane("text/html;", "Sample content
text"); return pane; } }, new ClientPropertyCommand( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE)); addControlRow(builderText, "Disabled", new CreationCommand() { public Component create() { JEditorPane pane = new JEditorPane("text/html;", "Sample content
text"); return pane; } }, new DisableCommand()); addControlRow(builderText, "Not editable", new CreationCommand() { public Component create() { JEditorPane pane = new JEditorPane("text/html;", "Sample content
text"); pane.setEditable(false); return pane; } }, null); builderText.appendSeparator("Text areas"); addControlRow(builderText, "Regular", new CreationCommand() { public Component create() { JTextArea area = new JTextArea("Sample content text", 3, 15); return area; } }, null); addControlRow(builderText, "Watermark", new CreationCommand() { public Component create() { JTextArea area = new JTextArea("Sample content text", 3, 15); return area; } }, new ClientPropertyCommand( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE)); addControlRow(builderText, "Disabled", new CreationCommand() { public Component create() { JTextArea area = new JTextArea("Sample content text", 3, 15); return area; } }, new DisableCommand()); addControlRow(builderText, "Not editable", new CreationCommand() { public Component create() { JTextArea area = new JTextArea("Sample content text", 3, 15); area.setEditable(false); return area; } }, null); builderText.appendSeparator("Text panes"); addControlRow(builderText, "Regular", new CreationCommand() { public Component create() { JTextPane pane = new JTextPane(); pane.replaceSelection("Sample content text"); pane.setPreferredSize(new Dimension(120, 40)); return pane; } }, null); addControlRow(builderText, "Watermark", new CreationCommand() { public Component create() { JTextPane pane = new JTextPane(); pane.replaceSelection("Sample content text"); pane.setPreferredSize(new Dimension(120, 40)); return pane; } }, new ClientPropertyCommand( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE)); addControlRow(builderText, "Disabled", new CreationCommand() { public Component create() { JTextPane pane = new JTextPane(); pane.replaceSelection("Sample content text"); pane.setPreferredSize(new Dimension(120, 40)); return pane; } }, new DisableCommand()); addControlRow(builderText, "Not editable", new CreationCommand() { public Component create() { JTextPane pane = new JTextPane(); pane.replaceSelection("Sample content text"); pane.setPreferredSize(new Dimension(120, 40)); pane.setEditable(false); return pane; } }, null); JPanel panelText = builderText.getPanel(); JScrollPane jspText = new JScrollPane(panelText); panelText.setOpaque(false); jspText.setOpaque(false); jspText.getViewport().setOpaque(false); JScrollPane coloredScrollPane = new JScrollPane(new CheckeredPanel()); coloredScrollPane.setBackground(Color.yellow); coloredScrollPane.getVerticalScrollBar().setBackground(Color.green); FormLayout lmCells = new FormLayout( "right:pref, 10dlu, fill:pref:grow(1), 4dlu," + "fill:pref:grow(1), 4dlu, fill:pref:grow(1), " + "4dlu, fill:pref:grow(1)", ""); lmCells.setColumnGroups(new int[][] { { 3, 5, 7, 9 } }); DefaultFormBuilder builderCells = new DefaultFormBuilder(lmCells, new ScrollablePanel()); builderCells.setDefaultDialogBorder(); builderCells.append(""); builderCells.append(new JLabel("Yellow"), new JLabel( "Blue + red foreground")); builderCells.append(new JLabel("Green"), new JLabel("Dark green")); builderCells.appendSeparator("Lists"); addControlRow(builderCells, "List", new CreationCommand() { public Component create() { JList list = new JList(new Object[] { "entry1", "entry2", "entry3" }); return list; } }, null); addControlRow(builderCells, "List watermark", new CreationCommand() { public Component create() { JList list = new JList(new Object[] { "entry1", "entry2", "entry3" }); return list; } }, new ClientPropertyCommand( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE)); addControlRow(builderCells, "List disabled", new CreationCommand() { public Component create() { JList list = new JList(new Object[] { "entry1", "entry2", "entry3" }); return list; } }, new DisableCommand()); CreationCommand tableCreationCmd = new CreationCommand() { public Component create() { final JTable table = new JTable(new Object[][] { { "entry11", "entry12", "entry13" }, { "entry21", "entry22", "entry23" }, { "entry31", "entry32", "entry33" } }, new Object[] { "Column1", "Column2", "Column3" }); table.setName("Table "); JScrollPane tableScroll = new JScrollPane(table) { @Override public void setBackground(Color bg) { super.setBackground(bg); table.setBackground(bg); table.getTableHeader().setBackground(bg); } @Override public void setForeground(Color fg) { super.setForeground(fg); table.setForeground(fg); table.getTableHeader().setForeground(fg); } }; Dimension prefTable = table.getPreferredSize(); tableScroll.setPreferredSize(new Dimension(prefTable.width, prefTable.height + 25)); return tableScroll; } }; builderCells.appendSeparator("Tables"); addControlRow(builderCells, "Table", tableCreationCmd, null); addControlRow(builderCells, "Table watermark", tableCreationCmd, new ClientPropertyCommand( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE)); addControlRow(builderCells, "Table disabled", tableCreationCmd, new DisableViewportCommand()); CreationCommand treeCreationCmd = new CreationCommand() { public void expandAll(JTree tree, boolean expand) { TreeNode root = (TreeNode) tree.getModel().getRoot(); // Traverse tree from root expandAll(tree, new TreePath(root), expand); } private void expandAll(JTree tree, TreePath parent, boolean expand) { // Traverse children TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.getChildCount() >= 0) { for (Enumeration e = node.children(); e.hasMoreElements();) { TreeNode n = (TreeNode) e.nextElement(); TreePath path = parent.pathByAddingChild(n); expandAll(tree, path, expand); } } // Expansion or collapse must be done bottom-up if (expand) { tree.expandPath(parent); } else { tree.collapsePath(parent); } } public Component create() { DefaultMutableTreeNode root = new DefaultMutableTreeNode("root"); DefaultMutableTreeNode son1 = new DefaultMutableTreeNode("son1"); DefaultMutableTreeNode son2 = new DefaultMutableTreeNode("son2"); DefaultMutableTreeNode son3 = new DefaultMutableTreeNode("son3"); DefaultMutableTreeNode gson11 = new DefaultMutableTreeNode( "gson11"); DefaultMutableTreeNode gson12 = new DefaultMutableTreeNode( "gson12"); DefaultMutableTreeNode gson21 = new DefaultMutableTreeNode( "gson21"); DefaultMutableTreeNode gson22 = new DefaultMutableTreeNode( "gson22"); DefaultMutableTreeNode gson31 = new DefaultMutableTreeNode( "gson31"); DefaultMutableTreeNode gson32 = new DefaultMutableTreeNode( "gson32"); DefaultMutableTreeNode ggson111 = new DefaultMutableTreeNode( "ggson111"); DefaultMutableTreeNode ggson112 = new DefaultMutableTreeNode( "ggson112"); DefaultMutableTreeNode ggson113 = new DefaultMutableTreeNode( "ggson113"); gson11.add(ggson111); gson11.add(ggson112); gson11.add(ggson113); son1.add(gson11); son1.add(gson12); son2.add(gson21); son2.add(gson22); son3.add(gson31); son3.add(gson32); root.add(son1); root.add(son2); root.add(son3); JTree tree = new JTree(root); expandAll(tree, true); return tree; } }; builderCells.appendSeparator("Trees"); addControlRow(builderCells, "Tree", treeCreationCmd, null); addControlRow(builderCells, "Tree watermark", treeCreationCmd, new ClientPropertyCommand( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE)); addControlRow(builderCells, "Tree disabled", treeCreationCmd, new DisableCommand()); JPanel panelCells = builderCells.getPanel(); JScrollPane jspCells = new JScrollPane(panelCells); panelCells.setOpaque(false); jspCells.setOpaque(false); jspCells.getViewport().setOpaque(false); JDesktopPane desktopPane = new JDesktopPane(); CreationCommand internalFrameCreationCmd = new CreationCommand() { public Component create() { JInternalFrame jif = new JInternalFrame("Internal frame"); jif.setLayout(new FlowLayout()); JButton button = new JButton("red button"); button.setBackground(Color.red); jif.add(button); jif.setClosable(true); jif.setMaximizable(true); jif.setIconifiable(true); jif.setResizable(true); jif.setVisible(true); JMenuBar jmb = new JMenuBar(); JMenu coloredMenu = new JMenu("Colors"); coloredMenu.setMnemonic('0'); JMenuItem coloredMI = new JMenuItem("Italic red"); coloredMI.setFont(coloredMI.getFont().deriveFont(Font.ITALIC)); coloredMI.setForeground(Color.red); coloredMI.setBackground(Color.yellow); coloredMenu.add(coloredMI); JRadioButtonMenuItem coloredRBMI = new JRadioButtonMenuItem( "Bold green"); coloredRBMI .setFont(coloredRBMI.getFont().deriveFont(Font.BOLD)); coloredRBMI.setForeground(Color.green); coloredRBMI.setBackground(Color.blue.brighter()); coloredMenu.add(coloredRBMI); JCheckBoxMenuItem coloredCBMI = new JCheckBoxMenuItem( "Big blue"); coloredCBMI.setFont(coloredCBMI.getFont().deriveFont(32f)); coloredCBMI.setForeground(Color.blue); coloredCBMI.setBackground(Color.green.brighter()); coloredMenu.add(coloredCBMI); JMenu coloredM = new JMenu("Always big magenta"); coloredM.setForeground(Color.magenta); coloredM.setBackground(Color.red.darker()); coloredM.setFont(coloredM.getFont().deriveFont(24f)); coloredMenu.add(coloredM); jmb.add(coloredMenu); JMenu blueMenu = new JMenu("Blue"); blueMenu.setForeground(Color.blue); blueMenu.setBackground(Color.yellow); jmb.add(blueMenu); jif.setJMenuBar(jmb); return jif; } }; addInternalFrame(desktopPane, internalFrameCreationCmd, new ChainCommand(new BackgroundColorCommand( Color.yellow), new SetBoundsCommand(new Rectangle(0, 0, 200, 100)))); addInternalFrame(desktopPane, internalFrameCreationCmd, new ChainCommand(new BackgroundColorCommand( Color.green), new SetBoundsCommand(new Rectangle(250, 0, 200, 100)))); addInternalFrame(desktopPane, internalFrameCreationCmd, new ChainCommand(new BackgroundColorCommand( Color.yellow), new SetBoundsCommand(new Rectangle(0, 150, 200, 100)), new MinimizeInternalFrameCommand())); addInternalFrame(desktopPane, internalFrameCreationCmd, new ChainCommand(new BackgroundColorCommand( Color.green), new SetBoundsCommand(new Rectangle(250, 150, 200, 100)), new MinimizeInternalFrameCommand())); desktopPane.setBackground(Color.blue); final JTabbedPane tabbed = new JTabbedPane(); tabbed.addTab("Buttons", jspButtons); tabbed.addTab("Text", jspText); tabbed.addTab("Scroll", coloredScrollPane); tabbed.addTab("Cells", jspCells); tabbed.addTab("Desktop", desktopPane); tabbed.addTab("Other", jspOther); tabbed.addTab("Yellow / Magenta", new JPanel()); tabbed.setBackgroundAt(tabbed.getTabCount() - 1, Color.yellow); tabbed.setForegroundAt(tabbed.getTabCount() - 1, Color.magenta); tabbed.addTab("Green / Blue", new JPanel()); tabbed.setBackgroundAt(tabbed.getTabCount() - 1, Color.green); tabbed.setForegroundAt(tabbed.getTabCount() - 1, Color.blue); tabbed.addTab("Dark Green", new JPanel()); tabbed.setBackgroundAt(tabbed.getTabCount() - 1, Color.green.darker()); tabbed.addTab("Disabled Green / Red", new JPanel()); tabbed.setBackgroundAt(tabbed.getTabCount() - 1, Color.green); tabbed.setForegroundAt(tabbed.getTabCount() - 1, Color.red.darker()); tabbed.setEnabledAt(tabbed.getTabCount() - 1, false); this.add(tabbed, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.LEFT)); final JSlider colorizationSlider = new JSlider(0, 100, 50); this.putClientProperty(SubstanceLookAndFeel.COLORIZATION_FACTOR, 0.5); colorizationSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { double val = colorizationSlider.getValue() / 100.0; ColorizedControlsPanel.this.putClientProperty( SubstanceLookAndFeel.COLORIZATION_FACTOR, new Double( val)); tabbed.repaint(); } }); controls.add(colorizationSlider); this.add(controls, BorderLayout.NORTH); this.isInitialized = true; } } substance-5.3.orig/src/test/check/TabControlPanel.java0000644000175000017500000005041311021243346022717 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.*; import java.util.*; import javax.swing.*; import org.jvnet.lafwidget.LafWidgetUtilities2; import org.jvnet.lafwidget.utils.LafConstants.TabOverviewKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.TabContentPaneBorderKind; import org.jvnet.substance.skin.SkinChangeListener; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.SubstanceImageCreator; import com.jgoodies.forms.builder.PanelBuilder; import com.jgoodies.forms.layout.CellConstraints; import com.jgoodies.forms.layout.FormLayout; /** * Control panel for the tabbed panes. * * @author Kirill Grouchnikov */ public class TabControlPanel extends JPanel { /** * Tabbed pane. */ private JTabbedPane jtp; /** * Contains the closed components. */ public LinkedList closed; /** * Model for the combobox that contains the list of all tabs. * * @author Kirill Grouchnikov */ private static class TabComboBoxModel extends DefaultComboBoxModel { /** * Tabbed pane. */ private JTabbedPane jtp; /** * Creates the combobox model. * * @param jtp * Tabbed pane. */ public TabComboBoxModel(JTabbedPane jtp) { this.jtp = jtp; } /* * (non-Javadoc) * * @see javax.swing.DefaultComboBoxModel#getSize() */ @Override public int getSize() { return this.jtp.getTabCount(); } /* * (non-Javadoc) * * @see javax.swing.DefaultComboBoxModel#getElementAt(int) */ @Override public Object getElementAt(int index) { return index; } /* * (non-Javadoc) * * @see javax.swing.DefaultComboBoxModel#getIndexOf(java.lang.Object) */ @Override public int getIndexOf(Object anObject) { return (Integer) anObject; } /** * Fires the event that the combo contents has been changed. */ public void changed() { this.fireContentsChanged(this, 0, this.getSize() - 1); } } /** * Cell renderer for the combobox that lists the tabs. * * @author Kirill Grouchnikov */ private class TabCellRenderer extends JLabel implements ListCellRenderer { /* * (non-Javadoc) * * @see * javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing * .JList, java.lang.Object, int, boolean, boolean) */ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value == null) { this.setText(""); this.setIcon(null); } else { this.setText(jtp.getTitleAt((Integer) value)); this.setIcon(jtp.getIconAt((Integer) value)); } return this; } } /** * Returns the contents of the control panel. * * @param jtp * Tabbed pane. * @param mainTabPreviewPainter * Tab preview painter. * @return Control panel contents. */ private JPanel getContents(final JTabbedPane jtp, final MyTabPreviewPainter mainTabPreviewPainter) { FormLayout lm = new FormLayout( "right:pref, 4dlu, fill:min:grow(1), 2dlu, fill:min:grow(1)", "p, 2dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 7dlu, " + "p, 2dlu, p, 0dlu, p, 0dlu, p, 0dlu, p, 7dlu," + "p, 2dlu, p, 3dlu, p, 0dlu, p, 3dlu, p, 3dlu, p, 7dlu, " + "p, 2dlu, p, 0dlu, p, 0dlu, p, 0dlu, p, 7dlu, " + "p, 2dlu, p, 3dlu, p"); lm.setColumnGroups(new int[][] { { 3, 5 } }); PanelBuilder builder = new PanelBuilder(lm); // builder.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); int row = 1; builder.addSeparator("General", cc.xyw(1, row, 5)); final JComboBox addKindCombo = new JComboBox(new Object[] { "regular", "null", "modified" }); JButton addNewTabButton = new JButton("Add"); addNewTabButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String selectedKind = (String) addKindCombo.getSelectedItem(); if ("null".equals(selectedKind)) { SwingUtilities.invokeLater(new Runnable() { public void run() { jtp .addTab( "null tab", new ImageIcon( SubstanceImageCreator .getBigHexaMarker( 0, SubstanceLookAndFeel .getCurrentSkin( jtp) .getMainActiveColorScheme())), null); } }); return; } final int count = 1 + jtp.getTabCount(); final JComponent tabComp = new NumberedPanel(count); if ("modified".equals(selectedKind)) { tabComp.putClientProperty( SubstanceLookAndFeel.WINDOW_MODIFIED, Boolean.TRUE); } SwingUtilities.invokeLater(new Runnable() { public void run() { jtp.addTab("tab" + count, new ImageIcon( SubstanceImageCreator.getBigHexaMarker(count, SubstanceLookAndFeel .getCurrentSkin(jtp) .getMainActiveColorScheme())), tabComp); } }); SubstanceLookAndFeel .registerSkinChangeListener(new SkinChangeListener() { @Override public void skinChanged() { int index = jtp.indexOfComponent(tabComp); if (index >= 0) jtp .setIconAt( index, SubstanceImageCreator .getHexaMarker( count, SubstanceLookAndFeel .getCurrentSkin( jtp) .getMainActiveColorScheme())); } }); } }); row += 2; builder.addLabel("Add tab", cc.xy(1, row)); builder.add(addKindCombo, cc.xy(3, row)); builder.add(addNewTabButton, cc.xy(5, row)); final JComboBox placementCombo = new JComboBox(new Object[] { "top", "bottom", "left", "right" }); placementCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String selected = (String) placementCombo.getSelectedItem(); if ("top".equals(selected)) jtp.setTabPlacement(JTabbedPane.TOP); if ("bottom".equals(selected)) jtp.setTabPlacement(JTabbedPane.BOTTOM); if ("left".equals(selected)) jtp.setTabPlacement(JTabbedPane.LEFT); if ("right".equals(selected)) jtp.setTabPlacement(JTabbedPane.RIGHT); } }); row += 2; builder.addLabel("Placement", cc.xy(1, row)); builder.add(placementCombo, cc.xyw(3, row, 3)); try { final JComboBox overviewKindCombo = new FlexiComboBox( TabOverviewKind.GRID, TabOverviewKind.MENU_CAROUSEL, TabOverviewKind.ROUND_CAROUSEL) { @Override public String getCaption(TabOverviewKind item) { return item.getName(); } }; overviewKindCombo.setSelectedItem(LafWidgetUtilities2 .getTabPreviewPainter(jtp).getOverviewKind(jtp)); overviewKindCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { mainTabPreviewPainter .setTabOverviewKind((TabOverviewKind) overviewKindCombo .getSelectedItem()); } }); row += 2; builder.addLabel("Overview kind", cc.xy(1, row)); builder.add(overviewKindCombo, cc.xyw(3, row, 3)); } catch (NoClassDefFoundError ncdfe) { } final JCheckBox useScrollLayout = new JCheckBox("Uses scroll layout"); useScrollLayout.setSelected(false); useScrollLayout.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jtp .setTabLayoutPolicy(useScrollLayout.isSelected() ? JTabbedPane.SCROLL_TAB_LAYOUT : JTabbedPane.WRAP_TAB_LAYOUT); } }); row += 2; builder.addLabel("Layout", cc.xy(1, row)); builder.add(useScrollLayout, cc.xyw(3, row, 3)); final JComboBox contentBorderCombo = new JComboBox(new Object[] { TabContentPaneBorderKind.DOUBLE_FULL, TabContentPaneBorderKind.SINGLE_FULL, TabContentPaneBorderKind.DOUBLE_PLACEMENT, TabContentPaneBorderKind.SINGLE_PLACEMENT }); contentBorderCombo.setSelectedItem(SubstanceCoreUtilities .getContentBorderKind(jtp)); contentBorderCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { TabContentPaneBorderKind contentBorderKind = (TabContentPaneBorderKind) contentBorderCombo .getSelectedItem(); jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND, contentBorderKind); jtp.updateUI(); jtp.repaint(); } }); row += 2; builder.addLabel("Content border", cc.xy(1, row)); builder.add(contentBorderCombo, cc.xyw(3, row, 3)); JButton enableAll = new JButton("+ all"); enableAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { for (int i = 0; i < jtp.getTabCount(); i++) { jtp.setEnabledAt(i, true); } } }); JButton disableAll = new JButton("- all"); disableAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { for (int i = 0; i < jtp.getTabCount(); i++) { jtp.setEnabledAt(i, false); } } }); row += 2; builder.addLabel("Enable all", cc.xy(1, row)); builder.add(enableAll, cc.xy(3, row)); builder.add(disableAll, cc.xy(5, row)); JButton closeAllEnabled = new JButton("Close"); closeAllEnabled.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Set toRemove = new HashSet(); for (int i = 0; i < jtp.getTabCount(); i++) { if (jtp.isEnabledAt(i)) toRemove.add(jtp.getComponentAt(i)); } for (Component comp : toRemove) jtp.remove(comp); } }); JButton restoreClosed = new JButton("Restore"); restoreClosed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { for (Component tnp : closed) { jtp.addTab("restored", tnp); } } }); row += 2; builder.addLabel("Close all", cc.xy(1, row)); builder.add(closeAllEnabled, cc.xy(3, row)); builder.add(restoreClosed, cc.xy(5, row)); row += 2; builder.addSeparator("Single Tab", cc.xyw(1, row, 5)); final JComboBox tabSelectorCombo = new JComboBox(new TabComboBoxModel( this.jtp)); tabSelectorCombo.setRenderer(new TabCellRenderer()); jtp.addContainerListener(new ContainerAdapter() { @Override public void componentAdded(ContainerEvent e) { ((TabComboBoxModel) tabSelectorCombo.getModel()).changed(); } @Override public void componentRemoved(ContainerEvent e) { ((TabComboBoxModel) tabSelectorCombo.getModel()).changed(); } }); row += 2; builder.addLabel("Select", cc.xy(1, row)); builder.add(tabSelectorCombo, cc.xyw(3, row, 3)); final JCheckBox markAsModified = new JCheckBox("Marked modified"); markAsModified.setSelected(false); markAsModified.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (tabSelectorCombo.getSelectedItem() == null) return; Component comp = jtp.getComponentAt((Integer) tabSelectorCombo .getSelectedItem()); if ((comp != null) && (comp instanceof JComponent)) { JComponent jc = (JComponent) comp; jc .putClientProperty( SubstanceLookAndFeel.WINDOW_MODIFIED, (markAsModified.isSelected() ? Boolean.TRUE : false)); } } }); tabSelectorCombo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { Component selComp = jtp .getComponentAt((Integer) tabSelectorCombo .getSelectedItem()); if ((selComp != null) && (selComp instanceof JComponent)) { JComponent selected = (JComponent) selComp; markAsModified .setSelected(Boolean.TRUE .equals(selected .getClientProperty(SubstanceLookAndFeel.WINDOW_MODIFIED))); } } }); row += 2; builder.addLabel("Modified", cc.xy(1, row)); builder.add(markAsModified, cc.xyw(3, row, 3)); final JCheckBox isModifiedAnimOnClose = new JCheckBox("Animation on X"); isModifiedAnimOnClose.setSelected(false); isModifiedAnimOnClose.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (tabSelectorCombo.getSelectedItem() == null) return; Component comp = jtp.getComponentAt((Integer) tabSelectorCombo .getSelectedItem()); if ((comp != null) && (comp instanceof JComponent)) { JComponent jc = (JComponent) comp; jc .putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION, (isModifiedAnimOnClose.isSelected() ? Boolean.TRUE : null)); } } }); tabSelectorCombo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { Component selComp = jtp .getComponentAt((Integer) tabSelectorCombo .getSelectedItem()); if ((selComp != null) && (selComp instanceof JComponent)) { JComponent selected = (JComponent) selComp; isModifiedAnimOnClose .setSelected(Boolean.TRUE .equals(selected .getClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION))); } } }); row += 2; builder.add(isModifiedAnimOnClose, cc.xyw(3, row, 3)); final JCheckBox hasCloseButton = new JCheckBox("No close button"); hasCloseButton.setSelected(false); hasCloseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (tabSelectorCombo.getSelectedItem() == null) return; Component comp = jtp.getComponentAt((Integer) tabSelectorCombo .getSelectedItem()); if ((comp != null) && (comp instanceof JComponent)) { JComponent jc = (JComponent) comp; jc .putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, (hasCloseButton.isSelected() ? Boolean.FALSE : null)); jtp.repaint(); } } }); tabSelectorCombo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { Component selComp = jtp .getComponentAt((Integer) tabSelectorCombo .getSelectedItem()); if ((selComp != null) && (selComp instanceof JComponent)) { JComponent selected = (JComponent) selComp; hasCloseButton .setSelected(Boolean.FALSE .equals(selected .getClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY))); } } }); JButton closeButton = new JButton("Close"); closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (tabSelectorCombo.getSelectedItem() == null) return; Component comp = jtp .getComponentAt((Integer) tabSelectorCombo .getSelectedItem()); jtp.removeTabAt((Integer) tabSelectorCombo .getSelectedItem()); closed.add(comp); jtp.repaint(); } }); } }); JButton selectButton = new JButton("Select"); selectButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (tabSelectorCombo.getSelectedItem() == null) return; jtp.setSelectedIndex((Integer) tabSelectorCombo .getSelectedItem()); } }); } }); row += 2; builder.addLabel("Tab op", cc.xy(1, row)); builder.add(closeButton, cc.xy(3, row)); builder.add(selectButton, cc.xy(5, row)); row += 2; builder.addSeparator("Close Button Single", cc.xyw(1, row, 5)); row += 2; builder.addLabel("Visible", cc.xy(1, row)); builder.add(hasCloseButton, cc.xyw(3, row, 3)); return builder.getPanel(); } /** * Creates the tab control panel. * * @param jtp * Tabbed pane. * @param previewPainter * Preview painter. */ public TabControlPanel(JTabbedPane jtp, MyTabPreviewPainter previewPainter) { super(); this.jtp = jtp; this.closed = new LinkedList(); this.setLayout(new BorderLayout()); JPanel contents = getContents(jtp, previewPainter); contents.setOpaque(false); contents.putClientProperty( SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE); this.add(contents, BorderLayout.CENTER); } // @Override // public Dimension getPreferredSize() { // Dimension result = super.getPreferredSize(); // return new Dimension(190, result.height); // } // // private class TabControlPanelLayout implements LayoutManager { // public void addLayoutComponent(String name, Component comp) { // } // // public void removeLayoutComponent(Component comp) { // } // // public void layoutContainer(Container parent) { // Insets pIns = paneControls.getInsets(); // Insets tIns = tabControls.getInsets(); // int width = Math.max(paneControls.getPreferredSize().width // + pIns.left + pIns.right, // tabControls.getPreferredSize().width + tIns.left // + tIns.right); // width = Math.min(parent.getWidth(), width); // // int h = paneControls.getPreferredSize().height + pIns.top // + pIns.bottom; // paneControls.setBounds(0, 0, width, h); // // tabControls.setBounds(0, h, width, // tabControls.getPreferredSize().height + tIns.top // + tIns.bottom); // } // // public Dimension minimumLayoutSize(Container parent) { // int w = Math.max(tabControls.getMinimumSize().width, paneControls // .getMinimumSize().width); // Insets tIns = tabControls.getInsets(); // Insets pIns = paneControls.getInsets(); // int h = tabControls.getMinimumSize().height // + paneControls.getMinimumSize().height + tIns.top // + tIns.bottom + pIns.top + pIns.bottom; // return new Dimension(w, h); // } // // public Dimension preferredLayoutSize(Container parent) { // int w = Math.max(tabControls.getPreferredSize().width, paneControls // .getPreferredSize().width); // Insets tIns = tabControls.getInsets(); // Insets pIns = paneControls.getInsets(); // int h = tabControls.getPreferredSize().height // + paneControls.getPreferredSize().height + tIns.top // + tIns.bottom + pIns.top + pIns.bottom; // return new Dimension(w, h); // } // } // // private void addSeparator(JPanel panel, String text) { // JLabel l = new JLabel(text, SwingConstants.LEADING); // l.setFont(l.getFont().deriveFont(Font.BOLD)); // // panel.add(l, "gapbottom 1,gaptop para, span, split 2"); // panel.add(new JSeparator(), "gapleft rel, gaptop para, growx"); // } } substance-5.3.orig/src/test/check/SubstanceLafChanger.java0000644000175000017500000000777311061670402023546 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; /** * @author kirillg * @author Daniel Stonier * @author Keith Woodward */ public class SubstanceLafChanger implements ActionListener { private JFrame frame; private String lafClassName; private boolean wasOriginallyDecoratedByOS; public static JMenuItem getMenuItem(JFrame frame, String lafName, String lafClassName) { JMenuItem result = new JMenuItem(lafName); result.addActionListener(new SubstanceLafChanger(frame, lafClassName)); return result; } public SubstanceLafChanger(JFrame frame, String lafClassName) { super(); this.frame = frame; this.lafClassName = lafClassName; this.wasOriginallyDecoratedByOS = !frame.isUndecorated(); } public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { final boolean wasDecoratedByOS = !frame.isUndecorated(); try { UIManager.setLookAndFeel(lafClassName); for (Window window : Window.getWindows()) { SwingUtilities.updateComponentTreeUI(window); } boolean canBeDecoratedByLAF = UIManager.getLookAndFeel() .getSupportsWindowDecorations(); if (canBeDecoratedByLAF == wasDecoratedByOS) { boolean wasVisible = frame.isVisible(); frame.setVisible(false); frame.dispose(); if (!canBeDecoratedByLAF || wasOriginallyDecoratedByOS) { // see the java docs under the method // JFrame.setDefaultLookAndFeelDecorated(boolean // value) for description of these 2 lines: frame.setUndecorated(false); frame.getRootPane().setWindowDecorationStyle( JRootPane.NONE); } else { frame.setUndecorated(true); frame.getRootPane().setWindowDecorationStyle( JRootPane.FRAME); } frame.setVisible(wasVisible); // wasDecoratedByOS = !frame.isUndecorated(); } } catch (ClassNotFoundException cnfe) { out("LAF main class '" + lafClassName + "' not found"); } catch (Exception exc) { exc.printStackTrace(); } } }); } public static void out(Object obj) { try { System.out.println(obj); } catch (Exception exc) { // ignore - is thrown on Mac in WebStart (security access) } } }substance-5.3.orig/src/test/check/MyLocaleChangeListener.java0000644000175000017500000001511310734705420024215 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Locale; import javax.swing.*; import javax.swing.plaf.FontUIResource; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.fonts.FontPolicy; import org.jvnet.substance.fonts.FontSet; /** * Listener to change the current locale. * * @author Kirill Grouchnikov */ public class MyLocaleChangeListener implements ActionListener { /** * Language code. */ private String langCode; /** * Country code. */ private String countryCode; /** * Main test frame. */ private JFrame frame; /** * Wrapper around the base Substance font set. Is used to create larger / * smaller font sets. * * @author Kirill Grouchnikov */ private static class DialogFontSet implements FontSet { /** * The base Substance font set. */ private FontSet delegate; /** * Creates a wrapper font set. * * @param delegate * The base Substance font set. */ public DialogFontSet(FontSet delegate) { super(); this.delegate = delegate; } /** * Returns the wrapped font. * * @param systemFont * Original font. * @return Wrapped font. */ private FontUIResource getWrappedFont(FontUIResource systemFont) { return new FontUIResource("Dialog", systemFont.getStyle(), systemFont.getSize()); } public FontUIResource getControlFont() { return this.getWrappedFont(this.delegate.getControlFont()); } public FontUIResource getMenuFont() { return this.getWrappedFont(this.delegate.getMenuFont()); } public FontUIResource getMessageFont() { return this.getWrappedFont(this.delegate.getMessageFont()); } public FontUIResource getSmallFont() { return this.getWrappedFont(this.delegate.getSmallFont()); } public FontUIResource getTitleFont() { return this.getWrappedFont(this.delegate.getTitleFont()); } public FontUIResource getWindowTitleFont() { return this.getWrappedFont(this.delegate.getWindowTitleFont()); } } /** * Creates the locale change listener. * * @param langCode * Language code. * @param countryCode * Country code. * @param frame * Main test frame. */ public MyLocaleChangeListener(String langCode, String countryCode, JFrame frame) { this.langCode = langCode; this.countryCode = countryCode; this.frame = frame; } // String getDefaultPattern(Locale locale) { // ResourceBundle r = LocaleData.getLocaleElements(locale); // // ResourceBundle r = ResourceBundle.getBundle( // // "java.text.resources.LocaleElements", locale); // String[] dateTimePatterns = r.getStringArray("DateTimePatterns"); // Object[] dateTimeArgs = { dateTimePatterns[DateFormat.SHORT], // dateTimePatterns[DateFormat.SHORT + 4] }; // return MessageFormat.format(dateTimePatterns[8], dateTimeArgs); // } // /** * Sets the specified locale on a component and all its children * (recursively). * * @param component * Component. * @param locale * Locale to set. */ void setLocale(Component component, Locale locale) { component.setLocale(locale); // if (component instanceof JSpinner) { // JSpinner spinner = (JSpinner) component; // if (spinner.getModel() instanceof SpinnerDateModel) { // // probably not the best way. Since this is test // // application, this will do. // spinner.setEditor(new JSpinner.DateEditor(spinner, // getDefaultPattern(locale))); // } // } if (component instanceof Container) { Container cont = (Container) component; for (int i = 0; i < cont.getComponentCount(); i++) setLocale(cont.getComponent(i), locale); } } public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { LookAndFeel currLaf = UIManager.getLookAndFeel(); // Locale currLocale = Locale.getDefault(); Locale newLocale = new Locale(langCode, countryCode); Locale.setDefault(newLocale); frame.applyComponentOrientation(ComponentOrientation .getOrientation(Locale.getDefault())); if (currLaf instanceof SubstanceLookAndFeel) { SubstanceLookAndFeel.resetLabelBundle(); if ("CN".equals(countryCode)) { final FontSet currFontSet = SubstanceLookAndFeel .getFontPolicy().getFontSet("Substance", null); SubstanceLookAndFeel.setFontPolicy(new FontPolicy() { public FontSet getFontSet(String lafName, UIDefaults table) { return new DialogFontSet(currFontSet); } }); } else { SubstanceLookAndFeel.setFontPolicy(null); } } try { UIManager.setLookAndFeel(currLaf.getClass().getName()); } catch (Exception exc) { } // this.setLocale(this.frame, newLocale); SwingUtilities.updateComponentTreeUI(frame); } }); } }substance-5.3.orig/src/test/check/SizesPanel.java0000644000175000017500000002226211010041276021742 0ustar drazzibdrazzibpackage test.check; import java.awt.*; import java.util.LinkedList; import java.util.List; import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; import javax.swing.tree.DefaultMutableTreeNode; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.renderers.SubstanceDefaultListCellRenderer; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; public class SizesPanel extends JPanel { private static interface Creator { public JComponent create(int fontSize); } private static class Mapping { public String caption; public Creator creator; public Mapping(String caption, Creator creator) { super(); this.caption = caption; this.creator = creator; } } private List model; private JScrollPane central; public SizesPanel() { this.model = new LinkedList(); this.model.add(new Mapping("buttons", new Creator() { public JComponent create(int fontSize) { JButton result = new JButton("size " + fontSize); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("toggle buttons", new Creator() { public JComponent create(int fontSize) { JToggleButton result = new JToggleButton("size " + fontSize); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("check boxes", new Creator() { public JComponent create(int fontSize) { JCheckBox result = new JCheckBox("size " + fontSize); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("radio buttons", new Creator() { public JComponent create(int fontSize) { JRadioButton result = new JRadioButton("size " + fontSize); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("combo boxes", new Creator() { public JComponent create(int fontSize) { JComboBox result = new JComboBox(new Object[] { "size " + fontSize }); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("spinners", new Creator() { public JComponent create(int fontSize) { JSpinner result = new JSpinner(new SpinnerNumberModel(fontSize, fontSize, fontSize, 1)); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("text fields", new Creator() { public JComponent create(int fontSize) { JTextField result = new JTextField("size " + fontSize); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("password fields", new Creator() { public JComponent create(int fontSize) { JPasswordField result = new JPasswordField("size " + fontSize); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("scroll bars", new Creator() { public JComponent create(int fontSize) { JScrollBar result = new JScrollBar(JScrollBar.HORIZONTAL); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("progress bars", new Creator() { public JComponent create(int fontSize) { JProgressBar result = new JProgressBar(JProgressBar.HORIZONTAL); result.setMinimum(0); result.setMaximum(100); result.setValue(60); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("progress bars 2", new Creator() { public JComponent create(int fontSize) { JProgressBar result = new JProgressBar(JProgressBar.HORIZONTAL); result.setMinimum(0); result.setMaximum(100); result.setValue(60); result.setStringPainted(true); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("sliders", new Creator() { public JComponent create(int fontSize) { JSlider result = new JSlider(JSlider.HORIZONTAL, 0, 100, 50); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("sliders 2", new Creator() { public JComponent create(int fontSize) { JSlider result = new JSlider(JSlider.HORIZONTAL, 0, 100, 50); result.setMajorTickSpacing(20); result.setMinorTickSpacing(5); result.setPaintLabels(true); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("sliders 3", new Creator() { public JComponent create(int fontSize) { JSlider result = new JSlider(JSlider.HORIZONTAL, 0, 100, 50); result.setMajorTickSpacing(20); result.setMinorTickSpacing(5); result.setPaintTicks(true); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("sliders 4", new Creator() { public JComponent create(int fontSize) { JSlider result = new JSlider(JSlider.HORIZONTAL, 0, 100, 50); result.setMajorTickSpacing(20); result.setMinorTickSpacing(5); result.setPaintTicks(true); result.setPaintLabels(true); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("trees", new Creator() { public JComponent create(int fontSize) { DefaultMutableTreeNode root = new DefaultMutableTreeNode( "size " + fontSize); DefaultMutableTreeNode son1 = new DefaultMutableTreeNode("son1"); DefaultMutableTreeNode gson11 = new DefaultMutableTreeNode( "gson11"); son1.add(gson11); root.add(son1); JTree result = new JTree(root); // result.setRootVisible(false); // result.setShowsRootHandles(true); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("lists", new Creator() { public JComponent create(int fontSize) { JList result = new JList(new Object[] { "item1", "item2" }); result.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return result; } })); this.model.add(new Mapping("tables", new Creator() { public JComponent create(int fontSize) { DefaultTableModel model = new DefaultTableModel() { @Override public int getRowCount() { return 2; } @Override public int getColumnCount() { return 3; } @Override public Object getValueAt(int row, int column) { return row + ":" + column; } @Override public boolean isCellEditable(int row, int column) { return false; } @Override public String getColumnName(int column) { return "Column " + column; } }; JTable table = new JTable(model); table.setFont(new Font("Tahoma", Font.PLAIN, fontSize)); return table; } })); final JList list = new JList(new AbstractListModel() { public Object getElementAt(int index) { return model.get(index); } public int getSize() { return model.size(); } }); if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) { list.setCellRenderer(new SubstanceDefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return super.getListCellRendererComponent(list, ((Mapping) value).caption, index, isSelected, cellHasFocus); } }); } this.setLayout(new BorderLayout()); this.add(new JScrollPane(list), BorderLayout.WEST); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.getSelectionModel().addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (central != null) remove(central); central = null; int selIndex = list.getSelectedIndex(); if (selIndex >= 0) { Mapping sel = (Mapping) list .getSelectedValue(); FormLayout lm = new FormLayout( "right:pref, 4dlu, left:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder( lm, new ScrollablePanel()); builder.setDefaultDialogBorder(); for (int fontSize = 11; fontSize < 25; fontSize++) { builder.append(fontSize + " pixels", sel.creator.create(fontSize)); } builder.append("72 pixels", sel.creator .create(72)); central = new JScrollPane( builder.getPanel(), JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); add(central, BorderLayout.CENTER); doLayout(); revalidate(); } } }); } }); } } substance-5.3.orig/src/test/check/ListPanel.java0000644000175000017500000003070711010041274021561 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; import javax.swing.*; import javax.swing.event.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.utils.LafConstants.AnimationKind; import org.jvnet.substance.*; import org.jvnet.substance.api.combo.WidestComboPopupPrototype; import org.jvnet.substance.api.renderers.SubstanceDefaultListCellRenderer; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; /** * Test application panel for testing {@link JList} component. * * @author Kirill Grouchnikov */ public class ListPanel extends ControllablePanel { /** * List model implementation with support for moving elements. * * @author Kirill Grouchnikov */ private static class MoveableListModel extends AbstractListModel { /** * The string list backing up the model. */ protected List model; /** * Creates a new model. */ public MoveableListModel(int modelSize) { super(); model = new ArrayList(); for (int i = 0; i < modelSize; i++) { model.add("element " + i); } } /* * (non-Javadoc) * * @see javax.swing.ListModel#getElementAt(int) */ public Object getElementAt(int index) { return model.get(index); } /* * (non-Javadoc) * * @see javax.swing.ListModel#getSize() */ public int getSize() { return model.size(); } /** * Moves the element at the specified index one position up. * * @param index * Element index. */ public void moveUp(int index) { String entry = model.get(index); model.set(index, model.get(index - 1)); model.set(index - 1, entry); fireContentsChanged(this, index - 1, index); } /** * Moves the element at the specified index one position down. * * @param index * Element index. */ public void moveDown(int index) { String entry = model.get(index); model.set(index, model.get(index + 1)); model.set(index + 1, entry); fireContentsChanged(this, index, index + 1); } /** * Deletes the element at the specified index. * * @param index * Element index. */ public void delete(int index) { model.remove(index); fireIntervalRemoved(this, index, index); } /* * (non-Javadoc) * * @see org.jvnet.lafwidget.list.MutableListModel#move(int, int) */ public void move(int fromIndex, int toIndex) { String from = model.remove(fromIndex); model.add(toIndex, from); fireContentsChanged(this, fromIndex, toIndex); } } /** * List. */ private JList list; /** * Button to move the selected element up. */ private JButton bUp; /** * Button to move the selected element down. */ private JButton bDown; /** * Button to delete the selected element. */ private JButton bDelete; /** * Old background color. */ private Color oldBackColor; /** * Creates a new list panel. */ public ListPanel() { super(); setLayout(new BorderLayout()); list = new JList(new MoveableListModel(100)); final JScrollPane jsp = new JScrollPane(list); this.add(jsp, BorderLayout.CENTER); FormLayout lm = new FormLayout("right:pref, 4dlu, fill:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); builder.appendSeparator("General"); final JCheckBox isEnabled = new JCheckBox("is enabled"); isEnabled.setSelected(list.isEnabled()); isEnabled.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { list.setEnabled(isEnabled.isSelected()); } }); builder.append("Enabled", isEnabled); final JSlider rowCountSlider = new JSlider(10, 1000, this.list .getModel().getSize()); rowCountSlider.setPaintLabels(false); rowCountSlider.setPaintTicks(false); rowCountSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (rowCountSlider.getValueIsAdjusting()) return; list.setModel(new MoveableListModel(rowCountSlider.getValue())); } }); builder.append("Row count", rowCountSlider); final JCheckBox watermarkBleed = new JCheckBox("watermark bleed"); watermarkBleed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { list.putClientProperty(SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.valueOf(watermarkBleed.isSelected())); jsp.putClientProperty(SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.valueOf(watermarkBleed.isSelected())); list.repaint(); } }); builder.append("Watermark", watermarkBleed); final JComboBox animCombo = new FlexiComboBox( AnimationKind.NONE, AnimationKind.SLOW, AnimationKind.REGULAR, AnimationKind.FAST) { @Override public String getCaption(AnimationKind item) { return item.getName(); } }; animCombo.setSelectedItem(AnimationKind.REGULAR); animCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { list.putClientProperty(LafWidget.ANIMATION_KIND, animCombo .getSelectedItem()); } }); builder.append("Animation", animCombo); bUp = new JButton("Move selected up"); bUp.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); bDown = new JButton("Move selected down"); bDown.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); bDelete = new JButton("Delete selected"); bDelete.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); builder.append("Actions", bUp); builder.append("", bDown); builder.append("", bDelete); bUp.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int si = list.getSelectedIndex(); MoveableListModel mlm = (MoveableListModel) list.getModel(); mlm.moveUp(si); list.setSelectedIndex(si - 1); } }); bDown.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int si = list.getSelectedIndex(); MoveableListModel mlm = (MoveableListModel) list.getModel(); mlm.moveDown(si); list.setSelectedIndex(si + 1); } }); bDelete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MoveableListModel mlm = (MoveableListModel) list.getModel(); for (int i = list.getMaxSelectionIndex(); i >= list .getMinSelectionIndex(); i--) { if (list.isSelectedIndex(i)) { mlm.delete(i); } } list.clearSelection(); } }); synchronize(); list.getSelectionModel().addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { synchronize(); } }); } }); final JComboBox selectionModelCb = new JComboBox(new Object[] { "single", "single interval", "multiple interval" }); selectionModelCb.setSelectedIndex(0); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); selectionModelCb.putClientProperty( SubstanceLookAndFeel.COMBO_POPUP_PROTOTYPE, new WidestComboPopupPrototype()); selectionModelCb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { String selected = (String) selectionModelCb .getSelectedItem(); if ("single".equals(selected)) list .setSelectionMode(ListSelectionModel.SINGLE_SELECTION); if ("single interval".equals(selected)) list .setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); if ("multiple interval".equals(selected)) list .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } }); } }); builder.append("Selection", selectionModelCb); final JCheckBox customBackgroundCb = new JCheckBox( "Has pink background"); customBackgroundCb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (customBackgroundCb.isSelected()) { oldBackColor = list.getBackground(); list.setBackground(new Color(255, 128, 128)); } else { list.setBackground(oldBackColor); } } }); builder.append("Background", customBackgroundCb); builder.appendSeparator("Renderer"); ButtonGroup listRendererGroup = new ButtonGroup(); final JRadioButton substanceRenderer = new JRadioButton("Substance"); substanceRenderer.setSelected(true); substanceRenderer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (substanceRenderer.isSelected()) list.setCellRenderer(new SubstanceDefaultListCellRenderer()); } }); final JRadioButton coreDefaultRenderer = new JRadioButton("Default core"); coreDefaultRenderer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (coreDefaultRenderer.isSelected()) list.setCellRenderer(new DefaultListCellRenderer()); } }); final JRadioButton customRenderer = new JRadioButton("Custom"); customRenderer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (customRenderer.isSelected()) list.setCellRenderer(new MyListCellRenderer()); } }); final JRadioButton customSubstanceRenderer = new JRadioButton("Custom Substance"); customSubstanceRenderer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (customSubstanceRenderer.isSelected()) list.setCellRenderer(new MySubstanceListCellRenderer()); } }); listRendererGroup.add(substanceRenderer); listRendererGroup.add(coreDefaultRenderer); listRendererGroup.add(customRenderer); listRendererGroup.add(customSubstanceRenderer); builder.append("Select type", substanceRenderer); builder.append("", coreDefaultRenderer); builder.append("", customRenderer); builder.append("", customSubstanceRenderer); controlPanel = builder.getPanel(); } /** * Synchronizes the list selection and the enable / disable status of the * control buttons. */ public void synchronize() { int sc = list.getSelectedIndices().length; if (sc != 1) { bUp.setEnabled(false); bDown.setEnabled(false); return; } bDelete.setEnabled(sc > 0); int si = list.getSelectedIndex(); bUp.setEnabled(si > 0); bDown.setEnabled(si < (list.getModel().getSize() - 1)); // this.bDelete.setEnabled(true); } } substance-5.3.orig/src/test/check/ControlPanelFactory.java0000644000175000017500000011031411253516762023631 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.awt.event.*; import java.lang.ref.*; import java.util.Locale; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.LafWidgetUtilities2; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.preview.DefaultPreviewPainter; import org.jvnet.lafwidget.utils.LafConstants.TabOverviewKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.*; import org.jvnet.substance.skin.NebulaBrickWallSkin; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.SubstanceImageCreator; import test.Check; import test.Check.MyMainTabPreviewPainter; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; /** * Factory for creating the global control panels (for global settings and * testing the dialogs). * * @author Kirill Grouchnikov */ public class ControlPanelFactory { /** * Instance of a simple dialog. */ private static SimpleDialog simpleDialog; /** * Instance of a disposable dialog. */ private static JDialog disposableDialog; private static GlobalFadeTrackerCallback globalFadeTrackerCallback; /** * Returns the main control panel. * * @param mainFrame * The main test frame. * @param mainTabbedPane * The main tabbed pane. * @param mainTabPreviewPainter * The preview painter of the main tabbed pane. * @param toolbar * The toolbar of the main test frame. * @return The main control panel. */ public static JPanel getMainControlPanel(final JFrame mainFrame, final JTabbedPane mainTabbedPane, final MyMainTabPreviewPainter mainTabPreviewPainter, final JToolBar toolbar) { FormLayout lm = new FormLayout("right:pref, 4dlu, fill:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm); // builder.setDefaultDialogBorder(); builder.appendSeparator("Title pane settings"); final JCheckBox markAsModified = new JCheckBox("Marked modified"); markAsModified.setSelected(false); markAsModified.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { mainFrame.getRootPane().putClientProperty( SubstanceLookAndFeel.WINDOW_MODIFIED, (markAsModified.isSelected() ? Boolean.TRUE : false)); } }); builder.append("Modified", markAsModified); final JCheckBox heapPanel = new JCheckBox("Has heap panel"); heapPanel.setSelected(false); heapPanel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SubstanceLookAndFeel.setWidgetVisible(mainFrame.getRootPane(), heapPanel.isSelected(), SubstanceWidgetType.TITLE_PANE_HEAP_STATUS); } }); builder.append("Heap panel", heapPanel); JButton changeTitleButton = new JButton("Change"); changeTitleButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String random = "abcdefghijklmnopqrstuvwxyz "; int length = 60 + (int) (150 * Math.random()); String title = ""; while (length > 0) { title += random.charAt((int) (random.length() * Math .random())); length--; } mainFrame.setTitle(title); } }); builder.append("Title string", changeTitleButton); builder.appendSeparator("Miscellaneous"); final JCheckBox useThemedDefaultIconsCheckBox = new JCheckBox( "use themed icons"); useThemedDefaultIconsCheckBox.setSelected(SubstanceCoreUtilities .useThemedDefaultIcon()); useThemedDefaultIconsCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { UIManager .put( SubstanceLookAndFeel.USE_THEMED_DEFAULT_ICONS, useThemedDefaultIconsCheckBox .isSelected() ? Boolean.TRUE : null); mainFrame.repaint(); } }); } }); builder.append("Themed icons", useThemedDefaultIconsCheckBox); final JCheckBox useConstantThemesOnDialogs = new JCheckBox( "use constant themes"); useConstantThemesOnDialogs.setSelected(SubstanceLookAndFeel .isToUseConstantThemesOnDialogs()); useConstantThemesOnDialogs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel .setToUseConstantThemesOnDialogs(useConstantThemesOnDialogs .isSelected()); SubstanceLookAndFeel.setSkin(SubstanceLookAndFeel .getCurrentSkin(mainFrame.getRootPane())); } }); } }); builder.append("Option pane icons", useConstantThemesOnDialogs); final JComboBox placementCombo = new JComboBox(new Object[] { "top", "bottom", "left", "right" }); placementCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String selected = (String) placementCombo.getSelectedItem(); if ("top".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.TOP); if ("bottom".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.BOTTOM); if ("left".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.LEFT); if ("right".equals(selected)) mainTabbedPane.setTabPlacement(JTabbedPane.RIGHT); } }); builder.append("Placement", placementCombo); try { final JComboBox overviewKindCombo = new FlexiComboBox( TabOverviewKind.GRID, TabOverviewKind.MENU_CAROUSEL, TabOverviewKind.ROUND_CAROUSEL) { @Override public String getCaption(TabOverviewKind item) { return item.getName(); } }; overviewKindCombo.setSelectedItem(LafWidgetUtilities2 .getTabPreviewPainter(mainTabbedPane).getOverviewKind( mainTabbedPane)); overviewKindCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { mainTabPreviewPainter .setTabOverviewKind((TabOverviewKind) overviewKindCombo .getSelectedItem()); } }); builder.append("Overview kind", overviewKindCombo); } catch (NoClassDefFoundError ncdfe) { } final JComboBox menuGutterFillCombo = new FlexiComboBox( MenuGutterFillKind.NONE, MenuGutterFillKind.SOFT, MenuGutterFillKind.HARD, MenuGutterFillKind.SOFT_FILL, MenuGutterFillKind.HARD_FILL) { @Override public String getCaption(MenuGutterFillKind item) { return item.name(); } }; menuGutterFillCombo.setSelectedItem(SubstanceCoreUtilities .getMenuGutterFillKind()); menuGutterFillCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UIManager.put(SubstanceLookAndFeel.MENU_GUTTER_FILL_KIND, menuGutterFillCombo.getSelectedItem()); } }); builder.append("Menu fill", menuGutterFillCombo); final JComboBox focusKindCombo = new FlexiComboBox(FocusKind .values()) { @Override public String getCaption(FocusKind item) { return item.name(); } }; focusKindCombo.setSelectedItem(SubstanceCoreUtilities .getFocusKind(null)); focusKindCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UIManager.put(SubstanceLookAndFeel.FOCUS_KIND, focusKindCombo .getSelectedItem()); } }); builder.append("Focus kind", focusKindCombo); JButton buttonGlassPane = new JButton("Show"); buttonGlassPane.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final JPanel glassPane = new JPanel() { @Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D graphics = (Graphics2D) g; int height = getHeight(); int width = getWidth(); Composite c = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, (float) 0.4); graphics.setComposite(c); for (int i = 0; i < height; i++) { Color color = (i % 2 == 0) ? new Color(200, 200, 255) : new Color(230, 230, 255); graphics.setColor(color); graphics.drawLine(0, i, width, i); } Composite c2 = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, (float) 1.0); graphics.setComposite(c2); } }; glassPane.setOpaque(false); glassPane.addMouseListener(new MouseAdapter() { }); glassPane.addKeyListener(new KeyAdapter() { }); mainFrame.setGlassPane(glassPane); new Thread() { @Override public void run() { glassPane.setVisible(true); try { Thread.sleep(5000); } catch (InterruptedException ie) { ie.printStackTrace(); } glassPane.setVisible(false); } }.start(); } }); builder.append("Glass pane", buttonGlassPane); builder.appendSeparator("Custom animations"); final JCheckBox allowFocusLoopAnimations = new JCheckBox( "Allow animation"); allowFocusLoopAnimations .setSelected(FadeConfigurationManager.getInstance() .fadeAllowed(FadeKind.FOCUS_LOOP_ANIMATION, null)); allowFocusLoopAnimations.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (allowFocusLoopAnimations.isSelected()) { FadeConfigurationManager.getInstance().allowFades( FadeKind.FOCUS_LOOP_ANIMATION); } else { FadeConfigurationManager.getInstance().disallowFades( FadeKind.FOCUS_LOOP_ANIMATION); } } }); builder.append("Focus loop", allowFocusLoopAnimations); final JCheckBox allowGlowIconAnimations = new JCheckBox( "Allow animation"); allowGlowIconAnimations.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (allowGlowIconAnimations.isSelected()) { FadeConfigurationManager.getInstance().allowFades( FadeKind.ICON_GLOW); } else { FadeConfigurationManager.getInstance().disallowFades( FadeKind.ICON_GLOW); } } }); builder.append("Icon glow", allowGlowIconAnimations); final JCheckBox allowGhostIconAnimations = new JCheckBox( "Allow animation"); allowGhostIconAnimations.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (allowGhostIconAnimations.isSelected()) { FadeConfigurationManager.getInstance().allowFades( FadeKind.GHOSTING_ICON_ROLLOVER); } else { FadeConfigurationManager.getInstance().disallowFades( FadeKind.GHOSTING_ICON_ROLLOVER); } } }); builder.append("Icon rollover", allowGhostIconAnimations); final JCheckBox allowGhostPressAnimations = new JCheckBox( "Allow animation"); allowGhostPressAnimations.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (allowGhostPressAnimations.isSelected()) { FadeConfigurationManager.getInstance().allowFades( FadeKind.GHOSTING_BUTTON_PRESS); } else { FadeConfigurationManager.getInstance().disallowFades( FadeKind.GHOSTING_BUTTON_PRESS); } } }); builder.append("Button press", allowGhostPressAnimations); globalFadeTrackerCallback = new GlobalFadeTrackerCallback() { @Override public void fadePerformed(Component comp, Comparable subID, FadeKind fadeKind, float fadeCycle10) { System.out.println(fadeKind.toString() + " performed on " + comp.getName() + "[" + comp.getClass().getSimpleName() + ":@" + comp.hashCode() + ":" + subID + "] at cycle " + fadeCycle10); } @Override public void fadeStarted(Component comp, Comparable subID, FadeKind fadeKind, float initialFadeCycle10) { System.out.println(fadeKind.toString() + " started on " + comp.getName() + "[" + comp.getClass().getSimpleName() + ":@" + comp.hashCode() + ":" + subID + "] at cycle " + initialFadeCycle10); } @Override public void fadeEnded(Component comp, Comparable subID, FadeKind fadeKind) { System.out.println(fadeKind.toString() + " ended on " + comp.getName() + "[" + comp.getClass().getSimpleName() + ":@" + comp.hashCode() + ":" + subID + "]"); } @Override public void fadeReversed(Component comp, Comparable subID, FadeKind fadeKind, boolean isFadingIn, float fadeCycle10) { System.out.println(fadeKind.toString() + " reversed on " + comp.getName() + "[" + comp.getClass().getSimpleName() + ":@" + comp.hashCode() + ":" + subID + "] at cycle " + fadeCycle10 + " to fade " + (isFadingIn ? "in" : "out")); } }; final JCheckBox toTrackAllApplicationFades = new JCheckBox( "track and report"); toTrackAllApplicationFades.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (toTrackAllApplicationFades.isSelected()) { FadeConfigurationManager .addGlobalFadeTrackerCallback(globalFadeTrackerCallback); } else { FadeConfigurationManager .removeGlobalFadeTrackerCallback(globalFadeTrackerCallback); } } }); builder.append("Global fade events", toTrackAllApplicationFades); builder.appendSeparator("Toolbar"); final JCheckBox isToolbarFlat = new JCheckBox("Is flat"); isToolbarFlat.setSelected(true); isToolbarFlat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { toolbar.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.valueOf(isToolbarFlat.isSelected())); toolbar.repaint(); } }); builder.append("Flat", isToolbarFlat); builder.appendSeparator("Menu bar"); final JCheckBox menuSearch = new JCheckBox("Has menu search"); menuSearch.setSelected(false); menuSearch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SubstanceLookAndFeel.setWidgetVisible(mainFrame.getRootPane(), menuSearch.isSelected(), SubstanceWidgetType.MENU_SEARCH); } }); builder.append("Menu search", menuSearch); final JCheckBox menuLocale = new JCheckBox("Has custom locale"); menuLocale.setSelected(false); menuLocale.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (menuLocale.isSelected()) { mainFrame.getJMenuBar().setLocale(Locale.FRENCH); mainFrame.getJMenuBar().putClientProperty( LafWidget.IGNORE_GLOBAL_LOCALE, Boolean.TRUE); } else { mainFrame.getJMenuBar().putClientProperty( LafWidget.IGNORE_GLOBAL_LOCALE, null); } } }); builder.append("Menu locale", menuLocale); JPanel result = builder.getPanel(); result.setName("Main control panel"); return result; } /** * Returns the control panel for testing dialogs. * * @param mainFrame * The main test frame. * @return Control panel for testing dialogs. */ public static JPanel getDialogControlPanel(final JFrame mainFrame) { FormLayout lm = new FormLayout("right:pref, 4dlu, fill:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm); builder.appendSeparator("Core choosers"); JButton bfo = new JButton("Open dialog", Check .getIcon("JFileChooserColor16")); bfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFileChooser jfc = new JFileChooser(); jfc.showOpenDialog(mainFrame); } }); } }); builder.append("File chooser", bfo); JButton bfs = new JButton("Save dialog", Check .getIcon("JFileChooserColor16")); bfs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFileChooser jfc = new JFileChooser(); jfc.showSaveDialog(mainFrame); } }); } }); builder.append("", bfs); JButton bc = new JButton("Open", Check.getIcon("JColorChooserColor16")); bc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { Color color = JColorChooser.showDialog(mainFrame, "Color chooser", new Color(23, 45, 200)); if (color != null) { Check.out("Chosen " + color.toString()); } } }); } }); builder.append("Color chooser", bc); JButton bcWindow = new JButton("open in window"); bcWindow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { final Window window = new Window(mainFrame); window.setLayout(new BorderLayout()); window.add(new JColorChooser()); window.pack(); window.setLocationRelativeTo(null); window.setVisible(true); Timer timerDispose = new Timer(5000, new ActionListener() { public void actionPerformed(ActionEvent e) { window.dispose(); } }); timerDispose.setRepeats(false); timerDispose.start(); } }); } }); builder.append("", bcWindow); builder.appendSeparator("Option panes"); JButton bop = new JButton("Show"); bop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane pane = new JOptionPane("Sample option pane"); JDialog dialog = pane.createDialog(mainFrame, "Sample title"); dialog.setVisible(true); dialog.dispose(); } }); }; }); builder.append("Plain", bop); JButton bopi = new JButton("Show", Check .getIcon("22/dialog-information")); bopi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(mainFrame, "Sample info message", "Sample title", JOptionPane.INFORMATION_MESSAGE); } }); }; }); builder.append("Info", bopi); JButton bope = new JButton("Show", Check.getIcon("22/dialog-error")); bope.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(mainFrame, "Sample error message", "Sample title", JOptionPane.ERROR_MESSAGE); } }); }; }); builder.append("Error", bope); JButton bopw = new JButton("Show", Check.getIcon("22/dialog-warning")); bopw.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(mainFrame, "Sample warning message", "Sample title", JOptionPane.WARNING_MESSAGE); } }); }; }); builder.append("Warning", bopw); JButton bopq = new JButton("Show", Check.getIcon("22/help-browser")); bopq.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(mainFrame, "Sample question message", "Sample title", JOptionPane.QUESTION_MESSAGE); } }); }; }); builder.append("Question", bopq); JButton bopc = new JButton("Show"); bopc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane.showOptionDialog(mainFrame, new JPanel(), "Option", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null); } }); }; }); builder.append("Custom", bopc); JButton buttonOptionPaneSimpleInput = new JButton("Show"); buttonOptionPaneSimpleInput.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { JDialog dialog = new JDialog(mainFrame, "Sample dialog", true); dialog.setSize(400, 300); dialog.setLocationRelativeTo(mainFrame); dialog.setLayout(new BorderLayout()); JDesktopPane panel = new JDesktopPane(); dialog.add(panel, BorderLayout.CENTER); JOptionPane.showInputDialog(panel, "Sample Question Message?", "Default Answer"); dialog.dispose(); } }); } }); builder.append("Simple input", buttonOptionPaneSimpleInput); JButton buttonOptionPaneComplexInput = new JButton("Show"); buttonOptionPaneComplexInput.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { JDialog dialog = new JDialog(mainFrame, "Sample dialog", true); dialog.setSize(400, 300); dialog.setLocationRelativeTo(mainFrame); dialog.setLayout(new BorderLayout()); JDesktopPane panel = new JDesktopPane(); dialog.add(panel, BorderLayout.CENTER); // dialog.setVisible(true); String optionChoices[] = new String[] { "entry1", "entry2", "entry3", "entry4" }; JOptionPane.showInputDialog(panel, "Sample Question Message?", "Title Goes Here", JOptionPane.QUESTION_MESSAGE, null, optionChoices, "entry1"); dialog.dispose(); } }); } }); builder.append("Complex input", buttonOptionPaneComplexInput); JButton buttonOptionPaneInternalInput = new JButton("Show"); buttonOptionPaneInternalInput.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { JDialog dialog = new JDialog(mainFrame, "Sample dialog", true); dialog.setSize(400, 300); dialog.setLocationRelativeTo(mainFrame); dialog.setLayout(new BorderLayout()); JDesktopPane panel = new JDesktopPane(); dialog.add(panel, BorderLayout.CENTER); // dialog.setVisible(true); JOptionPane.showInternalInputDialog(panel, "Sample info message", "Sample title", JOptionPane.INFORMATION_MESSAGE); dialog.dispose(); } }); } }); builder.append("Internal input", buttonOptionPaneInternalInput); builder.appendSeparator("Default buttons"); JButton openDisposable = new JButton("Open"); openDisposable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (disposableDialog != null) { disposableDialog.setVisible(true); return; } disposableDialog = new JDialog(); disposableDialog.setTitle("Disposable"); JTree tree = new JTree(); JScrollPane jsp = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); jsp.putClientProperty( LafWidget.COMPONENT_PREVIEW_PAINTER, new DefaultPreviewPainter()); disposableDialog.setLayout(new BorderLayout()); disposableDialog.add(jsp, BorderLayout.CENTER); disposableDialog.setSize(200, 100); disposableDialog.setLocationRelativeTo(null); disposableDialog .setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); disposableDialog.setVisible(true); } }); }; }); builder.append("Disposable dialog", openDisposable); JButton launchFrameDialogWithIcon = new JButton("Open"); launchFrameDialogWithIcon.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { SimpleDialog sd = new SimpleDialog(); if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) { sd .setIconImage(SubstanceImageCreator .getColorSchemeImage( null, new ImageIcon( Thread .currentThread() .getContextClassLoader() .getResource( "test/resource/image-x-generic.png")), SubstanceLookAndFeel .getCurrentSkin( sd .getRootPane()) .getMainActiveColorScheme(), 0.0f)); } sd.getRootPane().setWindowDecorationStyle( JRootPane.FRAME); sd.setModal(false); sd.pack(); sd.setLocationRelativeTo(null); sd.setVisible(true); sd.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); } }); }; }); builder.append("Dialog with icon", launchFrameDialogWithIcon); JButton bd = new JButton("Open"); bd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { SimpleDialog sd = new SimpleDialog(); sd.setModal(false); sd.pack(); sd.setLocationRelativeTo(null); sd.setVisible(true); simpleDialog = sd; } }); }; }); builder.append("Open a dialog", bd); JButton bcd = new JButton("Close"); bcd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (simpleDialog != null) { simpleDialog.removeAll(); simpleDialog.dispose(); ReferenceQueue weakQueue = new ReferenceQueue(); WeakReference weakRef = new WeakReference( simpleDialog.b1, weakQueue); weakRef.enqueue(); simpleDialog.b1 = null; simpleDialog = null; System.gc(); // Wait until the weak reference is on the queue and // remove // it Check.out("Waiting to remove"); try { Reference ref = weakQueue.remove(); ref.clear(); } catch (InterruptedException ie) { ie.printStackTrace(); return; } Check.out("Removed"); } } }); }; }); builder.append("Close the dialog", bcd); JButton buttonDialogCloseOnEsc = new JButton("Show"); buttonDialogCloseOnEsc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { final JDialog dialog = new JDialog((Frame) null, "Click ESC to dispose"); dialog.setSize(200, 200); dialog.setLayout(new BorderLayout()); JPanel myContentPane = new JPanel(); myContentPane.setLayout(new BorderLayout()); dialog.setContentPane(myContentPane); JTabbedPane tabs = new JTabbedPane(); JPanel tab1 = new JPanel(new FlowLayout()); tab1.add(new JLabel("test")); JTextField tab1TextField = new JTextField("some text"); tab1TextField.putClientProperty( LafWidget.TEXT_FLIP_SELECT_ON_ESCAPE, Boolean.TRUE); tab1.add(tab1TextField); tabs.addTab("Foo", tab1); JPanel tab2 = new JPanel(new FlowLayout()); tab2.add(new JButton("Test")); tabs.addTab("Bar", tab2); dialog.add(tabs, BorderLayout.CENTER); dialog.add(new JLabel("Press Esc to close dialog"), BorderLayout.NORTH); // connect "Esc" key with disposing the dialog String actionName = "VK_ESCAPE"; Action action = new AbstractAction(actionName) { public void actionPerformed(ActionEvent e) { dialog.dispose(); } }; myContentPane.getActionMap().put(actionName, action); myContentPane.getInputMap( JComponent.WHEN_IN_FOCUSED_WINDOW).put( KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_ESCAPE, 0), actionName); dialog.setLocationRelativeTo(null); dialog.setVisible(true); } }); } }); builder.append("Dialog with ESC close", buttonDialogCloseOnEsc); JButton buttonDialogUndecorated = new JButton("Show"); buttonDialogUndecorated.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { final JDialog dialog = new JDialog((Frame) null, ""); dialog.setSize(200, 200); dialog.setUndecorated(true); dialog.setLayout(new BorderLayout()); JPanel myContentPane = new JPanel(); myContentPane.setLayout(new BorderLayout()); dialog.setContentPane(myContentPane); dialog.add(new JLabel("Press Esc to close dialog"), BorderLayout.NORTH); // connect "Esc" key with "System.exit(0)" String actionName = "VK_ESCAPE"; Action action = new AbstractAction(actionName) { public void actionPerformed(ActionEvent e) { dialog.dispose(); } }; myContentPane.getActionMap().put(actionName, action); myContentPane.getInputMap( JComponent.WHEN_IN_FOCUSED_WINDOW).put( KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_ESCAPE, 0), actionName); dialog.setLocationRelativeTo(null); dialog.setVisible(true); } }); } }); builder.append("Undecorated dialog", buttonDialogUndecorated); builder.appendSeparator("Miscellaneous"); JButton customSkinFrame = new JButton("Show"); customSkinFrame.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JFrame testFrame = new SampleFrame(true); testFrame.getRootPane().putClientProperty( SubstanceLookAndFeel.SKIN_PROPERTY, new NebulaBrickWallSkin()); SwingUtilities.updateComponentTreeUI(testFrame .getRootPane()); testFrame.setSize(315, 245); testFrame.setLocationRelativeTo(mainFrame); testFrame .setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); testFrame.setVisible(true); } }); } }); builder.append("Nebula brick wall frame", customSkinFrame); JButton btf = new JButton("Show"); btf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame testFrame = new JFrame("test1"); testFrame.setSize(262, 100); testFrame.setLocationRelativeTo(mainFrame); testFrame .setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); testFrame.setVisible(true); } }); }; }); builder.append("Regular frame", btf); JButton btfU = new JButton("Show"); btfU.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame.setDefaultLookAndFeelDecorated(false); JDialog.setDefaultLookAndFeelDecorated(false); JFrame testFrame = new JFrame("test undecorated"); // testFrame.setUndecorated(true); testFrame.setSize(262, 100); testFrame.setLocation(400, 400); testFrame .setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); testFrame.setVisible(true); JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); } }); }; }); builder.append("Undecorated frame", btfU); JButton bcp = new JButton("Open"); bcp.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame colorFrame = new JFrame(); final ColorPanel cp1 = new ColorPanel("default"); final ColorPanel cp2 = new ColorPanel("green"); cp2.setBackground(Color.green); final ColorPanel cp3 = new ColorPanel("red"); cp3.setBackground(Color.red); final ColorPanel cp4 = new ColorPanel("black"); cp4.setBackground(Color.black); // cp2.setBackground(Color.GREEN); colorFrame.setLayout(new LayoutManager() { public void addLayoutComponent(String name, Component comp) { } public void layoutContainer(Container parent) { int h = parent.getHeight() / 2; int w = parent.getWidth() / 2; cp1.setBounds(0, 0, w, h); cp2.setBounds(0, h, w, parent.getHeight() - h); cp3.setBounds(w, 0, w, h + 1); cp4.setBounds(w, h + 1, w, parent.getHeight() - h); } public Dimension minimumLayoutSize(Container parent) { return preferredLayoutSize(parent); } public Dimension preferredLayoutSize( Container parent) { return new Dimension(100, 100); } public void removeLayoutComponent(Component comp) { } }); colorFrame.add(cp1); colorFrame.add(cp2); colorFrame.add(cp3); colorFrame.add(cp4); colorFrame.setSize(400, 399); colorFrame.setLocation(300, 300); colorFrame .setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); colorFrame.setVisible(true); } }); }; }); builder.append("Color panels", bcp); JButton paneDialog = new JButton("Open"); paneDialog.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { JDialog dialog = new JDialog(mainFrame, true); dialog.setTitle("Test text pane in scroll pane"); JTextPane textPane = new JTextPane(); String contents = ""; for (int i = 0; i < 100; i++) contents += "This is sample line " + i + " and a lot of other irrelevant text\n"; textPane.replaceSelection(contents); JScrollPane scroll = new JScrollPane(textPane); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(scroll, BorderLayout.CENTER); dialog.setLayout(new BorderLayout()); dialog.add(panel, BorderLayout.CENTER); dialog.setSize(400, 400); dialog.setLocation(400, 200); dialog.setVisible(true); } }); }; }); builder.append("Text pane dialog", paneDialog); return builder.getPanel(); } } substance-5.3.orig/src/test/check/statusbar/0000755000175000017500000000000011256731160021040 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/check/statusbar/FontSizePanel.java0000644000175000017500000001046710775130124024432 0ustar drazzibdrazzibpackage test.check.statusbar; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.FontUIResource; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.fonts.FontPolicy; import org.jvnet.substance.fonts.FontSet; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; public class FontSizePanel { private static class WrapperFontSet implements FontSet { private int extra; private FontSet delegate; public WrapperFontSet(FontSet delegate, int extra) { super(); this.delegate = delegate; this.extra = extra; } private FontUIResource getWrappedFont(FontUIResource systemFont) { return new FontUIResource(systemFont.getFontName(), systemFont .getStyle(), systemFont.getSize() + extra); } public FontUIResource getControlFont() { return getWrappedFont(delegate.getControlFont()); } public FontUIResource getMenuFont() { return getWrappedFont(delegate.getMenuFont()); } public FontUIResource getMessageFont() { return getWrappedFont(delegate.getMessageFont()); } public FontUIResource getSmallFont() { return getWrappedFont(delegate.getSmallFont()); } public FontUIResource getTitleFont() { return getWrappedFont(delegate.getTitleFont()); } public FontUIResource getWindowTitleFont() { // FontUIResource f = this.getWrappedFont(this.delegate // .getWindowTitleFont()); // return new FontUIResource(f.deriveFont(Font.BOLD, f.getSize() + // 1)); return getWrappedFont(delegate.getWindowTitleFont()); } } public static JPanel getPanel() { FormLayout lm = new FormLayout( "fill:pref, 2dlu, fill:pref, 0dlu, fill:min:grow, 0dlu, fill:pref", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm); builder.setBorder(new EmptyBorder(0, 0, 0, 0)); final JLabel fontSizeLabel = new JLabel(); fontSizeLabel.setText(SubstanceLookAndFeel.getFontPolicy().getFontSet( "Substance", null).getControlFont().getSize() + " pt."); builder.append(fontSizeLabel); // fontSizeLabel.add(Box.createHorizontalStrut(5)); Icon zoomOutIcon = new ImageIcon(Thread.currentThread() .getContextClassLoader().getResource( "test/check/icons/16/zoom_out.png")); JLabel zoomOutLabel = new JLabel(zoomOutIcon); zoomOutLabel.putClientProperty( SubstanceLookAndFeel.USE_THEMED_DEFAULT_ICONS, Boolean.TRUE); builder.append(zoomOutLabel); final JSlider fontSizeSlider = new JSlider(0, 10, 0); fontSizeSlider.setFocusable(false); // fontSizeSlider.setOpaque(false); fontSizeSlider .setToolTipText("Controls the global font set size. Resets Substance as the current LAF."); fontSizeSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // if the value is adjusting - ignore. This is done // to make CPU usage better. if (!fontSizeSlider.getModel().getValueIsAdjusting()) { final int newValue = fontSizeSlider.getValue(); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setFontPolicy(null); final FontSet substanceCoreFontSet = SubstanceLookAndFeel .getFontPolicy().getFontSet("Substance", null); FontPolicy newFontPolicy = new FontPolicy() { public FontSet getFontSet(String lafName, UIDefaults table) { return new WrapperFontSet( substanceCoreFontSet, newValue); } }; SubstanceLookAndFeel.setFontPolicy(newFontPolicy); fontSizeLabel.setText(SubstanceLookAndFeel .getFontPolicy().getFontSet("Substance", null).getControlFont().getSize() + " pt."); } }); } } }); builder.append(fontSizeSlider); Icon zoomInIcon = new ImageIcon(Thread.currentThread() .getContextClassLoader().getResource( "test/check/icons/16/zoom_in.png")); JLabel zoomInLabel = new JLabel(zoomInIcon); zoomInLabel.putClientProperty( SubstanceLookAndFeel.USE_THEMED_DEFAULT_ICONS, Boolean.TRUE); builder.append(zoomInLabel); JPanel result = builder.getPanel(); // result.setOpaque(false); return result; } } substance-5.3.orig/src/test/check/MyTabPreviewPainter.java0000644000175000017500000000610010734705420023571 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import javax.swing.JTabbedPane; import org.jvnet.lafwidget.tabbed.DefaultTabPreviewPainter; import org.jvnet.lafwidget.utils.LafConstants.TabOverviewKind; /** * A custom tab preview painter for the test application. * * @author Kirill Grouchnikov */ public class MyTabPreviewPainter extends DefaultTabPreviewPainter { /** * The current tab overview kind. */ protected TabOverviewKind tabOverviewKind; /** * Sets the tab overview kind. * * @param tabOverviewKind * New tab overview kind. */ public void setTabOverviewKind(TabOverviewKind tabOverviewKind) { this.tabOverviewKind = tabOverviewKind; } /* * (non-Javadoc) * * @see org.jvnet.lafwidget.tabbed.TabPreviewPainter#getOverviewKind(javax.swing.JTabbedPane) */ @Override public TabOverviewKind getOverviewKind(JTabbedPane tabPane) { if (this.tabOverviewKind == null) return super.getOverviewKind(tabPane); return this.tabOverviewKind; } /* * (non-Javadoc) * * @see org.jvnet.lafwidget.tabbed.TabPreviewPainter#toUpdatePeriodically(javax.swing.JTabbedPane) */ @Override public boolean toUpdatePeriodically(JTabbedPane tabPane) { return true; } /* * (non-Javadoc) * * @see org.jvnet.lafwidget.tabbed.TabPreviewPainter#getUpdateCycle(javax.swing.JTabbedPane) */ @Override public int getUpdateCycle(JTabbedPane tabPane) { return 3000; } }substance-5.3.orig/src/test/check/MyPasswordStrengthChecker.java0000644000175000017500000000561710734705420025020 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import org.jvnet.lafwidget.text.PasswordStrengthChecker; import org.jvnet.lafwidget.utils.LafConstants.PasswordStrength; /** * A custom password strength checker for the test application. * * @author Kirill Grouchnikov */ public class MyPasswordStrengthChecker implements PasswordStrengthChecker { /* * (non-Javadoc) * * @see org.jvnet.lafwidget.text.PasswordStrengthChecker#getStrength(char[]) */ public PasswordStrength getStrength(char[] password) { if (password == null) return PasswordStrength.WEAK; int length = password.length; if (length < 3) return PasswordStrength.WEAK; if (length < 6) return PasswordStrength.MEDIUM; return PasswordStrength.STRONG; } /* * (non-Javadoc) * * @see org.jvnet.lafwidget.text.PasswordStrengthChecker#getDescription(org.jvnet.lafwidget.utils.LafConstants.PasswordStrength) */ public String getDescription(PasswordStrength strength) { if (strength == PasswordStrength.WEAK) return "This password is way too weak"; if (strength == PasswordStrength.MEDIUM) return "Come on, you can do
a little better than that"; if (strength == PasswordStrength.STRONG) return "OK"; return null; } }substance-5.3.orig/src/test/check/SimpleDialog.java0000644000175000017500000000517210734705420022251 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.FlowLayout; import javax.swing.JButton; import javax.swing.JDialog; /** * A simple dialog for the test application. * * @author Kirill Grouchnikov */ public class SimpleDialog extends JDialog { /** * Dialog button. */ public JButton b1; /** * Creates a simple dialog. */ public SimpleDialog() { this.setLayout(new FlowLayout()); b1 = new JButton("regular") { // @Override // public void paint(Graphics g) { // System.out.println("b1.paint focus:" + b1.isFocusOwner()); // super.paint(g); // } }; JButton b2 = new JButton("disabled"); b2.setEnabled(false); JButton b3 = new JButton("default") { // @Override // public void paint(Graphics g) { // System.out.println("b3.paint focus:" + b1.isFocusOwner()); // super.paint(g); // } }; this.add(b1); this.add(b2); this.add(b3); this.getRootPane().setDefaultButton(b3); this.setTitle("Simple dialog"); } }substance-5.3.orig/src/test/check/ControllablePanel.java0000644000175000017500000000412710734705420023277 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import javax.swing.JPanel; /** * Abstract implementation of a controllable panel. * * @author Kirill Grouchnikov */ public abstract class ControllablePanel extends JPanel implements Controllable { /** * Control panel. */ protected JPanel controlPanel; /* * (non-Javadoc) * * @see test.check.Controllable#getControlPanel() */ public JPanel getControlPanel() { return this.controlPanel; } } substance-5.3.orig/src/test/check/CheckeredPanel.java0000644000175000017500000000340611021242560022522 0ustar drazzibdrazzib/** * */ package test.check; import java.awt.*; import javax.swing.UIManager; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.SubstanceLookAndFeel; final class CheckeredPanel extends ScrollablePanel { @Override protected void paintComponent(Graphics g) { Graphics2D graphics = (Graphics2D) g.create(); graphics.setComposite(TransitionLayout.getAlphaComposite(this)); int w = this.getWidth(); int h = this.getHeight(); int cols = 1 + w / 10; int rows = 1 + h / 10; if ((UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) && SubstanceLookAndFeel.getCurrentSkin(this) .getMainActiveColorScheme().isDark()) graphics.setColor(Color.black); else graphics.setColor(Color.white); graphics.fillRect(0, 0, w, h); for (int i = 0; i < cols; i++) { for (int j = 0; j < rows; j++) { if (((i + j) % 2) == 0) { float val = (i + j) / 100.f; val -= Math.floor(val); boolean isDark = (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) ? SubstanceLookAndFeel .getCurrentSkin(this).getMainActiveColorScheme() .isDark() : false; float brightness = isDark ? 0.1f : 0.9f; float saturation = 0.2f; graphics.setColor(new Color(Color.HSBtoRGB(val, saturation, brightness))); graphics.fillRect(i * 10, j * 10, 10, 10); } } } graphics.setColor(Color.gray); graphics.setFont(new Font("Arial", Font.PLAIN, 11)); rows = 1 + h / 25; for (int i = 0; i < rows; i++) { for (int j = 0; j < w / 25; j++) { graphics.drawString("" + (i + j), j * 25, 25 * i); } } graphics.dispose(); } @Override public Dimension getPreferredSize() { return new Dimension(1200, 800); } }substance-5.3.orig/src/test/check/CardPanel.java0000644000175000017500000000637610734705416021545 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import javax.swing.*; /** * Test application panel that test {@link CardLayout}. * * @author Kirill Grouchnikov */ public class CardPanel extends JPanel implements ItemListener { /** * Test panel with {@link CardLayout} */ JPanel cards; /** * ID for the button panel. */ final static String BUTTONPANEL = "JPanel with JButtons"; /** * ID for the text panel. */ final static String TEXTPANEL = "JPanel with JTextField"; /** * Creates a new panel. */ public CardPanel() { // Put the JComboBox in a JPanel to get a nicer look. JPanel comboBoxPane = new JPanel(); // use FlowLayout String comboBoxItems[] = { BUTTONPANEL, TEXTPANEL }; JComboBox cb = new JComboBox(comboBoxItems); cb.setEditable(false); cb.addItemListener(this); comboBoxPane.add(cb); // Create the "cards". JPanel card1 = new JPanel(); card1.add(new JButton("Button 1")); card1.add(new JButton("Button 2")); card1.add(new JButton("Button 3")); JPanel card2 = new JPanel(); card2.add(new JTextField("TextField", 20)); // Create the panel that contains the "cards". cards = new JPanel(new CardLayout()); cards.add(card1, BUTTONPANEL); cards.add(card2, TEXTPANEL); this.add(comboBoxPane, BorderLayout.PAGE_START); this.add(cards, BorderLayout.CENTER); } public void itemStateChanged(ItemEvent evt) { CardLayout cl = (CardLayout) (cards.getLayout()); cl.show(cards, (String) evt.getItem()); } }substance-5.3.orig/src/test/check/SampleFrame.java0000644000175000017500000004030111246143656022073 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; import java.util.List; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.tree.DefaultMutableTreeNode; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.lafwidget.layout.TransitionLayoutManager; import org.jvnet.lafwidget.utils.LafConstants.AnimationKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.skin.MagellanSkin; import org.jvnet.substance.skin.SkinChangeListener; import org.jvnet.substance.utils.SubstanceImageCreator; import test.Check; import com.jgoodies.forms.builder.PanelBuilder; import com.jgoodies.forms.layout.CellConstraints; import com.jgoodies.forms.layout.FormLayout; public class SampleFrame extends JFrame { protected JButton prev; private JTabbedPane tabbed; private JTree tree; private JList list; private static class MyListModel extends AbstractListModel { protected List model; public MyListModel() { super(); this.model = new ArrayList(); this.model.add("Ohio State [Buckeyes]"); this.model.add("Auburn [Tigers]"); this.model.add("University of South California [Trojans]"); this.model.add("West Virginia [Mountaineers]"); this.model.add("Florida [Gators]"); this.model.add("Michigan [Wolverines]"); this.model.add("Texas [Longhorns]"); this.model.add("Louisville [Cardinals]"); this.model.add("Louisiana State University [Tigers]"); this.model.add("Georgia [Bulldogs]"); this.model.add("Virginia Tech [Hokies]"); this.model.add("Notre Dame [Fighting Irish]"); this.model.add("Iowa [Hawkeyes]"); this.model.add("Oregon [Ducks]"); this.model.add("Tennessee [Volunteers]"); this.model.add("Oklahoma [Sooners]"); this.model.add("Texas Christian University [Horned Frogs]"); } public Object getElementAt(int index) { return this.model.get(index); } public int getSize() { return this.model.size(); } } protected static class TraitChangeListener implements SkinChangeListener { protected JTabbedPane jtp; protected boolean installTransitionLayout; public TraitChangeListener(JTabbedPane jtp, boolean installTransitionLayout) { this.jtp = jtp; this.installTransitionLayout = installTransitionLayout; } protected void update() { if (this.jtp.getLayout() instanceof TransitionLayout) return; if (!this.installTransitionLayout) return; TransitionLayoutManager.getInstance().track(this.jtp, true); } public void skinChanged() { this.update(); } } public SampleFrame(boolean installTransitionLayout) { super("Test application"); this.setLayout(new BorderLayout()); this.tabbed = new JTabbedPane(); if (installTransitionLayout) TransitionLayoutManager.getInstance().track(this.tabbed, true); TraitChangeListener tcl = new TraitChangeListener(this.tabbed, installTransitionLayout); SubstanceLookAndFeel.registerSkinChangeListener(tcl); this.add(Check.getToolbar("", 16, false), BorderLayout.NORTH); this.add(this.tabbed, BorderLayout.CENTER); // this.tabbed.putClientProperty(LafWidget.TABBED_PANE_PREVIEW_PAINTER, // new DefaultTabPreviewPainter()); JPanel transPanel = new JPanel(); transPanel.setLayout(new BorderLayout()); JPanel buttons = new JPanel(new FlowLayout(FlowLayout.CENTER, 1, 0)); transPanel.add(buttons, BorderLayout.SOUTH); // for the first movie, change the following line to // use the BorderLayout final JPanel mainPanel = new JPanel(new FlowLayout()); final JPanel mainPanel2 = new JPanel(new FlowLayout()); final JPanel centerPanel = new JPanel(new GridLayout(2, 1)); centerPanel.add(mainPanel); centerPanel.add(mainPanel2); // bring the magic in one single line if (installTransitionLayout) { TransitionLayoutManager.getInstance().track(mainPanel, true); TransitionLayoutManager.getInstance().track(mainPanel2, true); } final JButton b1 = new JButton("1"); final JButton b2 = new JButton("2"); final JButton b3 = new JButton("3"); final JButton b4 = new JButton("4"); final JButton b5 = new JButton("5"); final JButton b6 = new JButton("6"); final JButton add1 = new JButton("add"); final JButton add2 = new JButton("add"); add1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { mainPanel.add(b1); mainPanel.add(b2); mainPanel.add(b3); mainPanel.revalidate(); add1.setVisible(false); } }); } }); add2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { mainPanel2.add(b4); mainPanel2.add(b5); mainPanel2.add(b6); mainPanel2.revalidate(); add2.setVisible(false); } }); } }); mainPanel.add(add1); mainPanel2.add(add2); final JCheckBox cb = new JCheckBox("border layout"); cb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { TransitionLayoutManager.getInstance().untrack(mainPanel); TransitionLayoutManager.getInstance().untrack(mainPanel2); if (cb.isSelected()) { mainPanel.setLayout(new BorderLayout()); mainPanel2.setLayout(new BorderLayout()); } else { mainPanel.setLayout(new FlowLayout()); mainPanel2.setLayout(new FlowLayout()); } TransitionLayoutManager.getInstance().track(mainPanel, true); TransitionLayoutManager.getInstance().track(mainPanel2, true); mainPanel.revalidate(); mainPanel.doLayout(); mainPanel.repaint(); mainPanel2.revalidate(); } }); // buttons.add(cb); transPanel.add(centerPanel, BorderLayout.CENTER); final JCheckBox cb1 = new JCheckBox("1"); cb1.setSelected(true); final JCheckBox cb2 = new JCheckBox("2"); cb2.setSelected(true); final JCheckBox cb3 = new JCheckBox("3"); cb3.setSelected(true); final JCheckBox cb4 = new JCheckBox("4"); cb4.setSelected(true); final JCheckBox cb5 = new JCheckBox("5"); cb5.setSelected(true); final JCheckBox cb6 = new JCheckBox("6"); cb6.setSelected(true); buttons.add(cb1); buttons.add(cb2); buttons.add(cb3); buttons.add(cb4); buttons.add(cb5); buttons.add(cb6); JButton showHide = new JButton("Toggle"); showHide.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { b1.setVisible(cb1.isSelected()); b2.setVisible(cb2.isSelected()); b3.setVisible(cb3.isSelected()); b4.setVisible(cb4.isSelected()); b5.setVisible(cb5.isSelected()); b6.setVisible(cb6.isSelected()); mainPanel.doLayout(); mainPanel2.doLayout(); } }); buttons.add(showHide); this.tabbed.addTab("Regular", transPanel); JPanel samplePanel = new JPanel(new BorderLayout()); FormLayout lm = new FormLayout("fill:default:grow(1), 2dlu," + "fill:default:grow(1)", "pref, 0dlu, pref, 0dlu, pref, 0dlu, pref"); PanelBuilder builder = new PanelBuilder(lm); builder.setBorder(new EmptyBorder(0, 2, 0, 2)); CellConstraints cc = new CellConstraints(); JCheckBox cbes = new JCheckBox("Enabled selected"); cbes.setSelected(true); JCheckBox cbds = new JCheckBox("Disabled selected"); cbds.setSelected(true); cbds.setEnabled(false); JCheckBox cbeu = new JCheckBox("Enabled unselected"); JRadioButton rb1 = new JRadioButton("Enabled selected"); rb1.setSelected(true); JRadioButton rb2 = new JRadioButton("Disabled selected"); rb2.setSelected(true); rb2.setEnabled(false); JRadioButton rb3 = new JRadioButton("Enabled unselected"); builder.add(cbes, cc.xy(1, 1)); builder.add(rb1, cc.xy(3, 1)); builder.add(cbds, cc.xy(1, 3)); builder.add(rb2, cc.xy(3, 3)); builder.add(cbeu, cc.xy(1, 5)); builder.add(rb3, cc.xy(3, 5)); JComboBox combo = new JComboBox(new Object[] { "item1" }); combo.setSelectedIndex(0); JTextField text = new JTextField("Text field"); // text.setEditable(false); text.putClientProperty(LafWidget.ANIMATION_KIND, AnimationKind.SLOW); builder.add(combo, cc.xy(1, 7)); builder.add(text, cc.xy(3, 7)); JPanel contentPanel = builder.getPanel(); contentPanel.setPreferredSize(new Dimension(contentPanel .getPreferredSize().width, contentPanel.getPreferredSize().height + 100)); // contentPanel.setBorder(null); contentPanel.setOpaque(false); final JScrollPane scroll = new JScrollPane(contentPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scroll.setBorder(new EmptyBorder(0, 0, 0, 0)); scroll.setOpaque(false); scroll.getViewport().setOpaque(false); final JPanel buttons2 = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 2)); this.prev = new JButton("prev"); JButton cancel = new JButton("cancel"); cancel.setEnabled(false); final JButton ok = new JButton("OK"); // ok.putClientProperty(SubstanceLookAndFeel.PAINT_ACTIVE_PROPERTY, // Boolean.TRUE); buttons2.add(this.prev); buttons2.add(cancel); buttons2.add(ok); this.getRootPane().setDefaultButton(ok); // ok.requestFocusInWindow(); this.addWindowListener(new WindowAdapter() { @Override public void windowActivated(WindowEvent e) { ok.requestFocusInWindow(); } }); samplePanel.add(scroll, BorderLayout.CENTER); samplePanel.add(buttons2, BorderLayout.SOUTH); this.tabbed.addTab("Sample", samplePanel); JPanel samplePanel2 = new JPanel(new BorderLayout()); DefaultMutableTreeNode root = new DefaultMutableTreeNode("root"); DefaultMutableTreeNode son1 = new DefaultMutableTreeNode("son1"); DefaultMutableTreeNode son2 = new DefaultMutableTreeNode("son2"); DefaultMutableTreeNode son3 = new DefaultMutableTreeNode("son3"); DefaultMutableTreeNode gson11 = new DefaultMutableTreeNode("gson11"); DefaultMutableTreeNode gson12 = new DefaultMutableTreeNode("gson12"); DefaultMutableTreeNode gson21 = new DefaultMutableTreeNode("gson21"); DefaultMutableTreeNode gson22 = new DefaultMutableTreeNode("gson22"); DefaultMutableTreeNode gson31 = new DefaultMutableTreeNode("gson31"); DefaultMutableTreeNode gson32 = new DefaultMutableTreeNode("gson32"); DefaultMutableTreeNode ggson111 = new DefaultMutableTreeNode("ggson111"); DefaultMutableTreeNode ggson112 = new DefaultMutableTreeNode("ggson112"); DefaultMutableTreeNode ggson113 = new DefaultMutableTreeNode("ggson113"); gson11.add(ggson111); gson11.add(ggson112); gson11.add(ggson113); son1.add(gson11); son1.add(gson12); son2.add(gson21); son2.add(gson22); son3.add(gson31); son3.add(gson32); root.add(son1); root.add(son2); root.add(son3); this.tree = new JTree(root); this.tree.setBorder(new EmptyBorder(0, 0, 0, 0)); JScrollPane jspTree = new JScrollPane(this.tree); // TransitionLayoutManager.getInstance().track(jspTree, true); // jspTree.setBorder(new EmptyBorder(0, 0, 0, 0)); this.list = new JList(new MyListModel()); this.list.setBorder(new EmptyBorder(0, 0, 0, 0)); this.list .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); JScrollPane jspList = new JScrollPane(this.list); // jspList.setBorder(new EmptyBorder(0, 0, 0, 0)); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jspTree, jspList); split.setDividerLocation(130); samplePanel2.add(split, BorderLayout.CENTER); this.tabbed.add("Renderers", samplePanel2); this.tabbed.setSelectedComponent(samplePanel); this.tabbed.setOpaque(false); this.tabbed.setBorder(new EmptyBorder(0, 2, 2, 2)); JMenuBar jmb = new JMenuBar(); if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) { // jmb.add(SampleMenuFactory.getThemeMenu()); jmb.add(SampleMenuFactory.getSkinMenu()); } JMenu testMenu = SampleMenuFactory.getTestMenu(); jmb.add(testMenu); testMenu .putClientProperty(LafWidget.ANIMATION_KIND, AnimationKind.SLOW); this.setJMenuBar(jmb); this.setResizable(true); this.synchronize(); SubstanceLookAndFeel .registerSkinChangeListener(new SkinChangeListener() { @Override public void skinChanged() { SampleFrame.this.synchronize(); } }); this.getRootPane().setDefaultButton(ok); } protected void synchronize() { SwingUtilities.invokeLater(new Runnable() { public void run() { if (SubstanceLookAndFeel.isCurrentLookAndFeel()) { SampleFrame.this .setIconImage(SubstanceImageCreator .getColorSchemeImage( null, new ImageIcon( Check.class .getClassLoader() .getResource( "test/resource/image-x-generic.png")), SubstanceLookAndFeel .getCurrentSkin( SampleFrame.this .getRootPane()) .getMainActiveColorScheme(), 0.0f)); } } }); } public static void main(String... args) throws Exception { // UIDefaults uid = UIManager.getLookAndFeelDefaults(); // Font segoe = new Font("Segoe UI", Font.PLAIN, 12); // for (Object key : uid.keySet()) { // if (key instanceof String) { // String skey = (String) key; // if (skey.endsWith(".font")) { // System.out.println(skey); // uid.put(skey, segoe); // } // } // } SwingUtilities.invokeLater(new Runnable() { public void run() { if (System.getProperty("swing.defaultlaf") == null) { SubstanceLookAndFeel.setSkin(new MagellanSkin()); } JFrame.setDefaultLookAndFeelDecorated(true); SampleFrame sf = new SampleFrame(true); sf.setSize(315, 245); sf.setLocationRelativeTo(null); sf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); sf.setVisible(true); } }); // h(sf, 0); } public static void h(Component comp, int depth) { for (int i = 0; i < depth; i++) System.out.print(" "); Rectangle r = comp.getBounds(); System.out.println(comp.getClass().getSimpleName() + " [" + r.x + "," + r.y + " : " + (r.x + r.width) + "," + (r.y + r.height) + "]"); if (comp instanceof Container) { Container cont = (Container) comp; for (int i = 0; i < cont.getComponentCount(); i++) { h(cont.getComponent(i), depth + 1); } } } public void switchToLastTab() { this.tabbed.setSelectedIndex(2); this.list.setSelectedIndices(new int[] { 1, 4 }); this.tree.setSelectionRow(1); } } substance-5.3.orig/src/test/check/ColorPanel.java0000644000175000017500000000520610734705420021734 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import javax.swing.JPanel; import org.jvnet.lafwidget.layout.TransitionLayout; /** * Colored panel for the test application. * * @author Kirill Grouchnikov */ public class ColorPanel extends JPanel { /** * Caption text. */ private String str; /** * Creates a new colored panel. * * @param str * Caption text. */ public ColorPanel(String str) { this.str = str; } /* * (non-Javadoc) * * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) */ protected void paintComponent(Graphics g) { Graphics2D graphics = (Graphics2D) g.create(); graphics.setComposite(TransitionLayout.getAlphaComposite(this)); super.paintComponent(graphics); graphics.setColor(Color.black); Color bg = this.getBackground(); graphics.drawString(this.str + " [" + bg.getRed() + ", " + bg.getGreen() + ", " + bg.getBlue() + "]", 10, this .getHeight() / 2); graphics.dispose(); } }substance-5.3.orig/src/test/check/Deferrable.java0000644000175000017500000000365411212460666021740 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import javax.swing.JPanel; /** * Base interface for test application panels that are loaded only on first * selection. * * @author Kirill Grouchnikov */ public interface Deferrable { public boolean isInitialized(); public void initialize(); } substance-5.3.orig/src/test/check/ColorComboBox.java0000644000175000017500000001517211037273706022414 0ustar drazzibdrazzib/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ package test.check; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.HashMap; import java.util.Map; import javax.swing.*; /** * * @author Administrator */ public class ColorComboBox extends JComboBox { public static final String PROP_COLOR = "color"; // NOI18N public static final Value CUSTOM_COLOR = new Value(loc("Custom"), null); // NOI18N private static Map colorMap = new HashMap(); static { colorMap.put(Color.BLACK, loc("Black")); // NOI18N colorMap.put(Color.BLUE, loc("Blue")); // NOI18N colorMap.put(Color.CYAN, loc("Cyan")); // NOI18N colorMap.put(Color.DARK_GRAY, loc("Dark_Gray")); // NOI18N colorMap.put(Color.GRAY, loc("Gray")); // NOI18N colorMap.put(Color.GREEN, loc("Green")); // NOI18N colorMap.put(Color.LIGHT_GRAY, loc("Light_Gray")); // NOI18N colorMap.put(Color.MAGENTA, loc("Magenta")); // NOI18N colorMap.put(Color.ORANGE, loc("Orange")); // NOI18N colorMap.put(Color.PINK, loc("Pink")); // NOI18N colorMap.put(Color.RED, loc("Red")); // NOI18N colorMap.put(Color.WHITE, loc("White")); // NOI18N colorMap.put(Color.YELLOW, loc("Yellow")); // NOI18N } private static Object[] content = new Object[] { new Value(Color.BLACK), new Value(Color.BLUE), new Value(Color.CYAN), new Value(Color.DARK_GRAY), new Value(Color.GRAY), new Value(Color.GREEN), new Value(Color.LIGHT_GRAY), new Value(Color.MAGENTA), new Value(Color.ORANGE), new Value(Color.PINK), new Value(Color.RED), new Value(Color.WHITE), new Value(Color.YELLOW), CUSTOM_COLOR }; private Color lastColor; /** Creates a new instance of ColorChooser */ public ColorComboBox() { super(content); setRenderer(new Renderer()); setEditable(true); setEditor(new Renderer()); setSelectedItem(new Value(null, null)); addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { if (getSelectedItem() == CUSTOM_COLOR) { Color c = JColorChooser.showDialog(SwingUtilities .getAncestorOfClass(Dialog.class, ColorComboBox.this), loc("SelectColor"), lastColor); if (c != null) setColor(c); } else { lastColor = ((Value) getSelectedItem()).color; } ColorComboBox.this.firePropertyChange(PROP_COLOR, null, null); } }); } public void setInheritedColor(Color color) { Object[] ncontent = new Object[content.length]; System.arraycopy(content, 0, ncontent, 0, content.length); if (color != null) ncontent[content.length - 1] = new Value( loc("CTL_Inherited_Color"), color // NOI18N ); else ncontent[content.length - 1] = new Value(loc("CTL_None_Color"), null // NOI18N ); setModel(new DefaultComboBoxModel(ncontent)); } public void setColor(Color color) { if (color == null) { setSelectedIndex(content.length - 1); lastColor = ((Value) getItemAt(content.length - 1)).color; } else { setSelectedItem(new Value(color)); lastColor = color; } } public Color getColor() { if (getSelectedIndex() == (content.length - 1)) return null; return ((Value) getSelectedItem()).color; } private static String loc(String key) { return key; } // innerclasses ............................................................ public static class Value { String text; Color color; Value(Color color) { this.color = color; text = colorMap.get(color); if (text != null) return; StringBuffer sb = new StringBuffer(); sb.append('[').append(color.getRed()).append(',').append( color.getGreen()).append(',').append(color.getBlue()) .append(']'); text = sb.toString(); } Value(String text, Color color) { this.text = text; this.color = color; } } private class Renderer extends JComponent implements ListCellRenderer, ComboBoxEditor { private int SIZE = 9; private Value value; Renderer() { setPreferredSize(new Dimension(50, getFontMetrics( ColorComboBox.this.getFont()).getHeight() + 2)); setOpaque(true); setFocusable(true); // setBorder(new SubstanceBorder()); } @Override public void paint(Graphics g) { Color oldColor = g.getColor(); Dimension size = getSize(); if (isFocusOwner()) g.setColor(SystemColor.textHighlight); else g.setColor(getBackground()); g.fillRect(0, 0, size.width, size.height); int i = (size.height - SIZE) / 2; if (value.color != null) { g.setColor(Color.black); g.drawRect(i, i, SIZE, SIZE); g.setColor(value.color); g.fillRect(i + 1, i + 1, SIZE - 1, SIZE - 1); } if (value.text != null) { if (isFocusOwner()) g.setColor(SystemColor.textHighlightText); else g.setColor(getForeground()); if (value.color != null) g.drawString(value.text, i + SIZE + 5, i + SIZE); else g.drawString(value.text, 5, i + SIZE); } g.setColor(oldColor); } @Override public void setEnabled(boolean enabled) { setBackground(enabled ? SystemColor.text : SystemColor.control); super.setEnabled(enabled); } public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { this.value = (Value) value; setEnabled(list.isEnabled()); setBackground(isSelected ? SystemColor.textHighlight : SystemColor.text); setForeground(isSelected ? SystemColor.textHighlightText : SystemColor.textText); return this; } public Component getEditorComponent() { setEnabled(ColorComboBox.this.isEnabled()); setBackground(ColorComboBox.this.isFocusOwner() ? SystemColor.textHighlight : SystemColor.text); setForeground(ColorComboBox.this.isFocusOwner() ? SystemColor.textHighlightText : SystemColor.textText); return this; } public void setItem(Object anObject) { this.value = (Value) anObject; } public Object getItem() { return value; } public void selectAll() { } public void addActionListener(ActionListener l) { } public void removeActionListener(ActionListener l) { } } } substance-5.3.orig/src/test/check/ButtonsPanel.java0000644000175000017500000004603211020323076022306 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.util.EnumSet; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.utils.LafConstants.AnimationKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.FocusKind; import org.jvnet.substance.api.SubstanceConstants.Side; import test.Check; import test.check.command.*; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; /** * Test application panel for testing {@link JButton}, {@link JToggleButton}, * {@link JRadioButton} and {@link JCheckBox} components. * * @author Kirill Grouchnikov */ public class ButtonsPanel extends JPanel { /** * The default button. */ public JButton defaultButton; /** * A configure command that removes the focus painting from the specified * button. * * @author Kirill Grouchnikov */ private class NoFocusCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(AbstractButton ab) { ab.setFocusPainted(false); } } /** * A configure command that sets the specified focus painting kind the * specified button. * * @author Kirill Grouchnikov */ private class FocusKindCommand implements ConfigurationCommand { /** * Focus painting kind. */ private FocusKind focusKind; /** * Creates the focus painting configuration command. * * @param focusKind * Focus painting kind. */ public FocusKindCommand(FocusKind focusKind) { this.focusKind = focusKind; } /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(AbstractButton ab) { ab.putClientProperty(SubstanceLookAndFeel.FOCUS_KIND, focusKind); } } /** * A configure command that sets the specified animation kind the specified * button. * * @author Kirill Grouchnikov */ private class AnimationKindCommand implements ConfigurationCommand { /** * Animation kind. */ private AnimationKind animationKind; /** * Creates a new animation configuration command. * * @param animationKind * Animation kind. */ public AnimationKindCommand(AnimationKind animationKind) { this.animationKind = animationKind; } /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(AbstractButton ab) { ab.putClientProperty(LafWidget.ANIMATION_KIND, animationKind); } } /** * A configure command that marks the specified button to not have minimum * size. * * @author Kirill Grouchnikov */ private class NoMinSizeCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(AbstractButton ab) { ab.putClientProperty( SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE); } } /** * A configure command that sets a 5-pixel margin on the specified button. * * @author Kirill Grouchnikov */ private class MarginCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(AbstractButton ab) { ab.setMargin(new Insets(5, 5, 5, 5)); } } /** * A configure command that sets straight sides on the specified button. * * @author Kirill Grouchnikov */ private class StraightSideCommand implements ConfigurationCommand { /** * Straight sides object. */ private Object sideObj; /** * Creates a straight side configuration command. * * @param sideObj * Straight side object. */ public StraightSideCommand(Object sideObj) { this.sideObj = sideObj; } /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(AbstractButton ab) { ab.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, this.sideObj); } } /** * A configure command that sets open sides on the specified button. * * @author Kirill Grouchnikov */ private class OpenSideCommand implements ConfigurationCommand { /** * Open sides object. */ private Object sideObj; /** * Creates an open side configuration command. * * @param sideObj * Open side object. */ public OpenSideCommand(Object sideObj) { this.sideObj = sideObj; } /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(AbstractButton ab) { ab.putClientProperty( SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, this.sideObj); } } /** * A configure command that sets the specified text on the specified button. * * @author Kirill Grouchnikov */ private class TextCommand implements ConfigurationCommand { /** * Text to set. */ private String text; /** * Creates a text configuration command. * * @param text * Text to set. */ public TextCommand(String text) { this.text = text; } /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(AbstractButton ab) { ab.setText(this.text); } } /** * A configure command that sets the specified tooltip text on the specified * button. * * @author Kirill Grouchnikov */ private class TooltipTextCommand implements ConfigurationCommand { /** * Tooltip text to set. */ private String tooltipText; /** * Creates a tooltip text configuration command. * * @param tooltipText * Tooltip text to set. */ public TooltipTextCommand(String tooltipText) { this.tooltipText = tooltipText; } /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(AbstractButton ab) { ab.setToolTipText(this.tooltipText); } } /** * A configure command that sets a popup menu handler on the specified * button. * * @author Kirill Grouchnikov */ private class PopupMenuCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(AbstractButton ab) { ab.addMouseListener(new MousePopupListener(ab)); } } /** * A configure command that sets the specified font on the specified button. * * @author Kirill Grouchnikov */ private class FontCommand implements ConfigurationCommand { /** * Font to set. */ private Font font; /** * Creates a font configuration command. * * @param font * Font to set. */ public FontCommand(Font font) { this.font = font; } /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(AbstractButton ab) { ab.setFont(this.font); } } /** * A configure command that sets the specified icon on the specified button. * * @author Kirill Grouchnikov */ private class IconCommand implements ConfigurationCommand { /** * Icon to set. */ private Icon icon; /** * Creates an icon configuration command. * * @param icon * Icon to set. */ public IconCommand(Icon icon) { this.icon = icon; } /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(AbstractButton ab) { if ((ab instanceof JRadioButton) || (ab instanceof JCheckBox)) return; ab.setIcon(this.icon); } } /** * A configure command that marks the button to not have content area * filled. * * @author Kirill Grouchnikov */ private class NoContentAreaFilledCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(AbstractButton ab) { ab.setContentAreaFilled(false); } } /** * A configure command that marks the button to not have border painted. * * @author Kirill Grouchnikov */ private class NoBorderPaintedCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(AbstractButton ab) { ab.setBorderPainted(false); } } /** * Returns a row of buttons, consisting of {@link JButton}, {@link * JToggleButton}, {@link JCheckBox} and {@link JRadioButton} in default * states. * * @return A row of buttons, consisting of {@link JButton}, {@link * JToggleButton}, {@link JCheckBox} and {@link JRadioButton} in default * states. */ private AbstractButton[] getRow() { AbstractButton[] result = new AbstractButton[4]; result[0] = new JButton("sample"); result[0].setName("Button " + rowCount); result[1] = new JToggleButton("sample"); result[1].setName("Toggle " + rowCount); result[2] = new JCheckBox("sample"); result[2].setName("Check " + rowCount); result[3] = new JRadioButton("sample"); result[3].setName("Radio " + rowCount); rowCount++; return result; } private int rowCount = 0; /** * Adds a row of buttons configured with the specified text, icon and * configuration command. * * @param builder * Form builder. * @param label * Text to set. * @param icon * Icon to set. * @param cmd * Configuration command to apply. */ private void addRow(DefaultFormBuilder builder, String label, Icon icon, ConfigurationCommand cmd) { AbstractButton[] row = this.getRow(); if (cmd != null) { for (AbstractButton ab : row) { cmd.configure(ab); } } JLabel jl = new JLabel(label); if (icon != null) jl.setIcon(icon); builder.append(jl); for (AbstractButton ab : row) builder.append(ab); } /** * Creates a new button panel. */ @SuppressWarnings("unchecked") public ButtonsPanel() { this.setLayout(new BorderLayout()); FormLayout lm = new FormLayout( "right:pref, 10dlu, left:pref:grow(1), 4dlu," + "left:pref:grow(1), 4dlu, left:pref:grow(1), " + "4dlu, left:pref:grow(1)", ""); lm.setColumnGroups(new int[][] { { 3, 5, 7, 9 } }); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); builder.setDefaultDialogBorder(); builder.append(""); JLabel bLabel = new JLabel("Buttons"); bLabel.setIcon(Check.getIcon("JButtonColor16")); JLabel tbLabel = new JLabel("Toggle buttons"); tbLabel.setIcon(Check.getIcon("JToggleButtonColor16")); JLabel cbLabel = new JLabel("Check boxes"); cbLabel.setIcon(Check.getIcon("JCheckBoxColor16")); JLabel rbLabel = new JLabel("Radio buttons"); rbLabel.setIcon(Check.getIcon("JRadioButtonColor16")); // bLabel.setFont(bLabel.getFont().deriveFont(Font.BOLD)); // tbLabel.setFont(rbLabel.getFont().deriveFont(Font.BOLD)); // cbLabel.setFont(cbLabel.getFont().deriveFont(Font.BOLD)); // rbLabel.setFont(rbLabel.getFont().deriveFont(Font.BOLD)); builder.append(bLabel, tbLabel); builder.append(cbLabel, rbLabel); builder.appendSeparator("Regular settings"); this.addRow(builder, "Enabled", null, null); this.addRow(builder, "Disabled", null, new DisableCommand()); this.addRow(builder, "Selected", null, new SelectCommand()); this.addRow(builder, "Disabled selected", null, new ChainCommand(new DisableCommand(), new SelectCommand())); this.addRow(builder, "HTML text", null, new TextCommand( "text text text")); this.addRow(builder, "Long text", null, new TextCommand( "Some long long text")); this.addRow(builder, "With tooltip", null, new TooltipTextCommand( "Sample tooltip")); this .addRow(builder, "Disabled with tooltip", null, new ChainCommand(new TooltipTextCommand( "Sample tooltip"), new DisableCommand())); this.addRow(builder, "Popup menu", null, new PopupMenuCommand()); this.addRow(builder, "With icon", Check.getIcon("flag_sweden"), new IconCommand(Check.getIcon("flag_sweden"))); builder.appendSeparator("Focus indications"); this.addRow(builder, "No focus painted", null, new NoFocusCommand()); this .addRow(builder, "None", null, new FocusKindCommand( FocusKind.NONE)); this .addRow(builder, "Text", null, new FocusKindCommand( FocusKind.TEXT)); this.addRow(builder, "All", null, new FocusKindCommand(FocusKind.ALL)); this.addRow(builder, "All inner", null, new FocusKindCommand( FocusKind.ALL_INNER)); this.addRow(builder, "All strong inner", null, new FocusKindCommand( FocusKind.ALL_STRONG_INNER)); this.addRow(builder, "Underline", null, new FocusKindCommand( FocusKind.UNDERLINE)); this.addRow(builder, "Strong underline", null, new FocusKindCommand( FocusKind.STRONG_UNDERLINE)); builder.appendSeparator("Animation speed settings"); this.addRow(builder, "None", null, new AnimationKindCommand( AnimationKind.NONE)); this.addRow(builder, "Fast", null, new AnimationKindCommand( AnimationKind.FAST)); this.addRow(builder, "Regular", null, new AnimationKindCommand( AnimationKind.REGULAR)); this.addRow(builder, "Slow", null, new AnimationKindCommand( AnimationKind.SLOW)); this.addRow(builder, "Debug", null, new AnimationKindCommand( AnimationKind.DEBUG)); builder.appendSeparator("Size settings"); this.addRow(builder, "No min size", null, new NoMinSizeCommand()); this.addRow(builder, "Custom margin", null, new MarginCommand()); builder.appendSeparator("Side settings"); this.addRow(builder, "Straight top", null, new StraightSideCommand( Side.TOP)); this.addRow(builder, "Straight bottom", null, new StraightSideCommand( Side.BOTTOM)); this.addRow(builder, "Straight left", null, new StraightSideCommand( EnumSet.of(Side.LEFT))); this.addRow(builder, "Straight right", null, new StraightSideCommand( EnumSet.of(Side.RIGHT))); this.addRow(builder, "Open top", null, new ChainCommand(new StraightSideCommand( Side.TOP), new OpenSideCommand(Side.TOP))); this.addRow(builder, "Open bottom", null, new ChainCommand(new StraightSideCommand( Side.BOTTOM), new OpenSideCommand(Side.BOTTOM))); this.addRow(builder, "Open left", null, new ChainCommand(new StraightSideCommand( EnumSet.of(Side.LEFT)), new OpenSideCommand(EnumSet .of(Side.LEFT)))); this.addRow(builder, "Open right", null, new ChainCommand(new StraightSideCommand( EnumSet.of(Side.RIGHT)), new OpenSideCommand(EnumSet .of(Side.RIGHT)))); builder.appendSeparator("Unicode texts"); this.addRow(builder, "Hebrew", null, new ChainCommand( new TextCommand("\u05D0\u05D1\u05D2"), new IconCommand(Check .getIcon("flag_israel")))); this.addRow(builder, "Chinese", null, new ChainCommand( new FontCommand(new Font("Arial Unicode MS", Font.PLAIN, 11)), new TextCommand("\u4E01\u4E02\u4E03"), new IconCommand(Check .getIcon("flag_china")))); this.addRow(builder, "Cyrillic", null, new ChainCommand(new TextCommand( "\u0430\u0431\u0432"), new IconCommand(Check .getIcon("flag_russia")))); this.addRow(builder, "Greek", null, new ChainCommand( new TextCommand("\u03B1\u03B2\u03B3"), new IconCommand(Check .getIcon("flag_greece")))); this.addRow(builder, "Latin", null, new ChainCommand( new TextCommand("\u00E6\u00F0\u0127\u2248"), new IconCommand( Check.getIcon("flag_italy")))); builder.appendSeparator("Misc settings"); this.addRow(builder, "No content area", null, new NoContentAreaFilledCommand()); this.addRow(builder, "No border", null, new NoBorderPaintedCommand()); this.addRow(builder, "No background", null, new ChainCommand( new NoContentAreaFilledCommand(), new NoBorderPaintedCommand())); this.addRow(builder, "Flat", null, new ClientPropertyCommand( SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE)); this .addRow(builder, "Never", null, new ClientPropertyCommand( SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY, Boolean.TRUE)); this.addRow(builder, "Fixed font", null, new FontCommand(new Font( "Arial", Font.PLAIN, 12))); this.addRow(builder, "Null text", null, new TextCommand(null)); this.addRow(builder, "Empty text", null, new TextCommand("")); JPanel panel = builder.getPanel(); JScrollPane jsp = new JScrollPane(panel); panel.setOpaque(false); jsp.putClientProperty(LafWidget.AUTO_SCROLL, Boolean.TRUE); jsp.setOpaque(false); jsp.getViewport().setOpaque(false); this.add(jsp, BorderLayout.CENTER); } } substance-5.3.orig/src/test/check/decoration/0000755000175000017500000000000011256731152021160 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/check/decoration/DecorationTrees.java0000644000175000017500000001123511250135356025115 0ustar drazzibdrazzibpackage test.check.decoration; import java.awt.*; import java.util.Enumeration; import javax.swing.*; import javax.swing.tree.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.utils.LafConstants.AnimationKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.skin.MistSilverSkin; import test.check.SubstanceSkinComboSelector; public class DecorationTrees extends JFrame { private static class TreePanel extends JPanel { public TreePanel(String caption, DecorationAreaType decorationAreaType, boolean isEnabled) { super(new BorderLayout()); SubstanceLookAndFeel.setDecorationType(this, decorationAreaType); JLabel captionLabel = new JLabel(" " + caption); Font font = captionLabel.getFont(); captionLabel.setFont(font.deriveFont(Font.BOLD)); this.add(captionLabel, BorderLayout.NORTH); DefaultMutableTreeNode root = new DefaultMutableTreeNode("root"); DefaultMutableTreeNode son1 = new DefaultMutableTreeNode("son1"); DefaultMutableTreeNode son2 = new DefaultMutableTreeNode("son2"); DefaultMutableTreeNode son3 = new DefaultMutableTreeNode("son3"); DefaultMutableTreeNode gson11 = new DefaultMutableTreeNode("gson11"); DefaultMutableTreeNode gson12 = new DefaultMutableTreeNode("gson12"); DefaultMutableTreeNode gson21 = new DefaultMutableTreeNode("gson21"); DefaultMutableTreeNode gson22 = new DefaultMutableTreeNode("gson22"); DefaultMutableTreeNode gson31 = new DefaultMutableTreeNode("gson31"); DefaultMutableTreeNode gson32 = new DefaultMutableTreeNode("gson32"); DefaultMutableTreeNode ggson111 = new DefaultMutableTreeNode( "ggson111"); DefaultMutableTreeNode ggson112 = new DefaultMutableTreeNode( "ggson112"); DefaultMutableTreeNode ggson113 = new DefaultMutableTreeNode( "ggson113"); gson11.add(ggson111); gson11.add(ggson112); gson11.add(ggson113); son1.add(gson11); son1.add(gson12); son2.add(gson21); son2.add(gson22); son3.add(gson31); son3.add(gson32); root.add(son1); root.add(son2); root.add(son3); JTree tree = new JTree(root); expandAll(tree, true); tree.setEnabled(isEnabled); this.add(tree, BorderLayout.CENTER); } private static void expandAll(JTree tree, boolean expand) { TreeNode root = (TreeNode) tree.getModel().getRoot(); // Traverse tree from root expandAll(tree, new TreePath(root), expand); } private static void expandAll(JTree tree, TreePath parent, boolean expand) { // Traverse children TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.getChildCount() >= 0) { for (Enumeration e = node.children(); e.hasMoreElements();) { TreeNode n = (TreeNode) e.nextElement(); TreePath path = parent.pathByAddingChild(n); expandAll(tree, path, expand); } } // Expansion or collapse must be done bottom-up if (expand) { tree.expandPath(parent); } else { tree.collapsePath(parent); } } } public DecorationTrees() { super("Trees in decoration areas"); JPanel treePanel = new JPanel(new GridLayout(2, 4)); treePanel.add(new TreePanel("Enabled in HEADER", DecorationAreaType.HEADER, true)); treePanel.add(new TreePanel("Disabled in HEADER", DecorationAreaType.HEADER, false)); treePanel.add(new TreePanel("Enabled in NONE", DecorationAreaType.NONE, true)); treePanel.add(new TreePanel("Disabled in NONE", DecorationAreaType.NONE, false)); treePanel.add(new TreePanel("Enabled in GENERAL", DecorationAreaType.GENERAL, true)); treePanel.add(new TreePanel("Disabled in GENERAL", DecorationAreaType.GENERAL, false)); treePanel.add(new TreePanel("Enabled in FOOTER", DecorationAreaType.FOOTER, true)); treePanel.add(new TreePanel("Disabled in FOOTER", DecorationAreaType.FOOTER, false)); this.setLayout(new BorderLayout()); this.add(treePanel, BorderLayout.CENTER); JPanel controlPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); controlPanel.add(new SubstanceSkinComboSelector()); this.add(controlPanel, BorderLayout.SOUTH); this.setSize(500, 400); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); UIManager.put(LafWidget.ANIMATION_KIND, AnimationKind.DEBUG_FAST); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new MistSilverSkin()); new DecorationTrees().setVisible(true); } }); } } substance-5.3.orig/src/test/check/decoration/DecorationLists.java0000644000175000017500000000522511247721276025143 0ustar drazzibdrazzibpackage test.check.decoration; import java.awt.*; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.utils.LafConstants.AnimationKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import test.check.SubstanceSkinComboSelector; public class DecorationLists extends JFrame { private static class ListPanel extends JPanel { public ListPanel(String caption, DecorationAreaType decorationAreaType, boolean isEnabled) { super(new BorderLayout()); SubstanceLookAndFeel.setDecorationType(this, decorationAreaType); JLabel captionLabel = new JLabel(" " + caption); Font font = captionLabel.getFont(); captionLabel.setFont(font.deriveFont(Font.BOLD)); this.add(captionLabel, BorderLayout.NORTH); JList list = new JList(new Object[] { "entry1", "entry2", "entry3", "entry4" }); list.setEnabled(isEnabled); this.add(list, BorderLayout.CENTER); } } public DecorationLists() { super("Lists in decoration areas"); JPanel listsPanel = new JPanel(new GridLayout(2, 4)); listsPanel.add(new ListPanel("Enabled in HEADER", DecorationAreaType.HEADER, true)); listsPanel.add(new ListPanel("Disabled in HEADER", DecorationAreaType.HEADER, false)); listsPanel.add(new ListPanel("Enabled in NONE", DecorationAreaType.NONE, true)); listsPanel.add(new ListPanel("Disabled in NONE", DecorationAreaType.NONE, false)); listsPanel.add(new ListPanel("Enabled in GENERAL", DecorationAreaType.GENERAL, true)); listsPanel.add(new ListPanel("Disabled in GENERAL", DecorationAreaType.GENERAL, false)); listsPanel.add(new ListPanel("Enabled in FOOTER", DecorationAreaType.FOOTER, true)); listsPanel.add(new ListPanel("Disabled in FOOTER", DecorationAreaType.FOOTER, false)); this.setLayout(new BorderLayout()); this.add(listsPanel, BorderLayout.CENTER); JPanel controlPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); controlPanel.add(new SubstanceSkinComboSelector()); this.add(controlPanel, BorderLayout.SOUTH); this.setSize(500, 400); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); UIManager.put(LafWidget.ANIMATION_KIND, AnimationKind.DEBUG_FAST); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new DecorationLists().setVisible(true); } }); } } substance-5.3.orig/src/test/check/decoration/DecorationTables.java0000644000175000017500000000560411250135344025245 0ustar drazzibdrazzibpackage test.check.decoration; import java.awt.*; import javax.swing.*; import javax.swing.border.EmptyBorder; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.utils.LafConstants.AnimationKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.skin.MistSilverSkin; import test.check.SubstanceSkinComboSelector; public class DecorationTables extends JFrame { private static class TablePanel extends JPanel { public TablePanel(String caption, DecorationAreaType decorationAreaType, boolean isEnabled) { super(new BorderLayout()); SubstanceLookAndFeel.setDecorationType(this, decorationAreaType); JLabel captionLabel = new JLabel(" " + caption); Font font = captionLabel.getFont(); captionLabel.setFont(font.deriveFont(Font.BOLD)); this.add(captionLabel, BorderLayout.NORTH); JTable table = new JTable(new Object[][] { { "cell00", "cell01" }, { "cell10", "cell11" }, { "cell20", "cell21" }, { "cell30", "cell31" } }, new Object[] { "col1", "col2" }); table.setEnabled(isEnabled); JScrollPane scroll = new JScrollPane(table); this.add(scroll, BorderLayout.CENTER); this.setBorder(new EmptyBorder(0, 1, 0, 1)); } } public DecorationTables() { super("Tables in decoration areas"); JPanel tablePanel = new JPanel(new GridLayout(2, 4)); tablePanel.add(new TablePanel("Enabled in HEADER", DecorationAreaType.HEADER, true)); tablePanel.add(new TablePanel("Disabled in HEADER", DecorationAreaType.HEADER, false)); tablePanel.add(new TablePanel("Enabled in NONE", DecorationAreaType.NONE, true)); tablePanel.add(new TablePanel("Disabled in NONE", DecorationAreaType.NONE, false)); tablePanel.add(new TablePanel("Enabled in GENERAL", DecorationAreaType.GENERAL, true)); tablePanel.add(new TablePanel("Disabled in GENERAL", DecorationAreaType.GENERAL, false)); tablePanel.add(new TablePanel("Enabled in FOOTER", DecorationAreaType.FOOTER, true)); tablePanel.add(new TablePanel("Disabled in FOOTER", DecorationAreaType.FOOTER, false)); this.setLayout(new BorderLayout()); this.add(tablePanel, BorderLayout.CENTER); JPanel controlPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); controlPanel.add(new SubstanceSkinComboSelector()); this.add(controlPanel, BorderLayout.SOUTH); this.setSize(500, 400); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); UIManager.put(LafWidget.ANIMATION_KIND, AnimationKind.DEBUG_FAST); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new MistSilverSkin()); new DecorationTables().setVisible(true); } }); } } substance-5.3.orig/src/test/check/icons/0000755000175000017500000000000011256731160020143 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/check/icons/JFileChooserColor16.gif0000644000175000017500000000037710421430360024312 0ustar drazzibdrazzibGIF89a{zvzfff!,| !d9&GRNJ 27R_F"`M28 X(xE xl/Df!!R#P xxUY; Wn [SgZVYtkc Zf JK Q+O+&%!;substance-5.3.orig/src/test/check/icons/flag_canada.png0000644000175000017500000000124110520765374023056 0ustar drazzibdrazzibPNG  IHDRa+tEXtCreation TimeMi 31 Mrz 2004 11:05:11 +0100.tIME (2 pHYs B4gAMA aIDATxœKA.5-(>px{ƕ#"p! Bq L3"cۯgg` &!"Ui@O?wFM#9+BU#?ύ2c|߻_Ylm]>?HJ\U#l }a|:@ eA( E:)"mzEvԊ^@伃I F;c9] (Фvd-DQvո5q[ )?\BcXIQMڮh8N^8>Rgg!61ٱ=!J8Krrs1k+7pӷ wlUWiAĬ_ğGP>L8ESN "3(4 %,mw}ImUY\o(HM *o ДdٕdOiV:*ӉoM:Q(>IQϳ vJQ+X〭IENDB`substance-5.3.orig/src/test/check/icons/JColorChooserColor16.gif0000644000175000017500000000110610421430360024500 0ustar drazzibdrazzibGIF89aeV_R)++SX33gRg=03f&gV ]@ f3 _+])++V+33)gf34~]օ]Zح+@ g)_ >g: &+Rg ]̙Oص3̮]֙3e>R]V+]]]]V+gR3 @վ泙z!e,eeffccfbb$%[1QE,*;8^@5:=aB6pHH⦋ iQP ;substance-5.3.orig/src/test/check/icons/JLayeredPaneColor16.gif0000644000175000017500000000023410421430362024273 0ustar drazzibdrazzibGIF89a̙fffff33f!,@II,` BAW@a,kqJ]*%4N/hVJQ Kޤ4%;substance-5.3.orig/src/test/check/icons/flag_thailand.png0000644000175000017500000000114610520765376023441 0ustar drazzibdrazzibPNG  IHDRa*tEXtCreation TimeFr 2 Apr 2004 18:26:23 +0100(^tIME0ae pHYs B4gAMA aIDATxœjAɲ/+D0 Ճ/>=x5CDD!*f]U37_@ W; q# ʧ@صM1ؒ"زsp=ZiebSIPk妤:iߧ:0cOhkA헡DZ )P;fh1kF3ohax`XŜ!Yu.-Z- l=R3J-(p,bޞB)') %tjk~w&6lF6Q=ZkvKe/:ME8~|QTgYCTSRIENDB`substance-5.3.orig/src/test/check/icons/flag_mexico.png0000644000175000017500000000123110520765376023134 0ustar drazzibdrazzibPNG  IHDRa*tEXtCreation TimeDo 1 Apr 2004 12:07:52 +0100>+tIME uZ pHYs B4gAMA aIDATxSjA=hۉ 4(ĕ r^?Ý~RA>2 `f#$][0?HtݺsON{h^مv2I)CAOH 9o>"Jukʺ-/!z1z |Fg&8w{˨ļ?@%($eKP1rGXVfLC1B%IIJz Җhm a$p\(yPTK}eҟ ԉ(G1!D~7?A|[@x(KZO$없b{3~C~aE1 ME]U)-x;TA0U+- RLgǽKO+{{ "\X!烣 YxX b؏PH ̂iqɜnXPlIa`>U0UA;Q_'Oj9'!qF:4IENDB`substance-5.3.orig/src/test/check/icons/JSplitPaneColor16.gif0000644000175000017500000000017010421430362024000 0ustar drazzibdrazzibGIF89az!,=H2EaL,8pAHr2be뷤*=O6>[< O*hX;substance-5.3.orig/src/test/check/icons/JDesktopPaneColor16.gif0000644000175000017500000000024610421430360024320 0ustar drazzibdrazzibGIF89aefh{wxzuffeggg!,SPI+u pM(6 ̠pVK$ {BP0_J@pI"VԀj=XHR#r'MD;substance-5.3.orig/src/test/check/icons/flag_turkey.png0000644000175000017500000000120210520765376023171 0ustar drazzibdrazzibPNG  IHDRa*tEXtCreation TimeFr 2 Apr 2004 11:14:33 +0100vutIME 8w pHYs B4gAMA aIDATxSA=U̪8 "j/h` nbb& & D;<^ϭ-]u9jఇGRM1µPb3?( M=E3kNamiZ/+ĖHhZǗ 2qA gC/$-s;#+B<_=¿y BQcU#veݼ HfԺF- 5R! S83&&[ۈδ,smg,2ҙ}9Y,<6ITЃ{tJCoqb||hVQuHx@|չKؿ;XykAtLL̩SHT(i!עۅ\ѫ~`c}kEc،6`FffodWXA'*?"􌂋܊:g&l sr|g~Uq{ɭgsma\ŷfP#"3tw=c`snL^ I/J:eƸTw앞o?TfuW)6>.񓋋r喾qtʲ{nFULW*^we x8$MkhFQC})pΪ`>8.[ gL9-U (.\MHVofm[#i#^? #AuIkV v[LxUqAdAxx:lEzFVn1WXŅDH(s~#)`3 v/^Ems94 RɷwNE,== j$<+谁iFk:H " xp_K*&z6; ̡}K%S̳OF<s]Go:wNN}_su)cgzO=Q"־| s%FPB# KAdCdjBxo08t[%Bk] Z`ܓGʡH $ Z$ǝ] 7XbJ?#P_@ğ5!VJYo \IbEDǒX 'zeJb?(K9>R6IENDB`substance-5.3.orig/src/test/check/icons/22/dialog-information.png0000644000175000017500000000226410623715560024665 0ustar drazzibdrazzibPNG  IHDRĴl;bKGDC pHYs  tIME / ={HAIDAT8˝]lUw|NgnRU[PJ!i@DjjR#} AM !$1`ԄBb4F%>!Ceq@;ͽ%EB9a,!$Ι-?E#Na7nZص[4,A/HeEsשFNx]íoتԃD`q\~IÇ7E#낷صi-ejqpsBŌOdϣmZPicHfpkamM)#~mPb6xĒK>TlNyA D9߱p+WoòM)1 !eA %JHRRDР)*M|Pq|xs]gl[CA 1 !VN5N1̙.l8.f_%J yN7尢+D fEt(~" GUPGKY:נޮ`C7-F5:=3k8U1"c'y Վu9ʖ&i=ۻCuɹS3/ S}Ŭ^4*X"q}QVs\<GNYgFG߷ی6ṳ̏1*lJSͪlmT:ri98؜9C KAu?\ sm"/L-.c[cшyG*j(m)$!?P8U%'XQC@$jy#Eq{;頔I!2mwWf|0wʪcEo< Ͷ5ۺ$'1}p^Z8 !?9${oqLOV Xdϯ՞J.NJFnO5>uٸYV,*|?z=R录3i_lp3`I}-ؖeXA]] C~![D Q鱗4t]0R߲vd&?{J-40MycH!R(MCi=+^bژT@UtCGHJZ[e@U6!DRRRC}_P\z]ױ-1 ])FT}sItv.tVS7*}[鷿t cJ`\u<\M^]=$]tv%NP0?}pwEt .Q8r޶M2{R(!@iSc}\jX{`ӎ^ֿfb{VdL7Wnq>7ZuQˢ003e ަ/twt !0)2ތ#v̙͟2ãDAT7Ey-+ɳ5mh>vh<`!D60g  YO2rt6'Z[/? mpy^q+|@VZ̴ Ri " >@IENDB`substance-5.3.orig/src/test/check/icons/22/dialog-error.png0000644000175000017500000000163510623715560023472 0ustar drazzibdrazzibPNG  IHDRĴl;bKGD pHYs  tIME 4/`h*IDAT8Ք?hg?'$4ihLBzdҩK@ 2dOJ:kB$[B!!$N,d[ήtrqUwYtY ,xY^o[g*\98ðkeVcիpm~: ܘ)xy(.R?ݽ Ʊ3)n/^Ro"*h -lϣn7~M\z}98@E T3*3a 8< rLzmtAUD1A0sE:L4w#M$btU5*X07-a3nNlp,Cׯի:Dӎ㌯yƶO Xd13Q٤>[2b(;m9PEm?mLEjV*F?0.P nn!ol5ff2ɠw @ETn:MU U$~ ^wggideNƕb$NHap*<tlg4N1n:M譨cP][c׻3Gm dZ66qRRT[,!=ǥCV;-1ފq{QNoy ^އU6@w 49sw!30+Ʉ)` ;f?Rh@c2֡3߫C=%.:/ɧIENDB`substance-5.3.orig/src/test/check/icons/22/format-justify-left.png0000644000175000017500000000075610565041056025017 0ustar drazzibdrazzibPNG  IHDRĴl;sBIT|dtEXtSoftwarewww.inkscape.org<IDAT8N@ϙ^0bV !W0!^C|LPGb! \*hJA$d&wguy^vPm7.*WU]6nצ(f̻@zn?nժ x^?Ӵ?RJ($" MJٷMWmxMl:HT*-`G(g}P,`lqsKXNI+e _$x]:6_ @5bfq0Fݮֶb$fr qAZl6N1 ,pw'j#"bA G#tf2-,-%b 3BWekZжa&q{`9.`_x"IENDB`substance-5.3.orig/src/test/check/icons/22/process-stop.png0000644000175000017500000000237010565041060023532 0ustar drazzibdrazzibPNG  IHDRĴl;bKGDC pHYs  tIME +C+GIDAT8ˍ[hTGsnl jH[M f R DB)TzЇBPA (ڂsѴIۺI9sD߮޾M:!v#Ș&v6[' ]x8#JxwF ; 77{]]dB!rJ,}H|L ieejme޽BV # [lh'hB OZ3gBRڊmF8iB.źT*y!@)*lӧYq /?ihJ1p0r9R()IU*Ò*`r pz<8^"/bmc?Gxm=%tvM4FnaIF&i4 JJX|3HI0<^:v gY:EhBPs(Sĥ$C=~0i?*)HIr^ﯯwIx*+YY[_mxԭe2h08s ttiWU/dbmxX1|V}ֆ %ee/hy%!R`9< v oB B䣠os8SUyP,y@xP(0 (?dyIENDB`substance-5.3.orig/src/test/check/icons/22/format-text-bold.png0000644000175000017500000000165310565041056024271 0ustar drazzibdrazzibPNG  IHDRĴl;sBIT|dtEXtSoftwarewww.inkscape.org<=IDAT8ՕOh\Eǿ3Kv?I\HiM.$*(DsKiJQ hvMO_R!܇9A긷 ޠC3|.ȹ M[ᬑXY.vc3ضUTP)h~ ͯE} oU,N8Z߮$Ff.$ԌR O u͹ϺB$>| jK_0 NWՀ0#r JI)ةS2{Z tBr"d.KEk8 }Mᤄ<IENDB`substance-5.3.orig/src/test/check/icons/22/format-justify-center.png0000644000175000017500000000077210565041056025343 0ustar drazzibdrazzibPNG  IHDRĴl;sBIT|dtEXtSoftwarewww.inkscape.org<IDAT8j@XR6- BQC}R+WO`-ڍBE]K%s1d0zl1iiUP|>)fw%fnj @DHpܲ7籠7D:p2 Ran`j,=[n`!d& `7Dzv_bB 2 |`z-c+XJ邢!Q{&zUT(歍 Èf=`W 9ImAlK_j5m#qàTBzR1[_TNDT:QţHLB_.eNeNJ2sf;؊L4Msy{8~__cPIENDB`substance-5.3.orig/src/test/check/icons/22/edit-select-all.png0000644000175000017500000000120510565041056024042 0ustar drazzibdrazzibPNG  IHDRĴl;sBIT|dtEXtSoftwarewww.inkscape.org<IDAT8=@$|(5'(qRP IQQPF'Dh(\K((`O8nzǻϾ3;EUeNgًu<;` "_,߼s*h_0Tcc4" 08n 4l6k_J=X,h6a "ɻN$$ܖ_ "|$JX~~k|R0l6{fJ/"VLym4^ JUJח"8`0(U[ǥmM*Ae&'R EQf-NR)|Wm8:UE$oZ8t):BDIJ,g4}y><uy<} q*RqEՊ|ͫ}Q"`)z=SJpyamۅ bnl.k2x*v7.WGbZ%#nH|p41qFޓ3༉H8fo}_ a ~IENDB`substance-5.3.orig/src/test/check/icons/22/edit-delete.png0000644000175000017500000000244210565041056023263 0ustar drazzibdrazzibPNG  IHDRĴl;sBIT|dtEXtSoftwarewww.inkscape.org<IDAT8Mle3uڮ*"ZB z %Ę áb-/(F&V@/mtqn[Zvߧݙy} d R(GB\Dfn_sۿ=70pmJŋX\žfcf&^qjO Qy|RzjZ.d7044uuy8rd`MKKmвuX;#vVO`R^p\oN0v塐"F@9bUUuojڴ~S۲:cfoEpժ ;@啕{tiaÚflwG3y}ZJx2Z**JHz^+X֏w+iv>/)Xn굵LA8n{׊B@Z5boR*R..Vv9ZqT i=L-<]* +0Vz t:U%G+X= 0X6̃`0ޚ.DD ==}hd};5NL&%6 S{/Zk:`tEዌiøwRcvu߀ j͛7UlT8&ʶn_DkȃRhH? nT*݂U7_IdtcQi ^I/T,Zv733\.RK=0b9 'fgji4^Tm\׍EJERuoV7-89=ŅB!:J-|.5 S 9XnGFKuVT*iUV/u6Mpu#"bAkCdbO2!4!%d13}!W,1,sL$N=n\ߤIENDB`substance-5.3.orig/src/test/check/icons/22/edit-copy.png0000644000175000017500000000132510565041054022770 0ustar drazzibdrazzibPNG  IHDRĴl;bKGD pHYs  tIME 3 EZbIDAT8˕MOQsLt_vc+W&.](Q0&D!qƭ+C $@k]XX"2әNٴ9Tyv1CB4>[q-,O7N\33YQlWdft:r7$I03O n6FGnn "3a}BH))2kv-݊B@kkm8JeFbe7s #zT^4gEFaD1Mˊ|-p8]4 ֙x=lN;$-C- #Zu;++n{#*5n|-Yފ7$Fi<tOvKT@{B^DE@lɪnS`pj@*А@6̌`pJ^a9&PkIENDB`substance-5.3.orig/src/test/check/icons/22/edit-cut.png0000644000175000017500000000214510565041056022614 0ustar drazzibdrazzibPNG  IHDRĴl;bKGD pHYs  tIME '/DIDAT8˝mL[UZhsMdl8`EP8`_@_İ~X062l 3&nlfLdd/dCBY@;a6 Ɠ<<'RF[{k][sI3ubJ7͵ޚf8- -X+-9ygRࢵōyy˷oQ<(嚦zhdu|mEcǏ&G `ժU J Gƒw&ynش֮)|IdyǴ`M,X,YjiPaaVEцn5Zw҂]-nM Ox@;vD;lϲdb1l6sy,RPoqEQd]ǟRP_pY("G~q-Ɛ]$VʹbET=a3v.]WfcRƆf8#ä~'|&!7GFsA~2"`Y;ccvCCtߤ-[q@|mPlh5Գ1(/Ue2?SĂvv9|BpZܶal ]B!U콀-#A<#<dgre*Tt=MM͛ui zWd=MM렮BoE=ޗ\ tt q4^|pXttDA+5I8 R$E{yl!YiAUj $EAwc)gBhee9!Ue|}No=n7ʂgaVWG\-} 0p={Xp: =w.zƁ裵J N' ?.RDr*Cg_«Ű7 "忑 O~i ]O{$hҌHɴ!iJ }דI#`IENDB`substance-5.3.orig/src/test/check/icons/flag_italy.png0000644000175000017500000000113710501772474022773 0ustar drazzibdrazzibPNG  IHDRa+tEXtCreation TimeMi 31 Mrz 2004 16:47:00 +0100{gjtIME1%f7 pHYs B4gAMA aIDATxœ@NʂϢ ,,:>$z^= 3IwuuWgIBUW-^MMkmx?~mCCD`U<ԛ/ߍEK-Mx J-IW^lf@c7ƗoF^1V~QXǭj[!Aov`jL >pdʻy̻^;+֠QAxRP( B"g027Tuv ȁ !Cs@&2e*P13? ق.[P.*hr3TXk#lYNt+Y.']}U9 $`Ȣu=},4@f“ LXbS ^nٗx hi%Yhx~ui--a'@)@K#IH4nGM'+r0\ଌ#l9Q 7bX:Xxcn9S8n ?`Zy̍&nOpu6mWb(P2`iH Ŧ];6}!WјzA Csm *A*`c_u~92a>#B``efjF*9Sraj{~җTE.ݖ\i\  mlaqz2CFvl#-uieb;E?D" vb;VmCD!Qʝ(Ɖ0MYpu=BCkvA!$2DR{ ~5|`PfQ,]K.~k1PSiB)17O=2PW scl<0X+so!#' Xki^ .z߷~D|Ҭ 0MVqV-$yHS}ĴXUaaܷ؝pZlgAW8O&yt~J!׌fFcۜ(sN& ᝝=yG>!(`pseq,}.rު0sօA)N<|yZ!L&POQ|rYBFXGTV|b BJ Ƶm#P2/w0\&8:iyl[mt##M;]lK^Oo Bգק O#KtIENDB`substance-5.3.orig/src/test/check/icons/JTabbedPaneColor16.gif0000644000175000017500000000016310421430362024070 0ustar drazzibdrazzibGIF89aHo!,8(<8P!Ca7#iJ3ݸߺ_&(쭊 RFk:";substance-5.3.orig/src/test/check/icons/flag_taiwan.png0000644000175000017500000000114010520765376023132 0ustar drazzibdrazzibPNG  IHDRa*tEXtCreation TimeFr 2 Apr 2004 09:47:10 +0100MtIME0 M pHYs B4gAMA aIDATxSQn1}viҨ)*U+E@PRnz8D 4TUDMb{<ܠ־w=.ÕۏT.DHU>oO݈~aV^5E^HٖlLV[\=7&Wd"KBеz|Bp:襖'oDTJ-451Xq:窢v$8E6L}.M$#`&Չ%N qdڰF~)%ѦӰx:n,j%N>c2S6 &0IENDB`substance-5.3.orig/src/test/check/icons/flag_finland.png0000644000175000017500000000115210520765374023263 0ustar drazzibdrazzibPNG  IHDRa+tEXtCreation TimeMi 31 Mrz 2004 13:04:55 +0100'~;tIME %)x. pHYs B4gAMA aIDATxœKn1#+4IX#0;,Xp .b",#fFlP$f:'m܏lO뫇]gr3:(~7?yU i1F"m۫b4@UU|>\Qgryz(p?jAz}Raj?F1FǨ(p)l*H(.6VHI BP0Ƣ8(.k"QB2_O7{0" JmN <@G P@7Xm~5 h4 ěN޶蹲w˝c/-YD pV-k&֥r fSkťl7!bL.|0!Iso00{=:!^xnjU]6T_?_.Za4Mw؏2VkIENDB`substance-5.3.orig/src/test/check/icons/flag_germany.png0000644000175000017500000000113110501772474023305 0ustar drazzibdrazzibPNG  IHDRa+tEXtCreation TimeMi 31 Mrz 2004 13:57:16 +0100tIME 5Lņ pHYs B4gAMA aIDATxSKn1 }| UM^te/УN7=F:@O1#I0;џR_T"XZNEfuIENDB`substance-5.3.orig/src/test/check/icons/JProgressBarColor16.gif0000644000175000017500000000017410421430362024336 0ustar drazzibdrazzibGIF89ad˹怊!,)PI8ͧ`J`g@{̬P|bvpHD;substance-5.3.orig/src/test/check/icons/JWindowColor16.gif0000644000175000017500000000016310421430364023354 0ustar drazzibdrazzibGIF89acfff!,8([0 L';-A([aɜo5h+t=z=y ~'2x>:>uIAʤXzqLId6G?/^f(4IENDB`substance-5.3.orig/src/test/check/icons/flag_china.png0000644000175000017500000000104210501772474022726 0ustar drazzibdrazzibPNG  IHDRa+tEXtCreation TimeMi 31 Mrz 2004 11:19:38 +0100SGtIME .%{V pHYs B4gAMA azIDATxSN@ ]*(g$ĵп*P c{K#~gxv6}9yAr.5'{w-ooXNM\\ME4k6F [i{p3Y3lh!XV|}T@ XqJ.ے(*agLُ0LE+ȉ/u $q*@08P⮀ωZDXŲ "TJOS4t2ed?boF J߁D0"% LCqfΩo&1샵>2ASJۆxR fy3R4=yszf.D 3l wp#]GSIENDB`substance-5.3.orig/src/test/check/icons/flag_brazil.png0000644000175000017500000000132210501772474023130 0ustar drazzibdrazzibPNG  IHDRa+tEXtCreation TimeMi 31 Mrz 2004 10:07:40 +0100"tIME ^ pHYs B4gAMA a*IDATxSkA}T+-ED 4"zMԓ/*/B'-V*E)RP-J5j6ٝo&m : |y[`Dk LIahмSA M } J dB8HK A4JAiBO  f('AE<8ؓI1L_ &&n(C8 nPGeϞh?Rē3C6:F 937׹lavq?#.^u1Pr0ܟA.xnFŝwc/tpuy  T«[ `e޷.q.G#QsQC w+GyN̬zl1do~*/y]* MxWYM^k UZ;QXGHf+Ԙ^ D6 8bgdžPQ:79Gׁ 5lcf l"|n^'iṞ![>DQDί'r::;Hjle pg,.\ ZqBx5K$b+M,*$GmiQWI2V&ahQQU8Qt)!?D~s Ht+TZ4 Y h,Y9t)>;#(D{k |sG,â\6o7`֧GKD6,8|w#ûUK3A.߮X  4w6p^8{x}u6xYWí\O"bKe1!ޱc[ 'zf>]"-Sl܃<^ = ɲ 0ۍan2^=D6ܴ`cw)䫠iJ|rRIENDB`substance-5.3.orig/src/test/check/icons/16/format-text-italic.png0000644000175000017500000000115310565041054024612 0ustar drazzibdrazzibPNG  IHDRabKGDC pHYs  tIME "IDAT8͒OHqǿb22ӨUӖ-f1R$!!EF!!T!,vj?4 2; uB|}?Xb^I3%@mvm9ǁ]:+w7pF\*u\s!;XN*\",f@Iݻ]#879CfP x~سxl6'&(+Ff$V4~y%D=O?Y鯣߅nbVVKZxuIO.Wa >twZJ!o(Xj@KgZvHbl F;1e(B!lTx:e$Go$ E UkD2={m݌U+4 IP41<@p69SǗh@Yn@U_X?V+r>*NŠw>d")XeMl Z؛Ser8bq5fDd^6n4IENDB`substance-5.3.orig/src/test/check/icons/16/format-text-strikethrough.png0000644000175000017500000000114310565041054026246 0ustar drazzibdrazzibPNG  IHDRabKGD pHYs  tIME) kIDAT8͑KqƟ3ԸbJd-Ztq @ۃ$`3x(rEb!sM[ tlgw߮=LJ>%U2[o< bs.c!J'.;ˆIDخk{kfH 0:Ck@$]>Aܵw4D$v/gLy p>P^x؁}NNggn&ɫEZ `+rIhP :tͽ;RJ2m@fAOz0;ʈ=isLi׫> 8?7*!?@)QY}҃gIENDB`substance-5.3.orig/src/test/check/icons/16/process-stop.png0000644000175000017500000000146410565041054023543 0ustar drazzibdrazzibPNG  IHDRabKGD pHYs  tIME - kIDAT8mOSasm%@+xij 6X\:8iL q1P$(Ji;&_M{Ua==1DUv \Be3?k.]vͭhRJiY|x23^(X5*FN><}j&1}QPȑ|8v728emZ:M W,JgZg&xccw6ǪG Df8޻w$_r<֍TD"̻w Ծ>Ԗu~ ڷEJJ.hϟ( %BaՑppq]Qpz<8;wu@ y%%}]pzXb1mc6 ;Rww(8vԅB*,e_)D V[Z޺e=gutǃ=<혹Ʒoȕt)冚a ,6\Uxqx4рԝ:iբ)+@[VJ$(~MOnޤP^\$k$oF4|~?%r^S'[AW*gX-kSH c:`C6"Orbizi~inU|^L= 1mv?x.ElBZVO$֧lvƆ(,nƭ"zvWiEay3MR׆IENDB`substance-5.3.orig/src/test/check/icons/16/format-text-bold.png0000644000175000017500000000130110565041052024256 0ustar drazzibdrazzibPNG  IHDRabKGD pHYs  tIME!}NIDAT8Œ?LSQƿ{oWЂ')PcI&&@Hp m\u˜8)AƁhb4apr8:2(AC -{}@EprlK/9؟[o,r3H/u"CQ荃-R }K>Ξ!/WS5GRǗiY=p<"|^eg2HdZ`لp+HʋVo. XD Z[b~đ! u29 .I˲X}wvnEx8N,>4ֹwdVʚ"9I$'MB2 1]`Jyer5 %8-HJEII'Li1Ɂh{P(Fq%k40#oAqZ̊1`ܵeGjQjŒ Q-9\UR 4Ι3J2=-BAƠ9&|A((Ohŀd]la(7i õhcOY/Tjfo-m"d}52?Z~Iu I1 kc IENDB`substance-5.3.orig/src/test/check/icons/16/format-justify-center.png0000644000175000017500000000051210565041044025333 0ustar drazzibdrazzibPNG  IHDRasBIT|dtEXtSoftwarewww.inkscape.org<IDAT8S[ @=ZPKIIB-!,i ,9}ȈSf#]80$krňpnvHpsl$I>#tf0\kAF.X,iyG fqi{ 򼀔o$eBJ9@ !:U vH,KmܶI4|x_Ioth FZKlo hi1ZkjRY12i4MX,0p/ DdqvXD"$IJžc:KVi" wxS8*9Q18m6*N7qRlFId2ٰEkWZh%{x.>+ml6[0."A%AP[dQQUl$Z-<@!`fqF2t IENDB`substance-5.3.orig/src/test/check/icons/16/edit-delete.png0000644000175000017500000000143110565041044023260 0ustar drazzibdrazzibPNG  IHDRasBIT|dtEXtSoftwarewww.inkscape.org<IDAT8]kTgy;Q"hEM\daʬ)bj.֗. ]uQ E7m(jD/A2ǀfܙ3s颓󜟘W8A/̤fz" ;PA)6u6޿ו,OWS?@U$thhllӉxws ;݁ιFR}Yj!GFOnbV_s@'}Q4h"c$yXkܼ{MovLڛ*n|7v0~rXyckNQ@j߷^}PaX&ɞ=re7|~^pEX.0+fƬȵ~.^{jR<|. ng[fSfSS䃪fK5 ᎲKgmS3- \; ˉsA*j5S3O q&(Yy/qZ( TIENDB`substance-5.3.orig/src/test/check/icons/16/format-justify-fill.png0000644000175000017500000000047510565041044025011 0ustar drazzibdrazzibPNG  IHDRasBIT|dtEXtSoftwarewww.inkscape.org<IDAT8 @Ϫ[`g5" L=$5]9 H|9<Gir=IliKpީy}0Vg9LTGѼvoiNmכ(!$wߟɀ0 :6F@e5r*@(E`ALڃcHtB)Uhy;+eezz8IIENDB`substance-5.3.orig/src/test/check/icons/16/format-justify-right.png0000644000175000017500000000052610565041050025172 0ustar drazzibdrazzibPNG  IHDRasBIT|dtEXtSoftwarewww.inkscape.org<IDAT8o0$ am)D;(.y~趛Iͼ8<Ͽ0Bqߗ $Ys I"G}B/&tYZ; h)e *VH$1w`+Ngj\ 粺rvP+!H*Hy.aa'IO#݀=|P=jE^x[%IENDB`substance-5.3.orig/src/test/check/icons/16/edit-copy.png0000644000175000017500000000076210565041042022774 0ustar drazzibdrazzibPNG  IHDRabKGDC pHYs  tIME /4IDAT8˕KKQ#3cڀ ZuBEvDDD616e007itFGoy;$3,F(Ͻmwa(z&vj5BЄ'sj^wcfnyu$IBTGE@QNV9TlGr(( ,˞H$?dYv pPRšz-,EA08vaSiJ%K дc,61Ӷ(XY^ePT䮳6֣yyrl;KUUn(zi.y}*($bBYIENDB`substance-5.3.orig/src/test/check/icons/16/zoom_in.png0000644000175000017500000000132510403031060022533 0ustar drazzibdrazzibPNG  IHDRagAMA7tEXtSoftwareAdobe ImageReadyqe<gIDAT8˥Kq zäqV(uD).Vۚ:nWS$#aKkz+mmL36v„"=>>}1: /8y>o??#TX|M-Rv,n1O1Eirf&F@lN.`9QXһ pg\{?~+E4  @[ˤ:!9%)ʅx.D F8]ND3deH']\ӍNtqP|PSt jʙЈ2A>"eƍ헮?F>3eh=,RA$!d8 «Y97'@77DQf5Ž֧@x&_mjn-̶/=e,ZbT\y—Gu+{!V%E[&ת+C0o2A Q{`:Nپ:ZpۅHy ;{`dSTyWF CT>;/좓IENDB`substance-5.3.orig/src/test/check/icons/16/edit-paste.png0000644000175000017500000000106110565041044023131 0ustar drazzibdrazzibPNG  IHDRa pHYs  tIME IDAT8˕kSQ4$1Ԕ "\\jbpv!8EmA84K.8)RHB^olF91/m ~=?T*{ϝ~I\.konΚ+*+v< |`_)h/Y2g .9.Ҵ0f LD9̤γ׫VTS yf,y_ϲxAPTB"Jqm.f!1 ނD"03sl08[y=j(߼ )>\qKa{UEEȝ<9DAU21 (mnh>A_4!5纀VҨ)onP^CDz\Z14I3XpcZ7l/D#팦$1fSU;`\13TKOxiIENDB`substance-5.3.orig/src/test/check/icons/16/edit-cut.png0000644000175000017500000000144710565041042022616 0ustar drazzibdrazzibPNG  IHDRabKGDC pHYs  tIME 1hAd^IDAT8˅]HQǟsw}lhxUtaIWEd"hiXi}J$ 0m36c6uu_vMaZ? <}rG$d F`Jiym7TDb$[ccS`eωXFt.8[R<v5:4`:nox<,:[-UOT58?c D59?!$U:^A.`٫ KJP$KHb?pz@bY^b,)4IF)q G$uRZ@JF^[%2$% ă2s&))aSM,o@x hlfaF{!=j&|na>ey:JNl4?/ QPIENDB`substance-5.3.orig/src/test/check/icons/flag_denmark.png0000644000175000017500000000122310501772474023266 0ustar drazzibdrazzibPNG  IHDRa+tEXtCreation TimeMi 31 Mrz 2004 12:26:36 +0100QyXtIME  pHYs B4gAMA aIDATxSn@{7!(@BlC(' ĕ ̉ = qA$HB=H1@!`}nY. rn}}`x ^oy4ӈ@{t57 x  mvs^(Mp<кm?i0SNP_ώ+Vfn"xV*ABhE LciBDǃxL^wh?Tۉ>IENDB`substance-5.3.orig/src/test/check/icons/flag_bulgaria.png0000644000175000017500000000103210501772474023431 0ustar drazzibdrazzibPNG  IHDRa+tEXtCreation TimeMi 31 Mrz 2004 10:16:05 +0100/ltIME!nnr pHYs B4gAMA arIDATxSKNAfLt A-\{ fCB7 ߲^7 [*ySLǫ* :v(<)@1FާK]6謆@߯aӶ-5MHι_֒1&d" %J.>(Vn+pzn+M#"l6X;OYN\mWO|?Ƭ HZJzRG&&-g،u \ϔ<*r%s-EXZ!qpΖh9#5.-/Hd,-uBnF<%;Q^Q;2F(`ҷ|*\<d36vQQH? !YKvd?[IENDB`substance-5.3.orig/src/test/check/icons/flag_vietnam.png0000644000175000017500000000107310261175542023307 0ustar drazzibdrazzibPNG  IHDRa*tEXtCreation TimeFr 2 Apr 2004 11:03:52 +0100<-tIME ;D} pHYs B4gAMA aIDATxSJAS|a`b&jjb$m~FƂ {L{ 3=]]] {# p*rYS4gN7jȃz`t*$)Bh'xyxR TUվj(37U@̅`@ Kia5 ꈥ[ ||oUM!qx/ f`2 z>n}W_K9@98$pl[&_NELe`92xƈg`]4 օ*|>F $"ɜ49g &LOZF_S('3d]|<6S4"e9[ۼhgekE ^:П_G$-ҋIENDB`substance-5.3.orig/src/test/check/icons/flag_czech_republic.png0000644000175000017500000000115210501772474024627 0ustar drazzibdrazzibPNG  IHDRa+tEXtCreation TimeMi 31 Mrz 2004 11:25:45 +0100<&tIME   pHYs B4gAMA aIDATxœn1?{."JDRJ@<PA@AGG[4HHPNZ.{8}=:Yg!39O){1F0wjyɣͳZ>THg]uG<{E*s ◵B6tpbdJ:j( 1.π'/*۲`{*aT |{UN5[M6Qc+[COrX<~<+s)g>zP٣s|O_phNVRʾ#xcr {k6QjjV[7LІҔhP7YBnqL%X~N|N)IZ/ji;ك[D/SSj1!tYNN9\ES<IENDB`substance-5.3.orig/src/test/check/icons/JInternalFrameColor16.gif0000644000175000017500000000016210421430360024627 0ustar drazzibdrazzibGIF89az!,7(;0J!< x_'WRg ϴluzpڊF!tzIF;substance-5.3.orig/src/test/check/icons/JSliderColor16.gif0000644000175000017500000000022010421430362023317 0ustar drazzibdrazzibGIF89aGp߭펪431!,=PI8=!LbHD2C3HK b0> K(8S H֬vk;substance-5.3.orig/src/test/check/icons/JTableColor16.gif0000644000175000017500000000023210421430362023127 0ustar drazzibdrazzibGIF89acz!,GPI,8k}/a)j fgG=/P#Hc-D8R2XOvYΔ;substance-5.3.orig/src/test/check/icons/JRadioButtonColor16.gif0000644000175000017500000000013210421430362024331 0ustar drazzibdrazzibGIF89az431!,(0Iu.]4)uUp,r;substance-5.3.orig/src/test/check/icons/flag_saudi_arabia.png0000644000175000017500000000124110501772476024253 0ustar drazzibdrazzibPNG  IHDRa*tEXtCreation TimeDo 1 Apr 2004 15:57:14 +0100GtIME ;$ pHYs B4gAMA aIDATxRKnA$cYQlb͆pN '@XXAbA`،ݏv,@f{zUKO(.{N >>X cs/dYrʥ4R Y@;ݶh׭Am Jݢv?>I nI'2lw)A)5u%;l 6dM q&t\ݾ'G.?Xj\J3{/.o\LJod5c+O37:s=ic$3:țYM\NQ@I7ӗGtC,l}ֻ,1ѯy!ÉC1Lq4+JE>nna3FbVhg|uXANk"-~S5=Yc`pbjΆi~#ήT?CKp;hپ?蕆BIENDB`substance-5.3.orig/src/test/check/icons/JSpinnerColor16.gif0000644000175000017500000000020710421430362023520 0ustar drazzibdrazzibGIF89ay—32.!,4PI8ͧ`zIiAb 21z,d 8h8%;substance-5.3.orig/src/test/check/icons/flag_greece.png0000644000175000017500000000130010520765374023075 0ustar drazzibdrazzibPNG  IHDRa*tEXtCreation TimeFr 2 Apr 2004 13:09:16 +0100GFtIME )4 pHYs B4gAMA aIDATxSMo@}k;I6M D*w!!/pB~\P/HZzB(=DױcY.?k]͛5pC)x[;]$بƿo=ka(eyOi$}ў\UL?ղ<5FRmBKI&),$OZM cg*NQݕJ46 Cm lU1cQzZ-Q}<mƬj}Q!QuA* ~L%lvqa*`B>F0D{A,AP$x0;wfNpUOYLs bCj=Mp. 3Lu, kǔ C §ßZ`ub$9Av\ զZH9\˘E{6:o'KښU$Xz3w/{ _tD΀ 1&LU(%%XE;t&FS~](??ItIENDB`substance-5.3.orig/src/test/check/icons/JScrollPaneColor16.gif0000644000175000017500000000022210421430362024141 0ustar drazzibdrazzibGIF89acz!,?PI,8k}_rhA+j\sit<` 3lnq0@jjɵx);substance-5.3.orig/src/test/check/icons/flag_portugal.png0000644000175000017500000000124210520765376023507 0ustar drazzibdrazzibPNG  IHDRa*tEXtCreation TimeDo 1 Apr 2004 16:12:05 +0100ptIME -: pHYs B4gAMA aIDATxSjA=U8HpBp 2+5d%fU~kw. ܹsR"2_`LLB;=] Eֹ[ n^zIYXB:'* *^[ 9g*7\;$NҜPi[[!Z@ к_'G/ = #Џd2BG !16 WCvyz 87aP< ӘU =$z$< Si }S=V73m0!hx1aAuLu'9.W> EBXrڅ=%Kn !F֮ۨazEzßOxp7[#\ &v W:eikH0+Ij,GN _ c2.M}p 4$3[\BwF;_1_]ÛcQ6y 2RIENDB`substance-5.3.orig/src/test/check/icons/JComboBoxColor16.gif0000644000175000017500000000051110421430360023606 0ustar drazzibdrazzibGIF89a{{||{~}}~xyy{}|{zy{}|}|vx243333222!,fpH,Ȥrf6 Hae`h9NA>ÉKybBmŽG(_ݾI攙mR0xˠ![XA}s5@ J܄Hi%uCdKw@?0>_{Í.]NB 2>"y-v)v5\yw&X6>Gf6j_h!N"~r ,XPXxB1ʮ==^Gu5Еkx>x58|lASD;{s7qn*:;.>rS{58FԽ!\F/@ڈ>¸2 O  ($Bod_@WwYG'EuzTD;6J|Mg.?j^xTIENDB`substance-5.3.orig/src/test/check/icons/JListColor16.gif0000644000175000017500000000023310421430362023014 0ustar drazzibdrazzibGIF89ac磸z!,HPI48k}FWhAz`)JfC8e; ;bH~Pdj`Ɣ9_T)o-I;substance-5.3.orig/src/test/check/icons/JTreeColor16.gif0000644000175000017500000000023010421430364022777 0ustar drazzibdrazzibGIF89aczW_d!,EPI,8k}Wt7 (1qiھ*TŢ)>&H9k44Aȍc)S";substance-5.3.orig/src/test/check/icons/flag_russia.png0000644000175000017500000000106710501772476023163 0ustar drazzibdrazzibPNG  IHDRa*tEXtCreation TimeDo 1 Apr 2004 16:06:25 +0100LtIME rS9P pHYs B4gAMA aIDATxSKN0q*nP B;19.@B-k$M?oA\^=?$D~X^rSYRJ1Fޓd,,~ܶY,S-Ml$,"Zr!scLZQfYPJe(0"MGGbQ'59؁ai~|y)jLHI.e& W)±bB!渰wXr/P;IZ3B i 1U nϼ7T'"  - Mtʫ;HIv!H>PsLGzZqv :O 6w',R0 a?d|7Pɘ` ׶5JXA R|8hbo?dO#=eTIENDB`substance-5.3.orig/src/test/check/icons/flag_spain.png0000644000175000017500000000117410501772476022766 0ustar drazzibdrazzibPNG  IHDRa*tEXtCreation TimeMi 7 Apr 2004 10:21:36 +0100p6KtIMEŨ pHYs B4gAMA aIDATxSjPfT`Q/ ވ}o|5 "h[Ԫv Ir~oɖЄ/ߜ93/e_>ڝ|KĞg{/pvd籨BCM Ӎa9[(Q  f7@Ӓiڦ{o+! l k%t@ wDђLZ &o\ ]Ϣ#k', ѹXݵ݇"!_n݆p N 9~Nc8_Ջ9o- =.j:AH׻7G0T 29f#1m~|+gWm`ku=M~=H"}'Bv6u0FCЩwIMzoZh+RX1و' 4r. Ah.t`Vn2Pƽ]lR\ #JF&ΐIENDB`substance-5.3.orig/src/test/check/icons/JCheckBoxColor16.gif0000644000175000017500000000027210421430360023570 0ustar drazzibdrazzibGIF89a54954:54<55756:~25:~||{~zzyx{!,7 dih, Q R)Gy%*Exhd0˅Q9"IzV;substance-5.3.orig/src/test/check/icons/flag_sweden.png0000644000175000017500000000116710520765376023145 0ustar drazzibdrazzibPNG  IHDRa*tEXtCreation TimeFr 2 Apr 2004 10:50:39 +0100> tIME3*;1g pHYs B4gAMA aIDATxSNA;N"",Zr`K82B ,H+#$ıDZ3T+MlWz~n8#D`af46|_%H|i"Pݔ}3(X~܅`u G\5Bɉa32:O#3ȻIdq EV%3P m)Iٸ;ˇ>.22bmp%BB, [^_d`'o,s塹k%#aHßzmkӌ  ꕀ1U$ҽ;kyz['yl޿gI, RY: ALVL"4)Klx#_ƪv ڷ$H͔{2*t&HYedo3%qtԳupWGE])QY;-Dw Yx4IENDB`substance-5.3.orig/src/test/check/icons/flag_poland.png0000644000175000017500000000101710501772476023125 0ustar drazzibdrazzibPNG  IHDRa*tEXtCreation TimeDo 1 Apr 2004 16:20:47 +0100H;<tIMEt pHYs B4gAMA ahIDATxS;n0 %W2 z ЭCݺ$NlH[ 3)Qd{xk2͕.BȼS en'ܳY@Ӝsm3,q+ސ-i_5PU7 ~<~9&?,Au#}`0xT9{OM7|IENDB`substance-5.3.orig/src/test/check/CellsPanel.java0000644000175000017500000001747311212461232021721 0ustar drazzibdrazzibpackage test.check; import java.awt.*; import java.util.Enumeration; import javax.swing.*; import javax.swing.tree.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.painter.decoration.DecorationAreaType; import test.check.command.*; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; public class CellsPanel extends JPanel implements Deferrable { private boolean isInitialized; @Override public boolean isInitialized() { return this.isInitialized; } public CellsPanel() { } @Override public synchronized void initialize() { FormLayout lmCells = new FormLayout( "right:pref, 10dlu, fill:pref:grow(1), 4dlu," + "fill:pref:grow(1), 4dlu, fill:pref:grow(1), " + "4dlu, fill:pref:grow(1)", ""); lmCells.setColumnGroups(new int[][] { { 3, 5, 7, 9 } }); DefaultFormBuilder builderCells = new DefaultFormBuilder(lmCells, new ScrollablePanel()); builderCells.setDefaultDialogBorder(); builderCells.append(""); builderCells.append(new JLabel("NONE"), new JLabel("GENERAL")); builderCells.append(new JLabel("HEADER"), new JLabel("FOOTER")); builderCells.appendSeparator("Lists"); addControlRow(builderCells, "List", new CreationCommand() { public Component create() { JList list = new JList(new Object[] { "entry1", "entry2", "entry3" }); return list; } }, null); addControlRow(builderCells, "List watermark", new CreationCommand() { public Component create() { JList list = new JList(new Object[] { "entry1", "entry2", "entry3" }); return list; } }, new ClientPropertyCommand( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE)); addControlRow(builderCells, "List disabled", new CreationCommand() { public Component create() { JList list = new JList(new Object[] { "entry1", "entry2", "entry3" }); return list; } }, new DisableCommand()); CreationCommand tableCreationCmd = new CreationCommand() { public Component create() { final JTable table = new JTable(new Object[][] { { "entry11", "entry12", "entry13" }, { "entry21", "entry22", "entry23" }, { "entry31", "entry32", "entry33" } }, new Object[] { "Column1", "Column2", "Column3" }); table.setName("Table "); JScrollPane tableScroll = new JScrollPane(table) { @Override public void setBackground(Color bg) { super.setBackground(bg); table.setBackground(bg); table.getTableHeader().setBackground(bg); } @Override public void setForeground(Color fg) { super.setForeground(fg); table.setForeground(fg); table.getTableHeader().setForeground(fg); } }; Dimension prefTable = table.getPreferredSize(); tableScroll.setPreferredSize(new Dimension(prefTable.width, prefTable.height + 25)); return tableScroll; } }; builderCells.appendSeparator("Tables"); addControlRow(builderCells, "Table", tableCreationCmd, null); addControlRow(builderCells, "Table watermark", tableCreationCmd, new ClientPropertyCommand( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE)); addControlRow(builderCells, "Table disabled", tableCreationCmd, new DisableViewportCommand()); CreationCommand treeCreationCmd = new CreationCommand() { public void expandAll(JTree tree, boolean expand) { TreeNode root = (TreeNode) tree.getModel().getRoot(); // Traverse tree from root expandAll(tree, new TreePath(root), expand); } private void expandAll(JTree tree, TreePath parent, boolean expand) { // Traverse children TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.getChildCount() >= 0) { for (Enumeration e = node.children(); e.hasMoreElements();) { TreeNode n = (TreeNode) e.nextElement(); TreePath path = parent.pathByAddingChild(n); expandAll(tree, path, expand); } } // Expansion or collapse must be done bottom-up if (expand) { tree.expandPath(parent); } else { tree.collapsePath(parent); } } public Component create() { DefaultMutableTreeNode root = new DefaultMutableTreeNode("root"); DefaultMutableTreeNode son1 = new DefaultMutableTreeNode("son1"); DefaultMutableTreeNode son2 = new DefaultMutableTreeNode("son2"); DefaultMutableTreeNode son3 = new DefaultMutableTreeNode("son3"); DefaultMutableTreeNode gson11 = new DefaultMutableTreeNode( "gson11"); DefaultMutableTreeNode gson12 = new DefaultMutableTreeNode( "gson12"); DefaultMutableTreeNode gson21 = new DefaultMutableTreeNode( "gson21"); DefaultMutableTreeNode gson22 = new DefaultMutableTreeNode( "gson22"); DefaultMutableTreeNode gson31 = new DefaultMutableTreeNode( "gson31"); DefaultMutableTreeNode gson32 = new DefaultMutableTreeNode( "gson32"); DefaultMutableTreeNode ggson111 = new DefaultMutableTreeNode( "ggson111"); DefaultMutableTreeNode ggson112 = new DefaultMutableTreeNode( "ggson112"); DefaultMutableTreeNode ggson113 = new DefaultMutableTreeNode( "ggson113"); gson11.add(ggson111); gson11.add(ggson112); gson11.add(ggson113); son1.add(gson11); son1.add(gson12); son2.add(gson21); son2.add(gson22); son3.add(gson31); son3.add(gson32); root.add(son1); root.add(son2); root.add(son3); JTree tree = new JTree(root); expandAll(tree, true); return tree; } }; builderCells.appendSeparator("Trees"); addControlRow(builderCells, "Tree", treeCreationCmd, null); addControlRow(builderCells, "Tree watermark", treeCreationCmd, new ClientPropertyCommand( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE)); addControlRow(builderCells, "Tree disabled", treeCreationCmd, new DisableCommand()); JPanel panelCells = builderCells.getPanel(); JScrollPane jspCells = new JScrollPane(panelCells); panelCells.setOpaque(false); jspCells.setOpaque(false); jspCells.getViewport().setOpaque(false); this.setLayout(new BorderLayout()); this.add(jspCells); this.isInitialized = true; } /** * Adds a row of components configured with the specified configuration * command. * * @param builder * Form builder. * @param label * Text to set. * @param creationCmd * Creation command. * @param configurationCmd * Configuration command to apply. */ private void addControlRow(DefaultFormBuilder builder, String label, CreationCommand creationCmd, ConfigurationCommand configurationCmd) { Component[] row = new Component[4]; row[0] = creationCmd.create(); SubstanceLookAndFeel.setDecorationType(((JComponent) row[0]), DecorationAreaType.NONE); row[0].setName(row[0].getName() + ": NONE"); row[1] = creationCmd.create(); SubstanceLookAndFeel.setDecorationType(((JComponent) row[1]), DecorationAreaType.GENERAL); row[1].setName(row[1].getName() + ": GENERAL"); row[2] = creationCmd.create(); SubstanceLookAndFeel.setDecorationType(((JComponent) row[2]), DecorationAreaType.HEADER); row[2].setName(row[2].getName() + ": HEADER"); row[3] = creationCmd.create(); SubstanceLookAndFeel.setDecorationType(((JComponent) row[3]), DecorationAreaType.FOOTER); row[3].setName(row[3].getName() + ": FOOTER"); if (configurationCmd != null) { for (Component comp : row) { configurationCmd.configure(comp); } } JLabel jl = new JLabel(label); builder.append(jl); for (Component comp : row) builder.append(comp); } } substance-5.3.orig/src/test/check/TextFieldsPanel.java0000644000175000017500000004132211213155420022720 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.text.DecimalFormat; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.text.PasswordStrengthChecker; import org.jvnet.lafwidget.utils.LafConstants.PasswordStrength; import org.jvnet.substance.SubstanceLookAndFeel; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; /** * Test application panel for testing {@link JTextArea}, {@link JTextField}, * {@link JTextPane}, {@link JPasswordField}, {@link JEditorPane} and * {@link JFormattedTextField} components. * * @author Kirill Grouchnikov */ public class TextFieldsPanel extends JPanel implements Deferrable { private boolean isInitialized; @Override public boolean isInitialized() { return this.isInitialized; } /** * Returns the panel contents. * * @return The panel contents. */ private JPanel getContents() { FormLayout lm = new FormLayout( "right:pref, 4dlu, fill:default:grow(1), 4dlu," + "fill:default:grow(1), 4dlu, fill:default:grow(1)", ""); // lm.setColumnGroups(new int[][] { { 3, 5, 7 } }); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); builder.setDefaultDialogBorder(); JLabel textLabel = new JLabel("Text fields"); JLabel formattedTextLabel = new JLabel("Formatted text fields"); JLabel passwordLabel = new JLabel("Password fields"); // textLabel.setFont(textLabel.getFont().deriveFont(Font.BOLD)); // formattedTextLabel.setFont(formattedTextLabel.getFont().deriveFont( // Font.BOLD)); // passwordLabel.setFont(passwordLabel.getFont().deriveFont(Font.BOLD)); builder.append("", textLabel); builder.append(formattedTextLabel, passwordLabel); JTextField jtf1 = new JTextField("sample text"); builder.append("Enabled", jtf1); JFormattedTextField jftf1 = new JFormattedTextField(new DecimalFormat( "#,##0.0000")); jftf1.setText("2,430.0000"); JPasswordField jpf1 = new JPasswordField("password", 10); builder.append(jftf1, jpf1); JTextField jtfNotEditable = new JTextField("sample text"); jtfNotEditable.setEditable(false); builder.append("Not editable", jtfNotEditable); JFormattedTextField jftfNotEditable = new JFormattedTextField( new DecimalFormat("#,##0.0000")); jftfNotEditable.setText("2,430.0000"); jftfNotEditable.setEditable(false); JPasswordField jpfNotEditable = new JPasswordField("password", 10); jpfNotEditable.setEditable(false); builder.append(jftfNotEditable, jpfNotEditable); JTextField jtfNotEditableNoLock = new JTextField("sample text"); jtfNotEditableNoLock.setEditable(false); jtfNotEditableNoLock.putClientProperty(LafWidget.NO_LOCK_ICON, Boolean.TRUE); builder.append("Not editable no lock", jtfNotEditableNoLock); JFormattedTextField jftfNotEditableNoLock = new JFormattedTextField( new DecimalFormat("#,##0.0000")); jftfNotEditableNoLock.setText("2,430.0000"); jftfNotEditableNoLock.setEditable(false); jftfNotEditableNoLock.putClientProperty(LafWidget.NO_LOCK_ICON, Boolean.TRUE); JPasswordField jpfNotEditableNoLock = new JPasswordField("password", 10); jpfNotEditableNoLock.setEditable(false); jpfNotEditableNoLock.putClientProperty(LafWidget.NO_LOCK_ICON, Boolean.TRUE); builder.append(jftfNotEditableNoLock, jpfNotEditableNoLock); JTextField jtfDisabled = new JTextField("sample text"); jtfDisabled.setEnabled(false); builder.append("Disabled", jtfDisabled); JFormattedTextField jftfDisabled = new JFormattedTextField( new DecimalFormat("#,##0.0000")); jftfDisabled.setText("2,430.0000"); jftfDisabled.setEnabled(false); JPasswordField jpfDisabled = new JPasswordField("password", 10); jpfDisabled.setEnabled(false); builder.append(jftfDisabled, jpfDisabled); JTextField jtfNonOpaque = new JTextField("sample text"); jtfNonOpaque.setOpaque(false); builder.append("Non opaque", jtfNonOpaque); JFormattedTextField jftfNonOpaque = new JFormattedTextField( new DecimalFormat("#,##0.0000")); jftfNonOpaque.setText("2,430.0000"); jftfNonOpaque.setOpaque(false); JPasswordField jpfNonOpaque = new JPasswordField("password", 10); jpfNonOpaque.setOpaque(false); builder.append(jftfNonOpaque, jpfNonOpaque); JTextField jtfWatermarkBleed = new JTextField("sample text"); jtfWatermarkBleed.putClientProperty( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE); builder.append("Watermark bleed", jtfWatermarkBleed); JFormattedTextField jftfWatermarkBleed = new JFormattedTextField( new DecimalFormat("#,##0.0000")); jftfWatermarkBleed.setText("2,430.0000"); jftfWatermarkBleed.putClientProperty( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE); JPasswordField jpfWatermarkBleed = new JPasswordField("password", 10); jpfWatermarkBleed.putClientProperty( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE); builder.append(jftfWatermarkBleed, jpfWatermarkBleed); JTextField jtf4 = new JTextField("sample text"); jtf4.putClientProperty(LafWidget.TEXT_SELECT_ON_FOCUS, Boolean.TRUE); builder.append("Select all on focus", jtf4); JFormattedTextField jftf4 = new JFormattedTextField(new DecimalFormat( "#,##0.0000")); jftf4.setText("2,430.0000"); jftf4.putClientProperty(LafWidget.TEXT_SELECT_ON_FOCUS, Boolean.TRUE); builder.append(jftf4); builder.nextLine(); JTextField jtf4_1 = new JTextField("sample text"); jtf4_1.putClientProperty(LafWidget.TEXT_FLIP_SELECT_ON_ESCAPE, Boolean.TRUE); builder.append("Flip selection on ESC", jtf4_1); JFormattedTextField jftf4_1 = new JFormattedTextField( new DecimalFormat("#,##0.0000")); jftf4_1.setText("2,430.0000"); jftf4_1.putClientProperty(LafWidget.TEXT_FLIP_SELECT_ON_ESCAPE, Boolean.TRUE); builder.append(jftf4_1); builder.nextLine(); JTextField jtf5 = new JTextField("sample text"); jtf5.putClientProperty(LafWidget.TEXT_EDIT_CONTEXT_MENU, Boolean.TRUE); builder.append("With context menu", jtf5); JFormattedTextField jftf5 = new JFormattedTextField(new DecimalFormat( "#,##0.0000")); jftf5.setText("2,430.0000"); jftf5.putClientProperty(LafWidget.TEXT_EDIT_CONTEXT_MENU, Boolean.TRUE); builder.append(jftf5); builder.nextLine(); JTextField jtf6 = new JTextField("sample text"); jtf6.setMargin(new Insets(2, 2, 2, 2)); builder.append("With margin a2", jtf6); JFormattedTextField jftf6 = new JFormattedTextField(new DecimalFormat( "#,##0.0000")); jftf6.setText("2,430.0000"); jftf6.setMargin(new Insets(2, 2, 2, 2)); JPasswordField jpf6 = new JPasswordField("password", 10); jpf6.setMargin(new Insets(2, 2, 2, 2)); builder.append(jftf6, jpf6); JTextField jtf60 = new JTextField("sample text"); jtf60.setMargin(new Insets(0, 10, 0, 0)); builder.append("With margin l10", jtf60); JFormattedTextField jftf60 = new JFormattedTextField(new DecimalFormat( "#,##0.0000")); jftf60.setText("2,430.0000"); jftf60.setMargin(new Insets(0, 10, 0, 0)); JPasswordField jpf60 = new JPasswordField("password", 10); jpf60.setMargin(new Insets(0, 10, 0, 0)); builder.append(jftf60, jpf60); JPasswordField jpfEmptyEchoChar = new JPasswordField("password", 10); jpfEmptyEchoChar.setEchoChar((char) 0); builder.append("Empty echo char", new JLabel()); builder.append(new JLabel(), jpfEmptyEchoChar); JPasswordField jpfStrengthChecker = new JPasswordField("password", 10); try { jpfStrengthChecker.putClientProperty( LafWidget.PASSWORD_STRENGTH_CHECKER, new PasswordStrengthChecker() { public PasswordStrength getStrength(char[] password) { if (password == null) return PasswordStrength.WEAK; int length = password.length; if (length < 3) return PasswordStrength.WEAK; if (length < 6) return PasswordStrength.MEDIUM; return PasswordStrength.STRONG; } public String getDescription(PasswordStrength strength) { if (strength == PasswordStrength.WEAK) return "This password is way too weak"; if (strength == PasswordStrength.MEDIUM) return "Come on, you can do
a little better than that"; if (strength == PasswordStrength.STRONG) return "OK"; return null; } }); builder.append("Strength checker", new JLabel()); builder.append(new JLabel(), jpfStrengthChecker); } catch (Throwable t) { } JPasswordField jpfTwoEchoChar = new JPasswordField("password", 10); jpfTwoEchoChar.putClientProperty( SubstanceLookAndFeel.PASSWORD_ECHO_PER_CHAR, new Integer(2)); builder.append("Two echo chars", new JLabel()); builder.append(new JLabel(), jpfTwoEchoChar); JLabel editorPaneLabel = new JLabel("Editor panes"); JLabel textAreaLabel = new JLabel("Text areas"); JLabel textPaneLabel = new JLabel("Text panes"); // editorPaneLabel // .setFont(editorPaneLabel.getFont().deriveFont(Font.BOLD)); // textAreaLabel.setFont(textAreaLabel.getFont().deriveFont(Font.BOLD)); // textPaneLabel.setFont(textPaneLabel.getFont().deriveFont(Font.BOLD)); builder.append("", editorPaneLabel); builder.append(textAreaLabel, textPaneLabel); JEditorPane jep1 = new JEditorPane("text/html;", "Sample content
text"); builder.append("Enabled", jep1); JTextArea jta1 = new JTextArea("Sample content text", 3, 20); JTextPane jtp1 = new JTextPane(); jtp1.replaceSelection("Sample content text"); jtp1.setPreferredSize(new Dimension(100, 40)); builder.append(jta1, jtp1); JEditorPane jepNotEditable = new JEditorPane("text/html;", "Sample content
text"); jepNotEditable.setEditable(false); builder.append("Not editable", jepNotEditable); JTextArea jtaNotEditable = new JTextArea("Sample content text", 3, 20); jtaNotEditable.setEditable(false); JTextPane jtpNotEditable = new JTextPane(); jtpNotEditable.replaceSelection("Sample content text"); jtpNotEditable.setPreferredSize(new Dimension(100, 40)); jtpNotEditable.setEditable(false); builder.append(jtaNotEditable, jtpNotEditable); JEditorPane jepNotEditableNoLock = new JEditorPane("text/html;", "Sample content
text"); jepNotEditableNoLock.setEditable(false); jepNotEditableNoLock.putClientProperty(LafWidget.NO_LOCK_ICON, Boolean.TRUE); builder.append("Not editable no lock", jepNotEditableNoLock); JTextArea jtaNotEditableNoLock = new JTextArea("Sample content text", 3, 20); jtaNotEditableNoLock.setEditable(false); jtaNotEditableNoLock.putClientProperty(LafWidget.NO_LOCK_ICON, Boolean.TRUE); JTextPane jtpNotEditableNoLock = new JTextPane(); jtpNotEditableNoLock.replaceSelection("Sample content text"); jtpNotEditableNoLock.setPreferredSize(new Dimension(100, 40)); jtpNotEditableNoLock.setEditable(false); jtpNotEditableNoLock.putClientProperty(LafWidget.NO_LOCK_ICON, Boolean.TRUE); builder.append(jtaNotEditableNoLock, jtpNotEditableNoLock); JEditorPane jep3 = new JEditorPane("text/html;", "Sample content
text"); jep3.setEnabled(false); builder.append("Disabled", jep3); JTextArea jta3 = new JTextArea("Sample content text", 3, 20); jta3.setEnabled(false); JTextPane jtp3 = new JTextPane(); jtp3.replaceSelection("Sample content text"); jtp3.setPreferredSize(new Dimension(100, 40)); jtp3.setEnabled(false); builder.append(jta3, jtp3); JEditorPane jepNonOpaque = new JEditorPane("text/html;", "Sample content
text"); jepNonOpaque.setOpaque(false); builder.append("Non opaque", jepNonOpaque); JTextArea jtaNonOpaque = new JTextArea("Sample content text", 3, 20); jtaNonOpaque.setOpaque(false); JTextPane jtpNonOpaque = new JTextPane(); jtpNonOpaque.replaceSelection("Sample content text"); jtpNonOpaque.setPreferredSize(new Dimension(100, 40)); jtpNonOpaque.setOpaque(false); builder.append(jtaNonOpaque, jtpNonOpaque); JEditorPane jepWatermarkBleed = new JEditorPane("text/html;", "Sample content
text"); jepWatermarkBleed.putClientProperty( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE); builder.append("Watermark bleed", jepWatermarkBleed); JTextArea jtaWatermarkBleed = new JTextArea("Sample content text", 3, 20); jtaWatermarkBleed.putClientProperty( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE); JTextPane jtpWatermarkBleed = new JTextPane(); jtpWatermarkBleed.replaceSelection("Sample content text"); jtpWatermarkBleed.setPreferredSize(new Dimension(100, 40)); jtpWatermarkBleed.putClientProperty( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.TRUE); builder.append(jtaWatermarkBleed, jtpWatermarkBleed); JEditorPane jep4 = new JEditorPane("text/html;", "Sample content
text"); jep4.setMargin(new Insets(2, 2, 2, 2)); builder.append("With margin", jep4); JTextArea jta4 = new JTextArea("Sample content text", 3, 20); jta4.setMargin(new Insets(2, 2, 2, 2)); JTextPane jtp4 = new JTextPane(); jtp4.replaceSelection("Sample content text"); jtp4.setPreferredSize(new Dimension(100, 40)); jtp4.setMargin(new Insets(2, 2, 2, 2)); builder.append(jta4, jtp4); JTextArea jtaLineWrap = new JTextArea( "The contents of this text area wrap, but not necessarily between words", 3, 15); jtaLineWrap.setLineWrap(true); builder.append("Line wrap", new JLabel("")); builder.append(jtaLineWrap, new JLabel("")); JTextArea jtaLineWrapWords = new JTextArea( "The contents of this text area wrap, necessarily between words", 3, 15); jtaLineWrapWords.setLineWrap(true); jtaLineWrapWords.setWrapStyleWord(true); builder.append("Line wrap words", new JLabel("")); builder.append(jtaLineWrapWords, new JLabel("")); JTextArea textAreaScroll = new JTextArea(5, 15); for (int i = 0; i < 20; i++) { textAreaScroll.append("Some long long long line with number " + i + "\n"); } textAreaScroll.setEditable(false); builder.append("Scrollable", new JScrollPane(textAreaScroll)); builder.nextLine(); JTextArea textAreaScrollNoLock = new JTextArea(5, 15); for (int i = 0; i < 20; i++) { textAreaScrollNoLock.append("Some long long long line with number " + i + "\n"); } textAreaScrollNoLock.setEditable(false); textAreaScrollNoLock.putClientProperty(LafWidget.NO_LOCK_ICON, Boolean.TRUE); builder.append("Scrollable no lock", new JScrollPane( textAreaScrollNoLock)); return builder.getPanel(); } /** * Creates a test panel with text components. */ public TextFieldsPanel() { setLayout(new BorderLayout()); } @Override public synchronized void initialize() { final JPanel contents = getContents(); JScrollPane scroller = new JScrollPane(contents); this.add(scroller, BorderLayout.CENTER); this.isInitialized = true; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { contents.scrollRectToVisible(new Rectangle(0, 0, 10, 10)); } }); } }substance-5.3.orig/src/test/check/TablePanel.java0000644000175000017500000004235611247721152021714 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Calendar; import java.util.Date; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.table.AbstractTableModel; import javax.swing.table.JTableHeader; import org.jvnet.lafwidget.animation.*; import org.jvnet.lafwidget.utils.LafConstants.AnimationKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.api.renderers.SubstanceDefaultTableCellRenderer; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.utils.SubstanceColorUtilities; import org.jvnet.substance.utils.SubstanceImageCreator; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; /** * Test application panel for testing {@link JTable} component. * * @author Kirill Grouchnikov */ public class TablePanel extends ControllablePanel implements Deferrable { private boolean isInitialized; @Override public boolean isInitialized() { return this.isInitialized; } /** * The table. */ private JTable table; /** * Custom renderer for columns that contain {@link Color} data. * * @author Kirill Grouchnikov */ private static class MyColorTableRenderer extends SubstanceDefaultTableCellRenderer { /* * (non-Javadoc) * * @see * javax.swing.table.TableCellRenderer#getTableCellRendererComponent * (javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Color color = (Color) value; this.setForeground(color); this.setBackground(SubstanceColorUtilities.invertColor(color)); this.setText("row " + row); return this; } } /** * Custom renderer for the columns that contain {@link Float} data. * * @author Kirill Grouchnikov */ private static class MyFloatTableRenderer extends SubstanceDefaultTableCellRenderer { /* * (non-Javadoc) * * @see * javax.swing.table.TableCellRenderer#getTableCellRendererComponent * (javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) */ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { int c = (10 * row) % 255; Color color = new Color(c, c, c); this.setForeground(new Color(255 - c, 0, 0)); this.setBackground(color); this.setText(value.toString()); return this; } } /** * Custom table model. * * @author Kirill Grouchnikov */ private static class MyTableModel extends AbstractTableModel { /** * The current row count. */ private int rows; /** * The column count. */ private int cols = 10; /** * The table data. */ private Object[][] data; /** * The table column classes. */ private Class[] columns = new Class[] { String.class, JComboBox.class, Boolean.class, Byte.class, Float.class, Double.class, String.class, Date.class, ImageIcon.class, Color.class }; /** * Creates the custom table model. * * @param rows * Initial number of rows. */ public MyTableModel(int rows) { this.rows = rows; this.data = new Object[rows][this.cols]; SubstanceColorScheme[] schemes = new SubstanceColorScheme[] { new AquaColorScheme(), new BottleGreenColorScheme(), new BarbyPinkColorScheme(), new PurpleColorScheme(), new OliveColorScheme(), new OrangeColorScheme(), new BrownColorScheme() }; for (int i = 0; i < rows; i++) { this.data[i][0] = "cell " + i + ":" + 0; this.data[i][1] = "predef"; this.data[i][2] = new Boolean(i % 2 == 0); this.data[i][3] = new Byte((byte) i); this.data[i][4] = new Float(i); this.data[i][5] = new Double(i); this.data[i][6] = "cell " + i + ":" + 6; Calendar cal = Calendar.getInstance(); cal.set(2000 + i, 1 + i, 1 + i); this.data[i][7] = cal.getTime(); int count = 0; if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) { try { this.data[i][8] = SubstanceImageCreator.getHexaMarker( 6, schemes[i % schemes.length]); } catch (Exception exc) { } } int comp = i * 20; int red = (comp / 3) % 255; int green = (comp / 2) % 255; int blue = comp % 255; this.data[i][9] = new Color(red, green, blue); } } /* * (non-Javadoc) * * @see javax.swing.table.AbstractTableModel#getColumnClass(int) */ @Override public Class getColumnClass(int columnIndex) { return this.columns[columnIndex]; } /* * (non-Javadoc) * * @see javax.swing.table.TableModel#getColumnCount() */ public int getColumnCount() { return this.cols; } /* * (non-Javadoc) * * @see javax.swing.table.TableModel#getRowCount() */ public int getRowCount() { return this.rows; } /* * (non-Javadoc) * * @see javax.swing.table.TableModel#getValueAt(int, int) */ public Object getValueAt(int row, int col) { return this.data[row][col]; } /* * (non-Javadoc) * * @see javax.swing.table.AbstractTableModel#getColumnName(int) */ @Override public String getColumnName(int column) { return this.getColumnClass(column).getSimpleName(); } /* * (non-Javadoc) * * @see javax.swing.table.AbstractTableModel#isCellEditable(int, int) */ @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return (rowIndex % 2 == 0); } /* * (non-Javadoc) * * @see * javax.swing.table.AbstractTableModel#setValueAt(java.lang.Object, * int, int) */ @Override public void setValueAt(Object value, int row, int col) { this.data[row][col] = value; this.fireTableCellUpdated(row, col); } } /** * Creates a test panel with table. */ public TablePanel() { } public synchronized void initialize() { this.table = new JTable(new MyTableModel(20)); this.table.setDefaultRenderer(Color.class, new MyColorTableRenderer()); this.table.setDefaultRenderer(Float.class, new MyFloatTableRenderer()); final JScrollPane tableScrollpane = new JScrollPane(this.table); tableScrollpane.setName("Main table in table panel"); JComboBox combo = new JComboBox(new Object[] { "aa", "bb", "cc" }); combo.setBorder(null); this.table.getColumnModel().getColumn(1).setCellEditor( new DefaultCellEditor(combo)); this.table .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); // We allow row selection as the default this.table.setCellSelectionEnabled(true); this.table.setRowSelectionAllowed(true); this.table.setColumnSelectionAllowed(false); this.table.setShowGrid(false); this.table.setDragEnabled(false); this.table .setTableHeader(new JTableHeader(this.table.getColumnModel())); this.setLayout(new BorderLayout()); this.add(tableScrollpane, BorderLayout.CENTER); final JLabel instructional = new JLabel("Every odd row is editable"); this.add(instructional, BorderLayout.NORTH); // create a looping animation to change the label foreground // from black to blue and back to draw some attention. FadeKind custom = new FadeKind("substance.testapp.table.instructional"); FadeTracker.getInstance().trackFadeLooping(custom, AnimationKind.DEBUG_FAST, instructional, 0, false, new FadeTrackerAdapter() { @Override public void fadePerformed(FadeKind fadeKind, float fadeCycle) { instructional.setForeground(SubstanceColorUtilities .getInterpolatedColor(Color.black, Color.blue, fadeCycle)); } }, -1, true); FormLayout lm = new FormLayout("right:pref, 4dlu, fill:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); builder.appendSeparator("Table settings"); final JCheckBox isEnabled = new JCheckBox("is enabled"); isEnabled.setSelected(table.isEnabled()); isEnabled.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { table.setEnabled(isEnabled.isSelected()); // the table header is not repainted on disabling / enabling :( table.getTableHeader().repaint(); } }); builder.append("Enabled", isEnabled); JButton changeFirstColumn = new JButton("change 1st column"); changeFirstColumn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new Thread(new Runnable() { public void run() { for (int i = 0; i < table.getModel().getRowCount(); i++) { table.getModel().setValueAt( Thread.currentThread().getName() + " " + i, i, 0); try { Thread.sleep(200); } catch (InterruptedException e) { } } } }).start(); } }); builder.append("Change values", changeFirstColumn); final JSlider rowCountSlider = new JSlider(20, 1000, this.table .getModel().getRowCount()); rowCountSlider.setPaintLabels(false); rowCountSlider.setPaintTicks(false); rowCountSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (rowCountSlider.getValueIsAdjusting()) return; TablePanel.this.table.setModel(new MyTableModel(rowCountSlider .getValue())); } }); builder.append("Row count", rowCountSlider); final JCheckBox areRowsSelectable = new JCheckBox("Rows selectable"); areRowsSelectable.setSelected(this.table.getRowSelectionAllowed()); areRowsSelectable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { TablePanel.this.table.setRowSelectionAllowed(areRowsSelectable .isSelected()); } }); builder.append("Selectable", areRowsSelectable); final JCheckBox areColsSelectable = new JCheckBox("Cols selectable"); areColsSelectable.setSelected(this.table.getColumnSelectionAllowed()); areColsSelectable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { TablePanel.this.table .setColumnSelectionAllowed(areColsSelectable .isSelected()); } }); builder.append("", areColsSelectable); final JCheckBox isSorted = new JCheckBox("Sorted"); isSorted.setSelected(table.getAutoCreateRowSorter()); isSorted.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { table.setAutoCreateRowSorter(isSorted.isSelected()); table.repaint(); table.getTableHeader().repaint(); } }); builder.append("Sorted", isSorted); final JCheckBox customBackgroundCb = new JCheckBox( "Has pink background"); customBackgroundCb.addActionListener(new ActionListener() { Color oldBackColor; public void actionPerformed(ActionEvent e) { if (customBackgroundCb.isSelected()) { oldBackColor = table.getBackground(); table.setBackground(new Color(255, 128, 128)); } else { table.setBackground(oldBackColor); } } }); builder.append("Background", customBackgroundCb); final JCheckBox watermarkBleed = new JCheckBox("Watermark bleed"); watermarkBleed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { TablePanel.this.table.putClientProperty( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean .valueOf(watermarkBleed.isSelected())); tableScrollpane.putClientProperty( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean .valueOf(watermarkBleed.isSelected())); tableScrollpane.repaint(); } }); builder.append("Watermark", watermarkBleed); final JCheckBox linesVertical = new JCheckBox("Vertical visible"); linesVertical.setSelected(this.table.getShowVerticalLines()); linesVertical.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { TablePanel.this.table.setShowVerticalLines(linesVertical .isSelected()); } }); builder.append("Lines", linesVertical); final JCheckBox linesHorizontal = new JCheckBox("Horizontal visible"); linesHorizontal.setSelected(this.table.getShowHorizontalLines()); linesHorizontal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { TablePanel.this.table.setShowHorizontalLines(linesHorizontal .isSelected()); } }); builder.append("", linesHorizontal); final JComboBox resizeModeCombo = new FlexiComboBox( JTable.AUTO_RESIZE_OFF, JTable.AUTO_RESIZE_NEXT_COLUMN, JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS, JTable.AUTO_RESIZE_LAST_COLUMN, JTable.AUTO_RESIZE_ALL_COLUMNS) { @Override public String getCaption(Integer item) { int iv = item; switch (iv) { case JTable.AUTO_RESIZE_OFF: return "off"; case JTable.AUTO_RESIZE_NEXT_COLUMN: return "next"; case JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS: return "subsequent"; case JTable.AUTO_RESIZE_LAST_COLUMN: return "last"; case JTable.AUTO_RESIZE_ALL_COLUMNS: return "all"; } return null; } }; resizeModeCombo.setSelectedItem(this.table.getAutoResizeMode()); resizeModeCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int selected = (Integer) resizeModeCombo.getSelectedItem(); TablePanel.this.table.setAutoResizeMode(selected); } }); builder.append("Resize mode", resizeModeCombo); final JCheckBox hasRollovers = new JCheckBox("Has rollover effect"); hasRollovers.setSelected(FadeConfigurationManager.getInstance() .fadeAllowed(FadeKind.ROLLOVER, this.table)); hasRollovers.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (hasRollovers.isSelected()) { FadeConfigurationManager.getInstance().allowFades( FadeKind.ROLLOVER, TablePanel.this.table); } else { FadeConfigurationManager.getInstance().disallowFades( FadeKind.ROLLOVER, TablePanel.this.table); } } }); builder.append("Rollovers", hasRollovers); final JCheckBox hasSelectionAnimations = new JCheckBox( "Has selection effect"); hasSelectionAnimations.setSelected(FadeConfigurationManager .getInstance().fadeAllowed(FadeKind.SELECTION, this.table)); hasSelectionAnimations.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (hasSelectionAnimations.isSelected()) { FadeConfigurationManager.getInstance().allowFades( FadeKind.SELECTION, TablePanel.this.table); } else { FadeConfigurationManager.getInstance().disallowFades( FadeKind.SELECTION, TablePanel.this.table); } } }); builder.append("Selections", hasSelectionAnimations); builder.appendSeparator("Font settings"); JButton tahoma12 = new JButton("Tahoma 12"); tahoma12.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { table.setFont(new Font("Tahoma", Font.PLAIN, 12)); } }); builder.append("Set font", tahoma12); JButton tahoma13 = new JButton("Tahoma 13"); tahoma13.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { table.setFont(new Font("Tahoma", Font.PLAIN, 13)); } }); builder.append("Set font", tahoma13); this.controlPanel = builder.getPanel(); this.isInitialized = true; } }substance-5.3.orig/src/test/check/FlexiComboBox.java0000644000175000017500000000350211010041274022357 0ustar drazzibdrazzibpackage test.check; import java.awt.Color; import java.awt.Component; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.renderers.SubstanceDefaultComboBoxRenderer; public abstract class FlexiComboBox extends JComboBox { public FlexiComboBox(T... items) { super(items); } @Override public void updateUI() { if (SubstanceLookAndFeel.isCurrentLookAndFeel()) { setRenderer(new SubstanceDefaultComboBoxRenderer(this) { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component result = super.getListCellRendererComponent(list, getCaption((T) value), index, isSelected, cellHasFocus); Color color = getItemColor((T) value); if (color != null) result.setBackground(color); if (result instanceof JLabel) { ((JLabel) result).setIcon(getItemIcon((T) value)); } return result; } }); } else { setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component result = super.getListCellRendererComponent(list, getCaption((T) value), index, isSelected, cellHasFocus); Color color = getItemColor((T) value); if (color != null) result.setBackground(color); if (result instanceof JLabel) { ((JLabel) result).setIcon(getItemIcon((T) value)); } return result; } }); } super.updateUI(); } public abstract String getCaption(T item); public Color getItemColor(T item) { return null; } public Icon getItemIcon(T item) { return null; } } substance-5.3.orig/src/test/check/MousePopupListener.java0000644000175000017500000001115510734705420023520 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.LinkedList; import javax.swing.*; import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuListener; import test.Check; /** * Popup listener for the test application. * * @author Kirill Grouchnikov */ public class MousePopupListener extends MouseAdapter { /** * The owner component. */ private JComponent owner; /** * Creates a popup listener. * * @param owner * The owner component. */ public MousePopupListener(JComponent owner) { this.owner = owner; } /* * (non-Javadoc) * * @see java.awt.event.MouseAdapter#mousePressed(java.awt.event.MouseEvent) */ public void mousePressed(MouseEvent e) { checkPopup(e); } /* * (non-Javadoc) * * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent) */ public void mouseClicked(MouseEvent e) { checkPopup(e); } /* * (non-Javadoc) * * @see java.awt.event.MouseAdapter#mouseReleased(java.awt.event.MouseEvent) */ public void mouseReleased(MouseEvent e) { checkPopup(e); } /** * Handles the mouse event, showing the popup menu as necessary. * * @param e * Mouse event. */ void checkPopup(MouseEvent e) { if (e.isPopupTrigger()) { JPopupMenu popup = new JPopupMenu(); // ActionListener menuListener = new ActionListener() { // public void actionPerformed(ActionEvent event) { // Check.out("Popup menu item [" + event.getActionCommand() // + "] was pressed."); // } // }; int mcount = 0; for (LinkedList miList : SampleMenuFactory .getTestMenuItems()) { if (mcount > 0) { if (mcount % 2 == 0) popup.addSeparator(); else popup.add(new JSeparator()); } for (JMenuItem menuItem : miList) { popup.add(menuItem); } mcount++; } popup.addPopupMenuListener(new PopupPrintListener()); popup.show(this.owner, e.getX(), e.getY()); } } /** * Custom popup listener. * * @author Kirill Grouchnikov */ protected static class PopupPrintListener implements PopupMenuListener { /* * (non-Javadoc) * * @see javax.swing.event.PopupMenuListener#popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent) */ public void popupMenuWillBecomeVisible(PopupMenuEvent e) { Check.out("Popup menu will be visible!"); } /* * (non-Javadoc) * * @see javax.swing.event.PopupMenuListener#popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent) */ public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { Check.out("Popup menu will be invisible!"); } /* * (non-Javadoc) * * @see javax.swing.event.PopupMenuListener#popupMenuCanceled(javax.swing.event.PopupMenuEvent) */ public void popupMenuCanceled(PopupMenuEvent e) { Check.out("Popup menu is hidden!"); } } }substance-5.3.orig/src/test/check/ScrollPanel.java0000644000175000017500000001515011001361470022102 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import javax.swing.border.LineBorder; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.preview.DefaultPreviewPainter; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.ScrollPaneButtonPolicyKind; import test.Check; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; /** * Test application panel for testing {@link JScrollPane} component. * * @author Kirill Grouchnikov */ public class ScrollPanel extends ControllablePanel { /** * Scroll panel. */ private JScrollPane sp; /** * The inner panel. */ private JPanel panel; /** * Creates the scroll panel for the test application. */ public ScrollPanel() { this.panel = new CheckeredPanel(); this.sp = new JScrollPane(this.panel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); this.setLayout(new BorderLayout()); this.add(this.sp, BorderLayout.CENTER); FormLayout lm = new FormLayout("right:pref, 4dlu, fill:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); builder.appendSeparator("General settings"); final JCheckBox isEnabled = new JCheckBox("is enabled"); isEnabled.setSelected(true); isEnabled.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean toEnable = isEnabled.isSelected(); sp.setEnabled(toEnable); updateEnabledState(sp, toEnable); Check.out("Scroll pane is " + toEnable); } }); builder.append("Enabled", isEnabled); final JCheckBox hasNullBorder = new JCheckBox("Has null border"); hasNullBorder.setSelected(false); hasNullBorder.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (hasNullBorder.isSelected()) sp.setBorder(null); else sp.setBorder(new LineBorder(Color.red)); sp.repaint(); } }); builder.append("Border", hasNullBorder); final JCheckBox hasPreview = new JCheckBox("Has preview"); hasPreview.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { sp.putClientProperty(LafWidget.COMPONENT_PREVIEW_PAINTER, hasPreview.isSelected() ? new DefaultPreviewPainter() : null); } }); builder.append("Preview", hasPreview); final JCheckBox hasAutoScroll = new JCheckBox("Has auto scroll"); hasAutoScroll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { sp.putClientProperty(LafWidget.AUTO_SCROLL, hasAutoScroll .isSelected() ? Boolean.TRUE : null); } }); builder.append("Auto scroll", hasAutoScroll); builder.appendSeparator("Scroll buttons settings"); final JComboBox buttonPolicyCombo = new JComboBox(new Object[] { ScrollPaneButtonPolicyKind.NONE, ScrollPaneButtonPolicyKind.OPPOSITE, ScrollPaneButtonPolicyKind.ADJACENT, ScrollPaneButtonPolicyKind.MULTIPLE, ScrollPaneButtonPolicyKind.MULTIPLE_BOTH }); buttonPolicyCombo.setSelectedItem(ScrollPaneButtonPolicyKind.OPPOSITE); buttonPolicyCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ScrollPaneButtonPolicyKind buttonPolicy = (ScrollPaneButtonPolicyKind) buttonPolicyCombo .getSelectedItem(); sp.putClientProperty( SubstanceLookAndFeel.SCROLL_PANE_BUTTONS_POLICY, buttonPolicy); sp.repaint(); } }); builder.append("Button policy", buttonPolicyCombo); final JCheckBox isFlat = new JCheckBox("Is flat"); isFlat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { sp.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, isFlat .isSelected() ? Boolean.TRUE : null); sp.repaint(); } }); builder.append("Flat", isFlat); final JCheckBox isNever = new JCheckBox("Is never painted"); isNever.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { sp.putClientProperty( SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY, isNever.isSelected() ? Boolean.TRUE : null); sp.repaint(); } }); builder.append("Never", isNever); this.controlPanel = builder.getPanel(); } /** * Recursively updates the enabled state of the specified container and its * children. * * @param c * Container. * @param enabled * New value for the enabled status. */ void updateEnabledState(Container c, boolean enabled) { for (int counter = c.getComponentCount() - 1; counter >= 0; counter--) { Component child = c.getComponent(counter); child.setEnabled(enabled); if (child instanceof Container) { updateEnabledState((Container) child, enabled); } } } }substance-5.3.orig/src/test/check/SubstanceSkinComboSelector.java0000644000175000017500000000346211171323576025141 0ustar drazzibdrazzibpackage test.check; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.api.renderers.SubstanceDefaultComboBoxRenderer; import org.jvnet.substance.skin.SkinInfo; public class SubstanceSkinComboSelector extends JComboBox { public SubstanceSkinComboSelector() { // populate the combobox super(new ArrayList(SubstanceLookAndFeel.getAllSkins() .values()).toArray()); // set the current skin as the selected item SubstanceSkin currentSkin = SubstanceLookAndFeel.getCurrentSkin(); for (SkinInfo skinInfo : SubstanceLookAndFeel.getAllSkins().values()) { if (skinInfo.getDisplayName().compareTo( currentSkin.getDisplayName()) == 0) { this.setSelectedItem(skinInfo); break; } } // set custom renderer to show the skin display name this.setRenderer(new SubstanceDefaultComboBoxRenderer(this) { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return super.getListCellRendererComponent(list, ((SkinInfo) value).getDisplayName(), index, isSelected, cellHasFocus); } }); // add an action listener to change skin based on user selection this.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { SubstanceLookAndFeel .setSkin(((SkinInfo) SubstanceSkinComboSelector.this .getSelectedItem()).getClassName()); } }); } }); } } substance-5.3.orig/src/test/check/SubstanceDiagonalGradientWatermark.java0000644000175000017500000001027411022223776026621 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; import org.jvnet.substance.watermark.SubstanceWatermark; /** * Implementation of {@link org.jvnet.substance.watermark.SubstanceWatermark}, * drawing diagonal gradient. * * @author Kirill Grouchnikov */ public class SubstanceDiagonalGradientWatermark implements SubstanceWatermark { /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#drawWatermarkImage(java.awt.Graphics, * int, int, int, int) */ public void drawWatermarkImage(Graphics g, Component c, int x, int y, int width, int height) { if (c != null) if (!c.isDisplayable() || !c.isShowing()) return; Component parent = c; if (parent != null) { while (parent.getParent() != null) parent = parent.getParent(); } if (!parent.isShowing()) return; int dx = (parent != null) ? c.getLocationOnScreen().x - parent.getLocationOnScreen().x : 0; int dy = (parent != null) ? c.getLocationOnScreen().y - parent.getLocationOnScreen().y : 0; int dw = (parent != null) ? parent.getWidth() : width; int dh = (parent != null) ? parent.getHeight() : height; Graphics2D graphics = (Graphics2D) g.create(); graphics.setPaint(new GradientPaint(x - dx, y - dy, Color.gray, x - dx + dw, y - dy + dh, SubstanceColorSchemeUtilities.getColorScheme(c, ComponentState.DEFAULT).getMidColor())); graphics.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.8f)); graphics.fillRect(x, y, width, height); graphics.dispose(); } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#updateWatermarkImage(org.jvnet.substance.skin.SubstanceSkin) */ public boolean updateWatermarkImage(SubstanceSkin skin) { return true; } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#previewWatermark(java.awt.Graphics, * int, int, int, int) */ public void previewWatermark(Graphics g, int x, int y, int width, int height) { this.drawWatermarkImage(g, null, x, y, width, height); } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#getDisplayName() */ public String getDisplayName() { return "Diagonal Gradient"; } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#dispose() */ public void dispose() { } } substance-5.3.orig/src/test/check/ScrollablePanel.java0000644000175000017500000000452410756612500022742 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.Dimension; import java.awt.Rectangle; import javax.swing.JPanel; import javax.swing.Scrollable; public class ScrollablePanel extends JPanel implements Scrollable { public Dimension getPreferredScrollableViewportSize() { return this.getPreferredSize(); } public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { return 30; } public boolean getScrollableTracksViewportHeight() { return false; } public boolean getScrollableTracksViewportWidth() { return false; } public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { return 10; } } substance-5.3.orig/src/test/check/ProgressBarPanel.java0000644000175000017500000002407611015715250023110 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.lafwidget.LafWidgetUtilities; import org.jvnet.lafwidget.animation.*; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; /** * Test application panel for testing {@link JProgressBar} component. * * @author Kirill Grouchnikov */ public class ProgressBarPanel extends JPanel { @RunOnUIThread private final class ProgressBarFadeTrackerAdapter extends FadeTrackerAdapter { @Override public void fadePerformed(FadeKind fadeKind, float fadeCycle10) { delta(ProgressBarPanel.this, 1); } } /** * ID of the looping task that updates the progress bars. */ private long progressFadeId; /** * Custom fade kind for updating the progress bars. */ private static final FadeKind PROGRESS_FADE = new FadeKind( "substancelaf.testApp.progress", true); /** * Button that starts the update of progress bars. */ private JButton startButton; /** * Button that stops the update of progress bars. */ private JButton stopButton; /** * Creates a new panel with progress bars. */ public ProgressBarPanel() { this.setLayout(new BorderLayout()); JPanel bars = new ScrollablePanel(); GridLayout gLayout = new GridLayout(1, 2); bars.setLayout(gLayout); FormLayout horizontalLm = new FormLayout("left:pref:grow", ""); DefaultFormBuilder horizontalBuilder = new DefaultFormBuilder( horizontalLm); horizontalBuilder.setDefaultDialogBorder(); JProgressBar determinateEnHor = new JProgressBar( JProgressBar.HORIZONTAL, 0, 100); determinateEnHor.setIndeterminate(false); horizontalBuilder.appendSeparator("Determinate enabled"); horizontalBuilder.append(determinateEnHor); JProgressBar determinateEnHorStr = new JProgressBar( JProgressBar.HORIZONTAL, 0, 100); determinateEnHorStr.setIndeterminate(false); determinateEnHorStr.setStringPainted(true); horizontalBuilder.appendSeparator("Determinate enabled + string"); horizontalBuilder.append(determinateEnHorStr); JProgressBar indeterminateEnHor = new JProgressBar( JProgressBar.HORIZONTAL, 0, 100); indeterminateEnHor.setIndeterminate(true); indeterminateEnHor.setStringPainted(true); indeterminateEnHor.setString("In progress"); horizontalBuilder.appendSeparator("Indeterminate enabled + string"); horizontalBuilder.append(indeterminateEnHor); JProgressBar determinateDisHor = new JProgressBar( JProgressBar.HORIZONTAL, 0, 100); determinateDisHor.setIndeterminate(false); determinateDisHor.setEnabled(false); horizontalBuilder.appendSeparator("Determinate disabled"); horizontalBuilder.append(determinateDisHor); JProgressBar determinateDisHorStr = new JProgressBar( JProgressBar.HORIZONTAL, 0, 100); determinateDisHorStr.setIndeterminate(false); determinateDisHorStr.setEnabled(false); determinateDisHorStr.setStringPainted(true); horizontalBuilder.appendSeparator("Determinate disabled + string"); horizontalBuilder.append(determinateDisHorStr); JProgressBar indeterminateDisHor = new JProgressBar( JProgressBar.HORIZONTAL, 0, 100); indeterminateDisHor.setIndeterminate(true); indeterminateDisHor.setEnabled(false); horizontalBuilder.appendSeparator("Indeterminate disabled"); horizontalBuilder.append(indeterminateDisHor); bars.add(horizontalBuilder.getPanel()); FormLayout verticalLm = new FormLayout( "center:pref:grow, 4dlu, center:pref:grow, 4dlu, " + "center:pref:grow, 4dlu, center:pref:grow, 4dlu, center:pref:grow", ""); DefaultFormBuilder verticalBuilder = new DefaultFormBuilder(verticalLm); verticalBuilder.setDefaultDialogBorder(); verticalBuilder.append("Enabled"); verticalBuilder.append("RTL"); verticalBuilder.append("Indeterm"); verticalBuilder.append("Disabled"); verticalBuilder.append("Dis indet"); JProgressBar determinateEnVer = new JProgressBar(JProgressBar.VERTICAL, 0, 100); determinateEnVer.setIndeterminate(false); determinateEnVer.setStringPainted(true); verticalBuilder.append(determinateEnVer); JProgressBar determinateEnVerRTL = new JProgressBar( JProgressBar.VERTICAL, 0, 100); determinateEnVerRTL.setIndeterminate(false); determinateEnVerRTL.setStringPainted(true); determinateEnVerRTL .setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); verticalBuilder.append(determinateEnVerRTL); JProgressBar indeterminateEnVer = new JProgressBar( JProgressBar.VERTICAL, 0, 100); indeterminateEnVer.setIndeterminate(true); indeterminateEnVer.setStringPainted(true); indeterminateEnVer.setString("In progress"); verticalBuilder.append(indeterminateEnVer); JProgressBar determinateDisVer = new JProgressBar( JProgressBar.VERTICAL, 0, 100); determinateDisVer.setIndeterminate(false); determinateDisVer.setEnabled(false); verticalBuilder.append(determinateDisVer); JProgressBar indeterminateDisVer = new JProgressBar( JProgressBar.VERTICAL, 0, 100); indeterminateDisVer.setIndeterminate(true); indeterminateDisVer.setEnabled(false); verticalBuilder.append(indeterminateDisVer); bars.add(verticalBuilder.getPanel()); this.add(new JScrollPane(bars), BorderLayout.CENTER); JPanel buttons = new JPanel(); buttons.setLayout(new FlowLayout(FlowLayout.CENTER)); this.startButton = new JButton("start"); this.startButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { progressFadeId = FadeTracker.getInstance().trackFadeLooping( PROGRESS_FADE, LafWidgetUtilities.getAnimationKind( ProgressBarPanel.this).derive(0.2f), ProgressBarPanel.this, null, false, new ProgressBarFadeTrackerAdapter(), -1, false); startButton.setEnabled(false); stopButton.setEnabled(true); } }); this.stopButton = new JButton("stop"); this.stopButton.setEnabled(false); this.stopButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FadeTracker.getInstance().cancelFadeInstance(progressFadeId); stopButton.setEnabled(false); startButton.setEnabled(true); } }); JButton plus10Button = new JButton("plus 10"); plus10Button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { delta(ProgressBarPanel.this, 10); } }); buttons.add(plus10Button); JButton minus10Button = new JButton("minus 10"); minus10Button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { delta(ProgressBarPanel.this, -10); } }); buttons.add(minus10Button); JButton plus1Button = new JButton("plus 1"); plus1Button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { delta(ProgressBarPanel.this, 1); } }); buttons.add(plus1Button); JButton minus1Button = new JButton("minus 1"); minus1Button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { delta(ProgressBarPanel.this, -1); } }); buttons.add(minus1Button); JButton resetButton = new JButton("reset"); resetButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { reset(ProgressBarPanel.this); } }); buttons.add(this.startButton); buttons.add(this.stopButton); buttons.add(resetButton); this.add(buttons, BorderLayout.SOUTH); } protected static void delta(Component c, int delta) { if (c instanceof JProgressBar) { JProgressBar pb = (JProgressBar) c; if (!pb.isIndeterminate()) { int newValue = pb.getValue() + delta; if (newValue < pb.getMinimum()) newValue = pb.getMinimum(); if (newValue > pb.getMaximum()) newValue = pb.getMaximum(); pb.setValue(newValue); } } if (c instanceof Container) { Container cont = (Container) c; for (int i = 0; i < cont.getComponentCount(); i++) { delta(cont.getComponent(i), delta); } } } protected static void reset(Component c) { if (c instanceof JProgressBar) { JProgressBar pb = (JProgressBar) c; if (!pb.isIndeterminate()) { pb.setValue(pb.getMinimum()); } } if (c instanceof Container) { Container cont = (Container) c; for (int i = 0; i < cont.getComponentCount(); i++) { reset(cont.getComponent(i)); } } } }substance-5.3.orig/src/test/check/FileTreePanel.java0000644000175000017500000003101511212462664022354 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.util.*; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.filechooser.FileSystemView; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.TreeNode; import org.jvnet.lafwidget.animation.FadeConfigurationManager; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.renderers.SubstanceDefaultTreeCellRenderer; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; /** * Test application panel for testing {@link JTree} component and * {@link SubstanceLookAndFeel#TREE_SMART_SCROLL_ANIMATION_KIND}. * * @author Kirill Grouchnikov */ public class FileTreePanel extends ControllablePanel implements Deferrable { private boolean isInitialized; @Override public boolean isInitialized() { return this.isInitialized; } /** * File system view. */ protected static FileSystemView fsv = FileSystemView.getFileSystemView(); /** * Renderer for the file tree. * * @author Kirill Grouchnikov */ private static class SubstanceFileTreeCellRenderer extends SubstanceDefaultTreeCellRenderer { /** * Icon cache to speed the rendering. */ private Map iconCache = new HashMap(); /** * Root name cache to speed the rendering. */ private Map rootNameCache = new HashMap(); /* * (non-Javadoc) * * @seeorg.jvnet.substance.SubstanceDefaultTreeCellRenderer# * getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, * boolean, boolean, boolean, int, boolean) */ @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { FileTreeNode ftn = (FileTreeNode) value; File file = ftn.file; String filename = ""; if (file != null) { if (ftn.isFileSystemRoot) { // long start = System.currentTimeMillis(); filename = rootNameCache.get(file); if (filename == null) { filename = fsv.getSystemDisplayName(file); rootNameCache.put(file, filename); } // long end = System.currentTimeMillis(); // System.out.println(filename + ":" + (end - start)); } else { filename = file.getName(); } } JLabel result = (JLabel) super.getTreeCellRendererComponent(tree, filename, sel, expanded, leaf, row, hasFocus); if (file != null) { Icon icon = iconCache.get(filename); if (icon == null) { // System.out.println("Getting icon of " + filename); icon = fsv.getSystemIcon(file); iconCache.put(filename, icon); } result.setIcon(icon); } return result; } } /** * Renderer for the file tree. * * @author Kirill Grouchnikov */ private static class FileTreeCellRenderer extends DefaultTreeCellRenderer { /** * Icon cache to speed the rendering. */ private Map iconCache = new HashMap(); /** * Root name cache to speed the rendering. */ private Map rootNameCache = new HashMap(); /* * (non-Javadoc) * * @seeorg.jvnet.substance.SubstanceDefaultTreeCellRenderer# * getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, * boolean, boolean, boolean, int, boolean) */ @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { FileTreeNode ftn = (FileTreeNode) value; File file = ftn.file; String filename = ""; if (file != null) { if (ftn.isFileSystemRoot) { // long start = System.currentTimeMillis(); filename = rootNameCache.get(file); if (filename == null) { filename = fsv.getSystemDisplayName(file); rootNameCache.put(file, filename); } // long end = System.currentTimeMillis(); // System.out.println(filename + ":" + (end - start)); } else { filename = file.getName(); } } JLabel result = (JLabel) super.getTreeCellRendererComponent(tree, filename, sel, expanded, leaf, row, hasFocus); if (file != null) { Icon icon = iconCache.get(filename); if (icon == null) { // System.out.println("Getting icon of " + filename); icon = fsv.getSystemIcon(file); iconCache.put(filename, icon); } result.setIcon(icon); } return result; } } /** * A node in the file tree. * * @author Kirill Grouchnikov */ private static class FileTreeNode implements TreeNode { /** * Node file. */ private File file; /** * Children of the node file. */ private List children; /** * Parent node. */ private TreeNode parent; /** * Indication whether this node corresponds to a file system root. */ private boolean isFileSystemRoot; /** * Creates a new file tree node. * * @param file * Node file * @param isFileSystemRoot * Indicates whether the file is a file system root. * @param parent * Parent node. */ public FileTreeNode(File file, boolean isFileSystemRoot, TreeNode parent) { this.file = file; this.isFileSystemRoot = isFileSystemRoot; this.parent = parent; this.children = new ArrayList(); File[] children = file.listFiles(); if (children != null) { for (File child : file.listFiles()) { if (fsv.isHiddenFile(child)) continue; this.children.add(child); } Collections.sort(this.children, new Comparator() { @Override public int compare(File o1, File o2) { if (o1.equals(o2)) return 0; if (o1.isDirectory() && o2.isFile()) return -1; if (o1.isFile() && o2.isDirectory()) return 1; int result = fsv.getSystemDisplayName(o1).toLowerCase() .compareTo( fsv.getSystemDisplayName(o2) .toLowerCase()); if (result != 0) return result; return o1.compareTo(o2); } }); } } /** * Creates a new file tree node. * * @param children * Children files. */ public FileTreeNode(List children) { this.file = null; this.parent = null; this.children = children; } /* * (non-Javadoc) * * @see javax.swing.tree.TreeNode#children() */ public Enumeration children() { final int elementCount = this.children.size(); return new Enumeration() { int count = 0; /* * (non-Javadoc) * * @see java.util.Enumeration#hasMoreElements() */ public boolean hasMoreElements() { return count < elementCount; } /* * (non-Javadoc) * * @see java.util.Enumeration#nextElement() */ public File nextElement() { if (count < elementCount) { return children.get(count++); } throw new NoSuchElementException("Vector Enumeration"); } }; } /* * (non-Javadoc) * * @see javax.swing.tree.TreeNode#getAllowsChildren() */ public boolean getAllowsChildren() { return true; } /* * (non-Javadoc) * * @see javax.swing.tree.TreeNode#getChildAt(int) */ public TreeNode getChildAt(int childIndex) { return new FileTreeNode(this.children.get(childIndex), this.parent == null, this); } /* * (non-Javadoc) * * @see javax.swing.tree.TreeNode#getChildCount() */ public int getChildCount() { return this.children.size(); } /* * (non-Javadoc) * * @see javax.swing.tree.TreeNode#getIndex(javax.swing.tree.TreeNode) */ public int getIndex(TreeNode node) { FileTreeNode ftn = (FileTreeNode) node; for (int i = 0; i < this.children.size(); i++) { if (ftn.file.equals(this.children.get(i))) return i; } return -1; } /* * (non-Javadoc) * * @see javax.swing.tree.TreeNode#getParent() */ public TreeNode getParent() { return this.parent; } /* * (non-Javadoc) * * @see javax.swing.tree.TreeNode#isLeaf() */ public boolean isLeaf() { return (this.getChildCount() == 0); } } /** * The file tree. */ private JTree tree; /** * Creates the file tree panel. */ public FileTreePanel() { this.setLayout(new BorderLayout()); } public synchronized void initialize() { List rootsList = new ArrayList(); for (File child : File.listRoots()) { rootsList.add(child); } FileTreeNode rootTreeNode = new FileTreeNode(rootsList); this.tree = new JTree(rootTreeNode); this.tree .setCellRenderer((UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) ? new SubstanceFileTreeCellRenderer() : new FileTreeCellRenderer()); this.tree.setRootVisible(false); final JScrollPane jsp = new JScrollPane(this.tree); jsp.setBorder(new EmptyBorder(0, 0, 0, 0)); this.add(jsp, BorderLayout.CENTER); FormLayout lm = new FormLayout("right:pref, 4dlu, fill:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); builder.appendSeparator("General"); final JCheckBox isEnabled = new JCheckBox("is enabled"); isEnabled.setSelected(tree.isEnabled()); isEnabled.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tree.setEnabled(isEnabled.isSelected()); } }); builder.append("Enabled", isEnabled); final JCheckBox watermarkBleed = new JCheckBox("is bleeding"); watermarkBleed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tree.putClientProperty(SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.valueOf(watermarkBleed.isSelected())); jsp.putClientProperty(SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.valueOf(watermarkBleed.isSelected())); tree.repaint(); } }); builder.append("Watermark", watermarkBleed); final JCheckBox cbTreeSmartScroll = new JCheckBox("smart tree scroll"); cbTreeSmartScroll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (cbTreeSmartScroll.isSelected()) { FadeConfigurationManager .getInstance() .allowFades( SubstanceLookAndFeel.TREE_SMART_SCROLL_ANIMATION_KIND, tree); } else { FadeConfigurationManager .getInstance() .disallowFades( SubstanceLookAndFeel.TREE_SMART_SCROLL_ANIMATION_KIND, tree); } tree.repaint(); } }); builder.append("Decorations", cbTreeSmartScroll); this.controlPanel = builder.getPanel(); this.isInitialized = true; } }substance-5.3.orig/src/test/check/MyListCellRenderer.java0000644000175000017500000000511711007400610023372 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.Color; import java.awt.Component; import javax.swing.*; /** * Cell renderer for the test application list. * * @author Kirill Grouchnikov */ public class MyListCellRenderer extends JLabel implements ListCellRenderer { /** * Creates the cell renderer. */ public MyListCellRenderer() { super(); setOpaque(true); } /* * (non-Javadoc) * * @see javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing.JList, * java.lang.Object, int, boolean, boolean) */ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { this.setText((String) value); this.setForeground(list.getForeground()); int comp = 156 + 10 * (index % 9); this.setBackground(new Color(comp, comp, comp)); if (isSelected) this.setBackground(list.getSelectionBackground()); return this; } }substance-5.3.orig/src/test/check/command/0000755000175000017500000000000011256731152020447 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/check/command/ForegroundColorCommand.java0000644000175000017500000000137010726625142025725 0ustar drazzibdrazzibpackage test.check.command; import java.awt.Color; import java.awt.Component; /** * A configure command that sets the specified foreground color on the * specified component. * * @author Kirill Grouchnikov */ public class ForegroundColorCommand implements ConfigurationCommand { /** * Color to set. */ private Color color; /** * Creates a foreground color configuration command. * * @param color * Foreground color to set. */ public ForegroundColorCommand(Color color) { this.color = color; } /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(Component ab) { ab.setForeground(this.color); } }substance-5.3.orig/src/test/check/command/EnableCommand.java0000644000175000017500000000064210730024232023767 0ustar drazzibdrazzibpackage test.check.command; import java.awt.Component; /** * A configure command that enables the specified component. * * @author Kirill Grouchnikov */ public class EnableCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(Component comp) { comp.setEnabled(true); } }substance-5.3.orig/src/test/check/command/SetBoundsCommand.java0000644000175000017500000000133410730024202024503 0ustar drazzibdrazzibpackage test.check.command; import java.awt.Component; import java.awt.Rectangle; /** * A configure command that sets bounds for the specified component. * * @author Kirill Grouchnikov */ public class SetBoundsCommand implements ConfigurationCommand { /** * Component bounds to set. */ private Rectangle bounds; /** * Creates a new configuration command. * * @param bounds * Component bounds to set. */ public SetBoundsCommand(Rectangle bounds) { this.bounds = bounds; } /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(Component comp) { comp.setBounds(this.bounds); } }substance-5.3.orig/src/test/check/command/ConfigurationCommand.java0000644000175000017500000000401510734705422025421 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check.command; /** * Base interface for configuring a single control. * * @author Kirill Grouchnikov * @param * Specifies the control class. */ public interface ConfigurationCommand { /** * Configures the specified control. * * @param control * Control to configure. */ public void configure(T control); } substance-5.3.orig/src/test/check/command/MinimizeInternalFrameCommand.java0000644000175000017500000000121610730024474027040 0ustar drazzibdrazzibpackage test.check.command; import java.awt.Component; import java.beans.PropertyVetoException; import javax.swing.JInternalFrame; /** * A configure command that minimizes internal frames. * * @author Kirill Grouchnikov */ public class MinimizeInternalFrameCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(Component ab) { if (ab instanceof JInternalFrame) { JInternalFrame jif = (JInternalFrame) ab; try { jif.setIcon(true); } catch (PropertyVetoException pve) { } } } }substance-5.3.orig/src/test/check/command/SelectCommand.java0000644000175000017500000000110710726625142024031 0ustar drazzibdrazzibpackage test.check.command; import java.awt.Component; import javax.swing.AbstractButton; import javax.swing.JButton; /** * A configure command that selects the specified component. * * @author Kirill Grouchnikov */ public class SelectCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(Component ab) { if (ab instanceof JButton) return; if (ab instanceof AbstractButton) ((AbstractButton) ab).setSelected(true); } }substance-5.3.orig/src/test/check/command/DisableViewportCommand.java0000644000175000017500000000111210727620376025716 0ustar drazzibdrazzibpackage test.check.command; import java.awt.Component; import javax.swing.JScrollPane; /** * A configure command that disables the viewport component specified component. * * @author Kirill Grouchnikov */ public class DisableViewportCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(Component ab) { if (ab instanceof JScrollPane) { JScrollPane jsp = (JScrollPane) ab; jsp.getViewport().getView().setEnabled(false); } } }substance-5.3.orig/src/test/check/command/ChainCommand.java0000644000175000017500000000142310726624774023647 0ustar drazzibdrazzibpackage test.check.command; /** * Chain command - applies a chain of configure commands on a component. * * @author Kirill Grouchnikov * @param * Component class. */ public class ChainCommand implements ConfigurationCommand { /** * Command chain. */ private ConfigurationCommand[] commands; /** * Creates the chain command. * * @param commands * Command chain. */ public ChainCommand(ConfigurationCommand... commands) { super(); this.commands = commands; } /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(T component) { for (ConfigurationCommand cmd : this.commands) cmd.configure(component); } } substance-5.3.orig/src/test/check/command/ClientPropertyCommand.java0000644000175000017500000000202310726627542025601 0ustar drazzibdrazzibpackage test.check.command; import java.awt.Component; import javax.swing.JComponent; /** * A configure command that sets the specified client property to the * specified value. * * @author Kirill Grouchnikov */ public class ClientPropertyCommand implements ConfigurationCommand { /** * Client property name. */ private String propName; /** * Client property value. */ private Object propValue; /** * Creates an client property configuration command. * * @param propName * Client property name. * @param propValue * Client property value. */ public ClientPropertyCommand(String propName, Object propValue) { this.propName = propName; this.propValue = propValue; } /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(Component ab) { if (ab instanceof JComponent) ((JComponent) ab).putClientProperty(this.propName, this.propValue); } }substance-5.3.orig/src/test/check/command/CreationCommand.java0000644000175000017500000000370210734705422024360 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check.command; /** * Base interface for creating a single slider. * * @author Kirill Grouchnikov * @param * Specifies the control class. */ public interface CreationCommand { /** * Creates a control. * * @return Control. */ public T create(); } substance-5.3.orig/src/test/check/command/BackgroundColorCommand.java0000644000175000017500000000137010726625142025672 0ustar drazzibdrazzibpackage test.check.command; import java.awt.Color; import java.awt.Component; /** * A configure command that sets the specified background color on the * specified component. * * @author Kirill Grouchnikov */ public class BackgroundColorCommand implements ConfigurationCommand { /** * Color to set. */ private Color color; /** * Creates a background color configuration command. * * @param color * Background color to set. */ public BackgroundColorCommand(Color color) { this.color = color; } /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(Component ab) { ab.setBackground(this.color); } }substance-5.3.orig/src/test/check/command/DisableCommand.java0000644000175000017500000000064310726625142024161 0ustar drazzibdrazzibpackage test.check.command; import java.awt.Component; /** * A configure command that disables the specified component. * * @author Kirill Grouchnikov */ public class DisableCommand implements ConfigurationCommand { /* * (non-Javadoc) * * @see test.check.ConfigurationCommand#invoke(java.lang.Object) */ public void configure(Component ab) { ab.setEnabled(false); } }substance-5.3.orig/src/test/check/CaribbeanBlueColorScheme.java0000644000175000017500000001016410776636010024503 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.Color; import org.jvnet.substance.colorscheme.BaseLightColorScheme; /** * Caribbean blue color scheme - for close buttons. * * @author Kirill Grouchnikov */ public class CaribbeanBlueColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(131, 166, 202); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(114, 155, 198); /** * The main light color. */ private static final Color mainLightColor = new Color(94, 150, 195); /** * The main medium color. */ private static final Color mainMidColor = new Color(53, 121, 176); /** * The main dark color. */ private static final Color mainDarkColor = new Color(61, 112, 161); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(30, 75, 101); /** * The foreground color. */ private static final Color foregroundColor = Color.black; public CaribbeanBlueColorScheme() { super("Caribbean Blue"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return CaribbeanBlueColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return CaribbeanBlueColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return CaribbeanBlueColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return CaribbeanBlueColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return CaribbeanBlueColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return CaribbeanBlueColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return CaribbeanBlueColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/test/check/SubstanceCoffeeBeansWatermark.java0000644000175000017500000001454611022223760025564 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.awt.geom.AffineTransform; import java.awt.geom.GeneralPath; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.utils.SubstanceCoreUtilities; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; import org.jvnet.substance.watermark.SubstanceWatermark; /** * Implementation of {@link org.jvnet.substance.watermark.SubstanceWatermark}, * drawing random coffee beans as watermark. * * @author Kirill Grouchnikov */ public class SubstanceCoffeeBeansWatermark implements SubstanceWatermark { /** * Watermark image (screen-sized). */ private static Image watermarkImage = null; /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#drawWatermarkImage(java.awt.Graphics, * int, int, int, int) */ public void drawWatermarkImage(Graphics graphics, Component c, int x, int y, int width, int height) { int dx = c.getLocationOnScreen().x; int dy = c.getLocationOnScreen().y; graphics.drawImage(SubstanceCoffeeBeansWatermark.watermarkImage, x, y, x + width, y + height, x + dx, y + dy, x + dx + width, y + dy + height, null); } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#updateWatermarkImage(org.jvnet.substance.skin.SubstanceSkin) */ public boolean updateWatermarkImage(SubstanceSkin skin) { Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize(); int screenWidth = screenDim.width; int screenHeight = screenDim.height; SubstanceCoffeeBeansWatermark.watermarkImage = SubstanceCoreUtilities .getBlankImage(screenWidth, screenHeight); Graphics2D graphics = (Graphics2D) SubstanceCoffeeBeansWatermark.watermarkImage .getGraphics().create(); boolean status = this.drawWatermarkImage(skin, graphics, 0, 0, screenWidth, screenHeight); graphics.dispose(); return status; } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#previewWatermark(java.awt.Graphics, * int, int, int, int) */ public void previewWatermark(Graphics g, int x, int y, int width, int height) { this.drawWatermarkImage(SubstanceColorSchemeUtilities.METALLIC_SKIN, (Graphics2D) g, x, y, width, height); } /** * Draws the watermark image. * * @param graphics * Graphics context. * @param x * Starting X position. * @param y * Starting Y position. * @param width * Width. * @param height * Height. * @return true if the drawing succeeded, false * otherwise. */ private boolean drawWatermarkImage(SubstanceSkin skin, Graphics2D graphics, int x, int y, int width, int height) { Color stampColor = skin.getWatermarkColorScheme().isDark() ? new Color(255, 255, 255, 25) : new Color(0, 0, 0, 15); int minBubbleRadius = 10; int maxBubbleRadius = 20; int cellSize = (minBubbleRadius + maxBubbleRadius); int rowCount = height / cellSize; int columnCount = width / cellSize; graphics.setColor(stampColor); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); for (int col = 0; col <= columnCount; col++) { for (int row = 0; row <= rowCount; row++) { // location int xc = x + (int) (col * cellSize + cellSize * Math.random()); int yc = y + (int) (row * cellSize + cellSize * Math.random()); int r = minBubbleRadius + (int) (Math.random() * (maxBubbleRadius - minBubbleRadius)); AffineTransform oldTransform = graphics.getTransform(); graphics.setTransform(AffineTransform.getRotateInstance(2.0 * Math.PI * Math.random(), xc, yc)); GeneralPath bean = new GeneralPath(); bean.moveTo(xc - r, yc - 0.1f * r); bean.quadTo(xc - r, yc - 0.6f * r, xc, yc - 0.6f * r); bean.quadTo(xc + r, yc - 0.6f * r, xc + r, yc - 0.1f * r); bean.lineTo(xc + r, yc + 0.1f * r); bean.quadTo(xc + r, yc + 0.6f * r, xc, yc + 0.6f * r); bean.quadTo(xc - r, yc + 0.6f * r, xc - r, yc + 0.1f * r); bean.lineTo(xc - r, yc - 0.1f * r); bean.lineTo(xc + r, yc - 0.1f * r); bean.lineTo(xc + r, yc + 0.1f * r); bean.lineTo(xc - r, yc + 0.1f * r); graphics.draw(bean); graphics.setTransform(oldTransform); } } graphics.dispose(); return true; } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#getDisplayName() */ public String getDisplayName() { return "Coffee Beans"; } /* * (non-Javadoc) * * @see org.jvnet.substance.watermark.SubstanceWatermark#dispose() */ public void dispose() { watermarkImage = null; } } substance-5.3.orig/src/test/check/ColoredControlsPanel.java0000644000175000017500000001176110756612730024001 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.BorderLayout; import java.awt.Color; import javax.swing.*; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; /** * Test application panel for testing components with custom background. * * @author Kirill Grouchnikov */ public class ColoredControlsPanel extends JPanel { public ColoredControlsPanel() { this.setLayout(new BorderLayout()); FormLayout lm = new FormLayout("right:pref, 4dlu, left:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); builder.setDefaultDialogBorder(); JLabel labelOpaque = new JLabel("Sample label"); labelOpaque.setOpaque(true); labelOpaque.setForeground(Color.green); labelOpaque.setBackground(Color.red); builder.append("Opaque label", labelOpaque); JLabel labelNonOpaque = new JLabel("Sample label"); labelNonOpaque.setOpaque(false); labelNonOpaque.setForeground(Color.green); labelNonOpaque.setBackground(Color.red); builder.append("Non-opaque label", labelNonOpaque); JLabel labelDefault = new JLabel("Sample label"); labelDefault.setOpaque(true); labelDefault.setForeground(Color.green); labelDefault.setBackground(Color.red); builder.append("Default label", labelDefault); JCheckBox checkboxOpaque = new JCheckBox("Sample checkbox"); checkboxOpaque.setOpaque(true); checkboxOpaque.setForeground(Color.blue); checkboxOpaque.setBackground(Color.yellow); builder.append("Opaque checkbox", checkboxOpaque); JCheckBox checkboxNonOpaque = new JCheckBox("Sample checkbox"); checkboxNonOpaque.setOpaque(false); checkboxNonOpaque.setForeground(Color.blue); checkboxNonOpaque.setBackground(Color.yellow); builder.append("Non-opaque checkbox", checkboxNonOpaque); JCheckBox checkboxDefault = new JCheckBox("Sample checkbox"); checkboxDefault.setForeground(Color.blue); checkboxDefault.setBackground(Color.yellow); builder.append("Default checkbox", checkboxDefault); JRadioButton radioOpaque = new JRadioButton("Sample radiobutton"); radioOpaque.setOpaque(true); radioOpaque.setForeground(new Color(0, 128, 0)); radioOpaque.setBackground(new Color(255, 180, 180)); builder.append("Opaque radio", radioOpaque); JRadioButton radioNonOpaque = new JRadioButton("Sample radiobutton"); radioNonOpaque.setOpaque(false); radioNonOpaque.setForeground(new Color(0, 128, 0)); radioNonOpaque.setBackground(new Color(255, 180, 180)); builder.append("Non-opaque radio", radioNonOpaque); JRadioButton radioDefault = new JRadioButton("Sample radiobutton"); radioDefault.setForeground(new Color(0, 128, 0)); radioDefault.setBackground(new Color(255, 180, 180)); builder.append("Default radio", radioDefault); JSlider colored3 = new JSlider(100, 1000, 400); colored3.setPaintTicks(true); colored3.setMajorTickSpacing(100); colored3.setForeground(new Color(128, 0, 0)); colored3.setBackground(new Color(180, 255, 180)); builder.append("Slider", colored3); JPanel colored4 = new JPanel(); colored4.setSize(100, 100); colored4.setPreferredSize(colored4.getSize()); colored4.setBackground(Color.cyan); builder.append("panel", colored4); JPanel resultPanel = builder.getPanel(); resultPanel.setBackground(new Color(200, 200, 255)); this.add(new JScrollPane(resultPanel), BorderLayout.CENTER); } } substance-5.3.orig/src/test/check/TreePanel.java0000644000175000017500000002132311015213562021545 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.tree.DefaultMutableTreeNode; import org.jvnet.lafwidget.LafWidget; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.renderers.SubstanceDefaultTreeCellRenderer; import test.Check; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; /** * Test application panel for testing {@link JTree} component. * * @author Kirill Grouchnikov */ public class TreePanel extends ControllablePanel { /** * The cell renderer for the tree. Uses HTML for bold text on selected row * and custom icon on selected row. * * @author Kirill Grouchnikov */ private static class TestTreeCellRenderer extends SubstanceDefaultTreeCellRenderer { @Override public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { JLabel result = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); if (sel) { result.setText("" + getText() + ""); result.setIcon(Check.getIcon("flag_sweden")); } return result; } } /** * The tree component. */ private JTree tree; /** * The scroll pane that contains the tree. */ private JScrollPane jsp; /** * Creates the tree panel. */ public TreePanel() { this.setLayout(new BorderLayout()); DefaultMutableTreeNode root = new DefaultMutableTreeNode("root"); DefaultMutableTreeNode son1 = new DefaultMutableTreeNode("son1"); DefaultMutableTreeNode son2 = new DefaultMutableTreeNode("son2"); DefaultMutableTreeNode son3 = new DefaultMutableTreeNode("son3"); DefaultMutableTreeNode gson11 = new DefaultMutableTreeNode("gson11"); DefaultMutableTreeNode gson12 = new DefaultMutableTreeNode("gson12"); DefaultMutableTreeNode gson21 = new DefaultMutableTreeNode("gson21"); DefaultMutableTreeNode gson22 = new DefaultMutableTreeNode("gson22"); DefaultMutableTreeNode gson31 = new DefaultMutableTreeNode("gson31"); DefaultMutableTreeNode gson32 = new DefaultMutableTreeNode("gson32"); DefaultMutableTreeNode ggson111 = new DefaultMutableTreeNode("ggson111"); DefaultMutableTreeNode ggson112 = new DefaultMutableTreeNode("ggson112"); DefaultMutableTreeNode ggson113 = new DefaultMutableTreeNode("ggson113"); gson11.add(ggson111); gson11.add(ggson112); gson11.add(ggson113); son1.add(gson11); son1.add(gson12); son2.add(gson21); son2.add(gson22); son3.add(gson31); son3.add(gson32); root.add(son1); root.add(son2); root.add(son3); this.tree = new JTree(root); // { // public Insets getInsets() { // return new Insets(5, 5, 5, 5); // } // }; // this.tree.setCellRenderer(new TestTreeCellRenderer()); this.tree.putClientProperty(LafWidget.TREE_AUTO_DND_SUPPORT, Boolean.TRUE); this.jsp = new JScrollPane(this.tree); this.jsp.setBorder(new EmptyBorder(0, 0, 0, 0)); this.add(this.jsp, BorderLayout.CENTER); FormLayout lm = new FormLayout("right:pref, 4dlu, fill:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); builder.appendSeparator("General"); final JCheckBox isEnabled = new JCheckBox("is enabled"); isEnabled.setSelected(tree.isEnabled()); isEnabled.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tree.setEnabled(isEnabled.isSelected()); } }); builder.append("Enabled", isEnabled); final JCheckBox isOpaque = new JCheckBox("is opaque"); isOpaque.setSelected(tree.isOpaque()); isOpaque.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tree.setOpaque(isOpaque.isSelected()); tree.repaint(); } }); builder.append("Opacity", isOpaque); final JCheckBox isEditable = new JCheckBox("is editable"); isEditable.setSelected(tree.isEditable()); isEditable.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tree.setEditable(isEditable.isSelected()); } }); builder.append("Editable", isEditable); final JCheckBox watermarkBleed = new JCheckBox("is visible"); watermarkBleed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tree.putClientProperty(SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.valueOf(watermarkBleed.isSelected())); jsp.putClientProperty(SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.valueOf(watermarkBleed.isSelected())); tree.repaint(); } }); builder.append("Watermark", watermarkBleed); final JCheckBox isWrappedInScrollPane = new JCheckBox( "is in scroll pane"); isWrappedInScrollPane.setSelected(true); isWrappedInScrollPane.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (isWrappedInScrollPane.isSelected()) { remove(tree); jsp.setViewportView(tree); add(jsp, BorderLayout.CENTER); } else { remove(jsp); add(tree, BorderLayout.CENTER); } revalidate(); repaint(); } }); builder.append("Container", isWrappedInScrollPane); final JCheckBox rendererCB = new JCheckBox("has custom renderer"); rendererCB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (rendererCB.isSelected()) { tree.setCellRenderer(new TestTreeCellRenderer()); } else { tree .setCellRenderer(new SubstanceDefaultTreeCellRenderer()); } } }); } }); builder.append("Renderer", rendererCB); builder.appendSeparator("Insets"); Insets ins = tree.getInsets(); final JSpinner topInsets = new JSpinner(new SpinnerNumberModel(ins.top, 0, 10, 1)); final JSpinner leftInsets = new JSpinner(new SpinnerNumberModel( ins.left, 0, 10, 1)); final JSpinner bottomInsets = new JSpinner(new SpinnerNumberModel( ins.bottom, 0, 10, 1)); final JSpinner rightInsets = new JSpinner(new SpinnerNumberModel( ins.right, 0, 10, 1)); builder.append("Top", topInsets); builder.append("Left", leftInsets); builder.append("Bottom", bottomInsets); builder.append("Right", rightInsets); ChangeListener cl = new ChangeListener() { public void stateChanged(ChangeEvent e) { tree.setBorder(new EmptyBorder((Integer) topInsets.getValue(), (Integer) leftInsets.getValue(), (Integer) bottomInsets .getValue(), (Integer) rightInsets.getValue())); } }; topInsets.addChangeListener(cl); leftInsets.addChangeListener(cl); bottomInsets.addChangeListener(cl); rightInsets.addChangeListener(cl); this.controlPanel = builder.getPanel(); // this.tree.setEditable(true); } }substance-5.3.orig/src/test/check/MySubstanceListCellRenderer.java0000644000175000017500000000661111035574364025265 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.Color; import java.awt.Component; import javax.swing.JLabel; import javax.swing.JList; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.api.renderers.SubstanceDefaultListCellRenderer; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; /** * Cell renderer for the test application list. * * @author Kirill Grouchnikov */ public class MySubstanceListCellRenderer extends SubstanceDefaultListCellRenderer { /** * Creates the cell renderer. */ public MySubstanceListCellRenderer() { super(); setOpaque(true); } /* * (non-Javadoc) * * @see * javax.swing.ListCellRenderer#getListCellRendererComponent(javax.swing * .JList, java.lang.Object, int, boolean, boolean) */ @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component result = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); result.setForeground(list.getForeground()); int comp = 156 + 10 * (index % 9); int blue = 255 - (255 - comp) / 2; result.setBackground(new Color(comp, comp, blue)); if (isSelected) result.setBackground(list.getSelectionBackground()); // mark every fifth row as disabled if ((index % 5) == 0) { result.setEnabled(false); ComponentState state = isSelected ? ComponentState.DISABLED_SELECTED : ComponentState.DISABLED_UNSELECTED; result.setForeground(SubstanceColorSchemeUtilities.getColorScheme( list, state).getForegroundColor()); result.setBackground(new Color(255, 196, 196)); ((JLabel) result).setText(value + " [disabled by renderer]"); } return this; } }substance-5.3.orig/src/test/check/CrimsonColorScheme.java0000644000175000017500000001005610776636010023437 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.Color; import org.jvnet.substance.colorscheme.BaseLightColorScheme; /** * Crimson color scheme - for close buttons. * * @author Kirill Grouchnikov */ public class CrimsonColorScheme extends BaseLightColorScheme { /** * The main ultra-light color. */ private static final Color mainUltraLightColor = new Color(175, 135, 153); /** * The main extra-light color. */ private static final Color mainExtraLightColor = new Color(183, 126, 140); /** * The main light color. */ private static final Color mainLightColor = new Color(194, 98, 101); /** * The main medium color. */ private static final Color mainMidColor = new Color(175, 41, 27); /** * The main dark color. */ private static final Color mainDarkColor = new Color(141, 24, 18); /** * The main ultra-dark color. */ private static final Color mainUltraDarkColor = new Color(116, 40, 31); /** * The foreground color. */ private static final Color foregroundColor = Color.black; public CrimsonColorScheme() { super("Crimson"); } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getForegroundColor() */ public Color getForegroundColor() { return CrimsonColorScheme.foregroundColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor() */ public Color getUltraLightColor() { return CrimsonColorScheme.mainUltraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor() */ public Color getExtraLightColor() { return CrimsonColorScheme.mainExtraLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getLightColor() */ public Color getLightColor() { return CrimsonColorScheme.mainLightColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getMidColor() */ public Color getMidColor() { return CrimsonColorScheme.mainMidColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getDarkColor() */ public Color getDarkColor() { return CrimsonColorScheme.mainDarkColor; } /* * (non-Javadoc) * * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor() */ public Color getUltraDarkColor() { return CrimsonColorScheme.mainUltraDarkColor; } } substance-5.3.orig/src/test/check/SampleInternalFrame.java0000644000175000017500000001436011177774120023575 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.util.LinkedList; import javax.swing.*; import javax.swing.border.EmptyBorder; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.skin.SkinChangeListener; import org.jvnet.substance.utils.SubstanceImageCreator; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; import com.jgoodies.forms.layout.Sizes; /** * Internal frame for the test application. * * @author Kirill Grouchnikov */ public class SampleInternalFrame extends JInternalFrame { /** * Creates the test internal frame. */ public SampleInternalFrame() { this.setLayout(new BorderLayout()); JTabbedPane tabbed = new JTabbedPane(); this.add(tabbed, BorderLayout.CENTER); tabbed.addTab("Regular", new JPanel()); JPanel samplePanel = new JPanel(new BorderLayout()); FormLayout lm = new FormLayout("fill:default:grow(1), 4dlu," + "fill:default:grow(1)", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); builder.setLineGapSize(Sizes.pixel(1)); builder.setBorder(new EmptyBorder(2, 2, 2, 2)); // lm.setColumnGroups(new int[][] { { 3, 5, 7 } }); // TwoColumnPanel stuff = new TwoColumnPanel(); // stuff.setVerticalSpacing(4); // stuff.setHorizontalSpacing(0); JCheckBox cb1 = new JCheckBox("Enabled selected"); cb1.setSelected(true); JCheckBox cb2 = new JCheckBox("Disabled selected"); cb2.setSelected(true); cb2.setEnabled(false); JCheckBox cb3 = new JCheckBox("Enabled unselected"); // cb3.setEnabled(false); JRadioButton rb1 = new JRadioButton("Enabled selected"); rb1.setSelected(true); JRadioButton rb2 = new JRadioButton("Disabled selected"); rb2.setSelected(true); rb2.setEnabled(false); JRadioButton rb3 = new JRadioButton("Enabled unselected"); // rb3.setEnabled(false); builder.append(cb1, rb1); builder.append(cb2, rb2); builder.append(cb3, rb3); JComboBox combo = new JComboBox(new Object[] { "item1", "item2", "item3", "item4" }); combo.setSelectedIndex(0); combo.setEditable(true); JTextField text = new JTextField("Text field"); text.setEditable(false); builder.append(combo, text); JPanel contentPanel = builder.getPanel(); contentPanel.setPreferredSize(new Dimension(contentPanel .getPreferredSize().width, contentPanel.getPreferredSize().height + 100)); // contentPanel.setOpaque(false); contentPanel.setBorder(null); // stuff.setBorder(null); JScrollPane scroll = new JScrollPane(contentPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scroll.setBorder(new EmptyBorder(0, 0, 0, 0)); samplePanel.add(scroll, BorderLayout.CENTER); JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton prev = new JButton("prev"); JButton cancel = new JButton("cancel"); cancel.setEnabled(false); JButton ok = new JButton("OK"); buttons.add(prev); buttons.add(cancel); buttons.add(ok); samplePanel.add(buttons, BorderLayout.SOUTH); tabbed.addTab("Sample", samplePanel); tabbed.setSelectedComponent(samplePanel); tabbed.setOpaque(false); JMenuBar jmb = new JMenuBar(); jmb.add(SampleMenuFactory.getSkinMenu()); JMenu jm1 = new JMenu("Menu1"); jm1.setMnemonic('1'); int mcount = 0; for (LinkedList miList : SampleMenuFactory .getTestMenuItems()) { if (mcount > 0) { if (mcount % 2 == 0) jm1.addSeparator(); else jm1.add(new JSeparator()); } for (JMenuItem menuItem : miList) { jm1.add(menuItem); } mcount++; } jmb.add(jm1); this.setJMenuBar(jmb); this.setClosable(true); this.setMaximizable(true); this.setIconifiable(true); this.setResizable(true); synchronize(); SubstanceLookAndFeel .registerSkinChangeListener(new SkinChangeListener() { @Override public void skinChanged() { synchronize(); } }); ok.requestFocusInWindow(); } /** * Synchronizes the frame icon with the current theme. */ protected void synchronize() { SwingUtilities.invokeLater(new Runnable() { public void run() { if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) { SubstanceSkin currentSkin = SubstanceLookAndFeel .getCurrentSkin(getRootPane()); setFrameIcon(new ImageIcon(SubstanceImageCreator .getBigHexaMarker(6, currentSkin .getMainActiveColorScheme()))); setTitle(currentSkin.getDisplayName()); } } }); } } substance-5.3.orig/src/test/check/DesktopPanel.java0000644000175000017500000002656411021243016022265 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyVetoException; import java.util.*; import javax.swing.*; import javax.swing.JInternalFrame.JDesktopIcon; import javax.swing.plaf.basic.BasicInternalFrameUI; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.SkinChangeListener; import org.jvnet.substance.utils.SubstanceImageCreator; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; /** * Test application panel for testing {@link JDesktopPane}, {@link * JInternalFrame} and {@link JDesktopIcon} components. * * @author Kirill Grouchnikov */ public class DesktopPanel extends ControllablePanel { /** * The desktop pane. */ private JDesktopPane jdp; /** * Counter for creating the internal frames. */ private int count = 0; /** * A set of disposed internal frames. */ private Set disposed = new HashSet(); /** * Creates the desktop panel. */ public DesktopPanel() { this.setLayout(new BorderLayout()); jdp = new JDesktopPane(); this.add(jdp, BorderLayout.CENTER); FormLayout lm = new FormLayout("right:pref, 4dlu, fill:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); builder.appendSeparator("New sample frame"); JButton sample = new JButton("Add"); sample.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { JInternalFrame jif = new SampleInternalFrame() { // @Override // public void paint(Graphics g) { // long start = System.nanoTime(); // super.paint(g); // long end = System.nanoTime(); // System.err.println("paint done in " + (end - // start)); // } }; jif.setBounds(0, 0, 300, 200); jdp.add(jif); jif.setVisible(true); jif.setComponentOrientation(jdp .getComponentOrientation()); } }); } }); builder.append("Add sample", sample); builder.appendSeparator("New custom frame"); final JCheckBox makeZero = new JCheckBox("Has zero bounds"); builder.append("Custom settings", makeZero); final JCheckBox isClosable = new JCheckBox("Is closable"); isClosable.setSelected(true); builder.append("", isClosable); final JCheckBox isMaximizable = new JCheckBox("Is maximizable"); isMaximizable.setSelected(true); builder.append("", isMaximizable); final JCheckBox isIconifiable = new JCheckBox("Is iconifiable"); isIconifiable.setSelected(true); builder.append("", isIconifiable); final JCheckBox isResizable = new JCheckBox("Is resizable"); isResizable.setSelected(true); builder.append("", isResizable); JButton bt = new JButton("Add"); bt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String title = "[" + count + "]Internal title "; int c = (int) (20 * Math.random()); for (int i = 0; i < c; i++) { title += "0"; } final JInternalFrame jif = new JInternalFrame(title); jif.setFrameIcon(new ImageIcon(SubstanceImageCreator .getBigHexaMarker(count, SubstanceLookAndFeel .getCurrentSkin(jif.getRootPane()) .getMainActiveColorScheme()))); SubstanceLookAndFeel .registerSkinChangeListener(new SkinChangeListener() { public void skinChanged() { jif .setFrameIcon(new ImageIcon( SubstanceImageCreator .getBigHexaMarker( count, SubstanceLookAndFeel .getCurrentSkin( jif .getRootPane()) .getMainActiveColorScheme()))); } }); jif.setLayout(new BorderLayout()); JPanel controls = new JPanel(new FlowLayout()); int comps = 5 + (int) (10 * Math.random()); for (int i = 0; i < comps; i++) { double r = Math.random(); if (r < 0.1) { controls.add(new JButton("button" + i)); } else { if (r < 0.2) { controls.add(new JLabel("label" + i)); } else { if (r < 0.3) { controls.add(new JRadioButton("radio" + i)); } else { if (r < 0.4) { controls.add(new JCheckBox("check" + i)); } else { if (r < 0.5) { controls.add(new JToggleButton("toggle" + i)); } else { if (r < 0.6) { controls .add(new JComboBox( new Object[] { "combo" + i })); } else { if (r < 0.7) { controls.add(new JTextField( "text field" + i)); } else { if (r < 0.8) { controls .add(new JPasswordField( "password" + i)); } else { if (r < 0.9) { controls .add(new JSpinner()); } else { controls .add(new JList( new Object[] { "list" + i })); } } } } } } } } } } jif.add(controls, BorderLayout.CENTER); jif.setClosable(isClosable.isSelected()); jif.setMaximizable(isMaximizable.isSelected()); jif.setIconifiable(isIconifiable.isSelected()); jif.setResizable(isResizable.isSelected()); JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox isModified = new JCheckBox("modified"); isModified.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jif.putClientProperty( SubstanceLookAndFeel.WINDOW_MODIFIED, Boolean .valueOf(isModified.isSelected())); } }); buttons.add(isModified); JButton changeTitleButton = new JButton("Change title"); changeTitleButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String random = "abcdefghijklmnopqrstuvwxyz "; int length = (int) (50 * Math.random()); String title = ""; while (length > 0) { title += random .charAt((int) (random.length() * Math .random())); length--; } jif.setTitle(title); } }); buttons.add(changeTitleButton); JButton setNullTitlePane = new JButton("Remove title pane"); setNullTitlePane.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { ((BasicInternalFrameUI) jif.getUI()) .setNorthPane(null); jif.revalidate(); } }); } }); buttons.add(setNullTitlePane); jif.add(buttons, BorderLayout.SOUTH); count++; int width = 50 + (int) (400 * Math.random()); int height = 50 + (int) (200 * Math.random()); jif.setBounds(20 * (count % 10), 20 * (count % 10), width, height); if (makeZero.isSelected()) jif.setBounds(0, 0, 0, 0); jif.setBackground(new Color(128 + (int) (128 * Math.random()), 128 + (int) (128 * Math.random()), 128 + (int) (128 * Math.random()))); // jif.setClosable(true); // jif.setMaximizable(true); // jif.setResizable(true); // jif.setIconifiable(true); jif.setComponentOrientation(jdp.getComponentOrientation()); jdp.add(jif, 1); JMenuBar jmb = new JMenuBar(); jmb.add(SampleMenuFactory.getSkinMenu()); JMenu jm1 = new JMenu("Menu1"); jm1.setMnemonic('1'); int mcount = 0; for (LinkedList miList : SampleMenuFactory .getTestMenuItems()) { if (mcount > 0) { if (mcount % 2 == 0) jm1.addSeparator(); else jm1.add(new JSeparator()); } for (JMenuItem menuItem : miList) { jm1.add(menuItem); } mcount++; } jmb.add(jm1); jif.setJMenuBar(jmb); jif.show(); } }); builder.append("Add custom", bt); builder.appendSeparator("Operations"); JButton minAll = new JButton("Execute"); minAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { for (JInternalFrame jif : jdp.getAllFrames()) { try { jif.setIcon(true); } catch (PropertyVetoException pve) { } } } }); builder.append("Minimize all", minAll); JButton closeAll = new JButton("Execute"); closeAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { for (JInternalFrame jif : jdp.getAllFrames()) { try { jif.setClosed(true); } catch (PropertyVetoException pve) { } } } }); builder.append("Close all", closeAll); JButton disposeAll = new JButton("Execute"); disposeAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { for (JInternalFrame jif : jdp.getAllFrames()) { disposed.add(jif); jif.dispose(); } } }); builder.append("Dispose all", disposeAll); JButton reshowAll = new JButton("Execute"); reshowAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { for (JInternalFrame jif : disposed) { jif.setVisible(true); } } }); builder.append("Reshow all", reshowAll); this.controlPanel = builder.getPanel(); this.setPreferredSize(new Dimension(400, 400)); this.setSize(this.getPreferredSize()); this.setMinimumSize(this.getPreferredSize()); } }substance-5.3.orig/src/test/check/AlignmentPanel.java0000644000175000017500000000475211212462640022575 0ustar drazzibdrazzibpackage test.check; import java.awt.*; import javax.swing.*; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; public class AlignmentPanel extends JPanel implements Deferrable { private boolean isInitialized; @Override public boolean isInitialized() { return this.isInitialized; } public AlignmentPanel() { this.setLayout(new BorderLayout()); } @Override public synchronized void initialize() { FormLayout lm = new FormLayout("left:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); builder.setDefaultDialogBorder(); for (int fontSize = 11; fontSize < 25; fontSize++) { builder.append(getSubPanel(fontSize)); } this.add(new JScrollPane(builder.getPanel())); this.isInitialized = true; } private static JPanel getSubPanel(int size) { JPanel result = new JPanel(new FlowLayout(FlowLayout.LEFT)); Font font = new Font("Tahoma", Font.PLAIN, size); JLabel label = new JLabel("Tahoma " + size); label.setFont(font); result.add(label); JTextField tf = new JTextField("sample"); tf.setFont(font); result.add(tf); // JFormattedTextField ftf = new JFormattedTextField("sample"); // ftf.setFont(font); // result.add(ftf); JPasswordField pf = new JPasswordField("sample"); pf.setFont(font); result.add(pf); JComboBox cb = new JComboBox(new Object[] { "sample" }); cb.setFont(font); result.add(cb); JComboBox ecb = new JComboBox(new Object[] { "sample" }); ecb.setFont(font); ecb.setEditable(true); result.add(ecb); JSpinner s = new JSpinner(new SpinnerListModel(new Object[] { "sample0", "sample", "sample2" })); s.getModel().setValue("sample"); s.setFont(font); result.add(s); return result; } public static void main(String[] args) throws Exception { JFrame.setDefaultLookAndFeelDecorated(true); UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame("Alignment"); frame.setSize(600, 400); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); AlignmentPanel panel = new AlignmentPanel(); panel.initialize(); frame.add(panel, BorderLayout.CENTER); frame.setVisible(true); } }); } } substance-5.3.orig/src/test/check/SpinnerPanel.java0000644000175000017500000001213511006401572022265 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.BorderLayout; import java.awt.Component; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.substance.SubstanceLookAndFeel; import test.check.command.*; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; /** * Test application panel for testing {@link JSpinner} component. * * @author Kirill Grouchnikov */ public class SpinnerPanel extends JPanel { /** * Creates a test panel with spinners. */ public SpinnerPanel() { this.setLayout(new BorderLayout()); FormLayout lm = new FormLayout("right:pref, 4dlu, left:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); builder.setDefaultDialogBorder(); CreationCommand basicCr = new CreationCommand() { public Component create() { JSpinner basicSpinner = new JSpinner(new SpinnerNumberModel()); return basicSpinner; } }; CreationCommand dateCr = new CreationCommand() { public Component create() { JSpinner dateEnSpinner = new JSpinner(new SpinnerDateModel()); return dateEnSpinner; } }; CreationCommand weekdaysCr = new CreationCommand() { public Component create() { String weekdaysEn[] = new String[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; JSpinner listEnSpinner = new JSpinner(new SpinnerListModel( weekdaysEn)); return listEnSpinner; } }; CreationCommand numberCr = new CreationCommand() { public Component create() { JSpinner numberEnSpinner = new JSpinner(new SpinnerNumberModel( 0, 0, 100, 5)); return numberEnSpinner; } }; builder.appendSeparator("Enabled"); addSpinner(builder, "Basic", basicCr, null); addSpinner(builder, "Date", dateCr, null); addSpinner(builder, "Weekdays", weekdaysCr, null); addSpinner(builder, "Weekdays select on focus", weekdaysCr, new ClientPropertyCommand(LafWidget.TEXT_SELECT_ON_FOCUS, Boolean.TRUE)); addSpinner(builder, "Number", numberCr, null); addSpinner(builder, "Number flat", numberCr, new ClientPropertyCommand( SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE)); builder.appendSeparator("Disabled"); addSpinner(builder, "Basic", basicCr, new DisableCommand()); addSpinner(builder, "Date", dateCr, new DisableCommand()); addSpinner(builder, "Weekdays", weekdaysCr, new DisableCommand()); addSpinner(builder, "Weekdays select on focus", weekdaysCr, new ChainCommand(new ClientPropertyCommand( LafWidget.TEXT_SELECT_ON_FOCUS, Boolean.TRUE), new DisableCommand())); addSpinner(builder, "Number", numberCr, new DisableCommand()); addSpinner(builder, "Number flat", numberCr, new ChainCommand(new ClientPropertyCommand( SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE), new DisableCommand())); this.add(new JScrollPane(builder.getPanel()), BorderLayout.CENTER); } private void addSpinner(DefaultFormBuilder builder, String label, CreationCommand creationCmd, ConfigurationCommand configurationCmd) { Component comp = creationCmd.create(); if (configurationCmd != null) { configurationCmd.configure(comp); } JLabel jl = new JLabel(label); builder.append(jl); builder.append(comp); } }substance-5.3.orig/src/test/check/SplitPanel.java0000644000175000017500000001045111015455466021754 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JCheckBox; import javax.swing.JSplitPane; import org.jvnet.substance.SubstanceLookAndFeel; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; /** * Test application panel for testing {@link JSplitPane} component. * * @author Kirill Grouchnikov */ public class SplitPanel extends ControllablePanel { /** * Split pane. */ private JSplitPane splitPane; /** * Creates a test panel with split pane. */ public SplitPanel() { this.setLayout(new BorderLayout()); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new NumberedPanel(1), new NumberedPanel(2)); splitPane.setDividerLocation(100); this.add(splitPane, BorderLayout.CENTER); FormLayout lm = new FormLayout("fill:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm, new ScrollablePanel()); final JCheckBox isOneTouch = new JCheckBox("is one-touch"); isOneTouch.setSelected(true); splitPane.setOneTouchExpandable(true); isOneTouch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { splitPane.setOneTouchExpandable(isOneTouch.isSelected()); } }); final JCheckBox isFlat = new JCheckBox("is flat"); isFlat.setSelected(true); isFlat.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { splitPane.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, (isFlat.isSelected() ? Boolean.TRUE : Boolean.FALSE)); splitPane.repaint(); } }); final JCheckBox isVertical = new JCheckBox("is vertical"); splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); isVertical.setSelected(true); isVertical.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { splitPane .setOrientation(isVertical.isSelected() ? JSplitPane.VERTICAL_SPLIT : JSplitPane.HORIZONTAL_SPLIT); } }); final JCheckBox isEnabled = new JCheckBox("is enabled"); isEnabled.setSelected(true); isEnabled.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { splitPane.setEnabled(isEnabled.isSelected()); } }); builder.append(isEnabled); builder.append(isOneTouch); builder.append(isFlat); builder.append(isVertical); this.controlPanel = builder.getPanel(); this.setPreferredSize(new Dimension(400, 400)); this.setSize(this.getPreferredSize()); this.setMinimumSize(this.getPreferredSize()); } }substance-5.3.orig/src/test/check/SampleMenuFactory.java0000644000175000017500000010767011246416640023306 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.Event; import java.awt.event.*; import java.util.LinkedList; import java.util.Map; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.painter.border.ClassicBorderPainter; import org.jvnet.substance.painter.decoration.ArcDecorationPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.gradient.GlassGradientPainter; import org.jvnet.substance.painter.highlight.GlassHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; import org.jvnet.substance.skin.SkinChangeListener; import org.jvnet.substance.skin.SkinInfo; import org.jvnet.substance.utils.SubstanceImageCreator; import test.Check; /** * Factory that creates menus for the test applications. * * @author Kirill Grouchnikov */ public class SampleMenuFactory { /** * Returns a sample test menu. * * @return Sample test menu. */ public static JMenu getTestMenu() { JMenu testMenu = new JMenu("Test"); testMenu.setMnemonic('1'); int mcount = 0; for (LinkedList miList : getTestMenuItems()) { if (mcount > 0) { if (mcount % 2 == 0) testMenu.addSeparator(); else testMenu.add(new JSeparator()); } for (JMenuItem menuItem : miList) { testMenu.add(menuItem); } mcount++; } return testMenu; } /** * Returns menu items for a sample test menu. * * @return Menu items for a sample test menu. */ public static LinkedList> getTestMenuItems() { LinkedList> result = new LinkedList>(); LinkedList list1 = new LinkedList(); final JMenuItem jmi1 = new JMenuItem("Menu item enabled", Check .getIcon("flag_sweden")); jmi1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)); JMenuItem jmi2 = new JMenuItem("Menu item disabled"); jmi2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, Event.CTRL_MASK | Event.ALT_MASK)); jmi2.setEnabled(false); list1.add(jmi1); list1.add(jmi2); result.add(list1); LinkedList list2 = new LinkedList(); boolean isSubstance = (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel); SubstanceSkin currentSkin = SubstanceLookAndFeel.getCurrentSkin(null); final JCheckBoxMenuItem jcbmi1 = new JCheckBoxMenuItem( "Check enabled selected", isSubstance ? SubstanceImageCreator .getHexaMarker(2, currentSkin .getMainActiveColorScheme()) : null); jcbmi1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK)); jcbmi1.setSelected(true); JCheckBoxMenuItem jcbmi2 = new JCheckBoxMenuItem( "Check enabled unselected"); jcbmi2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, Event.CTRL_MASK)); jcbmi2.setSelected(false); JCheckBoxMenuItem jcbmi3 = new JCheckBoxMenuItem( "Check disabled selected"); jcbmi3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, Event.CTRL_MASK)); jcbmi3.setSelected(true); jcbmi3.setEnabled(false); final JCheckBoxMenuItem jcbmi4 = new JCheckBoxMenuItem( "Check disabled unselected", isSubstance ? SubstanceImageCreator.getHexaMarker(3, currentSkin.getMainActiveColorScheme()) : null); jcbmi4.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK)); jcbmi4.setSelected(false); jcbmi4.setEnabled(false); list2.add(jcbmi1); list2.add(jcbmi2); list2.add(jcbmi3); list2.add(jcbmi4); result.add(list2); LinkedList list3 = new LinkedList(); final JRadioButtonMenuItem jrbmi1 = new JRadioButtonMenuItem( "Radio enabled selected", isSubstance ? SubstanceImageCreator .getHexaMarker(4, currentSkin .getMainActiveColorScheme()) : null); jrbmi1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, Event.CTRL_MASK)); jrbmi1.setSelected(true); JRadioButtonMenuItem jrbmi2 = new JRadioButtonMenuItem( "Radio enabled unselected"); jrbmi2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, Event.CTRL_MASK)); jrbmi2.setSelected(false); ButtonGroup bgRadioMenu1 = new ButtonGroup(); bgRadioMenu1.add(jrbmi1); bgRadioMenu1.add(jrbmi2); JRadioButtonMenuItem jrbmi3 = new JRadioButtonMenuItem( "Radio disabled selected"); jrbmi3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.CTRL_MASK)); jrbmi3.setSelected(true); jrbmi3.setEnabled(false); JRadioButtonMenuItem jrbmi4 = new JRadioButtonMenuItem( "Radio disabled unselected"); jrbmi4.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, Event.CTRL_MASK)); jrbmi4.setSelected(false); jrbmi4.setEnabled(false); ButtonGroup bgRadioMenu2 = new ButtonGroup(); bgRadioMenu2.add(jrbmi3); bgRadioMenu2.add(jrbmi4); list3.add(jrbmi1); list3.add(jrbmi2); list3.add(jrbmi3); list3.add(jrbmi4); result.add(list3); LinkedList list4 = new LinkedList(); JMenu submenu1 = new JMenu("submenu1"); submenu1.add(new JMenuItem("submenu item1")); submenu1.add(new JMenuItem("submenu item2")); submenu1.add(new JMenuItem("submenu item3")); final JMenu submenu11 = new JMenu("submenu1-1"); if (isSubstance) submenu11.setIcon(SubstanceImageCreator.getHexaMarker(5, currentSkin.getMainActiveColorScheme())); submenu11.add(new JMenuItem("submenu item111")); submenu11.add(new JMenuItem("submenu item112")); submenu11.add(new JMenuItem("submenu item113")); submenu11.add(new JMenuItem("submenu item114")); submenu1.add(submenu11); final JMenu submenu12 = new JMenu("submenu1-2"); if (isSubstance) submenu12.setIcon(SubstanceImageCreator.getHexaMarker(5, currentSkin.getMainActiveColorScheme())); submenu12.add(new JMenuItem("submenu item121")); submenu12.add(new JMenuItem("submenu item122")); submenu12.add(new JMenuItem("submenu item123")); submenu12.add(new JMenuItem("submenu item124")); submenu1.add(submenu12); final JMenu submenu13 = new JMenu("submenu1-3"); if (isSubstance) submenu13.setIcon(SubstanceImageCreator.getHexaMarker(5, currentSkin.getMainActiveColorScheme())); submenu13.add(new JMenuItem("submenu item131")); submenu13.add(new JMenuItem("submenu item132")); submenu13.add(new JMenuItem("submenu item133")); submenu13.add(new JMenuItem("submenu item134")); submenu13.add(new JMenuItem("submenu item135")); submenu1.add(submenu13); list4.add(submenu1); JMenu submenu2 = new JMenu("submenu2"); submenu2.add(new JMenuItem("submenu item1")); submenu2.add(new JMenuItem("submenu item2")); submenu2.add(new JMenuItem("submenu item3")); final JMenu submenu21 = new JMenu("submenu2-1"); if (isSubstance) submenu21.setIcon(SubstanceImageCreator.getHexaMarker(5, currentSkin.getMainActiveColorScheme())); submenu21.add(new JMenuItem("submenu item211")); submenu21.add(new JMenuItem("submenu item212")); submenu21.add(new JMenuItem("submenu item213")); submenu21.add(new JMenuItem("submenu item214")); submenu2.add(submenu21); final JMenu submenu22 = new JMenu("submenu2-2"); if (isSubstance) submenu22.setIcon(SubstanceImageCreator.getHexaMarker(5, currentSkin.getMainActiveColorScheme())); submenu22.add(new JMenuItem("submenu item221")); submenu22.add(new JMenuItem("submenu item222")); submenu22.add(new JMenuItem("submenu item223")); submenu22.add(new JMenuItem("submenu item224")); submenu2.add(submenu22); final JMenu submenu23 = new JMenu("submenu2-3"); if (isSubstance) submenu23.setIcon(SubstanceImageCreator.getHexaMarker(5, currentSkin.getMainActiveColorScheme())); submenu23.add(new JMenuItem("submenu item231")); submenu23.add(new JMenuItem("submenu item232")); submenu23.add(new JMenuItem("submenu item233")); submenu23.add(new JMenuItem("submenu item234")); submenu2.add(submenu23); list4.add(submenu2); JMenu submenu3 = new JMenu("submenu3 (disabled)"); submenu3.setEnabled(false); list4.add(submenu3); result.add(list4); SubstanceLookAndFeel .registerSkinChangeListener(new SkinChangeListener() { public void skinChanged() { SubstanceSkin currentSkin = SubstanceLookAndFeel .getCurrentSkin(null); jcbmi1.setIcon(SubstanceImageCreator.getHexaMarker(2, currentSkin.getMainActiveColorScheme())); jcbmi4.setIcon(SubstanceImageCreator.getHexaMarker(3, currentSkin.getMainActiveColorScheme())); jrbmi1.setIcon(SubstanceImageCreator.getHexaMarker(4, currentSkin.getMainActiveColorScheme())); submenu11.setIcon(SubstanceImageCreator.getHexaMarker( 5, currentSkin.getMainActiveColorScheme())); submenu12.setIcon(SubstanceImageCreator.getHexaMarker( 5, currentSkin.getMainActiveColorScheme())); submenu13.setIcon(SubstanceImageCreator.getHexaMarker( 5, currentSkin.getMainActiveColorScheme())); submenu21.setIcon(SubstanceImageCreator.getHexaMarker( 5, currentSkin.getMainActiveColorScheme())); submenu22.setIcon(SubstanceImageCreator.getHexaMarker( 5, currentSkin.getMainActiveColorScheme())); submenu23.setIcon(SubstanceImageCreator.getHexaMarker( 5, currentSkin.getMainActiveColorScheme())); } }); return result; } /** * Returns menu for setting skins. * * @return Menu for setting skins. */ public static JMenu getSkinMenu() { JMenu jmSkin = new JMenu("Skins"); Map skinMap = SubstanceLookAndFeel.getAllSkins(); for (final Map.Entry entry : skinMap.entrySet()) { JMenuItem jmiSkin = new JMenuItem(entry.getValue().getDisplayName()); jmiSkin.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SubstanceLookAndFeel.setSkin(entry.getValue() .getClassName()); } }); jmSkin.add(jmiSkin); } jmSkin.addSeparator(); final CustomSkin customSkin = new CustomSkin(); JMenuItem jmiSkin = new JMenuItem(customSkin.getDisplayName()); jmiSkin.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SubstanceLookAndFeel.setSkin(customSkin); } }); jmSkin.add(jmiSkin); return jmSkin; } protected static class CustomSkin extends SubstanceSkin { @Override public String getDisplayName() { return "Custom"; } public CustomSkin() { SubstanceColorScheme activeScheme = new OrangeColorScheme().shade( 0.2).invert(); SubstanceColorScheme defaultScheme = new MetallicColorScheme(); SubstanceColorScheme disabledScheme = new LightGrayColorScheme(); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); defaultSchemeBundle.registerHighlightColorScheme(activeScheme, 0.6f, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerHighlightColorScheme(activeScheme, 0.8f, ComponentState.SELECTED); defaultSchemeBundle.registerHighlightColorScheme(activeScheme, 0.95f, ComponentState.ROLLOVER_SELECTED); defaultSchemeBundle.registerHighlightColorScheme(activeScheme, 0.8f, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); SubstanceColorSchemeBundle headerSchemeBundle = new SubstanceColorSchemeBundle( activeScheme.saturate(0.3), activeScheme, disabledScheme); this.registerDecorationAreaSchemeBundle(headerSchemeBundle, headerSchemeBundle.getActiveColorScheme(), DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER); this.borderPainter = new ClassicBorderPainter(); this.gradientPainter = new GlassGradientPainter(); this.buttonShaper = new ClassicButtonShaper(); this.decorationPainter = new ArcDecorationPainter(); this.highlightPainter = new GlassHighlightPainter(); this.selectedTabFadeStart = 1.0f; this.selectedTabFadeEnd = 1.0f; } } public static JMenu getTransformMenu() { JMenu jmTransform = new JMenu("Transforms"); JMenuItem itemShade = new JMenuItem("Shade 10%"); itemShade.addActionListener(new SkinChanger(new ColorSchemeTransform() { @Override public SubstanceColorScheme transform(SubstanceColorScheme scheme) { return scheme.shade(0.1); }; }, "Shaded current")); jmTransform.add(itemShade); JMenuItem itemTone = new JMenuItem("Tone 10%"); itemTone.addActionListener(new SkinChanger(new ColorSchemeTransform() { @Override public SubstanceColorScheme transform(SubstanceColorScheme scheme) { return scheme.tone(0.1); }; }, "Toned current")); jmTransform.add(itemTone); JMenuItem itemTint = new JMenuItem("Tint 10%"); itemTint.addActionListener(new SkinChanger(new ColorSchemeTransform() { @Override public SubstanceColorScheme transform(SubstanceColorScheme scheme) { return scheme.tint(0.1); }; }, "Tinted current")); jmTransform.add(itemTint); JMenuItem itemHueShift = new JMenuItem("Hue shift 10%"); itemHueShift.addActionListener(new SkinChanger( new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.hueShift(0.1); }; }, "Hue shifted current")); jmTransform.add(itemHueShift); JMenuItem itemSaturate = new JMenuItem("Saturate 10%"); itemSaturate.addActionListener(new SkinChanger( new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.saturate(0.1); }; }, "Saturated current")); jmTransform.add(itemSaturate); JMenuItem itemDesaturate = new JMenuItem("Desaturate 10%"); itemDesaturate.addActionListener(new SkinChanger( new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.saturate(-0.1); }; }, "Desaturated current")); jmTransform.add(itemDesaturate); JMenuItem itemNegate = new JMenuItem("Negate"); itemNegate.addActionListener(new SkinChanger( new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.negate(); }; }, "Negated current")); jmTransform.add(itemNegate); JMenuItem itemInvert = new JMenuItem("Invert"); itemInvert.addActionListener(new SkinChanger( new ColorSchemeTransform() { @Override public SubstanceColorScheme transform( SubstanceColorScheme scheme) { return scheme.invert(); }; }, "Inverted current")); jmTransform.add(itemInvert); return jmTransform; } public static JMenu getLookAndFeelMenu(JFrame frame) { JMenu lafMenu = new JMenu("Look & feel"); JMenu substanceMenus = new JMenu("Substance family"); // for (Map.Entry substanceSkinInfo : // SubstanceLookAndFeel // .getAllSkins().entrySet()) { // substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, // substanceSkinInfo.getValue().getDisplayName(), // substanceSkinInfo.getValue().getClassName())); // } substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Business", "org.jvnet.substance.skin.SubstanceBusinessLookAndFeel")); substanceMenus .add(SubstanceLafChanger .getMenuItem(frame, "Business Black Steel", "org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel")); substanceMenus .add(SubstanceLafChanger .getMenuItem(frame, "Business Blue Steel", "org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel")); substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Creme", "org.jvnet.substance.skin.SubstanceCremeLookAndFeel")); substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Creme Coffee", "org.jvnet.substance.skin.SubstanceCremeCoffeeLookAndFeel")); substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Dust", "org.jvnet.substance.skin.SubstanceDustLookAndFeel")); substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Dust Coffee", "org.jvnet.substance.skin.SubstanceDustCoffeeLookAndFeel")); substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Gemini", "org.jvnet.substance.api.skin.SubstanceGeminiLookAndFeel")); substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Moderate", "org.jvnet.substance.skin.SubstanceModerateLookAndFeel")); substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Nebula", "org.jvnet.substance.skin.SubstanceNebulaLookAndFeel")); substanceMenus .add(SubstanceLafChanger .getMenuItem(frame, "Nebula Brick Wall", "org.jvnet.substance.skin.SubstanceNebulaBrickWallLookAndFeel")); substanceMenus .add(SubstanceLafChanger .getMenuItem(frame, "Office Silver 2007", "org.jvnet.substance.skin.SubstanceOfficeSilver2007LookAndFeel")); substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Sahara", "org.jvnet.substance.skin.SubstanceSaharaLookAndFeel")); substanceMenus.addSeparator(); substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Office Blue 2007", "org.jvnet.substance.skin.SubstanceOfficeBlue2007LookAndFeel")); substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Magellan", "org.jvnet.substance.api.skin.SubstanceMagellanLookAndFeel")); substanceMenus.addSeparator(); substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Challenger Deep", "org.jvnet.substance.skin.SubstanceChallengerDeepLookAndFeel")); substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Emerald Dusk", "org.jvnet.substance.skin.SubstanceEmeraldDuskLookAndFeel")); substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Magma", "org.jvnet.substance.skin.SubstanceMagmaLookAndFeel")); substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Raven", "org.jvnet.substance.skin.SubstanceRavenLookAndFeel")); substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Raven Graphite", "org.jvnet.substance.skin.SubstanceRavenGraphiteLookAndFeel")); substanceMenus .add(SubstanceLafChanger .getMenuItem(frame, "Raven Graphite Glass", "org.jvnet.substance.skin.SubstanceRavenGraphiteGlassLookAndFeel")); substanceMenus .add(SubstanceLafChanger .getMenuItem(frame, "Graphite Aqua", "org.jvnet.substance.api.skin.SubstanceGraphiteAquaLookAndFeel")); substanceMenus.add(SubstanceLafChanger.getMenuItem(frame, "Twilight", "org.jvnet.substance.skin.SubstanceTwilightLookAndFeel")); lafMenu.add(substanceMenus); lafMenu.addSeparator(); JMenu coreLafMenus = new JMenu("Core LAFs"); lafMenu.add(coreLafMenus); coreLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "System", UIManager.getSystemLookAndFeelClassName())); coreLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Metal", "javax.swing.plaf.metal.MetalLookAndFeel")); coreLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Windows", "com.sun.java.swing.plaf.windows.WindowsLookAndFeel")); coreLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Windows Classic", "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel")); coreLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Motif", "com.sun.java.swing.plaf.motif.MotifLookAndFeel")); coreLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Nimbus", "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel")); JMenu customLafMenus = new JMenu("Custom LAFs"); lafMenu.add(customLafMenus); JMenu jgoodiesMenu = new JMenu("JGoodies family"); customLafMenus.add(jgoodiesMenu); jgoodiesMenu.add(SubstanceLafChanger.getMenuItem(frame, "JGoodies Plastic", "com.jgoodies.looks.plastic.PlasticLookAndFeel")); jgoodiesMenu.add(SubstanceLafChanger.getMenuItem(frame, "JGoodies PlasticXP", "com.jgoodies.looks.plastic.PlasticXPLookAndFeel")); jgoodiesMenu.add(SubstanceLafChanger.getMenuItem(frame, "JGoodies Plastic3D", "com.jgoodies.looks.plastic.Plastic3DLookAndFeel")); jgoodiesMenu.add(SubstanceLafChanger.getMenuItem(frame, "JGoodies Windows", "com.jgoodies.looks.windows.WindowsLookAndFeel")); JMenu jtattooMenu = new JMenu("JTattoo family"); customLafMenus.add(jtattooMenu); jtattooMenu.add(SubstanceLafChanger.getMenuItem(frame, "JTattoo Acryl", "com.jtattoo.plaf.acryl.AcrylLookAndFeel")); jtattooMenu.add(SubstanceLafChanger.getMenuItem(frame, "JTattoo Aero", "com.jtattoo.plaf.aero.AeroLookAndFeel")); jtattooMenu.add(SubstanceLafChanger.getMenuItem(frame, "JTattoo Aluminium", "com.jtattoo.plaf.aluminium.AluminiumLookAndFeel")); jtattooMenu.add(SubstanceLafChanger.getMenuItem(frame, "JTattoo Bernstein", "com.jtattoo.plaf.bernstein.BernsteinLookAndFeel")); jtattooMenu.add(SubstanceLafChanger.getMenuItem(frame, "JTattoo Fast", "com.jtattoo.plaf.fast.FastLookAndFeel")); jtattooMenu.add(SubstanceLafChanger.getMenuItem(frame, "JTattoo HiFi", "com.jtattoo.plaf.hifi.HiFiLookAndFeel")); jtattooMenu.add(SubstanceLafChanger.getMenuItem(frame, "JTattoo Luna", "com.jtattoo.plaf.luna.LunaLookAndFeel")); jtattooMenu.add(SubstanceLafChanger.getMenuItem(frame, "JTattoo McWin", "com.jtattoo.plaf.mcwin.McWinLookAndFeel")); jtattooMenu.add(SubstanceLafChanger.getMenuItem(frame, "JTattoo Mint", "com.jtattoo.plaf.mint.MintLookAndFeel")); jtattooMenu.add(SubstanceLafChanger.getMenuItem(frame, "JTattoo Smart", "com.jtattoo.plaf.smart.SmartLookAndFeel")); JMenu syntheticaMenu = new JMenu("Synthetica family"); customLafMenus.add(syntheticaMenu); syntheticaMenu.add(SubstanceLafChanger.getMenuItem(frame, "Synthetica base", "de.javasoft.plaf.synthetica.SyntheticaStandardLookAndFeel")); syntheticaMenu.add(SubstanceLafChanger.getMenuItem(frame, "Synthetica BlackMoon", "de.javasoft.plaf.synthetica.SyntheticaBlackMoonLookAndFeel")); syntheticaMenu.add(SubstanceLafChanger.getMenuItem(frame, "Synthetica BlackStar", "de.javasoft.plaf.synthetica.SyntheticaBlackStarLookAndFeel")); syntheticaMenu.add(SubstanceLafChanger.getMenuItem(frame, "Synthetica BlueIce", "de.javasoft.plaf.synthetica.SyntheticaBlueIceLookAndFeel")); syntheticaMenu.add(SubstanceLafChanger.getMenuItem(frame, "Synthetica BlueMoon", "de.javasoft.plaf.synthetica.SyntheticaBlueMoonLookAndFeel")); syntheticaMenu.add(SubstanceLafChanger.getMenuItem(frame, "Synthetica BlueSteel", "de.javasoft.plaf.synthetica.SyntheticaBlueSteelLookAndFeel")); syntheticaMenu.add(SubstanceLafChanger.getMenuItem(frame, "Synthetica GreenDream", "de.javasoft.plaf.synthetica.SyntheticaGreenDreamLookAndFeel")); syntheticaMenu .add(SubstanceLafChanger .getMenuItem(frame, "Synthetica MauveMetallic", "de.javasoft.plaf.synthetica.SyntheticaMauveMetallicLookAndFeel")); syntheticaMenu .add(SubstanceLafChanger .getMenuItem(frame, "Synthetica OrangeMetallic", "de.javasoft.plaf.synthetica.SyntheticaOrangeMetallicLookAndFeel")); syntheticaMenu .add(SubstanceLafChanger .getMenuItem(frame, "Synthetica SkyMetallic", "de.javasoft.plaf.synthetica.SyntheticaSkyMetallicLookAndFeel")); syntheticaMenu.add(SubstanceLafChanger.getMenuItem(frame, "Synthetica SilverMoon", "de.javasoft.plaf.synthetica.SyntheticaSilverMoonLookAndFeel")); syntheticaMenu .add(SubstanceLafChanger .getMenuItem(frame, "Synthetica WhiteVision", "de.javasoft.plaf.synthetica.SyntheticaWhiteVisionLookAndFeel")); JMenu officeMenu = new JMenu("Office family"); customLafMenus.add(officeMenu); officeMenu.add(SubstanceLafChanger.getMenuItem(frame, "Office 2003", "org.fife.plaf.Office2003.Office2003LookAndFeel")); officeMenu.add(SubstanceLafChanger.getMenuItem(frame, "Office XP", "org.fife.plaf.OfficeXP.OfficeXPLookAndFeel")); officeMenu.add(SubstanceLafChanger.getMenuItem(frame, "Visual Studio 2005", "org.fife.plaf.VisualStudio2005.VisualStudio2005LookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "A03", "a03.swing.plaf.A03LookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Alloy", "com.incors.plaf.alloy.AlloyLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "EaSynth", "com.easynth.lookandfeel.EaSynthLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "FH", "com.shfarr.ui.plaf.fh.FhLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Hippo", "se.diod.hippo.plaf.HippoLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "InfoNode", "net.infonode.gui.laf.InfoNodeLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Kuntstoff", "com.incors.plaf.kunststoff.KunststoffLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Liquid", "com.birosoft.liquid.LiquidLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Lipstik", "com.lipstikLF.LipstikLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Metouia", "net.sourceforge.mlf.metouia.MetouiaLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Napkin", "net.sourceforge.napkinlaf.NapkinLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Nimbus", "org.jdesktop.swingx.plaf.nimbus.NimbusLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "NimROD", "com.nilo.plaf.nimrod.NimRODLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Oyoaha", "com.oyoaha.swing.plaf.oyoaha.OyoahaLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Pagosoft", "com.pagosoft.plaf.PgsLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Quaqua", "ch.randelshofer.quaqua.QuaquaLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Simple", "com.memoire.slaf.SlafLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Skin", "com.l2fprod.gui.plaf.skin.SkinLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Smooth Metal", "smooth.metal.SmoothLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Squareness", "net.beeger.squareness.SquarenessLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Tiny", "de.muntjak.tinylookandfeel.TinyLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Tonic", "com.digitprop.tonic.TonicLookAndFeel")); customLafMenus.add(SubstanceLafChanger.getMenuItem(frame, "Trendy", "com.Trendy.swing.plaf.TrendyLookAndFeel")); lafMenu.addSeparator(); JMenu localeMenus = new JMenu("Change locale"); lafMenu.add(localeMenus); // Locale changing JMenuItem localeArabic = new JMenuItem("Arabic Locale", Check .getIcon("flag_saudi_arabia")); localeArabic.addActionListener(new MyLocaleChangeListener("ar", "AR", frame)); JMenuItem localeBulgarian = new JMenuItem("Bulgarian Locale", Check .getIcon("flag_bulgaria")); localeBulgarian.addActionListener(new MyLocaleChangeListener("bg", "BG", frame)); JMenuItem localeChinese = new JMenuItem("Chinese (Simplified) Locale", Check.getIcon("flag_china")); localeChinese.addActionListener(new MyLocaleChangeListener("zh", "CN", frame)); JMenuItem localeChineseHK = new JMenuItem("Chinese (Hong Kong) Locale", Check.getIcon("flag_hong_kong")); localeChineseHK.addActionListener(new MyLocaleChangeListener("zh", "HK", frame)); JMenuItem localeChineseTW = new JMenuItem("Chinese (Taiwan) Locale", Check.getIcon("flag_taiwan")); localeChineseTW.addActionListener(new MyLocaleChangeListener("zh", "TW", frame)); JMenuItem localeCzech = new JMenuItem("Czech Locale", Check .getIcon("flag_czech_republic")); localeCzech.addActionListener(new MyLocaleChangeListener("cs", "CZ", frame)); JMenuItem localeDanish = new JMenuItem("Danish Locale", Check .getIcon("flag_denmark")); localeDanish.addActionListener(new MyLocaleChangeListener("da", "DK", frame)); JMenuItem localeDutch = new JMenuItem("Dutch Locale", Check .getIcon("flag_netherlands")); localeDutch.addActionListener(new MyLocaleChangeListener("nl", "NL", frame)); JMenuItem localeEnglish = new JMenuItem("English Locale", Check .getIcon("flag_united_states")); localeEnglish.addActionListener(new MyLocaleChangeListener("en", "US", frame)); JMenuItem localeFinnish = new JMenuItem("Finnish Locale", Check .getIcon("flag_finland")); localeFinnish.addActionListener(new MyLocaleChangeListener("fi", "FI", frame)); JMenuItem localeFrench = new JMenuItem("French Locale", Check .getIcon("flag_france")); localeFrench.addActionListener(new MyLocaleChangeListener("fr", "FR", frame)); JMenuItem localeFrenchCA = new JMenuItem("French (Canada) Locale", Check.getIcon("flag_canada")); localeFrenchCA.addActionListener(new MyLocaleChangeListener("fr", "CA", frame)); JMenuItem localeGerman = new JMenuItem("German Locale", Check .getIcon("flag_germany")); localeGerman.addActionListener(new MyLocaleChangeListener("de", "DE", frame)); JMenuItem localeGreek = new JMenuItem("Greek Locale", Check .getIcon("flag_greece")); localeGreek.addActionListener(new MyLocaleChangeListener("el", "GR", frame)); JMenuItem localeHebrew = new JMenuItem("Hebrew Locale", Check .getIcon("flag_israel")); localeHebrew.addActionListener(new MyLocaleChangeListener("iw", "IL", frame)); JMenuItem localeHungarian = new JMenuItem("Hungarian Locale", Check .getIcon("flag_hungary")); localeHungarian.addActionListener(new MyLocaleChangeListener("hu", "HU", frame)); JMenuItem localeItalian = new JMenuItem("Italian Locale", Check .getIcon("flag_italy")); localeItalian.addActionListener(new MyLocaleChangeListener("it", "IT", frame)); JMenuItem localeJapanese = new JMenuItem("Japanese Locale", Check .getIcon("flag_japan")); localeJapanese.addActionListener(new MyLocaleChangeListener("ja", "JP", frame)); JMenuItem localeNorwegian = new JMenuItem("Norwegian Locale", Check .getIcon("flag_norway")); localeNorwegian.addActionListener(new MyLocaleChangeListener("no", "NO", frame)); JMenuItem localePolish = new JMenuItem("Polish Locale", Check .getIcon("flag_poland")); localePolish.addActionListener(new MyLocaleChangeListener("pl", "PL", frame)); JMenuItem localePortuguese = new JMenuItem("Portuguese Locale", Check .getIcon("flag_portugal")); localePortuguese.addActionListener(new MyLocaleChangeListener("pt", "PT", frame)); JMenuItem localePortugueseBR = new JMenuItem( "Portuguese (Brazil) Locale", Check.getIcon("flag_brazil")); localePortugueseBR.addActionListener(new MyLocaleChangeListener("pt", "BR", frame)); JMenuItem localeRomanian = new JMenuItem("Romanian Locale", Check .getIcon("flag_romania")); localeRomanian.addActionListener(new MyLocaleChangeListener("ro", "RO", frame)); JMenuItem localeRussian = new JMenuItem("Russian Locale", Check .getIcon("flag_russia")); localeRussian.addActionListener(new MyLocaleChangeListener("ru", "RU", frame)); JMenuItem localeSpanish = new JMenuItem("Spanish Locale", Check .getIcon("flag_spain")); localeSpanish.addActionListener(new MyLocaleChangeListener("es", "ES", frame)); JMenuItem localeSpanishMX = new JMenuItem("Spanish (Mexico) Locale", Check.getIcon("flag_mexico")); localeSpanishMX.addActionListener(new MyLocaleChangeListener("es", "MX", frame)); JMenuItem localeSwedish = new JMenuItem("Swedish Locale", Check .getIcon("flag_sweden")); localeSwedish.addActionListener(new MyLocaleChangeListener("sv", "SE", frame)); JMenuItem localeThai = new JMenuItem("Thai Locale", Check .getIcon("flag_thailand")); localeThai.addActionListener(new MyLocaleChangeListener("th", "TH", frame)); JMenuItem localeTurkish = new JMenuItem("Turkish Locale", Check .getIcon("flag_turkey")); localeTurkish.addActionListener(new MyLocaleChangeListener("tr", "TR", frame)); JMenuItem localeVietnamese = new JMenuItem("Vietnamese Locale", Check .getIcon("flag_vietnam")); localeVietnamese.addActionListener(new MyLocaleChangeListener("vi", "VN", frame)); localeMenus.add(localeEnglish); localeMenus.add(localeArabic); localeMenus.add(localeBulgarian); localeMenus.add(localeChinese); localeMenus.add(localeChineseHK); localeMenus.add(localeChineseTW); localeMenus.add(localeCzech); localeMenus.add(localeDanish); localeMenus.add(localeDutch); localeMenus.add(localeFinnish); localeMenus.add(localeFrench); localeMenus.add(localeFrenchCA); localeMenus.add(localeGerman); localeMenus.add(localeGreek); localeMenus.add(localeHebrew); localeMenus.add(localeHungarian); localeMenus.add(localeItalian); localeMenus.add(localeJapanese); localeMenus.add(localeNorwegian); localeMenus.add(localePolish); localeMenus.add(localePortuguese); localeMenus.add(localePortugueseBR); localeMenus.add(localeRomanian); localeMenus.add(localeRussian); localeMenus.add(localeSpanish); localeMenus.add(localeSpanishMX); localeMenus.add(localeSwedish); localeMenus.add(localeThai); localeMenus.add(localeTurkish); localeMenus.add(localeVietnamese); return lafMenu; } protected static class SkinChanger implements ActionListener { protected ColorSchemeTransform transform; protected String name; public SkinChanger(ColorSchemeTransform transform, String name) { super(); this.transform = transform; this.name = name; } public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceSkin newSkin = SubstanceLookAndFeel .getCurrentSkin(null).transform(transform, name); SubstanceLookAndFeel.setSkin(newSkin); } }); } } } substance-5.3.orig/src/test/check/NumberedPanel.java0000644000175000017500000001077511076300340022416 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.check; import java.awt.*; import java.text.SimpleDateFormat; import java.util.Date; import javax.swing.JPanel; import javax.swing.UIManager; import org.jvnet.lafwidget.layout.TransitionLayout; import org.jvnet.substance.SubstanceLookAndFeel; /** * A simple panel that paints the current time on itself. * * @author Kirill Grouchnikov */ public class NumberedPanel extends JPanel { /** * Panel that paints the current time and has a custom colored background. * * @author Kirill Grouchnikov */ protected static class ColoredNumberedPanel extends JPanel { /** * Panel ID number. */ private int number; /** * Creates a new panel. * * @param number * Panel ID number. */ public ColoredNumberedPanel(int number) { this.number = number; this.setBackground(new Color(255 - (int) (50.0 * Math.random()), 255 - (int) (50.0 * Math.random()), 255 - (int) (50.0 * Math.random()))); } /* * (non-Javadoc) * * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) */ @Override protected void paintComponent(Graphics g) { int w = this.getWidth(); int h = this.getHeight(); Graphics2D graphics = (Graphics2D) g.create(); graphics.setComposite(TransitionLayout.getAlphaComposite(this)); if ((UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) && SubstanceLookAndFeel.getCurrentSkin(this) .getMainActiveColorScheme().isDark()) graphics.setColor(Color.black); else graphics.setColor(Color.white); graphics.fillRect(0, 0, w, h); graphics.setComposite(TransitionLayout .getAlphaComposite(this, 0.6f)); graphics.setColor(this.getBackground()); graphics.fillRect(0, 0, w, h); graphics.setComposite(TransitionLayout.getAlphaComposite(this)); if ((UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) && SubstanceLookAndFeel.getCurrentSkin(this) .getMainActiveColorScheme().isDark()) graphics.setColor(Color.white); else graphics.setColor(Color.black); int size = Math.min(60, Math.min(w, h) / 2); graphics.setFont(new Font("Arial", Font.BOLD, size)); graphics .drawString("" + number, (w - size) / 2, (h / 2 + size) / 2); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS"); String currDate = sdf.format(new Date()); int size2 = Math.min(50, Math.min(w, h) / 3); graphics.setFont(new Font("Arial", Font.BOLD, size2)); int timeLen = graphics.getFontMetrics().stringWidth(currDate); graphics.drawString(currDate, (w - timeLen) / 2, (h + size) / 2); graphics.dispose(); } } /** * Creates a new panel. * * @param number * Panel ID number. */ public NumberedPanel(int number) { this.setLayout(new BorderLayout()); this.add(new ColoredNumberedPanel(number)); } }substance-5.3.orig/src/test/samples/0000755000175000017500000000000011234634566017427 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/samples/lafwidget/0000755000175000017500000000000010570313724021365 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/samples/lafwidget/clientprop/0000755000175000017500000000000011256731162023546 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/samples/lafwidget/clientprop/TextEditContextMenu.java0000644000175000017500000000720211223634612030332 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.lafwidget.clientprop; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link LafWidget#TEXT_EDIT_CONTEXT_MENU} client property. * * @author Kirill Grouchnikov * @see LafWidget#TEXT_EDIT_CONTEXT_MENU */ public class TextEditContextMenu extends JFrame { /** * Creates the main frame for this sample. */ public TextEditContextMenu() { super("Text edit context menu"); this.setLayout(new BorderLayout()); final JTextField jtf = new JTextField("sample text"); jtf.setColumns(20); JPanel main = new JPanel(new FlowLayout(FlowLayout.CENTER)); this.add(main, BorderLayout.CENTER); main.add(jtf); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox hasEditContextMenu = new JCheckBox( "Has edit context menu"); hasEditContextMenu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jtf.putClientProperty(LafWidget.TEXT_EDIT_CONTEXT_MENU, hasEditContextMenu.isSelected() ? Boolean.TRUE : null); } }); controls.add(hasEditContextMenu); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new TextEditContextMenu().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/lafwidget/clientprop/TabbedPanePreviewPainter.java0000644000175000017500000001057511223634570031272 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.lafwidget.clientprop; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.tabbed.DefaultTabPreviewPainter; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import test.Check; /** * Test application that shows the use of the * {@link LafWidget#TABBED_PANE_PREVIEW_PAINTER} client property. * * @author Kirill Grouchnikov * @see LafWidget#TABBED_PANE_PREVIEW_PAINTER */ public class TabbedPanePreviewPainter extends JFrame { /** * Creates the main frame for this sample. */ public TabbedPanePreviewPainter() { super("Tabbed pane preview painter"); this.setLayout(new BorderLayout()); final JTabbedPane jtp = new JTabbedPane(); jtp.addTab("First", Check.getIcon("flag_mexico"), new JPanel() { @Override protected void paintComponent(Graphics g) { g.setColor(new Color(255, 200, 200)); g.fillRect(0, 0, getWidth(), getHeight()); } }); jtp.addTab("Second", Check.getIcon("flag_sweden"), new JPanel() { @Override protected void paintComponent(Graphics g) { g.setColor(new Color(200, 255, 200)); g.fillRect(0, 0, getWidth(), getHeight()); } }); jtp.addTab("Third", Check.getIcon("flag_hong_kong"), new JPanel() { @Override protected void paintComponent(Graphics g) { g.setColor(new Color(200, 200, 255)); g.fillRect(0, 0, getWidth(), getHeight()); } }); this.add(jtp, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox hasPreview = new JCheckBox("Has preview"); hasPreview.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jtp .putClientProperty( LafWidget.TABBED_PANE_PREVIEW_PAINTER, hasPreview.isSelected() ? new DefaultTabPreviewPainter() : null); jtp.revalidate(); jtp.repaint(); } }); controls.add(hasPreview); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are * ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new TabbedPanePreviewPainter().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/lafwidget/clientprop/AutoScroll.java0000644000175000017500000001023011223634510026465 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.lafwidget.clientprop; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the {@link LafWidget#AUTO_SCROLL} * client property. * * @author Kirill Grouchnikov * @see LafWidget#AUTO_SCROLL */ public class AutoScroll extends JFrame { /** * Creates the main frame for this sample. */ public AutoScroll() { super("Auto scroll"); this.setLayout(new BorderLayout()); // Create panel with custom painting logic - simple // diagonal fill. JPanel samplePanel = new JPanel() { @Override protected void paintComponent(Graphics g) { Graphics2D graphics = (Graphics2D) g.create(); graphics .setPaint(new GradientPaint(0, 0, new Color(100, 100, 255), getWidth(), getHeight(), new Color(255, 100, 100))); graphics.fillRect(0, 0, getWidth(), getHeight()); graphics.dispose(); } }; samplePanel.setPreferredSize(new Dimension(800, 400)); samplePanel.setSize(this.getPreferredSize()); samplePanel.setMinimumSize(this.getPreferredSize()); final JScrollPane scrollPane = new JScrollPane(samplePanel); this.add(scrollPane, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox hasAutoScroll = new JCheckBox("has auto scroll"); hasAutoScroll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { scrollPane.putClientProperty(LafWidget.AUTO_SCROLL, hasAutoScroll.isSelected() ? Boolean.TRUE : null); repaint(); } }); } }); controls.add(hasAutoScroll); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are * ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new AutoScroll().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/lafwidget/clientprop/TextSelectOnFocus.java0000644000175000017500000000717011223634676030005 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.lafwidget.clientprop; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link LafWidget#TEXT_SELECT_ON_FOCUS} client property. * * @author Kirill Grouchnikov * @see LafWidget#TEXT_SELECT_ON_FOCUS */ public class TextSelectOnFocus extends JFrame { /** * Creates the main frame for this sample. */ public TextSelectOnFocus() { super("Text select on focus"); this.setLayout(new BorderLayout()); final JTextField jtf = new JTextField("sample text"); jtf.setColumns(20); JPanel main = new JPanel(new FlowLayout(FlowLayout.CENTER)); this.add(main, BorderLayout.CENTER); main.add(jtf); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox hasSelectOnFocus = new JCheckBox( "Has \"select on focus\" behaviour"); hasSelectOnFocus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jtf.putClientProperty(LafWidget.TEXT_SELECT_ON_FOCUS, hasSelectOnFocus.isSelected() ? Boolean.TRUE : null); } }); controls.add(hasSelectOnFocus); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new TextSelectOnFocus().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/lafwidget/clientprop/PasswordStrengthCheckerProperty.java0000644000175000017500000001147211223634532032766 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.lafwidget.clientprop; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.text.PasswordStrengthChecker; import org.jvnet.lafwidget.utils.LafConstants.PasswordStrength; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link LafWidget#PASSWORD_STRENGTH_CHECKER} client property. * * @author Kirill Grouchnikov * @see LafWidget#PASSWORD_STRENGTH_CHECKER */ public class PasswordStrengthCheckerProperty extends JFrame { /** * Creates the main frame for this sample. */ public PasswordStrengthCheckerProperty() { super("Password strength checker"); this.setLayout(new BorderLayout()); final JPanel panel = new JPanel(new FlowLayout()); this.add(panel, BorderLayout.CENTER); final JPasswordField jpf = new JPasswordField(); jpf.setColumns(20); panel.add(new JLabel("Start typing password")); panel.add(jpf); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox hasPasswordStrengthChecker = new JCheckBox( "Has password strength checker"); hasPasswordStrengthChecker.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (hasPasswordStrengthChecker.isSelected()) { jpf.putClientProperty(LafWidget.PASSWORD_STRENGTH_CHECKER, new PasswordStrengthChecker() { public PasswordStrength getStrength( char[] password) { if (password == null) return PasswordStrength.WEAK; int length = password.length; if (length < 3) return PasswordStrength.WEAK; if (length < 6) return PasswordStrength.MEDIUM; return PasswordStrength.STRONG; } public String getDescription( PasswordStrength strength) { if (strength == PasswordStrength.WEAK) return "This password is way too weak"; if (strength == PasswordStrength.MEDIUM) return "Come on, you can do
a little better than that"; if (strength == PasswordStrength.STRONG) return "OK"; return null; } }); } else { jpf.putClientProperty(LafWidget.PASSWORD_STRENGTH_CHECKER, null); } } }); controls.add(hasPasswordStrengthChecker); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are * ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new PasswordStrengthCheckerProperty().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/lafwidget/clientprop/ComponentPreviewPainter.java0000644000175000017500000001051511223634466031245 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.lafwidget.clientprop; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.preview.DefaultPreviewPainter; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link LafWidget#COMPONENT_PREVIEW_PAINTER} client property. * * @author Kirill Grouchnikov * @see LafWidget#COMPONENT_PREVIEW_PAINTER */ public class ComponentPreviewPainter extends JFrame { /** * Creates the main frame for this sample. */ public ComponentPreviewPainter() { super("Component preview painter"); this.setLayout(new BorderLayout()); // Create panel with custom painting logic - simple // diagonal fill. JPanel samplePanel = new JPanel() { @Override protected void paintComponent(Graphics g) { Graphics2D graphics = (Graphics2D) g.create(); graphics .setPaint(new GradientPaint(0, 0, new Color(100, 100, 255), getWidth(), getHeight(), new Color(255, 100, 100))); graphics.fillRect(0, 0, getWidth(), getHeight()); graphics.dispose(); } }; samplePanel.setPreferredSize(new Dimension(800, 400)); samplePanel.setSize(this.getPreferredSize()); samplePanel.setMinimumSize(this.getPreferredSize()); final JScrollPane scrollPane = new JScrollPane(samplePanel); this.add(scrollPane, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox hasPreview = new JCheckBox("scroll has preview"); hasPreview.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { scrollPane .putClientProperty( LafWidget.COMPONENT_PREVIEW_PAINTER, hasPreview.isSelected() ? new DefaultPreviewPainter() : null); repaint(); } }); } }); controls.add(hasPreview); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new ComponentPreviewPainter().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/lafwidget/clientprop/TextFlipSelectOnEscape.java0000644000175000017500000000435511223645416030735 0ustar drazzibdrazzibpackage test.samples.lafwidget.clientprop; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link LafWidget#TEXT_FLIP_SELECT_ON_ESCAPE} client property. * * @author Kirill Grouchnikov * @see LafWidget#TEXT_FLIP_SELECT_ON_ESCAPE */ public class TextFlipSelectOnEscape extends JFrame { /** * Creates the main frame for this sample. */ public TextFlipSelectOnEscape() { super("Text flip select on ESC"); this.setLayout(new BorderLayout()); final JTextField jtf = new JTextField("sample text"); jtf.setColumns(20); JPanel main = new JPanel(new FlowLayout(FlowLayout.CENTER)); this.add(main, BorderLayout.CENTER); main.add(jtf); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox hasSelectOnFocus = new JCheckBox( "Has \"flip select on ESC\" behaviour"); hasSelectOnFocus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jtf.putClientProperty(LafWidget.TEXT_FLIP_SELECT_ON_ESCAPE, hasSelectOnFocus.isSelected() ? Boolean.TRUE : null); } }); controls.add(hasSelectOnFocus); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. * @throws Exception * If some exception occured. Note that there is no special * treatment of exception conditions in this sample * code. */ public static void main(String[] args) throws Exception { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new TextFlipSelectOnEscape().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/lafwidget/clientprop/AnimationKindProperty.java0000644000175000017500000001066711223634500030705 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.lafwidget.clientprop; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.LafWidgetUtilities; import org.jvnet.lafwidget.utils.LafConstants.AnimationKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.renderers.SubstanceDefaultComboBoxRenderer; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the {@link LafWidget#ANIMATION_KIND} * client property. * * @author Kirill Grouchnikov * @see LafWidget#ANIMATION_KIND */ public class AnimationKindProperty extends JFrame { /** * Creates the main frame for this sample. */ public AnimationKindProperty() { super("Animation kind"); setLayout(new BorderLayout()); final JButton button1 = new JButton("button"); JPanel main = new JPanel(new FlowLayout(FlowLayout.CENTER)); this.add(main, BorderLayout.CENTER); main.add(button1); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JComboBox animationKindCombo = new JComboBox(new Object[] { AnimationKind.NONE, AnimationKind.FAST, AnimationKind.REGULAR, AnimationKind.SLOW, AnimationKind.DEBUG_FAST, AnimationKind.DEBUG, AnimationKind.DEBUG_SLOW }); animationKindCombo.setRenderer(new SubstanceDefaultComboBoxRenderer( animationKindCombo) { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { AnimationKind kind = (AnimationKind) value; return super.getListCellRendererComponent(list, kind.getName(), index, isSelected, cellHasFocus); } }); animationKindCombo.setSelectedItem(LafWidgetUtilities .getAnimationKind(button1)); animationKindCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { button1.putClientProperty(LafWidget.ANIMATION_KIND, animationKindCombo.getSelectedItem()); button1.requestFocus(); } }); controls.add(new JLabel("Animation kind")); controls.add(animationKindCombo); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are * ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new AnimationKindProperty().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/0000755000175000017500000000000010570313726021410 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/samples/substance/clientprop/0000755000175000017500000000000011256731164023571 5ustar drazzibdrazzib././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsubstance-5.3.orig/src/test/samples/substance/clientprop/TabbedPaneCloseButtonsModifiedAnimation.javasubstance-5.3.orig/src/test/samples/substance/clientprop/TabbedPaneCloseButtonsModifiedAnimation.jav0000644000175000017500000001177211223636746034142 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION} * client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION */ public class TabbedPaneCloseButtonsModifiedAnimation extends JFrame { /** * Creates the main frame for this sample. */ public TabbedPaneCloseButtonsModifiedAnimation() { super("Tabbed pane close buttons modified animation"); this.setLayout(new BorderLayout()); // create a tabbed pane with few tabs final JTabbedPane jtp = new JTabbedPane(); String packageName = MenuGutterFillKindProperty.class.getPackage() .getName(); jtp.addTab("First", new ImageIcon(MenuGutterFillKindProperty.class .getClassLoader().getResource( packageName.replace('.', '/') + "/flag_mexico")), new JPanel()); jtp.addTab("Second", new ImageIcon(MenuGutterFillKindProperty.class .getClassLoader().getResource( packageName.replace('.', '/') + "/flag_sweden")), new JPanel()); // mark the tabbed pane to have close buttons on all tabs jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); this.add(jtp, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox firstTabModified = new JCheckBox("First tab modified"); firstTabModified.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Component comp = jtp.getComponentAt(0); // based on the checkbox selection, mark the first tab component // to have modified contents ((JComponent) comp).putClientProperty( SubstanceLookAndFeel.WINDOW_MODIFIED, firstTabModified .isSelected() ? Boolean.TRUE : null); jtp.repaint(); } }); final JCheckBox animationOnCloseButton = new JCheckBox( "Animation on close button"); animationOnCloseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // based on the checkbox selection, mark the tabbed pane to have // modified animations on the close button only jtp .putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_MODIFIED_ANIMATION, animationOnCloseButton.isSelected() ? Boolean.TRUE : null); jtp.repaint(); } }); controls.add(firstTabModified); controls.add(animationOnCloseButton); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new TabbedPaneCloseButtonsModifiedAnimation().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/ColorizationFactor.java0000644000175000017500000001005011223636452030241 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.*; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#COLORIZATION_FACTOR} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#COLORIZATION_FACTOR */ public class ColorizationFactor extends JFrame { /** * Creates the main frame for this sample. */ public ColorizationFactor() { super("Colorization factor"); this.setLayout(new BorderLayout()); final JPanel panel = new JPanel(new FlowLayout()); JButton button = new JButton("sample"); button.setBackground(Color.yellow); button.setForeground(Color.red); panel.add(button); JCheckBox checkbox = new JCheckBox("sample"); checkbox.setSelected(true); checkbox.setBackground(Color.green.brighter()); checkbox.setForeground(Color.blue.darker()); panel.add(checkbox); JRadioButton radiobutton = new JRadioButton("sample"); radiobutton.setSelected(true); radiobutton.setBackground(Color.yellow); radiobutton.setForeground(Color.green.darker()); panel.add(radiobutton); this.add(panel, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JSlider colorizationSlider = new JSlider(0, 100, 50); colorizationSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { double val = colorizationSlider.getValue() / 100.0; panel.putClientProperty( SubstanceLookAndFeel.COLORIZATION_FACTOR, new Double( val)); panel.repaint(); } }); controls.add(colorizationSlider); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new ColorizationFactor().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/flag_mexico.png0000644000175000017500000000123110520765376026556 0ustar drazzibdrazzibPNG  IHDRa*tEXtCreation TimeDo 1 Apr 2004 12:07:52 +0100>+tIME uZ pHYs B4gAMA aIDATxSjA=hۉ 4(ĕ r^?Ý~RA>2 `f#$][0?HtݺsON{h^مv2I)CAOH 9o>"Jukʺ-/!z1z |Fg&8w{˨ļ?@%($eKP1rGXVfLC1B%IIJz Җhm a$p\(yPTK}eҟ ԉ(G1!D~7?A|[@x(KZO$없b{3~C~aE1 ME]U)-x;TA0U+- RLgǽKO+{{ "\X!烣 YxX b؏PH ̂iqɜnXPlIa`>U0UA;Q_'Oj9'!qF:4IENDB`substance-5.3.orig/src/test/samples/substance/clientprop/TabbedPaneCloseButtonsProperty.java0000644000175000017500000001200211223636754032531 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#TABBED_PANE_CLOSE_BUTTONS_PROPERTY} client * property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#TABBED_PANE_CLOSE_BUTTONS_PROPERTY */ public class TabbedPaneCloseButtonsProperty extends JFrame { /** * Creates the main frame for this sample. */ public TabbedPaneCloseButtonsProperty() { super("Tabbed pane close buttons"); this.setLayout(new BorderLayout()); // create a tabbed pane with few tabs final JTabbedPane jtp = new JTabbedPane(); String packageName = MenuGutterFillKindProperty.class.getPackage() .getName(); jtp.addTab("First", new ImageIcon(MenuGutterFillKindProperty.class .getClassLoader().getResource( packageName.replace('.', '/') + "/flag_mexico.png")), new JPanel()); jtp.addTab("Second", new ImageIcon(MenuGutterFillKindProperty.class .getClassLoader().getResource( packageName.replace('.', '/') + "/flag_sweden.png")), new JPanel()); jtp .addTab("Third", new ImageIcon(MenuGutterFillKindProperty.class .getClassLoader().getResource( packageName.replace('.', '/') + "/flag_hong_kong.png")), new JPanel()); this.add(jtp, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox allHaveCloseButton = new JCheckBox("All tabs"); allHaveCloseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // based on the checkbox selection, mark the tabbed pane to have // close buttons on all tabs jtp .putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, allHaveCloseButton.isSelected() ? Boolean.TRUE : null); jtp.revalidate(); jtp.repaint(); } }); final JCheckBox firstHasCloseButton = new JCheckBox("First tab"); firstHasCloseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // based on the checkbox selection, mark the first tab component // to have close button ((JComponent) jtp.getComponentAt(0)) .putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, firstHasCloseButton.isSelected() ? Boolean.TRUE : null); jtp.revalidate(); jtp.repaint(); } }); controls.add(allHaveCloseButton); controls.add(firstHasCloseButton); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new TabbedPaneCloseButtonsProperty().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/SkinProperty.java0000644000175000017500000001106711223636736027115 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.skin.*; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#SKIN_PROPERTY} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#SKIN_PROPERTY */ public class SkinProperty extends JFrame { /** * Creates the main frame for this sample. */ public SkinProperty() { super("Per-window skins"); this.setLayout(new FlowLayout()); JButton autumnSkin = new JButton("Autumn skin"); autumnSkin.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { openSampleFrame(new AutumnSkin()); } }); } }); this.add(autumnSkin); JButton ravenGraphiteSkin = new JButton("Graphite skin"); ravenGraphiteSkin.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { openSampleFrame(new RavenGraphiteSkin()); } }); } }); this.add(ravenGraphiteSkin); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * Opens a sample frame under the specified skin. * * @param skin * Skin. */ private void openSampleFrame(SubstanceSkin skin) { JFrame sampleFrame = new JFrame(skin.getDisplayName()); sampleFrame.setLayout(new FlowLayout()); JButton defaultButton = new JButton("active"); JButton button = new JButton("default"); JButton disabledButton = new JButton("disabled"); disabledButton.setEnabled(false); sampleFrame.getRootPane().setDefaultButton(defaultButton); sampleFrame.add(defaultButton); sampleFrame.add(button); sampleFrame.add(disabledButton); sampleFrame.setVisible(true); sampleFrame.pack(); sampleFrame.setLocationRelativeTo(null); sampleFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); sampleFrame.getRootPane().putClientProperty( SubstanceLookAndFeel.SKIN_PROPERTY, skin); SwingUtilities.updateComponentTreeUI(sampleFrame); sampleFrame.repaint(); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new SkinProperty().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/ButtonPaintNeverProperty.java0000644000175000017500000000630611223636372031454 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.FlowLayout; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#BUTTON_PAINT_NEVER_PROPERTY} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#BUTTON_PAINT_NEVER_PROPERTY */ public class ButtonPaintNeverProperty extends JFrame { /** * Creates the main frame for this sample. */ public ButtonPaintNeverProperty() { super("Middle button never paints background"); this.setLayout(new FlowLayout()); JButton buttonA = new JButton("a"); JButton buttonB = new JButton("b"); // Mark button to never paint its background buttonB.putClientProperty( SubstanceLookAndFeel.BUTTON_PAINT_NEVER_PROPERTY, Boolean.TRUE); JButton buttonC = new JButton("c"); this.add(buttonA); this.add(buttonB); this.add(buttonC); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new ButtonPaintNeverProperty().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/FocusKindProperty.java0000644000175000017500000001053711223636662030075 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.FocusKind; import org.jvnet.substance.api.renderers.SubstanceDefaultComboBoxRenderer; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#FOCUS_KIND} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#FOCUS_KIND */ public class FocusKindProperty extends JFrame { /** * Creates the main frame for this sample. */ public FocusKindProperty() { super("Focus kind"); setLayout(new BorderLayout()); final JButton button1 = new JButton("button"); JPanel main = new JPanel(new FlowLayout(FlowLayout.CENTER)); this.add(main, BorderLayout.CENTER); main.add(button1); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JComboBox focusKindCombo = new JComboBox( new Object[] { FocusKind.NONE, FocusKind.ALL, FocusKind.ALL_INNER, FocusKind.TEXT, FocusKind.UNDERLINE, FocusKind.STRONG_UNDERLINE }); focusKindCombo.setRenderer(new SubstanceDefaultComboBoxRenderer( focusKindCombo) { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { FocusKind mgfk = (FocusKind) value; return super.getListCellRendererComponent(list, mgfk.name() .toLowerCase(), index, isSelected, cellHasFocus); } }); focusKindCombo.setSelectedItem(FocusKind.ALL_INNER); focusKindCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // based on the selected value, set focus kind on the // button and request focus button1.putClientProperty(SubstanceLookAndFeel.FOCUS_KIND, focusKindCombo.getSelectedItem()); button1.requestFocus(); } }); controls.add(new JLabel("Focus kind")); controls.add(focusKindCombo); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new FocusKindProperty().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/WindowModified.java0000644000175000017500000001023511223652660027342 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#WINDOW_MODIFIED} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#WINDOW_MODIFIED */ public class WindowModified extends JFrame { /** * Creates the main frame for this sample. */ public WindowModified() { super("Window modified"); this.setLayout(new BorderLayout()); this.add(new JLabel("Type something in the text pane " + "and hover over the close button"), BorderLayout.NORTH); // create a text pane JTextPane textArea = new JTextPane(); this.add(textArea, BorderLayout.CENTER); textArea.getDocument().addDocumentListener(new DocumentListener() { private void handleChange() { // on any document change, mark root pane as modified getRootPane().putClientProperty( SubstanceLookAndFeel.WINDOW_MODIFIED, Boolean.TRUE); } public void changedUpdate(DocumentEvent e) { handleChange(); } public void insertUpdate(DocumentEvent e) { handleChange(); } public void removeUpdate(DocumentEvent e) { handleChange(); } }); JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton saveButton = new JButton("Save"); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // on button click, mark root pane as not modified getRootPane().putClientProperty( SubstanceLookAndFeel.WINDOW_MODIFIED, Boolean.FALSE); } }); buttons.add(saveButton); this.add(buttons, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String... args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new WindowModified().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/MenuGutterFillKindProperty.java0000644000175000017500000001213611223636672031722 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.MenuGutterFillKind; import org.jvnet.substance.api.renderers.SubstanceDefaultComboBoxRenderer; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#MENU_GUTTER_FILL_KIND} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#MENU_GUTTER_FILL_KIND */ public class MenuGutterFillKindProperty extends JFrame { /** * Creates the main frame for this sample. */ public MenuGutterFillKindProperty() { super("Menu gutter fill kind"); setLayout(new BorderLayout()); // create sample menu bar with one menu and a few menu items JMenuBar jmb = new JMenuBar(); JMenu menu = new JMenu("menu"); String packageName = MenuGutterFillKindProperty.class.getPackage() .getName(); menu.add(new JMenuItem("test item 1", new ImageIcon( MenuGutterFillKindProperty.class.getClassLoader().getResource( packageName.replace('.', '/') + "/flag_mexico.png")))); menu.add(new JMenuItem("test item 2")); menu.add(new JMenuItem("test item 3")); menu.addSeparator(); menu.add(new JMenuItem("test menu item 4")); menu.add(new JMenuItem("test menu item 5", new ImageIcon( MenuGutterFillKindProperty.class.getClassLoader().getResource( packageName.replace('.', '/') + "/flag_sweden.png")))); menu.add(new JMenuItem("test menu item 6")); jmb.add(menu); setJMenuBar(jmb); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JComboBox menuGutterFillCombo = new JComboBox(new Object[] { MenuGutterFillKind.NONE, MenuGutterFillKind.SOFT, MenuGutterFillKind.HARD, MenuGutterFillKind.SOFT_FILL, MenuGutterFillKind.HARD_FILL }); menuGutterFillCombo.setRenderer(new SubstanceDefaultComboBoxRenderer( menuGutterFillCombo) { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { MenuGutterFillKind mgfk = (MenuGutterFillKind) value; return super.getListCellRendererComponent(list, mgfk.name() .toLowerCase(), index, isSelected, cellHasFocus); } }); menuGutterFillCombo.setSelectedItem(MenuGutterFillKind.HARD); menuGutterFillCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // based on the selected item, set the global menu gutter // fill kind UIManager.put(SubstanceLookAndFeel.MENU_GUTTER_FILL_KIND, menuGutterFillCombo.getSelectedItem()); } }); controls.add(new JLabel("Menu fill")); controls.add(menuGutterFillCombo); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new MenuGutterFillKindProperty().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/PasswordEchoPerChar.java0000644000175000017500000000746311223636702030310 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.BorderLayout; import java.awt.FlowLayout; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#PASSWORD_ECHO_PER_CHAR} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#PASSWORD_ECHO_PER_CHAR */ public class PasswordEchoPerChar extends JFrame { /** * Creates the main frame for this sample. */ public PasswordEchoPerChar() { super("Password echo per char"); this.setLayout(new BorderLayout()); final JPanel panel = new JPanel(new FlowLayout()); this.add(panel, BorderLayout.CENTER); final JPasswordField jpf = new JPasswordField("sample"); jpf.setColumns(20); panel.add(jpf); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JSpinner countSpinner = new JSpinner(); SpinnerNumberModel model = new SpinnerNumberModel(1, 1, 5, 1); countSpinner.setModel(model); countSpinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // set the amount of echo per character based on the current // value in the spinner jpf.putClientProperty( SubstanceLookAndFeel.PASSWORD_ECHO_PER_CHAR, countSpinner.getValue()); jpf.repaint(); } }); controls.add(new JLabel("Echo per char")); controls.add(countSpinner); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new PasswordEchoPerChar().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/TabbedPaneCloseCallback.java0000644000175000017500000001271611223636766031041 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.BorderLayout; import java.awt.event.MouseEvent; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.TabCloseKind; import org.jvnet.substance.api.tabbed.TabCloseCallback; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#TABBED_PANE_CLOSE_CALLBACK} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#TABBED_PANE_CLOSE_CALLBACK */ public class TabbedPaneCloseCallback extends JFrame { /** * Creates the main frame for this sample. */ public TabbedPaneCloseCallback() { super("Tabbed pane close callback"); this.setLayout(new BorderLayout()); // create tabbed pane with a few tabs final JTabbedPane jtp = new JTabbedPane(); String packageName = MenuGutterFillKindProperty.class.getPackage() .getName(); jtp.addTab("First", new ImageIcon(MenuGutterFillKindProperty.class .getClassLoader().getResource( packageName.replace('.', '/') + "/flag_mexico.png")), new JPanel()); jtp.addTab("Second", new ImageIcon(MenuGutterFillKindProperty.class .getClassLoader().getResource( packageName.replace('.', '/') + "/flag_sweden.png")), new JPanel()); jtp .addTab("Third", new ImageIcon(MenuGutterFillKindProperty.class .getClassLoader().getResource( packageName.replace('.', '/') + "/flag_hong_kong.png")), new JPanel()); // mark it to have close buttons on all the tabs jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); this.add(jtp, BorderLayout.CENTER); // create a custom implementation of TabCloseCallback interface. TabCloseCallback closeCallback = new TabCloseCallback() { public TabCloseKind onAreaClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.getButton() != MouseEvent.BUTTON3) return TabCloseKind.NONE; if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } public TabCloseKind onCloseButtonClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.isAltDown()) { return TabCloseKind.ALL_BUT_THIS; } if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) { return null; } public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex) { StringBuffer result = new StringBuffer(); result.append(""); result.append("Mouse click closes " + tabbedPane.getTitleAt(tabIndex) + " tab"); result .append("
Alt-Mouse click closes all tabs but " + tabbedPane.getTitleAt(tabIndex) + " tab"); result.append("
Shift-Mouse click closes all tabs"); result.append(""); return result.toString(); } }; // register the callback on the tabbed pane jtp.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK, closeCallback); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new TabbedPaneCloseCallback().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/UseThemedDefaultIcons.java0000644000175000017500000001024411223637022030611 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.RavenGraphiteSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#USE_THEMED_DEFAULT_ICONS} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#USE_THEMED_DEFAULT_ICONS */ public class UseThemedDefaultIcons extends JFrame { /** * Creates the main frame for this sample. */ public UseThemedDefaultIcons() { super("Use themed default icons"); this.setLayout(new BorderLayout()); final JPanel panel = new JPanel(new FlowLayout()); panel.add(new JButton("cut", new ImageIcon(UseThemedDefaultIcons.class .getResource("/org/jvnet/lafwidget/text/edit-cut.png")))); panel.add(new JButton("copy", new ImageIcon(UseThemedDefaultIcons.class .getResource("/org/jvnet/lafwidget/text/edit-copy.png")))); panel .add(new JButton( "paste", new ImageIcon( UseThemedDefaultIcons.class .getResource("/org/jvnet/lafwidget/text/edit-paste.png")))); this.add(panel, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox useThemedIcons = new JCheckBox("use themed icons"); useThemedIcons.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { // based on the checkbox selection status, set the // property UIManager.put( SubstanceLookAndFeel.USE_THEMED_DEFAULT_ICONS, useThemedIcons.isSelected() ? Boolean.TRUE : null); UseThemedDefaultIcons.this.repaint(); } }); } }); controls.add(useThemedIcons); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new RavenGraphiteSkin()); new UseThemedDefaultIcons().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/ButtonShaperProperty.java0000644000175000017500000000636511223636432030625 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.FlowLayout; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.shaper.StandardButtonShaper; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#BUTTON_SHAPER_PROPERTY} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#BUTTON_SHAPER_PROPERTY */ public class ButtonShaperProperty extends JFrame { /** * Creates the main frame for this sample. */ public ButtonShaperProperty() { super("Middle button uses standard button shaper"); this.setLayout(new FlowLayout()); JButton buttonA = new JButton("a"); JButton buttonB = new JButton("b"); // Mark button to use standard button shaper buttonB.putClientProperty(SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY, new StandardButtonShaper()); JButton buttonC = new JButton("c"); this.add(buttonA); this.add(buttonB); this.add(buttonC); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new ButtonShaperProperty().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/WatermarkVisible.java0000644000175000017500000001176511223637046027717 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import org.jvnet.substance.watermark.SubstanceCrosshatchWatermark; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#WATERMARK_VISIBLE} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#WATERMARK_VISIBLE */ public class WatermarkVisible extends JFrame { /** * Creates the main frame for this sample. */ public WatermarkVisible() { super("Watermark visibility"); this.setLayout(new GridLayout(1, 2)); JPanel listPanel = new JPanel(new BorderLayout()); JPanel coloredPanel = new JPanel(new BorderLayout()); this.add(listPanel); this.add(coloredPanel); // create list with a few values final JList jlist = new JList(new Object[] { "value1", "value2", "value3", "value4" }); listPanel.add(jlist, BorderLayout.CENTER); JPanel listControls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox isListWatermarkVisible = new JCheckBox( "watermark visible"); isListWatermarkVisible.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { // based on checkbox selection, mark the list to // show the watermark jlist.putClientProperty( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean .valueOf(isListWatermarkVisible .isSelected())); repaint(); } }); } }); listControls.add(isListWatermarkVisible); listPanel.add(listControls, BorderLayout.SOUTH); final JPanel colorPanel = new JPanel(); colorPanel.setBackground(new Color(0, 0, 64)); coloredPanel.add(colorPanel, BorderLayout.CENTER); JPanel panelControls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox isPanelWatermarkVisible = new JCheckBox( "watermark visible"); isPanelWatermarkVisible.setSelected(true); isPanelWatermarkVisible.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { // based on checkbox selection, mark the panel to // show the watermark colorPanel.putClientProperty( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean .valueOf(isPanelWatermarkVisible .isSelected())); repaint(); } }); } }); panelControls.add(isPanelWatermarkVisible); coloredPanel.add(panelControls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin() .withWatermark(new SubstanceCrosshatchWatermark())); new WatermarkVisible().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/ComboPopupPrototype.java0000644000175000017500000001145011223636474030450 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.FlowLayout; import java.awt.GridLayout; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.combo.ComboPopupPrototypeCallback; import org.jvnet.substance.api.combo.WidestComboPopupPrototype; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#COMBO_POPUP_PROTOTYPE} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#COMBO_POPUP_PROTOTYPE */ public class ComboPopupPrototype extends JFrame { /** * Creates the main frame for this sample. */ public ComboPopupPrototype() { super("Combo popup prototype"); this.setLayout(new GridLayout(1, 3)); JPanel panel1 = new JPanel(new FlowLayout()); JComboBox comboProto1 = new JComboBox(new Object[] { "aa", "aaaaa", "aaaaaaaaaa", "this one is the one", "abcdefghijklmnopqrstuvwxyz" }); comboProto1.setPrototypeDisplayValue("aaaaa"); // set popup prototype as hard-code value in the model comboProto1.putClientProperty( SubstanceLookAndFeel.COMBO_POPUP_PROTOTYPE, "this one is the one"); panel1.add(new JLabel("Hard-coded value")); panel1.add(comboProto1); this.add(panel1); JPanel panel2 = new JPanel(new FlowLayout()); JComboBox comboProto2 = new JComboBox(new Object[] { "aa", "aaaaa", "aaaaaaaaaa", "another one (not it)", "abcdefghijklmnopqrstuvwxyz" }); comboProto2.setPrototypeDisplayValue("aaaaa"); // set popup prototype as widest value (core implementation of // ComboPopupPrototypeCallback interface) comboProto2.putClientProperty( SubstanceLookAndFeel.COMBO_POPUP_PROTOTYPE, new WidestComboPopupPrototype()); panel2.add(new JLabel("Widest core callback")); panel2.add(comboProto2); this.add(panel2); JPanel panel3 = new JPanel(new FlowLayout()); JComboBox comboProto3 = new JComboBox(new Object[] { "aa", "aaaaa", "this is not", "this one is not it", "this one is it that is for the popup" }); comboProto3.setPrototypeDisplayValue("aaaaa"); // set popup prototype as custom implementation of // ComboPopupPrototypeCallback interface comboProto3.putClientProperty( SubstanceLookAndFeel.COMBO_POPUP_PROTOTYPE, new ComboPopupPrototypeCallback() { public Object getPopupPrototypeDisplayValue(JComboBox jc) { return jc.getModel().getElementAt( jc.getModel().getSize() - 1); } }); panel3.add(new JLabel("Custom callback")); panel3.add(comboProto3); this.add(panel3); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new ComboPopupPrototype().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/TabbedPaneContentBorderKind.java0000644000175000017500000001141411223637000031705 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.TabContentPaneBorderKind; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#TABBED_PANE_CONTENT_BORDER_KIND} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#TABBED_PANE_CONTENT_BORDER_KIND */ public class TabbedPaneContentBorderKind extends JFrame { /** * Creates the main frame for this sample. */ public TabbedPaneContentBorderKind() { super("Tabbed pane content border kind"); this.setLayout(new BorderLayout()); // create tabbed pane with a few tabs final JTabbedPane jtp = new JTabbedPane(); String packageName = MenuGutterFillKindProperty.class.getPackage() .getName(); jtp.addTab("First", new ImageIcon(MenuGutterFillKindProperty.class .getClassLoader().getResource( packageName.replace('.', '/') + "/flag_mexico.png")), new JPanel()); jtp.addTab("Second", new ImageIcon(MenuGutterFillKindProperty.class .getClassLoader().getResource( packageName.replace('.', '/') + "/flag_sweden.png")), new JPanel()); jtp .addTab("Third", new ImageIcon(MenuGutterFillKindProperty.class .getClassLoader().getResource( packageName.replace('.', '/') + "/flag_hong_kong.png")), new JPanel()); this.add(jtp, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JComboBox contentBorderCombo = new JComboBox(new Object[] { TabContentPaneBorderKind.DOUBLE_FULL, TabContentPaneBorderKind.SINGLE_FULL, TabContentPaneBorderKind.DOUBLE_PLACEMENT, TabContentPaneBorderKind.SINGLE_PLACEMENT }); contentBorderCombo .setSelectedItem(TabContentPaneBorderKind.DOUBLE_FULL); contentBorderCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { TabContentPaneBorderKind contentBorderKind = (TabContentPaneBorderKind) contentBorderCombo .getSelectedItem(); jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND, contentBorderKind); jtp.updateUI(); jtp.repaint(); } }); controls.add(new JLabel("Content border kind")); controls.add(contentBorderCombo); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new TabbedPaneContentBorderKind().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/FlatProperty.java0000644000175000017500000000616211223636652027074 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.FlowLayout; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#FLAT_PROPERTY} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#FLAT_PROPERTY */ public class FlatProperty extends JFrame { /** * Creates the main frame for this sample. */ public FlatProperty() { super("Middle button is flat (rollover mouse)"); this.setLayout(new FlowLayout()); JButton buttonA = new JButton("a"); JButton buttonB = new JButton("b"); // mark button to have flat background buttonB.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY, Boolean.TRUE); JButton buttonC = new JButton("c"); this.add(buttonA); this.add(buttonB); this.add(buttonC); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new FlatProperty().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/ButtonNoMinSizeProperty.java0000644000175000017500000000627511223636226031257 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.FlowLayout; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#BUTTON_NO_MIN_SIZE_PROPERTY} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#BUTTON_NO_MIN_SIZE_PROPERTY */ public class ButtonNoMinSizeProperty extends JFrame { /** * Creates the main frame for this sample. */ public ButtonNoMinSizeProperty() { super("Middle button has no min size"); this.setLayout(new FlowLayout()); JButton buttonA = new JButton("a"); JButton buttonB = new JButton("b"); // mark button to have no default minimum size buttonB.putClientProperty( SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE); JButton buttonC = new JButton("c"); this.add(buttonA); this.add(buttonB); this.add(buttonC); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new ButtonNoMinSizeProperty().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/flag_hong_kong.png0000644000175000017500000000126310520765374027246 0ustar drazzibdrazzibPNG  IHDRa*tEXtCreation TimeFr 2 Apr 2004 14:29:09 +0100stIME ? pHYs B4gAMA a IDATxœkAǿb Q<,ԓm)A? WOBoE/=DAJ(B6d7ݙy㛷?谓y},pMlFNzGYg 91K r(2ms#/`ڍADQ%W#PcގW8>ÉKybBmŽG(_ݾI攙mR0xˠ![XA}s5@ J܄Hi%uCdKw@?0>_{Í.]NB 2>"y-v)v5\yw&X6>Gf6j_h!N"~r ,XPXxB1ʮ==^Gu5Еkx>x58|lASD;{s7qn*:;.>rS{58FԽ!\F/@ڈ>¸2 O  ($Bod_@WwYG'EuzTD;6J|Mg.?j^xTIENDB`substance-5.3.orig/src/test/samples/substance/clientprop/ScrollPaneButtonsPolicy.java0000644000175000017500000001133311223636714031235 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.ScrollPaneButtonPolicyKind; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#SCROLL_PANE_BUTTONS_POLICY} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#SCROLL_PANE_BUTTONS_POLICY */ public class ScrollPaneButtonsPolicy extends JFrame { /** * Creates the main frame for this sample. */ public ScrollPaneButtonsPolicy() { super("Scroll pane buttons policy"); this.setLayout(new BorderLayout()); // Create panel with custom painting logic - simple // diagonal fill. JPanel samplePanel = new JPanel() { @Override protected void paintComponent(Graphics g) { Graphics2D graphics = (Graphics2D) g.create(); graphics .setPaint(new GradientPaint(0, 0, new Color(100, 100, 255), getWidth(), getHeight(), new Color(255, 100, 100))); graphics.fillRect(0, 0, getWidth(), getHeight()); graphics.dispose(); } }; samplePanel.setPreferredSize(new Dimension(800, 250)); samplePanel.setSize(this.getPreferredSize()); samplePanel.setMinimumSize(this.getPreferredSize()); final JScrollPane scrollPane = new JScrollPane(samplePanel); this.add(scrollPane, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JComboBox buttonsPolicyCombo = new JComboBox(new Object[] { ScrollPaneButtonPolicyKind.NONE, ScrollPaneButtonPolicyKind.OPPOSITE, ScrollPaneButtonPolicyKind.ADJACENT, ScrollPaneButtonPolicyKind.MULTIPLE, ScrollPaneButtonPolicyKind.MULTIPLE_BOTH }); buttonsPolicyCombo.setSelectedItem(ScrollPaneButtonPolicyKind.OPPOSITE); buttonsPolicyCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // set the selected button policy kind on the scroll pane ScrollPaneButtonPolicyKind buttonPolicy = (ScrollPaneButtonPolicyKind) buttonsPolicyCombo .getSelectedItem(); scrollPane.putClientProperty( SubstanceLookAndFeel.SCROLL_PANE_BUTTONS_POLICY, buttonPolicy); scrollPane.repaint(); } }); controls.add(new JLabel("Buttons policy")); controls.add(buttonsPolicyCombo); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new ScrollPaneButtonsPolicy().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/ShowExtraWidgets.java0000644000175000017500000000754611223636724027723 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#SHOW_EXTRA_WIDGETS} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#SHOW_EXTRA_WIDGETS */ public class ShowExtraWidgets extends JFrame { /** * Creates the main frame for this sample. */ public ShowExtraWidgets() { super("Show extra widgets"); this.setLayout(new BorderLayout()); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox showExtraWidgets = new JCheckBox("show extra widgets"); showExtraWidgets.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { // based on the checkbox selection status, set the // property UIManager.put(SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS, Boolean.valueOf(showExtraWidgets.isSelected())); SwingUtilities .updateComponentTreeUI(ShowExtraWidgets.this); } }); } }); controls.add(showExtraWidgets); this.add(controls, BorderLayout.SOUTH); JPanel centerPanel = new JPanel(new FlowLayout()); JTextField readOnlyTextField = new JTextField("read-only"); readOnlyTextField.setEditable(false); centerPanel.add(readOnlyTextField); this.add(centerPanel, BorderLayout.CENTER); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new ShowExtraWidgets().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/ButtonOpenSideProperty.java0000644000175000017500000001123311223636360031077 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.FlowLayout; import java.util.EnumSet; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants; import org.jvnet.substance.api.SubstanceConstants.Side; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#BUTTON_OPEN_SIDE_PROPERTY} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#BUTTON_OPEN_SIDE_PROPERTY */ public class ButtonOpenSideProperty extends JFrame { /** * Creates the main frame for this sample. */ public ButtonOpenSideProperty() { super("Buttons with open sides"); this.setLayout(new FlowLayout()); JButton buttonA = new JButton("left only"); // mark button to have open and straight left side // using side constant buttonA.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, SubstanceConstants.Side.LEFT); buttonA.putClientProperty( SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, SubstanceConstants.Side.LEFT); JButton buttonB = new JButton("right only"); // mark button to have open and straight right side using side constant buttonB.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, SubstanceConstants.Side.RIGHT); buttonB.putClientProperty( SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, SubstanceConstants.Side.RIGHT); JButton buttonC = new JButton("left+top"); // mark button to have open and straight left and top sides // using set of side constants EnumSet leftTopSides = EnumSet.of(SubstanceConstants.Side.LEFT, SubstanceConstants.Side.TOP); buttonC.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, leftTopSides); buttonC.putClientProperty( SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, leftTopSides); JButton buttonD = new JButton("right+bottom"); // mark button to have open and straight right and bottom sides // using set of side constants EnumSet rightBottomSides = EnumSet.of( SubstanceConstants.Side.RIGHT, SubstanceConstants.Side.BOTTOM); buttonD.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, rightBottomSides); buttonD.putClientProperty( SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightBottomSides); this.add(buttonA); this.add(buttonB); this.add(buttonC); this.add(buttonD); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new ButtonOpenSideProperty().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/ButtonSideProperty.java0000644000175000017500000001002511223636442030254 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.FlowLayout; import java.util.EnumSet; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#BUTTON_SIDE_PROPERTY} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#BUTTON_SIDE_PROPERTY */ public class ButtonSideProperty extends JFrame { /** * Creates the main frame for this sample. */ public ButtonSideProperty() { super("Buttons with straight sides"); this.setLayout(new FlowLayout()); JButton buttonA = new JButton("left only"); // Mark button to have straight left side // using side constant buttonA.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, SubstanceConstants.Side.LEFT); JButton buttonB = new JButton("right only"); // Mark button to have straight right side // using side constant buttonB.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, SubstanceConstants.Side.RIGHT); JButton buttonC = new JButton("left+top"); // Mark button to have straight left and top sides // using set of side constants buttonC.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, EnumSet.of(SubstanceConstants.Side.LEFT, SubstanceConstants.Side.TOP)); JButton buttonD = new JButton("right+bottom"); // Mark button to have straight right and bottom sides // using set of side constants buttonD.putClientProperty(SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, EnumSet.of(SubstanceConstants.Side.RIGHT, SubstanceConstants.Side.BOTTOM)); this.add(buttonA); this.add(buttonB); this.add(buttonC); this.add(buttonD); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new ButtonSideProperty().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/flag_sweden.png0000644000175000017500000000116710520765376026567 0ustar drazzibdrazzibPNG  IHDRa*tEXtCreation TimeFr 2 Apr 2004 10:50:39 +0100> tIME3*;1g pHYs B4gAMA aIDATxSNA;N"",Zr`K82B ,H+#$ıDZ3T+MlWz~n8#D`af46|_%H|i"Pݔ}3(X~܅`u G\5Bɉa32:O#3ȻIdq EV%3P m)Iٸ;ˇ>.22bmp%BB, [^_d`'o,s塹k%#aHßzmkӌ  ꕀ1U$ҽ;kyz['yl޿gI, RY: ALVL"4)Klx#_ƪv ڷ$H͔{2*t&HYedo3%qtԳupWGE])QY;-Dw Yx4IENDB`substance-5.3.orig/src/test/samples/substance/clientprop/ComboBoxPopupFlyoutOrientation.java0000644000175000017500000001144611223636464032616 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#COMBO_BOX_POPUP_FLYOUT_ORIENTATION} client * property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#COMBO_BOX_POPUP_FLYOUT_ORIENTATION */ public class ComboBoxPopupFlyoutOrientation extends JFrame { /** * Creates the main frame for this sample. */ public ComboBoxPopupFlyoutOrientation() { super("Combobox popup flyout orientation"); this.setLayout(new BorderLayout()); final JComboBox cb = new JComboBox(new Object[] { "Ester", "Jordi", "Jordina", "Jorge", "Sergi" }); JPanel main = new JPanel(new FlowLayout(FlowLayout.CENTER)); this.add(main, BorderLayout.CENTER); main.add(cb); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JComboBox flyoutCombo = new JComboBox(new Object[] { "default", "center", "north", "east", "west", "south" }); flyoutCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Object selected = flyoutCombo.getSelectedItem(); // set popup flyout orientation based on the selected // item if ("default".equals(selected)) cb .putClientProperty( SubstanceLookAndFeel.COMBO_BOX_POPUP_FLYOUT_ORIENTATION, null); if ("center".equals(selected)) cb .putClientProperty( SubstanceLookAndFeel.COMBO_BOX_POPUP_FLYOUT_ORIENTATION, SwingConstants.CENTER); if ("north".equals(selected)) cb .putClientProperty( SubstanceLookAndFeel.COMBO_BOX_POPUP_FLYOUT_ORIENTATION, SwingConstants.NORTH); if ("east".equals(selected)) cb .putClientProperty( SubstanceLookAndFeel.COMBO_BOX_POPUP_FLYOUT_ORIENTATION, SwingConstants.EAST); if ("west".equals(selected)) cb .putClientProperty( SubstanceLookAndFeel.COMBO_BOX_POPUP_FLYOUT_ORIENTATION, SwingConstants.WEST); if ("south".equals(selected)) cb .putClientProperty( SubstanceLookAndFeel.COMBO_BOX_POPUP_FLYOUT_ORIENTATION, SwingConstants.SOUTH); } }); controls.add(new JLabel("Combo popup flyout orientation")); controls.add(flyoutCombo); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new ComboBoxPopupFlyoutOrientation().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/clientprop/CornerRadius.java0000644000175000017500000000716611223636640027043 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.clientprop; import java.awt.BorderLayout; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#CORNER_RADIUS} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#CORNER_RADIUS */ public class CornerRadius extends JFrame { /** * Creates the main frame for this sample. */ public CornerRadius() { super("Toolbar button corner radius"); this.setLayout(new BorderLayout()); JToolBar toolBar = new JToolBar(""); toolBar.add(new JLabel("Sample toolbar")); toolBar.add(new JSeparator(SwingConstants.VERTICAL)); JToggleButton buttonDefault = new JToggleButton("radius default"); buttonDefault.setSelected(true); toolBar.add(buttonDefault); JToggleButton button1 = new JToggleButton("radius 5"); // set corner radius to 5 pixels button1.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, Float .valueOf(5.0f)); button1.setSelected(true); toolBar.add(button1); JToggleButton button2 = new JToggleButton("radius 0"); // set corner radius to 0 pixels (perfect rectangle) button2.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, Float .valueOf(0.0f)); button2.setSelected(true); toolBar.add(button2); this.add(toolBar, BorderLayout.NORTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new CornerRadius().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/0000755000175000017500000000000011256731162022161 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/samples/substance/api/SetSkin_ClassName.java0000644000175000017500000000700511223636122026326 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#setSkin(String)} API. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#setSkin(String) */ public class SetSkin_ClassName extends JFrame { /** * Creates the main frame for this sample. */ public SetSkin_ClassName() { super("Set skin"); this.setLayout(new BorderLayout()); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JButton changeSkin = new JButton("Change skin"); changeSkin.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { changeSkin.setEnabled(false); // set new skin by class name SubstanceLookAndFeel .setSkin("org.jvnet.substance.skin.BusinessSkin"); repaint(); } }); } }); controls.add(changeSkin); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new SetSkin_ClassName().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/GetAllTabCloseListeners_Specific.java0000644000175000017500000001207011223635370031305 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Set; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.tabbed.TabCloseListener; import org.jvnet.substance.api.tabbed.VetoableMultipleTabCloseListener; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import test.Check; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#getAllTabCloseListeners(JTabbedPane)} API. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#getAllTabCloseListeners(JTabbedPane) */ public class GetAllTabCloseListeners_Specific extends JFrame { /** * Creates the main frame for this sample. */ public GetAllTabCloseListeners_Specific() { super("Get all tab close listeners"); this.setLayout(new BorderLayout()); final JTabbedPane jtp = new JTabbedPane(); jtp.addTab("tab1", Check.getIcon("flag_sweden"), new JPanel()); jtp.addTab("tab2", Check.getIcon("flag_mexico"), new JPanel()); jtp.addTab("tab3", Check.getIcon("flag_hong_kong"), new JPanel()); jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); SubstanceLookAndFeel.registerTabCloseChangeListener(null, new TabCloseListener() { public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) { System.out.println("Tab closing"); } public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) { System.out.println("Tab closed"); } }); SubstanceLookAndFeel.registerTabCloseChangeListener(jtp, new VetoableMultipleTabCloseListener() { public void tabsClosed(JTabbedPane tabbedPane, Set tabComponents) { System.out.println("Tabs closed"); } public void tabsClosing(JTabbedPane tabbedPane, Set tabComponents) { System.out.println("Tabs closing"); } public boolean vetoTabsClosing(JTabbedPane tabbedPane, Set tabComponents) { System.out.println("Vetoing tabs closing"); return true; } }); this.add(jtp, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton getTabCloseListeners = new JButton("Get tab close listeners"); getTabCloseListeners.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( GetAllTabCloseListeners_Specific.this, SubstanceLookAndFeel.getAllTabCloseListeners(jtp) .size() + " specific tab close listeners registered"); } }); controls.add(getTabCloseListeners); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new GetAllTabCloseListeners_Specific().setVisible(true); } }); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootsubstance-5.3.orig/src/test/samples/substance/api/RegisterTabCloseChangeListener_GeneralMultiple.javasubstance-5.3.orig/src/test/samples/substance/api/RegisterTabCloseChangeListener_GeneralMultiple.jav0000644000175000017500000001411511223635750034053 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.MouseEvent; import java.util.Set; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.TabCloseKind; import org.jvnet.substance.api.tabbed.MultipleTabCloseListener; import org.jvnet.substance.api.tabbed.TabCloseCallback; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import test.Check; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#registerTabCloseChangeListener(org.jvnet.substance.tabbed.BaseTabCloseListener)} * API with registering a tab close listener that listens on multiple tab * closing on a specific tabbed pane. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#registerTabCloseChangeListener(org.jvnet.substance.tabbed.BaseTabCloseListener) */ public class RegisterTabCloseChangeListener_GeneralMultiple extends JFrame { /** * Creates the main frame for this sample. */ public RegisterTabCloseChangeListener_GeneralMultiple() { super("Register tab close listener"); this.setLayout(new BorderLayout()); final JTabbedPane jtp = new JTabbedPane(); jtp.addTab("tab1", Check.getIcon("flag_sweden"), new JPanel()); jtp.addTab("tab2", Check.getIcon("flag_mexico"), new JPanel()); jtp.addTab("tab3", Check.getIcon("flag_hong_kong"), new JPanel()); jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); // create a custom implementation of TabCloseCallback interface. TabCloseCallback closeCallback = new TabCloseCallback() { public TabCloseKind onAreaClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.getButton() != MouseEvent.BUTTON3) return TabCloseKind.NONE; if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } public TabCloseKind onCloseButtonClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.isAltDown()) { return TabCloseKind.ALL_BUT_THIS; } if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) { return null; } public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex) { StringBuffer result = new StringBuffer(); result.append(""); result.append("Mouse click closes " + tabbedPane.getTitleAt(tabIndex) + " tab"); result .append("
Alt-Mouse click closes all tabs but " + tabbedPane.getTitleAt(tabIndex) + " tab"); result.append("
Shift-Mouse click closes all tabs"); result.append(""); return result.toString(); } }; // register the callback on the tabbed pane jtp.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK, closeCallback); // register tab close listener on all tabbed panes. SubstanceLookAndFeel .registerTabCloseChangeListener(new MultipleTabCloseListener() { public void tabsClosing(JTabbedPane tabbedPane, Set tabComponents) { StringBuffer sb = new StringBuffer("Tab (s)"); String sep = " ["; for (Component comp : tabComponents) { sb.append(sep); sep = ", "; sb.append(tabbedPane.getTitleAt(tabbedPane .indexOfComponent(comp))); } sb.append("] closing"); System.out.println(sb.toString()); } public void tabsClosed(JTabbedPane tabbedPane, Set tabComponents) { System.out.println(tabComponents.size() + " tab(s) closed"); } }); this.add(jtp, BorderLayout.CENTER); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new RegisterTabCloseChangeListener_GeneralMultiple() .setVisible(true); } }); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootsubstance-5.3.orig/src/test/samples/substance/api/RegisterTabCloseChangeListener_SpecificSingle.javasubstance-5.3.orig/src/test/samples/substance/api/RegisterTabCloseChangeListener_SpecificSingle.java0000644000175000017500000001026611223636042034010 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.Component; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.tabbed.TabCloseListener; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import test.Check; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#registerTabCloseChangeListener(JTabbedPane, org.jvnet.substance.tabbed.BaseTabCloseListener)} * API with registering a tab close listener that listens on single tab closing * on a specific tabbed pane. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#registerTabCloseChangeListener(JTabbedPane, * org.jvnet.substance.tabbed.BaseTabCloseListener) */ public class RegisterTabCloseChangeListener_SpecificSingle extends JFrame { /** * Creates the main frame for this sample. */ public RegisterTabCloseChangeListener_SpecificSingle() { super("Register tab close listener"); this.setLayout(new BorderLayout()); final JTabbedPane jtp = new JTabbedPane(); jtp.addTab("tab1", Check.getIcon("flag_sweden"), new JPanel()); jtp.addTab("tab2", Check.getIcon("flag_mexico"), new JPanel()); jtp.addTab("tab3", Check.getIcon("flag_hong_kong"), new JPanel()); jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); // register tab close listener on the specific tabbed pane. SubstanceLookAndFeel.registerTabCloseChangeListener(jtp, new TabCloseListener() { public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) { System.out.println("Tab " + tabbedPane.getTitleAt(tabbedPane .indexOfComponent(tabComponent)) + " closing"); } public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) { System.out.println("Tab closed"); } }); this.add(jtp, BorderLayout.CENTER); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new RegisterTabCloseChangeListener_SpecificSingle() .setVisible(true); } }); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootsubstance-5.3.orig/src/test/samples/substance/api/RegisterTabCloseChangeListener_SpecificSingleVetoable.javasubstance-5.3.orig/src/test/samples/substance/api/RegisterTabCloseChangeListener_SpecificSingleVetoa0000644000175000017500000001132111223636056034065 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.Component; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.tabbed.VetoableTabCloseListener; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import test.Check; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#registerTabCloseChangeListener(JTabbedPane, org.jvnet.substance.tabbed.BaseTabCloseListener)} * API with registering a vetoable tab close listener that listens on single tab * closing on a specific tabbed pane. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#registerTabCloseChangeListener(JTabbedPane, * org.jvnet.substance.tabbed.BaseTabCloseListener) */ public class RegisterTabCloseChangeListener_SpecificSingleVetoable extends JFrame { /** * Creates the main frame for this sample. */ public RegisterTabCloseChangeListener_SpecificSingleVetoable() { super("Register tab close listener"); this.setLayout(new BorderLayout()); final JTabbedPane jtp = new JTabbedPane(); jtp.addTab("tab1", Check.getIcon("flag_sweden"), new JPanel()); jtp.addTab("tab2", Check.getIcon("flag_mexico"), new JPanel()); jtp.addTab("tab3", Check.getIcon("flag_hong_kong"), new JPanel()); jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); // register tab close listener on the specific tabbed pane. SubstanceLookAndFeel.registerTabCloseChangeListener(jtp, new VetoableTabCloseListener() { public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) { System.out.println("Tab " + tabbedPane.getTitleAt(tabbedPane .indexOfComponent(tabComponent)) + " closing"); } public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) { System.out.println("Tab closed"); } public boolean vetoTabClosing(JTabbedPane tabbedPane, Component tabComponent) { return (JOptionPane .showConfirmDialog( RegisterTabCloseChangeListener_SpecificSingleVetoable.this, "Are you sure you want to close " + tabbedPane .getTitleAt(tabbedPane .indexOfComponent(tabComponent)) + "?") != JOptionPane.YES_OPTION); } }); this.add(jtp, BorderLayout.CENTER); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new RegisterTabCloseChangeListener_SpecificSingleVetoable() .setVisible(true); } }); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootsubstance-5.3.orig/src/test/samples/substance/api/RegisterTabCloseChangeListener_GeneralMultipleVetoable.javasubstance-5.3.orig/src/test/samples/substance/api/RegisterTabCloseChangeListener_GeneralMultipleVeto0000644000175000017500000001545011223635762034140 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.MouseEvent; import java.util.Set; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.TabCloseKind; import org.jvnet.substance.api.tabbed.TabCloseCallback; import org.jvnet.substance.api.tabbed.VetoableMultipleTabCloseListener; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import test.Check; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#registerTabCloseChangeListener(org.jvnet.substance.tabbed.BaseTabCloseListener)} * API with registering a vetoable tab close listener that listens on multiple * tab closing on a specific tabbed pane. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#registerTabCloseChangeListener(org.jvnet.substance.tabbed.BaseTabCloseListener) */ public class RegisterTabCloseChangeListener_GeneralMultipleVetoable extends JFrame { /** * Creates the main frame for this sample. */ public RegisterTabCloseChangeListener_GeneralMultipleVetoable() { super("Register tab close listener"); this.setLayout(new BorderLayout()); final JTabbedPane jtp = new JTabbedPane(); jtp.addTab("tab1", Check.getIcon("flag_sweden"), new JPanel()); jtp.addTab("tab2", Check.getIcon("flag_mexico"), new JPanel()); jtp.addTab("tab3", Check.getIcon("flag_hong_kong"), new JPanel()); jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); // create a custom implementation of TabCloseCallback interface. TabCloseCallback closeCallback = new TabCloseCallback() { public TabCloseKind onAreaClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.getButton() != MouseEvent.BUTTON3) return TabCloseKind.NONE; if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } public TabCloseKind onCloseButtonClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.isAltDown()) { return TabCloseKind.ALL_BUT_THIS; } if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) { return null; } public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex) { StringBuffer result = new StringBuffer(); result.append(""); result.append("Mouse click closes " + tabbedPane.getTitleAt(tabIndex) + " tab"); result .append("
Alt-Mouse click closes all tabs but " + tabbedPane.getTitleAt(tabIndex) + " tab"); result.append("
Shift-Mouse click closes all tabs"); result.append(""); return result.toString(); } }; // register the callback on the tabbed pane jtp.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK, closeCallback); // register tab close listener on all tabbed panes. SubstanceLookAndFeel .registerTabCloseChangeListener(new VetoableMultipleTabCloseListener() { public void tabsClosing(JTabbedPane tabbedPane, Set tabComponents) { StringBuffer sb = new StringBuffer("Tab (s)"); String sep = " ["; for (Component comp : tabComponents) { sb.append(sep); sep = ", "; sb.append(tabbedPane.getTitleAt(tabbedPane .indexOfComponent(comp))); } sb.append("] closing"); System.out.println(sb.toString()); } public void tabsClosed(JTabbedPane tabbedPane, Set tabComponents) { System.out.println(tabComponents.size() + " tab(s) closed"); } public boolean vetoTabsClosing(JTabbedPane tabbedPane, Set tabComponents) { StringBuffer sb = new StringBuffer(""); String sep = "["; for (Component comp : tabComponents) { sb.append(sep); sep = ", "; sb.append(tabbedPane.getTitleAt(tabbedPane .indexOfComponent(comp))); } sb.append("]"); return (JOptionPane .showConfirmDialog( RegisterTabCloseChangeListener_GeneralMultipleVetoable.this, "Are you sure you want to close " + sb.toString() + "?") != JOptionPane.YES_OPTION); } }); this.add(jtp, BorderLayout.CENTER); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new RegisterTabCloseChangeListener_GeneralMultipleVetoable() .setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/GetAllSkins.java0000644000175000017500000000712711223635074025212 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.*; import java.util.Vector; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.renderers.SubstanceDefaultComboBoxRenderer; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import org.jvnet.substance.skin.SkinInfo; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#getAllSkins()} API. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#getAllSkins() */ public class GetAllSkins extends JFrame { /** * Creates the main frame for this sample. */ public GetAllSkins() { super("Get all skins"); setLayout(new BorderLayout()); final JPanel panel = new JPanel(new FlowLayout()); // Get all skins and set the vector as a model // for combobox. final JComboBox cb = new JComboBox(new Vector( SubstanceLookAndFeel.getAllSkins().values())); cb.setRenderer(new SubstanceDefaultComboBoxRenderer(cb) { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { SkinInfo si = (SkinInfo) value; return super.getListCellRendererComponent(list, si .getDisplayName(), index, isSelected, cellHasFocus); } }); panel.add(new JLabel("All skins:")); panel.add(cb); this.add(panel, BorderLayout.CENTER); this.setSize(400, 200); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new GetAllSkins().setVisible(true); } }); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootsubstance-5.3.orig/src/test/samples/substance/api/RegisterTabCloseChangeListener_SpecificMultipleVetoable.javasubstance-5.3.orig/src/test/samples/substance/api/RegisterTabCloseChangeListener_SpecificMultipleVet0000644000175000017500000001553311223636030034120 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.MouseEvent; import java.util.Set; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.TabCloseKind; import org.jvnet.substance.api.tabbed.TabCloseCallback; import org.jvnet.substance.api.tabbed.VetoableMultipleTabCloseListener; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import test.Check; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#registerTabCloseChangeListener(JTabbedPane, org.jvnet.substance.tabbed.BaseTabCloseListener)} * API with registering a vetoable tab close listener that listens on multiple * tab closing on a specific tabbed pane. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#registerTabCloseChangeListener(JTabbedPane, * org.jvnet.substance.tabbed.BaseTabCloseListener) */ public class RegisterTabCloseChangeListener_SpecificMultipleVetoable extends JFrame { /** * Creates the main frame for this sample. */ public RegisterTabCloseChangeListener_SpecificMultipleVetoable() { super("Register tab close listener"); this.setLayout(new BorderLayout()); final JTabbedPane jtp = new JTabbedPane(); jtp.addTab("tab1", Check.getIcon("flag_sweden"), new JPanel()); jtp.addTab("tab2", Check.getIcon("flag_mexico"), new JPanel()); jtp.addTab("tab3", Check.getIcon("flag_hong_kong"), new JPanel()); jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); // create a custom implementation of TabCloseCallback interface. TabCloseCallback closeCallback = new TabCloseCallback() { public TabCloseKind onAreaClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.getButton() != MouseEvent.BUTTON3) return TabCloseKind.NONE; if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } public TabCloseKind onCloseButtonClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.isAltDown()) { return TabCloseKind.ALL_BUT_THIS; } if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) { return null; } public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex) { StringBuffer result = new StringBuffer(); result.append(""); result.append("Mouse click closes " + tabbedPane.getTitleAt(tabIndex) + " tab"); result .append("
Alt-Mouse click closes all tabs but " + tabbedPane.getTitleAt(tabIndex) + " tab"); result.append("
Shift-Mouse click closes all tabs"); result.append(""); return result.toString(); } }; // register the callback on the tabbed pane jtp.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK, closeCallback); // register tab close listener on the specific tabbed pane. SubstanceLookAndFeel.registerTabCloseChangeListener(jtp, new VetoableMultipleTabCloseListener() { public void tabsClosing(JTabbedPane tabbedPane, Set tabComponents) { StringBuffer sb = new StringBuffer("Tab (s)"); String sep = " ["; for (Component comp : tabComponents) { sb.append(sep); sep = ", "; sb.append(tabbedPane.getTitleAt(tabbedPane .indexOfComponent(comp))); } sb.append("] closing"); System.out.println(sb.toString()); } public void tabsClosed(JTabbedPane tabbedPane, Set tabComponents) { System.out.println(tabComponents.size() + " tab(s) closed"); } public boolean vetoTabsClosing(JTabbedPane tabbedPane, Set tabComponents) { StringBuffer sb = new StringBuffer(""); String sep = "["; for (Component comp : tabComponents) { sb.append(sep); sep = ", "; sb.append(tabbedPane.getTitleAt(tabbedPane .indexOfComponent(comp))); } sb.append("]"); return (JOptionPane .showConfirmDialog( RegisterTabCloseChangeListener_SpecificMultipleVetoable.this, "Are you sure you want to close " + sb.toString() + "?") != JOptionPane.YES_OPTION); } }); this.add(jtp, BorderLayout.CENTER); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new RegisterTabCloseChangeListener_SpecificMultipleVetoable() .setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/GetDecorationType.java0000644000175000017500000001104011223635416026410 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#getDecorationType(java.awt.Component)} API called * on different components. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#getDecorationType(java.awt.Component) */ public class GetDecorationType extends JFrame { /** * Creates the main frame for this sample. */ public GetDecorationType() { super("Get decoration type"); this.setLayout(new BorderLayout()); final JTabbedPane tabs = new JTabbedPane(); SubstanceLookAndFeel.setDecorationType(tabs, DecorationAreaType.HEADER); JPanel tab1 = new JPanel(new FlowLayout()); tab1.add(new JTextField("sample")); final JComboBox combo = new JComboBox(new Object[] { "sample" }); tab1.add(combo); SubstanceLookAndFeel.setDecorationType(tab1, DecorationAreaType.NONE); JPanel tab2 = new JPanel(new FlowLayout()); tab2.add(new JTextField("sample2")); tab2.add(new JComboBox(new Object[] { "sample2" })); SubstanceLookAndFeel.setDecorationType(tab2, DecorationAreaType.NONE); tabs.addTab("tab1", tab1); tabs.addTab("tab2", tab2); this.add(tabs, BorderLayout.CENTER); JPanel controlPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton getTypes = new JButton("Get types"); getTypes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { DecorationAreaType tabsType = SubstanceLookAndFeel .getDecorationType(tabs); DecorationAreaType comboType = SubstanceLookAndFeel .getDecorationType(combo); JOptionPane.showMessageDialog(GetDecorationType.this, "Tabbed pane: " + tabsType.name() + "\n" + "Combo box: " + comboType.name()); } }); } }); controlPanel.add(getTypes); this.add(controlPanel, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new GetDecorationType().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/SetDecorationTypeMix.java0000644000175000017500000000727611223636076027125 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.FlowLayout; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#setDecorationType(JComponent, DecorationAreaType)} * API called on different components. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#setDecorationType(JComponent, DecorationAreaType) */ public class SetDecorationTypeMix extends JFrame { /** * Creates the main frame for this sample. */ public SetDecorationTypeMix() { super("Mix decoration types"); this.setLayout(new BorderLayout()); JTabbedPane tabs = new JTabbedPane(); SubstanceLookAndFeel.setDecorationType(tabs, DecorationAreaType.HEADER); JPanel tab1 = new JPanel(new FlowLayout()); tab1.add(new JTextField("sample")); tab1.add(new JComboBox(new Object[] { "sample" })); SubstanceLookAndFeel.setDecorationType(tab1, DecorationAreaType.NONE); JPanel tab2 = new JPanel(new FlowLayout()); tab2.add(new JTextField("sample2")); tab2.add(new JComboBox(new Object[] { "sample2" })); SubstanceLookAndFeel.setDecorationType(tab2, DecorationAreaType.NONE); tabs.addTab("tab1", tab1); tabs.addTab("tab2", tab2); this.add(tabs, BorderLayout.CENTER); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new SetDecorationTypeMix().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/RegisterTabCloseChangeListener_GeneralSingle.java0000644000175000017500000001020411223635774033643 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.Component; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.tabbed.TabCloseListener; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import test.Check; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#registerTabCloseChangeListener(org.jvnet.substance.tabbed.BaseTabCloseListener)} * API with registering a tab close listener that listens on single tab closing * on a specific tabbed pane. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#registerTabCloseChangeListener(org.jvnet.substance.tabbed.BaseTabCloseListener) */ public class RegisterTabCloseChangeListener_GeneralSingle extends JFrame { /** * Creates the main frame for this sample. */ public RegisterTabCloseChangeListener_GeneralSingle() { super("Register tab close listener"); this.setLayout(new BorderLayout()); final JTabbedPane jtp = new JTabbedPane(); jtp.addTab("tab1", Check.getIcon("flag_sweden"), new JPanel()); jtp.addTab("tab2", Check.getIcon("flag_mexico"), new JPanel()); jtp.addTab("tab3", Check.getIcon("flag_hong_kong"), new JPanel()); jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); // register tab close listener on all tabbed panes. SubstanceLookAndFeel .registerTabCloseChangeListener(new TabCloseListener() { public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) { System.out.println("Tab " + tabbedPane.getTitleAt(tabbedPane .indexOfComponent(tabComponent)) + " closing"); } public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) { System.out.println("Tab closed"); } }); this.add(jtp, BorderLayout.CENTER); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new RegisterTabCloseChangeListener_GeneralSingle() .setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/SetSkin_Instance.java0000644000175000017500000000712411223636132026227 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import org.jvnet.substance.skin.BusinessSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#setSkin(org.jvnet.substance.skin.SubstanceSkin)} * API. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#setSkin(org.jvnet.substance.skin.SubstanceSkin) */ public class SetSkin_Instance extends JFrame { /** * Creates the main frame for this sample. */ public SetSkin_Instance() { super("Set skin"); this.setLayout(new BorderLayout()); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JButton changeSkin = new JButton("Change skin"); changeSkin.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { changeSkin.setEnabled(false); // set new skin by instance SubstanceLookAndFeel.setSkin(new BusinessSkin()); repaint(); } }); } }); controls.add(changeSkin); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new SetSkin_Instance().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/SetFontPolicy.java0000644000175000017500000001517111223636110025562 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.*; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.FontUIResource; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.fonts.FontPolicy; import org.jvnet.substance.fonts.FontSet; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#setFontPolicy(FontPolicy)} API. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#setFontPolicy(FontPolicy) */ public class SetFontPolicy extends JFrame { /** * Wrapper around the base Substance font set. Is used to create larger / * smaller font sets. * * @author Kirill Grouchnikov */ private static class WrapperFontSet implements FontSet { /** * Extra size in pixels. Can be positive or negative. */ private int extra; /** * The base Substance font set. */ private FontSet delegate; /** * Creates a wrapper font set. * * @param delegate * The base Substance font set. * @param extra * Extra size in pixels. Can be positive or negative. */ public WrapperFontSet(FontSet delegate, int extra) { super(); this.delegate = delegate; this.extra = extra; } /** * Returns the wrapped font. * * @param systemFont * Original font. * @return Wrapped font. */ private FontUIResource getWrappedFont(FontUIResource systemFont) { return new FontUIResource(systemFont.getFontName(), systemFont .getStyle(), systemFont.getSize() + this.extra); } public FontUIResource getControlFont() { return this.getWrappedFont(this.delegate.getControlFont()); } public FontUIResource getMenuFont() { return this.getWrappedFont(this.delegate.getMenuFont()); } public FontUIResource getMessageFont() { return this.getWrappedFont(this.delegate.getMessageFont()); } public FontUIResource getSmallFont() { return this.getWrappedFont(this.delegate.getSmallFont()); } public FontUIResource getTitleFont() { return this.getWrappedFont(this.delegate.getTitleFont()); } public FontUIResource getWindowTitleFont() { return this.getWrappedFont(this.delegate.getWindowTitleFont()); } } /** * Creates the main frame for this sample. */ public SetFontPolicy() { super("Set font policy"); this.setLayout(new BorderLayout()); JPanel panel = new JPanel(new FlowLayout()); // create a slider to control the font size. final JSlider fontSizeSlider = new JSlider(-3, 3, 0); fontSizeSlider.setPaintLabels(true); fontSizeSlider.setMajorTickSpacing(1); fontSizeSlider.setToolTipText("Controls the global font set size"); fontSizeSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // if the value is adjusting - ignore. This is done // to make CPU usage better. if (!fontSizeSlider.getModel().getValueIsAdjusting()) { final int newValue = fontSizeSlider.getValue(); SwingUtilities.invokeLater(new Runnable() { public void run() { // reset the base font policy to null - this // restores the original font policy (default size). SubstanceLookAndFeel.setFontPolicy(null); // Get the default font set final FontSet substanceCoreFontSet = SubstanceLookAndFeel .getFontPolicy().getFontSet("Substance", null); // Create the wrapper font set FontPolicy newFontPolicy = new FontPolicy() { public FontSet getFontSet(String lafName, UIDefaults table) { return new WrapperFontSet( substanceCoreFontSet, newValue); } }; try { SetFontPolicy.this .setCursor(Cursor .getPredefinedCursor(Cursor.WAIT_CURSOR)); // set the new font policy SubstanceLookAndFeel .setFontPolicy(newFontPolicy); SetFontPolicy.this.setCursor(Cursor .getDefaultCursor()); } catch (Exception exc) { exc.printStackTrace(); } } }); } } }); panel.add(fontSizeSlider); panel.add(new JButton("button")); panel.add(new JComboBox(new Object[] { "item1", "item2" })); this.add(panel, BorderLayout.CENTER); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new SetFontPolicy().setVisible(true); } }); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootsubstance-5.3.orig/src/test/samples/substance/api/RegisterTabCloseChangeListener_SpecificMultiple.javasubstance-5.3.orig/src/test/samples/substance/api/RegisterTabCloseChangeListener_SpecificMultiple.ja0000644000175000017500000001417711223636016034041 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.MouseEvent; import java.util.Set; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.TabCloseKind; import org.jvnet.substance.api.tabbed.MultipleTabCloseListener; import org.jvnet.substance.api.tabbed.TabCloseCallback; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import test.Check; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#registerTabCloseChangeListener(JTabbedPane, org.jvnet.substance.tabbed.BaseTabCloseListener)} * API with registering a tab close listener that listens on multiple tab * closing on a specific tabbed pane. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#registerTabCloseChangeListener(JTabbedPane, * org.jvnet.substance.tabbed.BaseTabCloseListener) */ public class RegisterTabCloseChangeListener_SpecificMultiple extends JFrame { /** * Creates the main frame for this sample. */ public RegisterTabCloseChangeListener_SpecificMultiple() { super("Register tab close listener"); this.setLayout(new BorderLayout()); final JTabbedPane jtp = new JTabbedPane(); jtp.addTab("tab1", Check.getIcon("flag_sweden"), new JPanel()); jtp.addTab("tab2", Check.getIcon("flag_mexico"), new JPanel()); jtp.addTab("tab3", Check.getIcon("flag_hong_kong"), new JPanel()); jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); // create a custom implementation of TabCloseCallback interface. TabCloseCallback closeCallback = new TabCloseCallback() { public TabCloseKind onAreaClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.getButton() != MouseEvent.BUTTON3) return TabCloseKind.NONE; if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } public TabCloseKind onCloseButtonClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.isAltDown()) { return TabCloseKind.ALL_BUT_THIS; } if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) { return null; } public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex) { StringBuffer result = new StringBuffer(); result.append(""); result.append("Mouse click closes " + tabbedPane.getTitleAt(tabIndex) + " tab"); result .append("
Alt-Mouse click closes all tabs but " + tabbedPane.getTitleAt(tabIndex) + " tab"); result.append("
Shift-Mouse click closes all tabs"); result.append(""); return result.toString(); } }; // register the callback on the tabbed pane jtp.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK, closeCallback); // register tab close listener on the specific tabbed pane. SubstanceLookAndFeel.registerTabCloseChangeListener(jtp, new MultipleTabCloseListener() { public void tabsClosing(JTabbedPane tabbedPane, Set tabComponents) { StringBuffer sb = new StringBuffer("Tab (s)"); String sep = " ["; for (Component comp : tabComponents) { sb.append(sep); sep = ", "; sb.append(tabbedPane.getTitleAt(tabbedPane .indexOfComponent(comp))); } sb.append("] closing"); System.out.println(sb.toString()); } public void tabsClosed(JTabbedPane tabbedPane, Set tabComponents) { System.out.println(tabComponents.size() + " tab(s) closed"); } }); this.add(jtp, BorderLayout.CENTER); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new RegisterTabCloseChangeListener_SpecificMultiple() .setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/UnregisterSkinChangeListener.java0000644000175000017500000001237511223636170030621 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.*; import java.util.Vector; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.*; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#registerSkinChangeListener(SkinChangeListener)} * API. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#registerSkinChangeListener(SkinChangeListener) */ public class UnregisterSkinChangeListener extends JFrame { /** * Listener instance. */ private SkinChangeListener listener; /** * Creates the main frame for this sample. */ public UnregisterSkinChangeListener() { super("Register skin change listener"); this.setLayout(new BorderLayout()); JPanel panel = new JPanel(new FlowLayout()); // Get all skin display names and set the vector as a model // for combobox. final JComboBox cb = new JComboBox(new Vector( SubstanceLookAndFeel.getAllSkins().keySet())); cb.setSelectedIndex(-1); cb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent evt) { // Get the affected item final Object item = evt.getItem(); if (evt.getStateChange() == ItemEvent.SELECTED) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { // Get the skin info object based on // the selected skin display name SkinInfo skinInfo = SubstanceLookAndFeel .getAllSkins().get(item); // Set the global skin based on the // skin class name. SubstanceLookAndFeel.setSkin(skinInfo .getClassName()); SwingUtilities .updateComponentTreeUI(UnregisterSkinChangeListener.this); } catch (Exception exc) { } }; }); } } }); panel.add(new JLabel("All skins:")); panel.add(cb); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JButton unregisterListener = new JButton("Unregister listener"); unregisterListener.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { unregisterListener.setEnabled(false); // unregister listener SubstanceLookAndFeel .unregisterSkinChangeListener(listener); } }); } }); controls.add(unregisterListener); this.add(controls, BorderLayout.SOUTH); this.add(panel, BorderLayout.CENTER); // register listener SubstanceLookAndFeel .registerSkinChangeListener(listener = new SkinChangeListener() { public void skinChanged() { // show dialog with skin changed message. SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog( UnregisterSkinChangeListener.this, "Skin changed"); } }); } }); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new UnregisterSkinChangeListener().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/GetAllTabCloseListeners_Global.java0000644000175000017500000001201311223635362030756 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Set; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.tabbed.TabCloseListener; import org.jvnet.substance.api.tabbed.VetoableMultipleTabCloseListener; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import test.Check; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#getAllTabCloseListeners()} API. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#getAllTabCloseListeners() */ public class GetAllTabCloseListeners_Global extends JFrame { /** * Creates the main frame for this sample. */ public GetAllTabCloseListeners_Global() { super("Get all tab close listeners"); this.setLayout(new BorderLayout()); final JTabbedPane jtp = new JTabbedPane(); jtp.addTab("tab1", Check.getIcon("flag_sweden"), new JPanel()); jtp.addTab("tab2", Check.getIcon("flag_mexico"), new JPanel()); jtp.addTab("tab3", Check.getIcon("flag_hong_kong"), new JPanel()); jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); SubstanceLookAndFeel.registerTabCloseChangeListener(null, new TabCloseListener() { public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) { System.out.println("Tab closing"); } public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) { System.out.println("Tab closed"); } }); SubstanceLookAndFeel.registerTabCloseChangeListener(jtp, new VetoableMultipleTabCloseListener() { public void tabsClosed(JTabbedPane tabbedPane, Set tabComponents) { System.out.println("Tabs closed"); } public void tabsClosing(JTabbedPane tabbedPane, Set tabComponents) { System.out.println("Tabs closing"); } public boolean vetoTabsClosing(JTabbedPane tabbedPane, Set tabComponents) { System.out.println("Vetoing tabs closing"); return true; } }); this.add(jtp, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton getTabCloseListeners = new JButton("Get tab close listeners"); getTabCloseListeners.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( GetAllTabCloseListeners_Global.this, SubstanceLookAndFeel.getAllTabCloseListeners().size() + " global tab close listeners registered"); } }); controls.add(getTabCloseListeners); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JDialog.setDefaultLookAndFeelDecorated(true); JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new GetAllTabCloseListeners_Global().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/UnregisterTabCloseChangeListener_General.java0000644000175000017500000001150311223636200033030 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.tabbed.TabCloseListener; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import test.Check; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#unregisterTabCloseChangeListener(org.jvnet.substance.tabbed.BaseTabCloseListener)} * API with registering a tab close listener that listens on single tab closing * on a specific tabbed pane. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#unregisterTabCloseChangeListener(org.jvnet.substance.tabbed.BaseTabCloseListener) */ public class UnregisterTabCloseChangeListener_General extends JFrame { /** * Listener instance. */ private TabCloseListener listener; /** * Creates the main frame for this sample. */ public UnregisterTabCloseChangeListener_General() { super("Register tab close listener"); this.setLayout(new BorderLayout()); final JTabbedPane jtp = new JTabbedPane(); jtp.addTab("tab1", Check.getIcon("flag_sweden"), new JPanel()); jtp.addTab("tab2", Check.getIcon("flag_mexico"), new JPanel()); jtp.addTab("tab3", Check.getIcon("flag_hong_kong"), new JPanel()); jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); // register tab close listener on all tabbed panes. SubstanceLookAndFeel .registerTabCloseChangeListener(listener = new TabCloseListener() { public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) { System.out.println("Tab " + tabbedPane.getTitleAt(tabbedPane .indexOfComponent(tabComponent)) + " closing"); } public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) { System.out.println("Tab closed"); } }); this.add(jtp, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JButton unregisterListener = new JButton("Unregister listener"); unregisterListener.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { unregisterListener.setEnabled(false); // unregister listener SubstanceLookAndFeel .unregisterTabCloseChangeListener(listener); } }); } }); controls.add(unregisterListener); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new UnregisterTabCloseChangeListener_General().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/GetCurrentSkin.java0000644000175000017500000001144611223635402025733 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.skin.*; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#getCurrentSkin(java.awt.Component)} API. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#getCurrentSkin(java.awt.Component) */ public class GetCurrentSkin extends JFrame { /** * Creates the main frame for this sample. */ public GetCurrentSkin() { super("Per-window skins"); this.setLayout(new FlowLayout()); JButton autumnSkin = new JButton("Autumn skin"); autumnSkin.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { openSampleFrame(new AutumnSkin()); } }); } }); this.add(autumnSkin); JButton ravenGraphiteSkin = new JButton("Graphite skin"); ravenGraphiteSkin.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { openSampleFrame(new RavenGraphiteSkin()); } }); } }); this.add(ravenGraphiteSkin); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * Opens a sample frame under the specified skin. * * @param skin * Skin. */ private void openSampleFrame(SubstanceSkin skin) { final JFrame sampleFrame = new JFrame(skin.getDisplayName()); sampleFrame.setLayout(new FlowLayout()); final JButton button = new JButton("Get skin"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(sampleFrame, "Skin of this button is " + SubstanceLookAndFeel.getCurrentSkin( button).getDisplayName()); } }); } }); sampleFrame.add(button); sampleFrame.setVisible(true); sampleFrame.setSize(200, 100); sampleFrame.setLocationRelativeTo(null); sampleFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); sampleFrame.getRootPane().putClientProperty( SubstanceLookAndFeel.SKIN_PROPERTY, skin); SwingUtilities.updateComponentTreeUI(sampleFrame); sampleFrame.repaint(); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new GetCurrentSkin().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/GetFontPolicy.java0000644000175000017500000001703211223635430025550 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.FontUIResource; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.fonts.FontPolicy; import org.jvnet.substance.fonts.FontSet; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#getFontPolicy()} API. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#getFontPolicy() */ public class GetFontPolicy extends JFrame { /** * Wrapper around the base Substance font set. Is used to create larger / * smaller font sets. * * @author Kirill Grouchnikov */ private static class WrapperFontSet implements FontSet { /** * Extra size in pixels. Can be positive or negative. */ private int extra; /** * The base Substance font set. */ private FontSet delegate; /** * Creates a wrapper font set. * * @param delegate * The base Substance font set. * @param extra * Extra size in pixels. Can be positive or negative. */ public WrapperFontSet(FontSet delegate, int extra) { super(); this.delegate = delegate; this.extra = extra; } /** * Returns the wrapped font. * * @param systemFont * Original font. * @return Wrapped font. */ private FontUIResource getWrappedFont(FontUIResource systemFont) { return new FontUIResource(systemFont.getFontName(), systemFont .getStyle(), systemFont.getSize() + this.extra); } public FontUIResource getControlFont() { return this.getWrappedFont(this.delegate.getControlFont()); } public FontUIResource getMenuFont() { return this.getWrappedFont(this.delegate.getMenuFont()); } public FontUIResource getMessageFont() { return this.getWrappedFont(this.delegate.getMessageFont()); } public FontUIResource getSmallFont() { return this.getWrappedFont(this.delegate.getSmallFont()); } public FontUIResource getTitleFont() { return this.getWrappedFont(this.delegate.getTitleFont()); } public FontUIResource getWindowTitleFont() { return this.getWrappedFont(this.delegate.getWindowTitleFont()); } } /** * Creates the main frame for this sample. */ public GetFontPolicy() { super("Get font policy"); this.setLayout(new BorderLayout()); JPanel panel = new JPanel(new FlowLayout()); // create a slider to control the font size. final JSlider fontSizeSlider = new JSlider(-3, 3, 0); fontSizeSlider.setPaintLabels(true); fontSizeSlider.setMajorTickSpacing(1); fontSizeSlider.setToolTipText("Controls the global font set size"); fontSizeSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // if the value is adjusting - ignore. This is done // to make CPU usage better. if (!fontSizeSlider.getModel().getValueIsAdjusting()) { final int newValue = fontSizeSlider.getValue(); SwingUtilities.invokeLater(new Runnable() { public void run() { // reset the base font policy to null - this // restores the original font policy (default size). SubstanceLookAndFeel.setFontPolicy(null); // Get the default font set final FontSet substanceCoreFontSet = SubstanceLookAndFeel .getFontPolicy().getFontSet("Substance", null); // Create the wrapper font set FontPolicy newFontPolicy = new FontPolicy() { public FontSet getFontSet(String lafName, UIDefaults table) { return new WrapperFontSet( substanceCoreFontSet, newValue); } }; try { GetFontPolicy.this .setCursor(Cursor .getPredefinedCursor(Cursor.WAIT_CURSOR)); // set the new font policy SubstanceLookAndFeel .setFontPolicy(newFontPolicy); GetFontPolicy.this.setCursor(Cursor .getDefaultCursor()); } catch (Exception exc) { exc.printStackTrace(); } } }); } } }); panel.add(fontSizeSlider); JButton jb = new JButton("Show font info"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FontPolicy fontPolicy = SubstanceLookAndFeel.getFontPolicy(); FontSet fontSet = fontPolicy.getFontSet("Substance", null); String[] infoArray = new String[] { "Control: " + fontSet.getControlFont(), "Menu: " + fontSet.getMenuFont(), "Message: " + fontSet.getMessageFont(), "Small: " + fontSet.getSmallFont(), "Title: " + fontSet.getTitleFont(), "Window title: " + fontSet.getWindowTitleFont() }; JList infoList = new JList(infoArray); JDialog infoDialog = new JDialog(GetFontPolicy.this, "Font set info", true); infoDialog.setLayout(new BorderLayout()); infoDialog.add(infoList, BorderLayout.CENTER); infoDialog.pack(); infoDialog.setLocationRelativeTo(GetFontPolicy.this); infoDialog.setVisible(true); } }); panel.add(jb); this.add(panel, BorderLayout.CENTER); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new GetFontPolicy().setVisible(true); } }); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootsubstance-5.3.orig/src/test/samples/substance/api/RegisterTabCloseChangeListener_GeneralSingleVetoable.javasubstance-5.3.orig/src/test/samples/substance/api/RegisterTabCloseChangeListener_GeneralSingleVetoab0000644000175000017500000001123611223636006034057 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.Component; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.tabbed.VetoableTabCloseListener; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import test.Check; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#registerTabCloseChangeListener(org.jvnet.substance.tabbed.BaseTabCloseListener)} * API with registering a vetoable tab close listener that listens on single tab * closing on a specific tabbed pane. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#registerTabCloseChangeListener(org.jvnet.substance.tabbed.BaseTabCloseListener) */ public class RegisterTabCloseChangeListener_GeneralSingleVetoable extends JFrame { /** * Creates the main frame for this sample. */ public RegisterTabCloseChangeListener_GeneralSingleVetoable() { super("Register tab close listener"); this.setLayout(new BorderLayout()); final JTabbedPane jtp = new JTabbedPane(); jtp.addTab("tab1", Check.getIcon("flag_sweden"), new JPanel()); jtp.addTab("tab2", Check.getIcon("flag_mexico"), new JPanel()); jtp.addTab("tab3", Check.getIcon("flag_hong_kong"), new JPanel()); jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); // register tab close listener on all tabbed panes. SubstanceLookAndFeel .registerTabCloseChangeListener(new VetoableTabCloseListener() { public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) { System.out.println("Tab " + tabbedPane.getTitleAt(tabbedPane .indexOfComponent(tabComponent)) + " closing"); } public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) { System.out.println("Tab closed"); } public boolean vetoTabClosing(JTabbedPane tabbedPane, Component tabComponent) { return (JOptionPane .showConfirmDialog( RegisterTabCloseChangeListener_GeneralSingleVetoable.this, "Are you sure you want to close " + tabbedPane .getTitleAt(tabbedPane .indexOfComponent(tabComponent)) + "?") != JOptionPane.YES_OPTION); } }); this.add(jtp, BorderLayout.CENTER); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new RegisterTabCloseChangeListener_GeneralSingleVetoable() .setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/SetUseConstantThemesOnDialogs.java0000644000175000017500000001250211223637552030716 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.NebulaSkin; import test.Check; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#setToUseConstantThemesOnDialogs(boolean)} API. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#setToUseConstantThemesOnDialogs(boolean) */ public class SetUseConstantThemesOnDialogs extends JFrame { /** * Creates the main frame for this sample. */ public SetUseConstantThemesOnDialogs() { super("Use constant themes on dialogs"); this.setLayout(new BorderLayout()); JPanel buttonPanel = new JPanel(new FlowLayout()); JButton bopi = new JButton("Info", Check .getIcon("22/dialog-information")); bopi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( SetUseConstantThemesOnDialogs.this, "Sample info message", "Sample title", JOptionPane.INFORMATION_MESSAGE); } }); buttonPanel.add(bopi); JButton bope = new JButton("Show", Check.getIcon("22/dialog-error")); bope.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( SetUseConstantThemesOnDialogs.this, "Sample error message", "Sample title", JOptionPane.ERROR_MESSAGE); } }); buttonPanel.add(bope); JButton bopw = new JButton("Show", Check.getIcon("22/dialog-warning")); bopw.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( SetUseConstantThemesOnDialogs.this, "Sample warning message", "Sample title", JOptionPane.WARNING_MESSAGE); } }); buttonPanel.add(bopw); JButton bopq = new JButton("Show", Check.getIcon("22/help-browser")); bopq.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog( SetUseConstantThemesOnDialogs.this, "Sample question message", "Sample title", JOptionPane.QUESTION_MESSAGE); } }); buttonPanel.add(bopq); this.add(buttonPanel, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox useConstantThemesOnDialogs = new JCheckBox( "Use constant themes on dialogs"); useConstantThemesOnDialogs.setSelected(SubstanceLookAndFeel .isToUseConstantThemesOnDialogs()); useConstantThemesOnDialogs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel .setToUseConstantThemesOnDialogs(useConstantThemesOnDialogs .isSelected()); } }); } }); controls.add(useConstantThemesOnDialogs); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JDialog.setDefaultLookAndFeelDecorated(true); JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new NebulaSkin()); new SetUseConstantThemesOnDialogs().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/SetWidgetVisible.java0000644000175000017500000001047111223636160026240 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.SubstanceWidgetType; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#setWidgetVisible(JRootPane, boolean, SubstanceWidgetType...)} * API. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#setWidgetVisible(JRootPane, boolean, * SubstanceWidgetType...) */ public class SetWidgetVisible extends JFrame { /** * Creates the main frame for this sample. */ public SetWidgetVisible() { super("Set widget visible"); this.setLayout(new BorderLayout()); // create sample menu bar with two menus JMenuBar jmb = new JMenuBar(); JMenu menu = new JMenu("menu"); menu.add(new JMenuItem("test item 1")); menu.add(new JMenuItem("test item 2")); menu.add(new JMenuItem("test item 3")); menu.addSeparator(); menu.add(new JMenuItem("test menu item 4")); menu.add(new JMenuItem("test menu item 5")); menu.add(new JMenuItem("test menu item 6")); jmb.add(menu); JMenu menu2 = new JMenu("big"); for (int i = 0; i < 35; i++) menu2.add(new JMenuItem("menu item " + i)); jmb.add(menu2); this.setJMenuBar(jmb); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox showMenuSearchPanels = new JCheckBox( "Show menu search panels"); showMenuSearchPanels.setSelected(false); showMenuSearchPanels.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setWidgetVisible( SetWidgetVisible.this.getRootPane(), showMenuSearchPanels.isSelected(), SubstanceWidgetType.MENU_SEARCH); } }); } }); controls.add(showMenuSearchPanels); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new SetWidgetVisible().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/RegisterSkinChangeListener.java0000644000175000017500000001116711223635740030256 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.Vector; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.*; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#registerSkinChangeListener(SkinChangeListener)} * API. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#registerSkinChangeListener(SkinChangeListener) */ public class RegisterSkinChangeListener extends JFrame { /** * Creates the main frame for this sample. */ public RegisterSkinChangeListener() { super("Register skin change listener"); this.setLayout(new BorderLayout()); JPanel panel = new JPanel(new FlowLayout()); // Get all skin display names and set the vector as a model // for combobox. final JComboBox cb = new JComboBox(new Vector( SubstanceLookAndFeel.getAllSkins().keySet())); cb.setSelectedIndex(-1); cb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent evt) { // Get the affected item final Object item = evt.getItem(); if (evt.getStateChange() == ItemEvent.SELECTED) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { // Get the skin info object based on // the selected skin display name SkinInfo skinInfo = SubstanceLookAndFeel .getAllSkins().get(item); // Set the global skin based on the // skin class name. SubstanceLookAndFeel.setSkin(skinInfo .getClassName()); SwingUtilities .updateComponentTreeUI(RegisterSkinChangeListener.this); } catch (Exception exc) { } }; }); } } }); panel.add(new JLabel("All skins:")); panel.add(cb); this.add(panel, BorderLayout.CENTER); // register listener SubstanceLookAndFeel .registerSkinChangeListener(new SkinChangeListener() { public void skinChanged() { // show dialog with skin changed message. SwingUtilities.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog( RegisterSkinChangeListener.this, "Skin changed"); } }); } }); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new RegisterSkinChangeListener().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/dukeplug.gif0000644000175000017500000000475110537537474024512 0ustar drazzibdrazzibGIF87aUcJJJ{{{ccc)))ZZZέBBB111)skc1{)!)999!!!9s!RRZkRJcc!!!!JJ1{)ZZ!!!JR9!!!)kkkssZ1!RRR))sssBkJ9!RB)99c,UcH*‡#J8!3jTXaCȓ(tI+@L4sJSτxjϞD&84OMTUPZE k[gz6ʢ|06'Wn(Wތ6Nn%5L!1 ppi(+ܰf|/[lr 2h1;x@!AFx Qx 'PH!twCTx."]YڔAܺ4ְq#&iz-tDc%X%0Pg_ 9@!+ 1@FxuGB QRz_Qq0pœ H#}DImU pА5u,8a% #k5LIUpQDDO81=JIאiDAL0yOY"T4Q]. UWX` "2AdQCEU䙅5Cl P AEF0iA YiѐKGvLqtb$l%dAY_cRS,@+`* $ALtMH:Pf0taYIS@ 0A5QS$jI+URH%x/"QY+.pBH@6벀]%\R7Ѿ-urI8Ĥ5)sCS\f QY| =v{4EL  NHP(滳L<@#N }';Y.?WNC$DZtyP۝DDC@hDha [ yd}JAkdr5& {<쐒$p%f+lfArYз `X2tDeY979!X҅s"T* og yBy.!TYW6)FKє,&8kBҘF9eVpDT"p$U|!<҅X@gA*Pe}'Y8! &UDb*W )G @ bj /t䔸ʟ`eY#lvfeK*HGtGJɐIdi )` 6 9pD0?YJn"d1@pnZ9@"@BOl! =bblN2N'8Y;҄ ȩN QZS(+7)T@HRzόX ,ԑ}FV $렶,g0-X@ @"^2=[0r4M`&KY2|[`BS"Sd#`V66BXwu[- ೪YJ Cb-\Κ҅Z*oBFNRB:Td]764GˈwrCeJLʔ1@AHxoJ3&MKUI" b $z}r\LL dYkX`W 2,j]&EK & {Hcf_w2YH@;substance-5.3.orig/src/test/samples/substance/api/SetDecorationType.java0000644000175000017500000000774511223636066026447 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.BorderLayout; import java.awt.FlowLayout; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.skin.BusinessBlackSteelSkin; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#setDecorationType(JComponent, org.jvnet.substance.painter.decoration.DecorationAreaType)} * API. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#setDecorationType(JComponent, * org.jvnet.substance.painter.decoration.DecorationAreaType) */ public class SetDecorationType extends JFrame { /** * Creates the main frame for this sample. */ public SetDecorationType() { super("Set decoration type"); this.setLayout(new BorderLayout()); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); SubstanceLookAndFeel.setDecorationType(controls, DecorationAreaType.GENERAL); JToggleButton controlButton = new JToggleButton("control"); controlButton.setSelected(true); JCheckBox controlCheckBox = new JCheckBox("control"); controlCheckBox.setSelected(true); controls.add(new JLabel("GENERAL decoration:")); controls.add(controlButton); controls.add(controlCheckBox); this.add(controls, BorderLayout.SOUTH); JPanel content = new JPanel(new FlowLayout()); JToggleButton sampleButton = new JToggleButton("control"); sampleButton.setSelected(true); JCheckBox sampleCheckBox = new JCheckBox("control"); sampleCheckBox.setSelected(true); content.add(new JLabel("Default decoration:")); content.add(sampleButton); content.add(sampleCheckBox); this.add(content, BorderLayout.CENTER); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new SetDecorationType().setVisible(true); } }); } } substance-5.3.orig/src/test/samples/substance/api/UnregisterTabCloseChangeListener_Specific.java0000644000175000017500000001160411223636210033203 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test.samples.substance.api; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.tabbed.TabCloseListener; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import test.Check; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#unregisterTabCloseChangeListener(JTabbedPane, org.jvnet.substance.tabbed.BaseTabCloseListener)} * API with registering a tab close listener that listens on single tab closing * on a specific tabbed pane. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#unregisterTabCloseChangeListener(JTabbedPane, * org.jvnet.substance.tabbed.BaseTabCloseListener) */ public class UnregisterTabCloseChangeListener_Specific extends JFrame { /** * Listener instance. */ private TabCloseListener listener; /** * Creates the main frame for this sample. */ public UnregisterTabCloseChangeListener_Specific() { super("Unregister tab close listener"); this.setLayout(new BorderLayout()); final JTabbedPane jtp = new JTabbedPane(); jtp.addTab("tab1", Check.getIcon("flag_sweden"), new JPanel()); jtp.addTab("tab2", Check.getIcon("flag_mexico"), new JPanel()); jtp.addTab("tab3", Check.getIcon("flag_hong_kong"), new JPanel()); jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); // register tab close listener on the specific tabbed pane. SubstanceLookAndFeel.registerTabCloseChangeListener(jtp, listener = new TabCloseListener() { public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) { System.out.println("Tab " + tabbedPane.getTitleAt(tabbedPane .indexOfComponent(tabComponent)) + " closing"); } public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) { System.out.println("Tab closed"); } }); this.add(jtp, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JButton unregisterListener = new JButton("Unregister listener"); unregisterListener.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { unregisterListener.setEnabled(false); // unregister listener SubstanceLookAndFeel.unregisterTabCloseChangeListener( jtp, listener); } }); } }); controls.add(unregisterListener); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); new UnregisterTabCloseChangeListener_Specific() .setVisible(true); } }); } } substance-5.3.orig/src/test/Checkmark.java0000644000175000017500000000426111166402604020507 0ustar drazzibdrazzibpackage test; import java.awt.*; import java.awt.image.BufferedImage; import javax.swing.*; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.AquaColorScheme; import org.jvnet.substance.painter.border.StandardBorderPainter; import org.jvnet.substance.painter.border.SubstanceBorderPainter; import org.jvnet.substance.painter.gradient.StandardGradientPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; import org.jvnet.substance.utils.SubstanceImageCreator; public class Checkmark extends JFrame { public Checkmark() { this.add(new CPanel(), BorderLayout.CENTER); setSize(800, 400); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static class CPanel extends JPanel { @Override protected void paintComponent(Graphics g) { g.setColor(Color.lightGray.brighter()); g.fillRect(0, 0, getWidth(), getHeight()); SubstanceColorScheme st = new AquaColorScheme(); SubstanceGradientPainter gp = new StandardGradientPainter(); SubstanceBorderPainter bp = new StandardBorderPainter(); int x = 0; for (int i = 12; i < 36; i++) { JCheckBox jcb = new JCheckBox(); jcb.setFont(new Font("Arial", Font.PLAIN, i)); jcb.setSelected(true); BufferedImage cbi = SubstanceImageCreator.getCheckBox(jcb, gp, bp, i, ComponentState.SELECTED, ComponentState.SELECTED, st, st, st, st, st, st, 0, 1.0f, false); g.setColor(new Color(255, 196, 196)); g.fillRect(x, 100, cbi.getWidth(), cbi.getHeight()); g.drawImage(SubstanceImageCreator.getCheckBox(jcb, gp, bp, i, ComponentState.SELECTED, ComponentState.SELECTED, st, st, st, st, st, st, 0, 1.0f, false), x, 100, null); x += (i + 2); } } } public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Checkmark().setVisible(true); } }); } } substance-5.3.orig/src/test/MultipleSkinsInternalFrame.java0000644000175000017500000001025611166377550024106 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test; import java.awt.BorderLayout; import java.awt.Rectangle; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.skin.*; import test.check.SampleInternalFrame; public class MultipleSkinsInternalFrame { public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { SubstanceSkin[][] skinGrid = new SubstanceSkin[][] { { new AutumnSkin(), new BusinessSkin(), new BusinessBlueSteelSkin(), new BusinessBlackSteelSkin() }, { new NebulaSkin(), new CremeSkin(), new CremeCoffeeSkin(), new ModerateSkin() }, { new OfficeSilver2007Skin(), new SaharaSkin(), new MistAquaSkin(), new NebulaBrickWallSkin() }, { new RavenSkin(), new RavenGraphiteSkin(), new RavenGraphiteGlassSkin(), new MagmaSkin() } }; JFrame frame = new JFrame("Multiple skins"); final JDesktopPane desktopPane = new JDesktopPane(); final JInternalFrame[] frames = new JInternalFrame[12]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 3; j++) { SampleInternalFrame internalFrame = new SampleInternalFrame(); internalFrame.getRootPane().putClientProperty( SubstanceLookAndFeel.SKIN_PROPERTY, skinGrid[i][j]); SwingUtilities.updateComponentTreeUI(internalFrame); frames[i * 3 + j] = internalFrame; desktopPane.add(internalFrame); internalFrame.setVisible(true); } } desktopPane.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { Rectangle bounds = desktopPane.getBounds(); int x = bounds.x; for (int i = 0; i < 4; i++) { int y = bounds.y; for (int j = 0; j < 3; j++) { frames[i * 3 + j].setBounds(x, y, bounds.width / 4, bounds.height / 3); y += bounds.height / 3; } x += bounds.width / 4; } } }); frame.add(desktopPane, BorderLayout.CENTER); frame.setSize(400, 300); frame.setLocationRelativeTo(null); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.doLayout(); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } }); } } substance-5.3.orig/src/test/Check.java0000644000175000017500000010146711253512422017637 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test; import java.awt.*; import java.awt.event.*; import java.io.*; import java.net.URL; import java.util.*; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.plaf.FontUIResource; import org.jdesktop.swingx.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.tabbed.DefaultTabPreviewPainter; import org.jvnet.lafwidget.utils.LafConstants.TabOverviewKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.Side; import org.jvnet.substance.api.SubstanceConstants.TabCloseKind; import org.jvnet.substance.api.skin.SubstanceGeminiLookAndFeel; import org.jvnet.substance.api.tabbed.*; import org.jvnet.substance.fonts.FontSet; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.skin.SkinChangeListener; import org.jvnet.substance.utils.SubstanceImageCreator; import test.check.*; import test.check.statusbar.FontSizePanel; public class Check extends JFrame { private JTabbedPane jtp; private MyMainTabPreviewPainter mainTabPreviewPainter; private static class WrapperFontSet implements FontSet { private int extra; private FontSet delegate; public WrapperFontSet(FontSet delegate, int extra) { super(); this.delegate = delegate; this.extra = extra; } private FontUIResource getWrappedFont(FontUIResource systemFont) { return new FontUIResource(systemFont.getFontName(), systemFont .getStyle(), systemFont.getSize() + extra); } public FontUIResource getControlFont() { return getWrappedFont(delegate.getControlFont()); } public FontUIResource getMenuFont() { return getWrappedFont(delegate.getMenuFont()); } public FontUIResource getMessageFont() { return getWrappedFont(delegate.getMessageFont()); } public FontUIResource getSmallFont() { return getWrappedFont(delegate.getSmallFont()); } public FontUIResource getTitleFont() { return getWrappedFont(delegate.getTitleFont()); } public FontUIResource getWindowTitleFont() { // FontUIResource f = this.getWrappedFont(this.delegate // .getWindowTitleFont()); // return new FontUIResource(f.deriveFont(Font.BOLD, f.getSize() + // 1)); return getWrappedFont(delegate.getWindowTitleFont()); } } private boolean toUseThemeObjs; private boolean toUseWatermarksObjs; private boolean toUseButtonShapersObjs; private boolean toUseGradientPaintersObjs; private JXTaskPaneContainer taskPaneContainer; private JXTaskPane currentSpecificTaskPane; private JXTaskPane mainTaskPane; private JToolBar toolbar; public Check() { super( "Substance test with very very very very very very very very very very very very very very long title"); final ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) { setIconImage(SubstanceImageCreator.getColorSchemeImage(null, new ImageIcon(cl .getResource("test/resource/image-x-generic.png")), SubstanceLookAndFeel.getCurrentSkin(this.getRootPane()) .getMainActiveColorScheme(), 0.0f)); } SubstanceLookAndFeel .registerSkinChangeListener(new SkinChangeListener() { @Override public void skinChanged() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { setIconImage(SubstanceImageCreator .getColorSchemeImage( null, new ImageIcon( cl .getResource("test/resource/image-x-generic.png")), SubstanceLookAndFeel .getCurrentSkin(null) .getMainActiveColorScheme(), 0.0f)); } }); } }); setLayout(new BorderLayout()); jtp = new JTabbedPane(); try { mainTabPreviewPainter = new MyMainTabPreviewPainter(); jtp.putClientProperty(LafWidget.TABBED_PANE_PREVIEW_PAINTER, mainTabPreviewPainter); } catch (Throwable e) { } jtp.getModel().addChangeListener(new TabSwitchListener()); final JXPanel jxPanel = new JXPanel(new BorderLayout()); toolbar = getToolbar("", 22, true); jxPanel.add(toolbar, BorderLayout.NORTH); JXStatusBar statusBar = getStatusBar(jxPanel, jtp); this.add(statusBar, BorderLayout.SOUTH); taskPaneContainer = new JXTaskPaneContainer() { @Override public boolean getScrollableTracksViewportWidth() { return false; } }; taskPaneContainer.setScrollableTracksViewportHeight(false); taskPaneContainer.setScrollableTracksViewportWidth(false); mainTaskPane = new JXTaskPane(); mainTaskPane.setLayout(new BorderLayout()); JPanel mainControlPanel = ControlPanelFactory.getMainControlPanel(this, jtp, mainTabPreviewPainter, toolbar); // mainControlPanel.setOpaque(false); mainTaskPane.add(mainControlPanel, BorderLayout.CENTER); mainTaskPane.setTitle("General settings"); mainTaskPane.setIcon(getIcon("JFrameColor16")); mainTaskPane.setCollapsed(true); taskPaneContainer.add(mainTaskPane); JPanel dialogControlPanel = ControlPanelFactory .getDialogControlPanel(this); JXTaskPane dialogTaskPane = new JXTaskPane(); dialogTaskPane.setLayout(new BorderLayout()); dialogTaskPane.add(dialogControlPanel, BorderLayout.CENTER); dialogTaskPane.setTitle("Frames & Dialogs"); dialogTaskPane.setIcon(getIcon("JDialogColor16")); dialogTaskPane.setCollapsed(true); // dialogTaskPane.setOpaque(false); taskPaneContainer.add(dialogTaskPane); currentSpecificTaskPane = null; final JScrollPane scrollPane = new JScrollPane(taskPaneContainer, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); SubstanceLookAndFeel.setDecorationType(scrollPane, DecorationAreaType.GENERAL); // scrollPane.setOpaque(false); // scrollPane.getViewport().setOpaque(false); JPanel mainPanel = new JPanel(); mainPanel.add(scrollPane); mainPanel.add(jtp); mainPanel.setLayout(new LayoutManager() { public void addLayoutComponent(String name, Component comp) { } public Dimension minimumLayoutSize(Container parent) { Dimension min1 = scrollPane.getMinimumSize(); Dimension min2 = jtp.getMinimumSize(); return new Dimension(min1.width + min2.width, min1.height + min2.height); } public void layoutContainer(Container parent) { // give 30% width to task pane container and // 70% width to the tabbed pane with controls. int width = parent.getWidth(); int height = parent.getHeight(); scrollPane.setBounds(0, 0, (int) (0.3 * width), height); jtp.setBounds((int) (0.3 * width), 0, width - (int) (0.3 * width), height); } public Dimension preferredLayoutSize(Container parent) { Dimension pref1 = scrollPane.getPreferredSize(); Dimension pref2 = jtp.getPreferredSize(); return new Dimension(pref1.width + pref2.width, pref1.height + pref2.height); } public void removeLayoutComponent(Component comp) { } }); jxPanel.add(mainPanel, BorderLayout.CENTER); this.add(jxPanel, BorderLayout.CENTER); setPreferredSize(new Dimension(400, 400)); this.setSize(getPreferredSize()); setMinimumSize(getPreferredSize()); ButtonsPanel buttonsPanel = new ButtonsPanel(); // System.out.println(System.currentTimeMillis()); jtp.addTab("Buttons", getIcon("JButtonColor16"), buttonsPanel); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); getRootPane().setDefaultButton(buttonsPanel.defaultButton); // System.out.println(System.currentTimeMillis()); jtp.addTab("Combo box", getIcon("JComboBoxColor16"), new CombosPanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); // System.out.println(System.currentTimeMillis()); jtp.addTab("Scroll pane", getIcon("JScrollPaneColor16"), new ScrollPanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); TabCloseCallback closeCallback = new TabCloseCallback() { public TabCloseKind onAreaClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.getButton() != MouseEvent.BUTTON3) return TabCloseKind.NONE; if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } public TabCloseKind onCloseButtonClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.isAltDown()) { return TabCloseKind.ALL_BUT_THIS; } if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) { return null; } public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex) { StringBuffer result = new StringBuffer(); result.append(""); result.append("Mouse click closes " + tabbedPane.getTitleAt(tabIndex) + " tab"); result .append("
Alt-Mouse click closes all tabs but " + tabbedPane.getTitleAt(tabIndex) + " tab"); result.append("
Shift-Mouse click closes all tabs"); result.append(""); return result.toString(); } }; try { // System.out.println(System.currentTimeMillis()); TabPanel tp = new TabPanel(); tp.jtp.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK, closeCallback); jtp.addTab("Tabbed pane", getIcon("JTabbedPaneColor16"), tp); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); } catch (NoClassDefFoundError ncdfe) { } // System.out.println(System.currentTimeMillis()); jtp.addTab("Split", new SplitPanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); // System.out.println(System.currentTimeMillis()); jtp.addTab("Desktop", getIcon("JDesktopPaneColor16"), new DesktopPanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); // System.out.println(System.currentTimeMillis()); jtp.addTab("Text fields", getIcon("JTextPaneColor16"), new TextFieldsPanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); // System.out.println(System.currentTimeMillis()); jtp.addTab("Table", getIcon("JTableColor16"), new TablePanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); try { // System.out.println(System.currentTimeMillis()); jtp.addTab("List", getIcon("JListColor16"), new ListPanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); } catch (NoClassDefFoundError ncdfe) { } // System.out.println(System.currentTimeMillis()); jtp.addTab("Slider", getIcon("JSliderColor16"), new SliderPanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); // System.out.println(System.currentTimeMillis()); jtp.addTab("Progress bar", getIcon("JProgressBarColor16"), new ProgressBarPanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); // System.out.println(System.currentTimeMillis()); jtp.addTab("Spinner", getIcon("JSpinnerColor16"), new SpinnerPanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); // System.out.println(System.currentTimeMillis()); jtp.addTab("Tree", getIcon("JTreeColor16"), new TreePanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); // System.out.println(System.currentTimeMillis()); jtp.addTab("File tree", getIcon("JTreeColor16"), new FileTreePanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); // System.out.println(System.currentTimeMillis()); jtp.addTab("Cards", new CardPanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); // System.out.println(System.currentTimeMillis()); JPanel verticalButtonPanel = new JPanel(); verticalButtonPanel.setLayout(new GridLayout(1, 3)); verticalButtonPanel.add(new JButton("Vert button 1")); verticalButtonPanel.add(new JButton("Vert button 2")); JPanel smallVerticalButtonPanel = new JPanel(); smallVerticalButtonPanel.setLayout(new GridLayout(4, 4)); for (int row = 0; row < 4; row++) { for (int col = 0; col < 4; col++) { JButton vertButton = new JButton("vert"); vertButton.setToolTipText("Vertical button " + row + ":" + col); smallVerticalButtonPanel.add(vertButton); } } verticalButtonPanel.add(smallVerticalButtonPanel); jtp.addTab("Vertical buttons", verticalButtonPanel); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); // System.out.println(System.currentTimeMillis()); jtp.addTab("Colored", new ColoredControlsPanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); // System.out.println(System.currentTimeMillis()); jtp.addTab("Colorized", new ColorizedControlsPanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); // System.out.println(System.currentTimeMillis()); jtp.addTab("Cells", new CellsPanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); // buttonStripPanel = new JPanel(); // buttonStripPanel.setLayout(new FlowLayout()); // System.out.println(System.currentTimeMillis()); jtp.addTab("Sizes", new SizesPanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); // System.out.println(System.currentTimeMillis()); jtp.addTab("Alignment", new AlignmentPanel()); // System.out.println(System.currentTimeMillis() + // jtp.getTitleAt(jtp.getTabCount()-1)); // sample menu bar JMenuBar jmb = new JMenuBar(); if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) { jmb.add(SampleMenuFactory.getSkinMenu()); jmb.add(SampleMenuFactory.getTransformMenu()); } JMenu coloredMenu = new JMenu("Colors"); coloredMenu.setMnemonic('0'); JMenuItem coloredMI = new JMenuItem("Italic red"); coloredMI.setFont(coloredMI.getFont().deriveFont(Font.ITALIC)); coloredMI.setForeground(Color.red); coloredMenu.add(coloredMI); JRadioButtonMenuItem coloredRBMI = new JRadioButtonMenuItem( "Bold green"); coloredRBMI.setFont(coloredRBMI.getFont().deriveFont(Font.BOLD)); coloredRBMI.setForeground(Color.green); coloredMenu.add(coloredRBMI); JCheckBoxMenuItem coloredCBMI = new JCheckBoxMenuItem("Big blue"); coloredCBMI.setFont(coloredCBMI.getFont().deriveFont(32f)); coloredCBMI.setForeground(Color.blue); coloredMenu.add(coloredCBMI); JMenu coloredM = new JMenu("Always big magenta"); coloredM.setForeground(Color.magenta); coloredM.setFont(coloredM.getFont().deriveFont(24f)); coloredMenu.add(coloredM); jmb.add(coloredMenu); JMenu testMenu = SampleMenuFactory.getTestMenu(); jmb.add(testMenu); JMenu jm4 = new JMenu("Disabled"); jm4.add(new JMenuItem("dummy4")); jm4.setMnemonic('4'); jmb.add(jm4); jm4.setEnabled(false); // LAF changing jmb.add(SampleMenuFactory.getLookAndFeelMenu(this)); setJMenuBar(jmb); TabCloseCallback closeCallbackMain = new TabCloseCallback() { public TabCloseKind onAreaClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.getButton() != MouseEvent.BUTTON2) return TabCloseKind.NONE; if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } public TabCloseKind onCloseButtonClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.isAltDown()) { return TabCloseKind.ALL_BUT_THIS; } if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } return TabCloseKind.THIS; } public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) { return null; } public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex) { StringBuffer result = new StringBuffer(); result.append(""); result.append("Mouse click closes " + tabbedPane.getTitleAt(tabIndex) + " tab"); result .append("
Alt-Mouse click closes all tabs but " + tabbedPane.getTitleAt(tabIndex) + " tab"); result.append("
Shift-Mouse click closes all tabs"); result.append(""); return result.toString(); } }; jtp.putClientProperty(SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK, closeCallbackMain); SubstanceLookAndFeel .registerTabCloseChangeListener(new TabCloseListener() { public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) { out("Closed tab"); } public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) { out("Closing tab"); } }); SubstanceLookAndFeel.registerTabCloseChangeListener(jtp, new VetoableTabCloseListener() { public void tabClosed(JTabbedPane tabbedPane, Component tabComponent) { out("Closed tab - specific"); } public void tabClosing(JTabbedPane tabbedPane, Component tabComponent) { out("Closing tab - specific"); } public boolean vetoTabClosing(JTabbedPane tabbedPane, Component tabComponent) { int userCloseAnswer = JOptionPane .showConfirmDialog( Check.this, "Are you sure you want to close '" + tabbedPane .getTitleAt(tabbedPane .indexOfComponent(tabComponent)) + "' tab?", "Confirm dialog", JOptionPane.YES_NO_OPTION); return (userCloseAnswer == JOptionPane.NO_OPTION); } }); SubstanceLookAndFeel.registerTabCloseChangeListener(jtp, new VetoableMultipleTabCloseListener() { public void tabsClosed(JTabbedPane tabbedPane, Set tabComponents) { out("Closed " + tabComponents.size() + " tabs - specific"); } public void tabsClosing(JTabbedPane tabbedPane, Set tabComponents) { out("Closing " + tabComponents.size() + " tabs - specific"); } public boolean vetoTabsClosing(JTabbedPane tabbedPane, Set tabComponents) { int userCloseAnswer = JOptionPane.showConfirmDialog( Check.this, "Are you sure you want to close " + tabComponents.size() + " tabs?", "Confirm dialog", JOptionPane.YES_NO_OPTION); return (userCloseAnswer == JOptionPane.NO_OPTION); } }); addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { System.out.println("Size " + getSize()); } }); } protected static JXStatusBar getStatusBar(final JXPanel jxPanel, final JTabbedPane mainTabbedPane) { JXStatusBar statusBar = new JXStatusBar(); try { ClassLoader cl = Thread.currentThread().getContextClassLoader(); Enumeration urls = cl.getResources("META-INF/MANIFEST.MF"); String substanceVer = null; String substanceBuildStamp = null; while (urls.hasMoreElements()) { InputStream is = urls.nextElement().openStream(); BufferedReader br = new BufferedReader( new InputStreamReader(is)); while (true) { String line = br.readLine(); if (line == null) break; int firstColonIndex = line.indexOf(":"); if (firstColonIndex < 0) continue; String name = line.substring(0, firstColonIndex).trim(); String val = line.substring(firstColonIndex + 1).trim(); if (name.compareTo("Substance-Version") == 0) substanceVer = val; if (name.compareTo("Substance-BuildStamp") == 0) substanceBuildStamp = val; } try { br.close(); } catch (IOException ioe) { } } if (substanceVer != null) { JLabel statusLabel = new JLabel(substanceVer + " [built on " + substanceBuildStamp + "]"); JXStatusBar.Constraint cStatusLabel = new JXStatusBar.Constraint(); cStatusLabel.setFixedWidth(300); statusBar.add(statusLabel, cStatusLabel); } } catch (IOException ioe) { } JXStatusBar.Constraint c2 = new JXStatusBar.Constraint( JXStatusBar.Constraint.ResizeBehavior.FILL); final JLabel tabLabel = new JLabel(""); statusBar.add(tabLabel, c2); mainTabbedPane.getModel().addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { int selectedIndex = mainTabbedPane.getSelectedIndex(); if (selectedIndex < 0) tabLabel.setText("No selected tab"); else tabLabel.setText("Tab " + mainTabbedPane.getTitleAt(selectedIndex) + " selected"); } }); JPanel fontSizePanel = FontSizePanel.getPanel(); JXStatusBar.Constraint fontSizePanelConstraints = new JXStatusBar.Constraint(); fontSizePanelConstraints.setFixedWidth(190); statusBar.add(fontSizePanel, fontSizePanelConstraints); JPanel alphaPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0)); final JLabel alphaLabel = new JLabel("100%"); final JSlider alphaSlider = new JSlider(0, 100, 100); alphaSlider.setFocusable(false); alphaSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { int currValue = alphaSlider.getValue(); alphaLabel.setText(currValue + "%"); jxPanel.setAlpha(currValue / 100.0f); } }); alphaSlider .setToolTipText("Changes the global opacity. Is not Substance-specific"); alphaSlider.setPreferredSize(new Dimension(120, alphaSlider .getPreferredSize().height)); alphaPanel.add(alphaLabel); alphaPanel.add(alphaSlider); JXStatusBar.Constraint alphaPanelConstraints = new JXStatusBar.Constraint(); alphaPanelConstraints.setFixedWidth(160); statusBar.add(alphaPanel, alphaPanelConstraints); return statusBar; } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { boolean hasLafSpecified = false; try { hasLafSpecified = (System.getProperty("swing.defaultlaf") != null); } catch (Throwable t) { // JNLP sandbox } // LAFAdapter.startWidget(); try { if (!hasLafSpecified) { out(" CREATING LAF "); long time0 = System.currentTimeMillis(); LookAndFeel laf = new SubstanceGeminiLookAndFeel(); long time1 = System.currentTimeMillis(); out(" LAF CREATED " + (time1 - time0)); out(" SETTING LAF "); long time2 = System.currentTimeMillis(); UIManager.setLookAndFeel(laf); long time3 = System.currentTimeMillis(); out(" LAF SET " + (time3 - time2)); } } catch (Exception e) { e.printStackTrace(); } SubstanceLookAndFeel.setToUseConstantThemesOnDialogs(true); UIManager .put( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); UIManager.put(SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS, Boolean.TRUE); // try { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); long time2 = System.currentTimeMillis(); Check c = new Check(); c.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { super.componentResized(e); ((JFrame) e.getComponent()).getRootPane().repaint(); } }); c.setPreferredSize(new Dimension(820, 560)); c.setMinimumSize(new Dimension(150, 100)); c.pack(); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); // center the frame in the physical screen c.setLocation((d.width - c.getWidth()) / 2, (d.height - c .getHeight()) / 2); c.setVisible(true); c .setDefaultCloseOperation(System .getProperty("javawebstart.version") != null ? JFrame.EXIT_ON_CLOSE : JFrame.DISPOSE_ON_CLOSE); long time3 = System.currentTimeMillis(); out("App " + (time3 - time2)); } }); } public static void out(Object obj) { try { System.out.println(obj); } catch (Exception exc) { // ignore - is thrown on Mac in WebStart (security access) } } public static Icon getIcon(String iconName) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); URL url = cl.getResource("test/check/icons/" + iconName + ".gif"); if (url != null) return new ImageIcon(url); url = cl.getResource("test/check/icons/" + iconName + ".png"); if (url != null) return new ImageIcon(url); return null; } public static JToolBar getToolbar(String label, int size, boolean hasStrings) { JToolBar toolBar = new JToolBar(); JButton buttonCut = new JButton(hasStrings ? "cut" : null, getIcon(size + "/edit-cut")); buttonCut.putClientProperty( SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE); toolBar.add(buttonCut); JButton buttonCopy = new JButton(hasStrings ? "copy" : null, getIcon(size + "/edit-copy")); buttonCopy.putClientProperty( SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE); buttonCopy.setEnabled(false); toolBar.add(buttonCopy); JButton buttonPaste = new JButton(getIcon(size + "/edit-paste")); toolBar.add(buttonPaste); JButton buttonSelectAll = new JButton( getIcon(size + "/edit-select-all")); toolBar.add(buttonSelectAll); JButton buttonDelete = new JButton(getIcon(size + "/edit-delete")); toolBar.add(buttonDelete); toolBar.addSeparator(); // add an inner toolbar to check the painting of toolbar // gradient and drop shadows under different skins. JToolBar innerToolbar = new JToolBar(JToolBar.HORIZONTAL); innerToolbar.setFloatable(false); JToggleButton buttonFormatCenter = new JToggleButton(getIcon(size + "/format-justify-center")); buttonFormatCenter.putClientProperty( SubstanceLookAndFeel.CORNER_RADIUS, Float.valueOf(5.0f)); innerToolbar.add(buttonFormatCenter); JToggleButton buttonFormatLeft = new JToggleButton(getIcon(size + "/format-justify-left")); innerToolbar.add(buttonFormatLeft); JToggleButton buttonFormatRight = new JToggleButton(getIcon(size + "/format-justify-right")); innerToolbar.add(buttonFormatRight); JToggleButton buttonFormatFill = new JToggleButton(getIcon(size + "/format-justify-fill")); buttonFormatFill.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, Float.valueOf(0.0f)); innerToolbar.add(buttonFormatFill); toolBar.add(innerToolbar); toolBar.addSeparator(); if (size > 20) { JToolBar innerToolbar2 = new JToolBar(JToolBar.HORIZONTAL); innerToolbar2.setFloatable(false); JPanel innerPanel = new JPanel( new FlowLayout(FlowLayout.LEFT, 0, 0)); innerToolbar2.add(innerPanel, BorderLayout.CENTER); final JToggleButton buttonStyleBold = new JToggleButton( getIcon(size + "/format-text-bold")); Set rightSide = EnumSet.of(Side.RIGHT); buttonStyleBold.putClientProperty( SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide); buttonStyleBold.putClientProperty( SubstanceLookAndFeel.CORNER_RADIUS, Float.valueOf(3.0f)); final JToggleButton buttonStyleItalic = new JToggleButton( getIcon(size + "/format-text-italic")); buttonStyleItalic.putClientProperty( SubstanceLookAndFeel.CORNER_RADIUS, Float.valueOf(0.0f)); buttonStyleItalic.putClientProperty( SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide); final JToggleButton buttonStyleUnderline = new JToggleButton( getIcon(size + "/format-text-underline")); buttonStyleUnderline.putClientProperty( SubstanceLookAndFeel.CORNER_RADIUS, Float.valueOf(0.0f)); buttonStyleUnderline.putClientProperty( SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide); final JToggleButton buttonStyleStrikethrough = new JToggleButton( getIcon(size + "/format-text-strikethrough")); buttonStyleStrikethrough.putClientProperty( SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, EnumSet .of(Side.LEFT)); buttonStyleStrikethrough.putClientProperty( SubstanceLookAndFeel.CORNER_RADIUS, Float.valueOf(3.0f)); buttonStyleBold.setSelected(true); innerPanel.add(buttonStyleBold); innerPanel.add(buttonStyleItalic); innerPanel.add(buttonStyleUnderline); innerPanel.add(buttonStyleStrikethrough); toolBar.add(innerToolbar2); } toolBar.add(Box.createGlue()); JButton buttonExit = new JButton(getIcon(size + "/process-stop")); buttonExit.setToolTipText("Closes the test application"); buttonExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); toolBar.add(buttonExit); return toolBar; } public void setSpecificTaskPane(JPanel contents, String title, Icon icon) { if (currentSpecificTaskPane != null) { taskPaneContainer.remove(currentSpecificTaskPane); } currentSpecificTaskPane = new JXTaskPane(); currentSpecificTaskPane.setLayout(new BorderLayout()); currentSpecificTaskPane.setTitle(title); currentSpecificTaskPane.setIcon(icon); // contents.setOpaque(false); SwingUtilities.updateComponentTreeUI(contents); // currentSpecificTaskPane.setOpaque(false); currentSpecificTaskPane.add(contents, BorderLayout.CENTER); // this.mainTaskPane.setExpanded(false); taskPaneContainer.add(currentSpecificTaskPane); } public void clearSpecificTaskPane() { if (currentSpecificTaskPane != null) { taskPaneContainer.remove(currentSpecificTaskPane); } currentSpecificTaskPane = null; // this.mainTaskPane.setExpanded(true); } public class TabSwitchListener implements ChangeListener { public void stateChanged(ChangeEvent e) { Component selected = jtp.getSelectedComponent(); if (selected instanceof Deferrable) { Deferrable deferrable = (Deferrable) selected; if (!deferrable.isInitialized()) deferrable.initialize(); } if (selected instanceof Controllable) { JPanel controlPanel = ((Controllable) selected) .getControlPanel(); if (controlPanel == null) clearSpecificTaskPane(); else setSpecificTaskPane(controlPanel, jtp.getTitleAt(jtp .getSelectedIndex()), jtp.getIconAt(jtp .getSelectedIndex())); } else { clearSpecificTaskPane(); } } } public static class MyMainTabPreviewPainter extends DefaultTabPreviewPainter { protected TabOverviewKind tabOverviewKind; public void setTabOverviewKind(TabOverviewKind tabOverviewKind) { this.tabOverviewKind = tabOverviewKind; } @Override public TabOverviewKind getOverviewKind(JTabbedPane tabPane) { if (tabOverviewKind == null) return super.getOverviewKind(tabPane); return tabOverviewKind; } } public JTabbedPane getMainTabbedPane() { return this.jtp; } } substance-5.3.orig/src/test/EmptyFrame.java0000644000175000017500000000123711021415752020666 0ustar drazzibdrazzibpackage test; import javax.swing.*; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; public class EmptyFrame extends JFrame { public EmptyFrame() { this.add(new JTabbedPane()); this.setSize(400, 300); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) throws Exception { JFrame.setDefaultLookAndFeelDecorated(true); UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new EmptyFrame().setVisible(true); } }); } } substance-5.3.orig/src/test/SetFontPolicy.java0000644000175000017500000000657411106217376021376 0ustar drazzibdrazzibpackage test; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import javax.swing.plaf.FontUIResource; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.fonts.FontPolicy; import org.jvnet.substance.fonts.FontSet; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; public class SetFontPolicy extends JFrame { private static class WrapperFontSet implements FontSet { private boolean isBold; private FontSet delegate; public WrapperFontSet(FontSet delegate, boolean isBold) { super(); this.delegate = delegate; this.isBold = isBold; } private FontUIResource getWrappedFont(FontUIResource systemFont) { return new FontUIResource(systemFont.getFontName(), this.isBold ? Font.BOLD : systemFont.getStyle(), systemFont .getSize()); } public FontUIResource getControlFont() { return this.getWrappedFont(this.delegate.getControlFont()); } public FontUIResource getMenuFont() { return this.getWrappedFont(this.delegate.getMenuFont()); } public FontUIResource getMessageFont() { return this.getWrappedFont(this.delegate.getMessageFont()); } public FontUIResource getSmallFont() { return this.getWrappedFont(this.delegate.getSmallFont()); } public FontUIResource getTitleFont() { return this.getWrappedFont(this.delegate.getTitleFont()); } public FontUIResource getWindowTitleFont() { return this.getWrappedFont(this.delegate.getWindowTitleFont()); } } /** * Creates the main frame for this sample. */ public SetFontPolicy() { super("Set font policy"); this.setLayout(new BorderLayout()); JPanel panel = new JPanel(new FlowLayout()); final JCheckBox isBold = new JCheckBox("is bold"); isBold.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { // reset the base font policy to null - this // restores the original font policy SubstanceLookAndFeel.setFontPolicy(null); // Get the default font set final FontSet substanceCoreFontSet = SubstanceLookAndFeel .getFontPolicy().getFontSet("Substance", null); // Create the wrapper font set FontPolicy newFontPolicy = new FontPolicy() { public FontSet getFontSet(String lafName, UIDefaults table) { return new WrapperFontSet(substanceCoreFontSet, isBold.isSelected()); } }; // set the new font policy SubstanceLookAndFeel.setFontPolicy(newFontPolicy); } }); } }); panel.add(isBold); panel.add(new JButton("button")); panel.add(new JComboBox(new Object[] { "item1", "item2" })); this.add(panel, BorderLayout.CENTER); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { new SetFontPolicy().setVisible(true); } }); } } substance-5.3.orig/src/test/themes/0000755000175000017500000000000011256731164017244 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/themes/State.java0000644000175000017500000000222611023127532021157 0ustar drazzibdrazzibpackage test.themes; import java.awt.FlowLayout; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.FocusKind; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; public class State extends JFrame { public State() { super("Control states"); this.setLayout(new FlowLayout()); JToggleButton button1 = new JToggleButton("active"); button1.setSelected(true); JButton button2 = new JButton("default"); JButton button3 = new JButton("disabled"); button3.setEnabled(false); this.add(button1); this.add(button2); this.add(button3); this.pack(); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); UIManager.put(SubstanceLookAndFeel.FOCUS_KIND, FocusKind.NONE); JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new State().setVisible(true); } }); } } substance-5.3.orig/src/test/themes/State2.java0000644000175000017500000000432511134764446021261 0ustar drazzibdrazzibpackage test.themes; import java.awt.BorderLayout; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.FocusKind; import org.jvnet.substance.skin.OfficeSilver2007Skin; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; public class State2 extends JFrame { public State2() { super("States"); this.setLayout(new BorderLayout()); JButton defaultButton = new JButton("sample"); JButton rolloverButton = new JButton("sample"); rolloverButton.getModel().setRollover(true); JButton selectedButton = new JButton("sample"); selectedButton.getModel().setSelected(true); JButton rolloverSelectedButton = new JButton("sample"); rolloverSelectedButton.getModel().setRollover(true); rolloverSelectedButton.getModel().setSelected(true); JButton pressedButton = new JButton("sample"); pressedButton.getModel().setPressed(true); pressedButton.getModel().setArmed(true); JButton pressedSelectedButton = new JButton("sample"); pressedSelectedButton.getModel().setPressed(true); pressedSelectedButton.getModel().setSelected(true); pressedSelectedButton.getModel().setArmed(true); FormLayout lm = new FormLayout("right:pref, 4dlu, fill:pref:grow", ""); DefaultFormBuilder builder = new DefaultFormBuilder(lm); builder.append("Regular", defaultButton); builder.append("Rollover", rolloverButton); builder.append("Selected", selectedButton); builder.append("Rollover selected", rolloverSelectedButton); builder.append("Pressed", pressedButton); builder.append("Pressed selected", pressedSelectedButton); builder.setDefaultDialogBorder(); this.add(builder.getPanel()); this.pack(); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { SubstanceLookAndFeel.setSkin(new OfficeSilver2007Skin()); UIManager.put(SubstanceLookAndFeel.FOCUS_KIND, FocusKind.NONE); JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new State2().setVisible(true); } }); } } substance-5.3.orig/src/test/icons/0000755000175000017500000000000011256731162017070 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/icons/edit-select-all.png0000644000175000017500000000116710570355674022563 0ustar drazzibdrazzibPNG  IHDR szzsBIT|d.IDATXŗn@*R- %qP)ox$@SBzhUd6㈹L7+s_m׽ipmmlg`p LMwcu2l 7* @c."s@`SDdnd:qym^VEi8>(wV.•8%]` Ǭ#E-ً/ x\-HխIENDB`substance-5.3.orig/src/test/icons/edit-delete.png0000644000175000017500000000400110570355674021766 0ustar drazzibdrazzibPNG  IHDR szzsBIT|dtEXtSoftwarewww.inkscape.org<IDATXW[]Wuۗ9sfN3$M&Ѧ R-xy*} R+} ->ւh*AHiSۦA3Ld.͙9s}u߇ 3әPeֿBmx(C"Rʙo;;o#PJFU`l?z0"fF3_Ms "h`fcŶ&{{ z\ Q k-fggeٶ"yFFF+O;gxZ<=6&8w=}m ODӹ:Nf_wn?8F[crC6^g]f.v3ϝnx:[ND@s։{vt>'_..1sFM(X9!7=|= 3;rFIENDB`substance-5.3.orig/src/test/icons/access.png0000644000175000017500000001637310772763120021052 0ustar drazzibdrazzibPNG  IHDR@@iqIDATxy\Untu-t I[XVQAQgDdpygDQܑU [ ]Uun:!a={sY99%R\y.P`SB(DBY.@*RH1(ژ@I޴o G%dRL4yRsB3XSGɨtt%T {l:?t{z騗&Mh([ַӥύ4/8n~GKF[iPmP3uRyOH֫ss]Vq}p&$;Ҭړᕕ{8OC55?@m|{ϸ]r8#ά) @`hЎ@C6jC2^1 hX# LqtޛbabUOz[_nvVfo VqOgfyGdu|ZkaZda( i;TYӕZ/IPaOS-'˜Q,a$z`gv~oN++..f__i}.:kٲiܑ@(M |ޑЇ8*^0&UI" 0*>0M84bŎqv=֛5iǮ[&˸}Yk޻w޲,iKu,:{`v+v/0JTǠ=$X9X|`l<͊]l-_T'{׎k %`~[ޫ6m\*X]<ִWoOuET/ q ̄>9f'>f3!XV}#+!  8{Il?cphLnxj DcIN <6?Ff~`1|5 nRyzʼnU "$-KQ+|og<9Ԋ~֏J]QqQQ y'´Y:)`7bۿQ?|vNLyILxm= =VGbkI*>V5(Ul^Ir"*lG+ssnv%^/H $p|D6Y. _7U|5G@vS Ԭ+9>I$*BQ+&OD:bH8s]lG"Gd "xvӧh(W A}[_0qG7B$^guv14eqWdUc`uۅZ0\9NϮ20j3<~iH*㸅RE k.>wmuy S/`ݦ1>נ~ɂ6j/b$)3;yNXO#|^ MhJ7HMa>qI1 &2yجPs hJKϚyrK5IVM8 A<1owr|s9ea>0g{ٺkϗ"$7|ySȢ5H Fs(BP0q= 豘&b!(G#BC&LLd]$TdaS$AN"EVXD,>{b'?3r/=y,>/ށ 15@)+%4 *|$Ac;.AQC+ B] PH BG; \2=OƐ5t3t4BRe" )ji(x}\0ujh" *㈱$(P mǵ Lx*i(]W!~4- I'VݪAևdX 3fhQpx*I1~Ő("6yS4} ڦKɦ)Nw5zLdP.hfGXzT?(ohhE3hf݈Qt#[@t}Oe7++"H%QG>w <ҳ^@zTj%BCGpB А^MIÈ1)4M/mgR"JGy#p& Bf'Dq,+2:JCIU@MWGy:?°h8PVh!tsrU՘(B͝\: agBHU(PH"@y29Q9D:A~Ule)slzX$f2|p% y3Og; 캭=ͩf@'ʾ4,SM݀s\Jmm]v'HkhMJh1 &bzaoɜ.; GkBJ"0Gq7pwsCcW,H+0 U] 0L.d6+_OUDKރL~x>j;Pld˞/m=/9d8BJkW1gA'I6үرohg m]-o l}2)h\S3񙿨w g_޾-X5 yY3mžJ7ak6/ٞ$h!ί@sc  %+Ec2A\c${l 5 d"#4WqNL0C&e4C2nA _,J#ڐWRj{4esuB:sm(gnЁ (epkl{6N&{_ǎIYk_Aoܻ B}sϝ⬯ w{ fs㼲0Z-y(ՏDbݖ3Ͻ!:j\b ' ;CU  ™t(/V^1{>2낡OJ~Lhh7~N +{̘E⾗r#qݱu]󩫯z6dh: ~s4ׇYU/=Èdt+B躎i" %PLnAyWS_2 ya`JT-ǎ=ymw> GXmug0߱>tY1!$P=L=RB3 ˲0M@$+AxZ.(uW_d]Ǹ++0iӷӫn ?y <(i.Y sG3~f5k,YWzG򵻟aD"^'`Yeaa .P$y!΢l'qǗsg\9:M-SzJ7c}[y*tκoLYz|]g=SE\ήY>~ {z2E:N<9 *]HGvHgrHc^W?oHP˽m?ފԫhhnb39i_u^{CD.?g\s<{-N򳛹 io*Oy^_uMR%JX CG/.A|O=t%ʩDF5ոaPV%{˫ p`iiIy "%" a0Y"*Y!"OXqBT*AeIe tС( Dsev`px(@&,T),+ L]LjH BSU(HR璂~9BxHZ_H"D0n~$?T), DM c'a)iƘia IbJ{"~{b`{ fPi&"<|iLp4D>.k*q`n9We7;{7  I*c@O{a=?\I ڵJXup1 `6}9Y.W& TD"i҇1!}3?NP]zo.'[F񩤰nߵ1v0擕յiט{VT MIENDB`substance-5.3.orig/src/test/icons/edit-paste.png0000644000175000017500000000200310570355674021640 0ustar drazzibdrazzibPNG  IHDR szzsBIT|dIDATX݋UǦhx$WJ .^BEb- "( EPVA*zK,٦$s^/3LI9Μ91eNxSӌgN :wit] TJ~Q`#Cp4P\nUK4\_8U6gYY9a Cml;] k"SԐio|XU_Z0.{h 2LHMӘCgdSzy'W??X"Yy* oLK4Y,9O[C7 orjiD=!@V0 _}۶xgmT8/<ի[(5Cuh죔K>?Nj>dsuueV"4u2naa۶Τ!"!Y9uEqۏ$\*B2STJ,>j` 8X4(X(<( 7ZMG3-s8-J ރbvЩ-f&/ً `!B;!@2  oсlۦP(D`gSoD`Xbó6 /ޡe zH*/l&^*@G.BK6hMO> R8]g6@)5fa LϽ :NI >+8g/^۫qh5[RV \W!Nv6砃;Fۙn (fgN5zxڽt7mTe~~Ev$ˀdvBOuIYX6;Xnw D?y|M@)CP `Ht_{#Q{M0u<:,G<@ oUEIENDB`substance-5.3.orig/src/test/icons/edit-cut.png0000644000175000017500000000404710570355674021331 0ustar drazzibdrazzibPNG  IHDR szzsBIT|dIDATX{lǿ3;ww;M b40U$-U*"l7D@CMTJ64QԪ"`@0X6=vwf9dvl?]ff &ٵ0b/Gæ&v֛c9M6EƋ5fr7<^SI^S\V'w,TW\mwY8RJڝ{/}ʯJN55;Tۂ3.;lۓ]dP!$JKK5'SkJeeNW8R"7ap83%߹sg tWn0!Dzz&RL @?oHHiZXUҥĜƜ g6E8'P8@O8BJ CCAA]5SkRBSss٥) oJ-uRuuu?-`S˖L GunZ'*q~ƆÇtUR0Ŧ-$Ph25-5!!|͊S[V/DŽP hjjB %E=nOA]]:۞ʥ-w)%laD&BENi2cR"aE*7e~9XZH5ѯnթDMUU/ PUU.sıp|*=HR@uKrsX|o ! ݾ~SHt{wOg0 ,¼B,(uE"H)ii-^EEQӲk%3^xS0ݓPXgkXp9k}_ ndBL'*e +S\N'] B5?!Mѧ[7n#TQ,WФC(CDzRS^ @ڻHtFavCKw{_R !h z@nS!@ @EiHN~dNAsi $H{9@ngmmlGҎ`3@t[lRr} cÙ99ߜSͺŹv7`Yo% YV̟5K&{zA]Wcb…yӆ$`lE07Pz:1P@H.lC`$WSؖef:|>@OokkͲh`}Z12P7{Nw2SNɌ=3 gL۰r .LIJ1W~>>2bL]?K?{4HWIENDB`substance-5.3.orig/src/test/RoTextField.java0000644000175000017500000000275011174635522021017 0ustar drazzibdrazzibpackage test; import java.awt.FlowLayout; import java.awt.Font; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.OfficeBlue2007Skin; import org.jvnet.substance.skin.TwilightSkin; public class RoTextField extends JFrame { public RoTextField() { super("Some simple text"); this.setLayout(new FlowLayout()); final JButton button = new JButton("default"); this.add(button); this.getRootPane().setDefaultButton(button); this.addWindowListener(new WindowAdapter() { @Override public void windowActivated(WindowEvent e) { button.requestFocusInWindow(); } }); this.setSize(650, 400); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { // FadeTracker.DEBUG_MODE = true; JFrame.setDefaultLookAndFeelDecorated(true); // UIManager.put(LafWidget.ANIMATION_KIND, AnimationKind.NONE); SubstanceLookAndFeel.setSkin(new TwilightSkin()); System.out.println("bg: " + UIManager.getColor("Table.selectionBackground")); System.out.println("bg: " + UIManager.getColor("Tree.selectionBackground")); System.out.println("fg: " + UIManager.getColor("Tree.selectionForeground")); SwingUtilities.invokeLater(new Runnable() { public void run() { new RoTextField().setVisible(true); } }); } } substance-5.3.orig/src/test/Walkthrough.java0000644000175000017500000000132410776635512021127 0ustar drazzibdrazzibpackage test; import java.awt.Dimension; import java.awt.FlowLayout; import javax.swing.*; public class Walkthrough extends JFrame { public Walkthrough() { super("Sample app"); this.setLayout(new FlowLayout()); this.add(new JButton("button")); this.add(new JCheckBox("check")); this.add(new JLabel("label")); this.setSize(new Dimension(250, 80)); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { Walkthrough w = new Walkthrough(); w.setVisible(true); } }); } }substance-5.3.orig/src/test/ScreenInsetsTest.java0000644000175000017500000000255211226112474022065 0ustar drazzibdrazzibpackage test; import java.awt.GraphicsEnvironment; import java.awt.Toolkit; import java.awt.event.WindowEvent; import java.awt.event.WindowStateListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.JFrame; import javax.swing.SwingUtilities; public class ScreenInsetsTest extends JFrame { public ScreenInsetsTest() { Toolkit.getDefaultToolkit().addPropertyChangeListener("win.propNames", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { System.out.println(Toolkit.getDefaultToolkit() .getScreenInsets( GraphicsEnvironment .getLocalGraphicsEnvironment() .getDefaultScreenDevice() .getDefaultConfiguration())); } }); this.addWindowStateListener(new WindowStateListener() { @Override public void windowStateChanged(WindowEvent e) { System.out.println(e.getID() + ":" + e.getOldState() + ":" + e.getNewState()); } }); this.setSize(400, 300); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new ScreenInsetsTest().setVisible(true); } }); } } substance-5.3.orig/src/test/issues/0000755000175000017500000000000011256731162017270 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/issues/Issue436.java0000644000175000017500000000312611173347550021464 0ustar drazzibdrazzibpackage test.issues; import java.awt.Color; import java.awt.FlowLayout; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.SubstanceMistSilverLookAndFeel; /** * * @author blongstr */ public class Issue436 { public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { public void run() { UIManager.getDefaults().put( SubstanceLookAndFeel.COLORIZATION_FACTOR, new Double(1.0d)); try { UIManager .setLookAndFeel(new SubstanceMistSilverLookAndFeel()); } catch (UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); final JFrame appFrame = new JFrame("Substance Test Application"); appFrame.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); appFrame.setSize(400, 400); appFrame.setLocationRelativeTo(null); appFrame.setVisible(true); // Example of a component returning a null background color and // how it effects component UI initialization. JPanel panel = new JPanel() { @Override public Color getBackground() { return null; } }; panel.setLayout(new FlowLayout()); JButton button = new JButton("Test Button"); panel.add(button); panel.add(new JLabel("Test Label")); appFrame.add(panel); } }); } } substance-5.3.orig/src/test/issues/Issue397.java0000644000175000017500000000164011073357262021471 0ustar drazzibdrazzibpackage test.issues; import java.awt.ComponentOrientation; import javax.swing.*; public class Issue397 { public static void main(String[] args) throws Exception { UIManager .setLookAndFeel("org.jvnet.substance.skin.SubstanceCremeLookAndFeel"); SwingUtilities.invokeAndWait(new Runnable() { public void run() { JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 50); slider .applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); slider.setMajorTickSpacing(20); slider.setPaintTicks(true); slider.setPaintLabels(true); JDialog dialog = new JDialog((JFrame) null, true); dialog.setLayout(null); dialog.add(slider); slider.setBounds(10, 10, 200, 200); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setSize(250, 250); dialog.setLocationRelativeTo(null); dialog.setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue374.java0000644000175000017500000000657311035146616021473 0ustar drazzibdrazzibpackage test.issues; import org.jvnet.substance.skin.SubstanceRavenLookAndFeel; import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; import java.awt.image.ConvolveOp; import java.awt.image.Kernel; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class Issue374 extends JFrame { public Issue374(final boolean quick) throws HeadlessException { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JButton button = new JButton("This is a button"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { button.setEnabled(false); if (quick) blur(); else new Thread() { public void run() { SwingUtilities.invokeLater(new Runnable() { public void run() { try { Thread.sleep(1000); } catch (InterruptedException e1) { e1.printStackTrace(); } blur(); } }); } }.start(); } }); add(button); if (quick) setBounds(0, 0, 200, 80); else setBounds(200, 0, 200, 80); setVisible(true); } private void blur() { final BufferedImage bluredFrame = gaussianBlurImage( getBufferedImageOfFrame(this), 3); JPanel panel = new JPanel() { protected void paintComponent(Graphics g) { g.drawImage(bluredFrame, 0, 0, bluredFrame.getWidth(), bluredFrame.getHeight(), null); } }; setGlassPane(panel); getGlassPane().setVisible(true); } private static ConvolveOp getGaussianBlurFilter(int radius, boolean horizontal) { if (radius < 1) throw new IllegalArgumentException("Radius must be >= 1"); int size = radius * 2 + 1; float[] data = new float[size]; float sigma = radius / 3.0f; float twoSigmaSquare = 2.0f * sigma * sigma; float sigmaRoot = (float) Math.sqrt(twoSigmaSquare * Math.PI); float total = 0.0f; for (int i = -radius; i <= radius; i++) { float distance = i * i; int index = i + radius; data[index] = (float) Math.exp(-distance / twoSigmaSquare) / sigmaRoot; total += data[index]; } for (int i = 0; i < data.length; i++) data[i] /= total; Kernel kernel; if (horizontal) kernel = new Kernel(size, 1, data); else kernel = new Kernel(1, size, data); return new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null); } private static BufferedImage getBufferedImageOfFrame(JFrame frame) { JLayeredPane layeredPane = frame.getRootPane().getLayeredPane(); BufferedImage image = new BufferedImage(layeredPane.getWidth(), layeredPane.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics graphics = image.getGraphics(); layeredPane.paint(graphics); graphics.dispose(); return image; } public static BufferedImage gaussianBlurImage(BufferedImage image, int radius) { BufferedImage bluredImage = getGaussianBlurFilter(radius, true).filter( image, null); bluredImage = getGaussianBlurFilter(radius, false).filter(bluredImage, null); return bluredImage; } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { UIManager.setLookAndFeel(new SubstanceRavenLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } new Issue374(true); new Issue374(false); } }); } }substance-5.3.orig/src/test/issues/icon.png0000644000175000017500000000515011114135502020714 0ustar drazzibdrazzibPNG  IHDR00WsBIT|d IDAThyT?ٙ.AhiT#xDDc*UQ%m-BPTx` 1@%QIC\VEAkyuYX_y}ׯŷ_?̿L:s&E4΃O PF%2pC+^=뇥*`Μ[^vys.Zkutpᅓ%_n)dK'nٷӍ~--}]& Н]:˕мS\ٛ2OŌז//U(X:֬Y 'p,T:i lh`q4P(Tm|Ygƍ >²,> B qlήj톖&aм7A8b3CJ]͊VO1~xN9T cٗNqІt._X4B TeYر=\f1M_-[px$mt%پHCb9vqڵ'z+Wr٥QQQѫP%N%矷bYJ> T6 K.5yy>SFg6XP7"֚@d2vv|rs,.n^Su\^qB $PA&ޏyh߿?S\F9W놰, 0@PTΦh9眇4 ޷g /eq\ľ(l!i5²,&"Zm&;1bRaXm;!AK i9?:uxHRl7;Exg=aO;xt:M_ccBQRI("c&BJ$S.K_rApۜ[xBLx .ycFd bBCk@0 Xy$3I~ ik7vlgܳbK02MAH&0R@)V(v뫵FiR @y9ll6֊G e#DW[Y4Я_?UUrDZuqZ6mapwh;4MV7agx"8QQQH$ҧӉK.9嵵5MMioo6fO<FTWUd?J>0LB!p8\r9~ x:jGcB2㛈b pPE>;S)%aλ;0ߪ>'-H3lmm~S֚A&?(=)e~ọ4mN{!]+ *yqPg$3Yo*;tֳ^0UʃruݍeMg0~„ڲyA.> Uuq>p9ŸOuW_} 0yy),c"8D{C9({$z>2wYv_C5sݑy!os,Cq/<8+! p!ɿLm۾c072i,Nn4^Qߴ3x?}v!ZP .c'OlزuHE+lku/<͟K}lL*ZXt=SH+Wzn 'q!%'&LzkVy: /@h yٷ5xY theSorter = new TableRowSorter( model); JTable theTable = new JTable(model); theTable.setRowSorter(theSorter); JScrollPane theScrollingPane = new JScrollPane(theTable); mainPanel.add(theScrollingPane, BorderLayout.CENTER); // Add the button. JButton doSwitch = new JButton("Switch LAF"); doSwitch.setDefaultCapable(true); getRootPane().setDefaultButton(doSwitch); final Issue402 thisDialog = this; doSwitch.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { getRootPane().setCursor( Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { UIManager.setLookAndFeel(UIManager .getSystemLookAndFeelClassName()); SwingUtilities.updateComponentTreeUI(thisDialog); } catch (Exception e) { e.printStackTrace(); } getRootPane() .setCursor( Cursor .getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); } }); JPanel tempPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); tempPanel.add(doSwitch); mainPanel.add(tempPanel, BorderLayout.SOUTH); getContentPane().add(mainPanel); setSize(500, 300); setLocationRelativeTo(null); setVisible(true); } } substance-5.3.orig/src/test/issues/Issue437.java0000644000175000017500000000136211172050440021451 0ustar drazzibdrazzibpackage test.issues; import java.awt.BorderLayout; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; public class Issue437 extends JFrame { public Issue437() { JTabbedPane jtp = new JTabbedPane(); jtp.addTab("one", new JPanel()); jtp.addTab("two", new JPanel()); jtp.addTab("three", new JPanel()); this.add(jtp, BorderLayout.CENTER); this.setSize(400, 300); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { SubstanceLookAndFeel.setSkin(new Issue437Skin()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Issue437().setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue419.java0000644000175000017500000000440411140052756021460 0ustar drazzibdrazzibpackage test.issues; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.skin.OfficeSilver2007Skin; import org.jvnet.substance.skin.OfficeBlue2007Skin; import javax.swing.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.*; public class Issue419 extends JFrame { public Issue419() { super("Internal Frame Icon test"); } private static void changeSkin() { if (UIManager.getLookAndFeel() instanceof SubstanceLookAndFeel) { SubstanceSkin currentSkin = SubstanceLookAndFeel.getCurrentSkin(); if (currentSkin instanceof OfficeSilver2007Skin) SubstanceLookAndFeel.setSkin(new OfficeBlue2007Skin()); else SubstanceLookAndFeel.setSkin(new OfficeSilver2007Skin()); } else { try { UIManager.setLookAndFeel(UIManager .getSystemLookAndFeelClassName()); } catch (Exception e) { } for (Window window : Window.getWindows()) { SwingUtilities.updateComponentTreeUI(window); } } } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } private static void createAndShowGUI() { //JDialog.setDefaultLookAndFeelDecorated(true); //JFrame.setDefaultLookAndFeelDecorated(true); // SubstanceLookAndFeel.setSkin(new OfficeSilver2007Skin()); Issue419 frameTest = new Issue419(); JDesktopPane desktop = new JDesktopPane(); desktop.setPreferredSize(new Dimension(400, 400)); frameTest.add(desktop, BorderLayout.CENTER); JInternalFrame anInternalFrame = new JInternalFrame( "An internal frame", true, false, false, true); desktop.add(anInternalFrame); anInternalFrame.setPreferredSize(new Dimension(200, 200)); anInternalFrame.pack(); anInternalFrame.setFrameIcon(null); anInternalFrame.setLocation(0, 0); anInternalFrame.setVisible(true); JButton changeSkinButton = new JButton("Change skin"); changeSkinButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changeSkin(); } }); frameTest.add(changeSkinButton, BorderLayout.SOUTH); frameTest.pack(); frameTest.setVisible(true); } } substance-5.3.orig/src/test/issues/Issue437Skin.java0000644000175000017500000001463711172050534022313 0ustar drazzibdrazzib/* * aTunes 1.13.0 * Copyright (C) 2006-2009 Alex Aranda, Sylvain Gaudard, Thomas Beckers and contributors * * See http://www.atunes.org/wiki/index.php?title=Contributing for information about contributors * * http://www.atunes.org * http://sourceforge.net/projects/atunes * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package test.issues; import java.awt.Color; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.BaseLightColorScheme; import org.jvnet.substance.painter.border.ClassicBorderPainter; import org.jvnet.substance.painter.decoration.ArcDecorationPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.gradient.GlassGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * The Class SubstanceATunesSkin. */ public class Issue437Skin extends SubstanceSkin { static class BlueColorScheme extends BaseLightColorScheme { public BlueColorScheme(String displayName) { super(displayName); } private Color ultraDarkColor = new Color(32, 71, 143); private Color darkColor = new Color(43, 100, 177); private Color midColor = new Color(50, 111, 180); private Color lightColor = new Color(58, 132, 186); private Color extraLightColor = new Color(81, 152, 195); private Color ultraLightColor = new Color(103, 174, 195); private Color foregroundColor = new Color(246, 246, 246); @Override public Color getUltraDarkColor() { return ultraDarkColor; } @Override public Color getDarkColor() { return darkColor; } @Override public Color getMidColor() { return midColor; } @Override public Color getLightColor() { return lightColor; } @Override public Color getExtraLightColor() { return extraLightColor; } @Override public Color getUltraLightColor() { return ultraLightColor; } @Override public Color getForegroundColor() { return foregroundColor; } } static class MetallicColorScheme extends BaseLightColorScheme { public MetallicColorScheme(String displayName) { super(displayName); } private Color ultraDarkColor = new Color(87, 91, 95); private Color darkColor = new Color(123, 127, 131); private Color midColor = new Color(198, 202, 206); private Color lightColor = new Color(213, 221, 228); private Color extraLightColor = new Color(243, 247, 251); private Color ultraLightColor = new Color(251, 252, 255); private Color foregroundColor = new Color(25, 29, 33); @Override public Color getUltraDarkColor() { return ultraDarkColor; } @Override public Color getDarkColor() { return darkColor; } @Override public Color getMidColor() { return midColor; } @Override public Color getLightColor() { return lightColor; } @Override public Color getExtraLightColor() { return extraLightColor; } @Override public Color getUltraLightColor() { return ultraLightColor; } @Override public Color getForegroundColor() { return foregroundColor; } } static class DisabledMetallicColorScheme extends BaseLightColorScheme { public DisabledMetallicColorScheme(String displayName) { super(displayName); } private Color ultraDarkColor = new Color(100, 106, 112); private Color darkColor = new Color(180, 185, 190); private Color midColor = new Color(210, 214, 218); private Color lightColor = new Color(225, 228, 231); private Color extraLightColor = new Color(240, 242, 244); private Color ultraLightColor = new Color(250, 251, 252); private Color foregroundColor = new Color(120, 125, 130); @Override public Color getUltraDarkColor() { return ultraDarkColor; } @Override public Color getDarkColor() { return darkColor; } @Override public Color getMidColor() { return midColor; } @Override public Color getLightColor() { return lightColor; } @Override public Color getExtraLightColor() { return extraLightColor; } @Override public Color getUltraLightColor() { return ultraLightColor; } @Override public Color getForegroundColor() { return foregroundColor; } } /** * Creates a new skin. */ public Issue437Skin() { SubstanceColorScheme activeScheme = new BlueColorScheme("aTunes Blue"); SubstanceColorScheme defaultScheme = new MetallicColorScheme( "aTunes Metallic"); SubstanceColorScheme disabledScheme = new DisabledMetallicColorScheme( "aTunes Disabled Metallic"); // the default theme bundle SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); defaultSchemeBundle.registerHighlightColorScheme(activeScheme, 0.6f, ComponentState.ROLLOVER_UNSELECTED); defaultSchemeBundle.registerHighlightColorScheme(activeScheme, 0.8f, ComponentState.SELECTED); defaultSchemeBundle.registerHighlightColorScheme(activeScheme, 0.95f, ComponentState.ROLLOVER_SELECTED); defaultSchemeBundle.registerHighlightColorScheme(activeScheme, 0.8f, ComponentState.ARMED, ComponentState.ROLLOVER_ARMED); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); // the special theme bundle SubstanceColorSchemeBundle specialSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, activeScheme, disabledScheme); this.registerDecorationAreaSchemeBundle(specialSchemeBundle, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.TOOLBAR, DecorationAreaType.FOOTER, DecorationAreaType.HEADER, DecorationAreaType.GENERAL); this.setSelectedTabFadeStart(1); this.setSelectedTabFadeEnd(1); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new GlassGradientPainter(); this.borderPainter = new ClassicBorderPainter(); this.decorationPainter = new ArcDecorationPainter(); this.highlightPainter = new ClassicHighlightPainter(); } @Override public String getDisplayName() { return "aTunes Blue skin"; } } substance-5.3.orig/src/test/issues/Issue294.java0000644000175000017500000001414411021415162021453 0ustar drazzibdrazzibpackage test.issues; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.awt.Component; import java.util.Vector; import javax.swing.*; import org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel; /** * Simple non-editable combo under substance lnf. * * @author Prashant Bhat */ public class Issue294 { /** * @param args * the command line arguments */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { UIManager .setLookAndFeel(new SubstanceBusinessBlueSteelLookAndFeel()); } catch (Exception e) { e.printStackTrace(); } JFrame frame = new JFrame("Non-editable combo with renderer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Issue294 substanceCombo2 = new Issue294(); frame.add(substanceCombo2.createControl()); frame.pack(); frame.setSize(250, 150); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } private JComponent createControl() { JComboBox jComboBox = new JComboBox(createCustomersList()); jComboBox.setRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); setText(((Customer) value).getName()); ((JComponent) comp).setOpaque(false); return comp; } }); JButton jButton1 = new JButton("Ok"); JButton jButton2 = new JButton("Close"); JPanel controlPanel = new JPanel(); GroupLayout layout = new GroupLayout(controlPanel); controlPanel.setLayout(layout); layout .setHorizontalGroup(layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup( GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addComponent( jButton1) .addPreferredGap( LayoutStyle.ComponentPlacement.RELATED) .addComponent( jButton2)) .addGroup( layout .createSequentialGroup() .addGap( 38, 38, 38) .addComponent( jComboBox, GroupLayout.PREFERRED_SIZE, 177, GroupLayout.PREFERRED_SIZE))) .addContainerGap( GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); layout.setVerticalGroup(layout.createParallelGroup( GroupLayout.Alignment.LEADING).addGroup( layout.createSequentialGroup().addContainerGap().addComponent( jComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(31, 31, 31).addGroup( layout.createParallelGroup( GroupLayout.Alignment.BASELINE) .addComponent(jButton1).addComponent( jButton2)).addContainerGap( GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); return controlPanel; } private Vector createCustomersList() { Vector customers = new Vector(); customers.add(new Customer(1, "Bryan Chernick", "Regina")); customers.add(new Customer(2, "Clayton Lawless", "Maryfield")); customers.add(new Customer(3, "Linus Torvalds", "Portland")); customers.add(new Customer(4, "David Wilson", "Regina")); customers.add(new Customer(5, "King, Stephen", "Portland")); customers.add(new Customer(6, "Dan Bonin", "Milton")); customers.add(new Customer(7, "Doris Wilson", "Regina")); customers.add(new Customer(8, "Dyana Wilson", "Calgary")); customers.add(new Customer(9, "Graham Cale", "Walkerton")); customers.add(new Customer(10, "Jennifer Wilson", "Victoria")); customers.add(new Customer(11, "Matt Groening", "Portland")); customers.add(new Customer(12, "Jesse Wilson", "Waterloo")); customers.add(new Customer(13, "Joe Murray", "Cambridge")); customers.add(new Customer(14, "Jodie Ashford", "Caledonia")); customers.add(new Customer(15, "Jono Feldstein", "Toronto")); customers.add(new Customer(16, "Kevin Maltby", "Waterloo")); customers.add(new Customer(17, "Leanne Wilson", "Calgary")); customers.add(new Customer(18, "Lisa Kent", "Cambridge")); customers.add(new Customer(19, "Naomi Williams", "Guelph")); customers.add(new Customer(20, "Mark Wilson", "Assiniboia")); customers.add(new Customer(21, "Chuck Palahniuk", "Portland")); customers.add(new Customer(22, "Phil O'Dell", "Cambridge")); customers.add(new Customer(23, "Courtney Love", "Portland")); customers.add(new Customer(24, "Robbie Anderson", "Regina")); customers.add(new Customer(25, "Tuong Mao", "Regina")); customers.add(new Customer(26, "Wilson Harron", "Guelph")); customers.add(new Customer(27, "Sebastian Telfair", "Portland")); customers.add(new Customer(28, "Katherine Dunn", "Portland")); return customers; } public class Customer implements Comparable { public int code; public String name; public String location; public Customer(int code, String name, String location) { this.code = code; this.name = name; this.location = location; } public String getLocation() { return location; } public void setLocation(String location) { this.location = location; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getCode() { return code; } public void setCode(int code) { this.code = code; } public int compareTo(Customer o) { return name.compareTo(o.name); } } } substance-5.3.orig/src/test/issues/Issue444.java0000644000175000017500000000204711203752150021452 0ustar drazzibdrazzibpackage test.issues; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JFrame; import javax.swing.JRootPane; import javax.swing.UIManager; /** * to see the error click in the frame */ public class Issue444 extends JFrame { public Issue444() { setSize(1050, 600); setUndecorated(true); getRootPane().setWindowDecorationStyle(JRootPane.FRAME); addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent arg0) { // the order of these statements or using invokeLater does not change anything setExtendedState(MAXIMIZED_BOTH); getRootPane().setWindowDecorationStyle(JRootPane.NONE); } }); setVisible(true); } public static void main(String[] args) throws Exception { UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceBusinessLookAndFeel"); javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { new Issue444(); } }); } } substance-5.3.orig/src/test/issues/Issue446.java0000644000175000017500000000107411205533734021462 0ustar drazzibdrazzibpackage test.issues; import javax.swing.*; public class Issue446 extends JFrame { public Issue446() { JTree tabTree = new JTree(); tabTree.setEditable(true); add(tabTree); setSize(500, 500); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) throws Exception { UIManager .setLookAndFeel("org.jvnet.substance.skin.SubstanceBusinessLookAndFeel"); javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { new Issue446(); } }); } } substance-5.3.orig/src/test/issues/Issue233.java0000644000175000017500000000262011256367354021463 0ustar drazzibdrazzibpackage test.issues; import java.awt.BorderLayout; import java.awt.Frame; import java.awt.event.ActionEvent; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessSkin; public class Issue233 extends JDialog { Issue233() { super((Frame) null, "Test"); setSize(200, 200); JPanel myContentPane = new JPanel(); myContentPane.setLayout(new BorderLayout()); setContentPane(myContentPane); JTabbedPane tabs = new JTabbedPane(); tabs.addTab("Foo", new JButton("Test")); tabs.addTab("Bar", new JLabel()); add(tabs, BorderLayout.CENTER); // add(new JButton("Test"), BorderLayout.CENTER); add(new JLabel("Press Esc to close dialog"), BorderLayout.NORTH); // connect "Esc" key with "System.exit(0)" String actionName = "VK_ESCAPE"; Action action = new AbstractAction(actionName) { public void actionPerformed(ActionEvent e) { System.exit(0); } }; myContentPane.getActionMap().put(actionName, action); myContentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0), actionName); setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { SubstanceLookAndFeel.setSkin(new BusinessSkin()); new Issue233(); } }); } }substance-5.3.orig/src/test/issues/Issue412.java0000644000175000017500000000220011114141460021431 0ustar drazzibdrazzibpackage test.issues; import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessSkin; public class Issue412 extends JFrame { public Issue412() { super("Test big icon"); BufferedImage image = new BufferedImage(48, 48, BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = image.createGraphics(); g2d.setPaint(new GradientPaint(0, 0, Color.red, 48, 48, Color.blue)); g2d.fillRect(0, 0, 48, 48); g2d.dispose(); this.setIconImage(new ImageIcon(getClass().getResource("icon.png")) .getImage()); this.setSize(200, 100); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) throws Exception { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SubstanceLookAndFeel.setSkin(new BusinessSkin()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Issue412().setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue363.java0000644000175000017500000000467111022736454021467 0ustar drazzibdrazzibpackage test.issues; import java.awt.Dimension; import javax.swing.*; import org.jvnet.lafwidget.animation.FadeConfigurationManager; import org.jvnet.lafwidget.animation.FadeKind; public class Issue363 extends javax.swing.JDialog { public Issue363(java.awt.Frame parent, boolean modal) { super(parent, modal); // empty dialog final JDialog dialog = new JDialog(this, true); dialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); dialog.setMinimumSize(new Dimension(600, 600)); dialog.setPreferredSize(new Dimension(600, 600)); dialog.pack(); JButton btShow = new JButton(); this.add(btShow); btShow.setText("Show an empty dialog..."); btShow.setSelected(true); btShow.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { dialog.setVisible(true); } }); this.pack(); } public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { try { UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceRavenGraphiteGlassLookAndFeel"); // animations FadeConfigurationManager.getInstance() .allowFades(FadeKind.FOCUS_LOOP_ANIMATION); FadeConfigurationManager.getInstance() .allowFades(FadeKind.ICON_GLOW); FadeConfigurationManager.getInstance() .allowFades(FadeKind.GHOSTING_ICON_ROLLOVER); // comment out following line to "fix" bug #363 FadeConfigurationManager.getInstance() .allowFades(FadeKind.GHOSTING_BUTTON_PRESS); } catch (Exception e) { e.printStackTrace(); } Issue363 dialog = new Issue363(new javax.swing.JFrame(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue458.java0000644000175000017500000001546711255750242021500 0ustar drazzibdrazzibpackage test.issues; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.table.AbstractTableModel; import javax.swing.table.JTableHeader; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; public class Issue458 extends JFrame { JScrollPane scrollPane = new JScrollPane(); JTable scrollingTable = new JTable(); JTable headerTable = new JTable(); JPanel mainPanel = new JPanel(new BorderLayout()); int rowHeaderLastColumnDragStartX; public Issue458() { try { setContentPane(mainPanel); mainPanel.setOpaque(false); mainPanel.add(scrollPane, java.awt.BorderLayout.CENTER); headerTable.setModel(new HeaderTableModel()); scrollingTable.setModel(new ScrollingTableModel()); headerTable.setShowVerticalLines(true); headerTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); scrollingTable.setShowVerticalLines(true); scrollingTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); scrollPane.getViewport().add(scrollingTable); scrollPane.setRowHeaderView(headerTable); scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, headerTable .getTableHeader()); headerTable .setPreferredScrollableViewportSize(new Dimension(200, 0)); headerTable.getTableHeader().addMouseListener( new HeaderMouseHandler()); headerTable.getTableHeader().addMouseMotionListener( new HeaderMouseMotionHandler()); } catch (Exception ex) { ex.printStackTrace(); } } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { UIManager .setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); } catch (UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } Issue458 frame1 = new Issue458(); frame1.setSize(new Dimension(500, 300)); frame1.validate(); frame1.setVisible(true); } }); } private class HeaderMouseHandler extends MouseAdapter { /** * This handler allows the user to grab the row header table last column * and resize the row header table by dragging it. This assumes that the * rowHeader is correctly installed as the corner of a viewport, and * that the viewport itself contains the main table. This method sets * the starting point for subsequent drag operations. * * @param e * MouseEvent */ @Override public void mousePressed(MouseEvent e) { JTableHeader h = (JTableHeader) e.getSource(); int viewColumn = headerTable.getColumnModel().getColumnIndexAtX( e.getX()); int column = -1; if (viewColumn != -1) { column = headerTable.getColumnModel().getColumn(viewColumn) .getModelIndex(); } if (column == headerTable.getColumnCount() - 1) { Rectangle r = h.getHeaderRect(column); int extent = r.width + r.x; if (extent - e.getX() <= 3) { rowHeaderLastColumnDragStartX = e.getX(); } } } /** * Cancel the row header drag operation. * * @param e * MouseEvent */ @Override public void mouseReleased(MouseEvent e) { rowHeaderLastColumnDragStartX = -1; } } private class HeaderMouseMotionHandler extends MouseMotionAdapter { /** * This handler allows the user to grab the row header table last column * and resize the row header table by dragging it. This assumes that the * rowHeader is correctly installed as the corner of a viewport, and * that the viewport itself contains the main table. * * @param e * MouseEvent */ @Override public void mouseDragged(MouseEvent e) { JTableHeader h = (JTableHeader) e.getSource(); int viewColumn = headerTable.getColumnModel().getColumnIndexAtX( e.getX()); int column = -1; if (viewColumn != -1) { column = headerTable.getColumnModel().getColumn(viewColumn) .getModelIndex(); } if (column == headerTable.getColumnCount() - 1 && rowHeaderLastColumnDragStartX > -1) { int dragMovementX = e.getX() - rowHeaderLastColumnDragStartX; Dimension d = headerTable.getPreferredScrollableViewportSize(); Rectangle vr = scrollingTable.getVisibleRect(); // don't allow moving the column past the visible rectangle, // making it impossible to regrab the column // in fact don't allow the main table width to become less than // 100 otherwise its not so useful if (dragMovementX < vr.width - 100) { rowHeaderLastColumnDragStartX = e.getX(); Dimension newD = new Dimension(d.width + dragMovementX, d.height); headerTable.setPreferredScrollableViewportSize(newD); headerTable.revalidate(); repaint(); headerTable.repaint(); } } } } private class ScrollingTableModel extends AbstractTableModel { private Object[][] data; private String[] columnNames; public ScrollingTableModel() { columnNames = new String[] { "Data1", "Data2", "Data3", "Data 4", "Data 5", "Data 6" }; data = new Object[6][columnNames.length]; for (int i = 0; i < data.length; i++) { data[i][0] = "One"; data[i][1] = "Two"; data[i][2] = "Three"; data[i][3] = "Four"; data[i][4] = "Five"; data[i][5] = "Six"; } } public int getRowCount() { return data.length; } public int getColumnCount() { return columnNames.length; } @Override public String getColumnName(int column) { return columnNames[column]; } public Object getValueAt(int row, int column) { return data[row][column]; } @Override public void setValueAt(Object value, int row, int column) { data[row][column] = value; } @Override public boolean isCellEditable(int row, int column) { return false; } @Override public Class getColumnClass(int column) { return String.class; } } private class HeaderTableModel extends AbstractTableModel { private Object[][] data; private String[] columnNames; public HeaderTableModel() { columnNames = new String[] { "Header1", "Header2" }; data = new Object[6][columnNames.length]; for (int i = 0; i < data.length; i++) { data[i][0] = "ABC"; data[i][1] = "XYZ"; } } public int getRowCount() { return data.length; } public int getColumnCount() { return columnNames.length; } @Override public String getColumnName(int column) { return columnNames[column]; } public Object getValueAt(int row, int column) { return data[row][column]; } @Override public void setValueAt(Object value, int row, int column) { data[row][column] = value; } @Override public boolean isCellEditable(int row, int column) { return false; } @Override public Class getColumnClass(int column) { return String.class; } } } substance-5.3.orig/src/test/issues/Issue420.java0000644000175000017500000000232711140334054021444 0ustar drazzibdrazzibpackage test.issues; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.JScrollPane; import javax.swing.SwingUtilities; import java.awt.Dimension; import java.awt.Font; public class Issue420 extends JFrame { public static void main(String[] args) { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); SwingUtilities.invokeLater(new Runnable() { public void run() { new Issue420().setVisible(true); } }); } public Issue420() { JProgressBar progressBar = new JProgressBar(0, 100); progressBar.setFont(progressBar.getFont().deriveFont(Font.BOLD, 32.0f)); progressBar.setIndeterminate(false); progressBar.setStringPainted(true); progressBar.setString("some progressbar text"); JPanel scrollViewport = new JPanel(); scrollViewport.add(progressBar); JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportView(scrollViewport); scrollPane.setPreferredSize(new Dimension(300, 65)); getContentPane().add(scrollPane); pack(); setDefaultCloseOperation(EXIT_ON_CLOSE); } } substance-5.3.orig/src/test/issues/Issue394.java0000644000175000017500000000214011071567460021463 0ustar drazzibdrazzibpackage test.issues; import java.awt.Font; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.CremeSkin; import org.jvnet.substance.skin.SubstanceBusinessLookAndFeel; public class Issue394 extends JFrame { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { SubstanceLookAndFeel feel = new SubstanceBusinessLookAndFeel(); UIManager.setLookAndFeel(feel); SubstanceLookAndFeel.setSkin(new CremeSkin());// <- change // skin } catch (UnsupportedLookAndFeelException e) { } JComboBox comboBox = new JComboBox(); comboBox.setFont(new Font("Dialog", Font.BOLD, 12)); // <- so when we set new font, NPE will cause in old // comboboxUI (uninstalled from combo) Issue394 thisClass = new Issue394(); thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); thisClass.getContentPane().add(comboBox); thisClass.pack(); thisClass.setLocationRelativeTo(null); thisClass.setVisible(true); } }); } }substance-5.3.orig/src/test/issues/lafwidget/0000755000175000017500000000000011256731162021236 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/issues/lafwidget/Issue12.java0000644000175000017500000000400011223655654023333 0ustar drazzibdrazzibpackage test.issues.lafwidget; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.tabbed.DefaultTabPreviewPainter; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; public class Issue12 extends JFrame { public Issue12() { super("Issue12"); final JTabbedPane tabs = new JTabbedPane(); tabs.putClientProperty(LafWidget.TABBED_PANE_PREVIEW_PAINTER, new DefaultTabPreviewPainter()); tabs.addTab("tab", new JPanel()); this.add(tabs, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton remove = new JButton("remove"); remove.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { while (tabs.getTabCount() > 0) tabs.removeTabAt(0); } }); } }); controls.add(remove); JButton add = new JButton("add"); add.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { tabs.addTab("tab", new JPanel()); } }); } }); controls.add(add); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 300); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); UIManager.put(SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS, Boolean.TRUE); new Issue12().setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue437LookAndFeel.java0000644000175000017500000000235611172050216023522 0ustar drazzibdrazzib/* * aTunes 1.13.0 * Copyright (C) 2006-2009 Alex Aranda, Sylvain Gaudard, Thomas Beckers and contributors * * See http://www.atunes.org/wiki/index.php?title=Contributing for information about contributors * * http://www.atunes.org * http://sourceforge.net/projects/atunes * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ package test.issues; import org.jvnet.substance.SubstanceLookAndFeel; /** * The Class SubstanceATunesLookAndFeel. */ public class Issue437LookAndFeel extends SubstanceLookAndFeel { public Issue437LookAndFeel() { super(new Issue437Skin()); } private static final long serialVersionUID = -3907225219153995877L; @Override public String getID() { return "Substance aTunes Blue"; } @Override public String getName() { return "Substance aTunes Blue"; } } substance-5.3.orig/src/test/issues/Issue404.java0000644000175000017500000000421011100555362021442 0ustar drazzibdrazzibpackage test.issues; import java.awt.EventQueue; import java.awt.Font; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import javax.swing.*; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import org.jvnet.substance.skin.SubstanceRavenGraphiteLookAndFeel; public class Issue404 extends JPanel { private String aText; public Issue404() { final JTextField textField = new JTextField(20); add(textField); // Just a dummy widget for focus-change add(new JButton("Dummy")); textField.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { aText = textField.getText(); textField.setFont(textField.getFont().deriveFont(Font.PLAIN)); } @Override public void focusGained(FocusEvent e) { } }); textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateFont(); } @Override public void insertUpdate(DocumentEvent e) { updateFont(); } @Override public void changedUpdate(DocumentEvent e) { updateFont(); } private void updateFont() { if (aText == null || !aText.equals(textField.getText())) { textField .setFont(textField.getFont().deriveFont(Font.BOLD)); } else { textField.setFont(textField.getFont() .deriveFont(Font.PLAIN)); } } }); } public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { // UIManager.setLookAndFeel(new WindowsLookAndFeel()); // UIManager.setLookAndFeel(new MetalLookAndFeel()); UIManager .setLookAndFeel(new SubstanceRavenGraphiteLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } JFrame frame = new JFrame(); Issue404 contentPane = new Issue404(); frame.setContentPane(contentPane); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue460.java0000644000175000017500000000561311256345630021463 0ustar drazzibdrazzibpackage test.issues; import java.awt.*; import javax.swing.*; import javax.swing.table.AbstractTableModel; import javax.swing.table.TableCellRenderer; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; public class Issue460 extends JFrame { JTable demoTable = new JTable(); JPanel mainPanel = new JPanel(new BorderLayout()); public Issue460() { try { setContentPane(mainPanel); mainPanel.setOpaque(false); mainPanel.add(demoTable, java.awt.BorderLayout.CENTER); demoTable.setModel(new demoTableModel()); demoTable.setShowVerticalLines(true); demoTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); demoTable.setDefaultRenderer(String.class, new customTableCellRenderer()); setDefaultCloseOperation(DISPOSE_ON_CLOSE); } catch (Exception ex) { ex.printStackTrace(); } } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { UIManager .setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); } catch (UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } Issue460 frame1 = new Issue460(); frame1.setSize(new Dimension(500, 300)); frame1.validate(); frame1.setVisible(true); } }); } private class customTableCellRenderer extends JLabel implements TableCellRenderer { public customTableCellRenderer() { super(); setOpaque(true); } public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { setText(value.toString()); if (isSelected) { setBackground(Color.YELLOW); } else if (column == 0) { setBackground(Color.RED); } else if (column == 1) { setBackground(Color.CYAN); } else { setBackground(Color.MAGENTA); } return this; } } private class demoTableModel extends AbstractTableModel { private Object[][] data; private String[] columnNames; public demoTableModel() { columnNames = new String[] { "Data1", "Data2", "Data3" }; data = new Object[6][columnNames.length]; for (int i = 0; i < data.length; i++) { data[i][0] = "One"; data[i][1] = "Two"; data[i][2] = "Three"; } } public int getRowCount() { return data.length; } public int getColumnCount() { return columnNames.length; } @Override public String getColumnName(int column) { return columnNames[column]; } public Object getValueAt(int row, int column) { return data[row][column]; } @Override public void setValueAt(Object value, int row, int column) { data[row][column] = value; } @Override public boolean isCellEditable(int row, int column) { return false; } @Override public Class getColumnClass(int column) { return String.class; } } } substance-5.3.orig/src/test/issues/Issue431.java0000644000175000017500000000206311165153042021446 0ustar drazzibdrazzibpackage test.issues; import java.awt.BorderLayout; import java.awt.Color; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.SubstanceRavenGraphiteGlassLookAndFeel; /** * * @author bio-aulas */ public class Issue431 implements Runnable { public static void main(String[] args) { try { UIManager .setLookAndFeel(new SubstanceRavenGraphiteGlassLookAndFeel()); } catch (Exception e) { e.printStackTrace(); } SwingUtilities.invokeLater(new Issue431()); } public void run() { JFrame f = new JFrame(); JPanel p = new JPanel(new BorderLayout()); JTextArea a = new JTextArea(); a.setBackground(Color.WHITE); a.putClientProperty(SubstanceLookAndFeel.COLORIZATION_FACTOR, new Double(1.0)); if (!Color.WHITE.equals(a.getBackground())) { System.out.println("bad"); } p.add(a, BorderLayout.CENTER); f.add(p); f.pack(); // but displayed value is not white. f.setVisible(true); } private static void setLookAndFeel() { } } substance-5.3.orig/src/test/issues/Issue414.java0000644000175000017500000000215711120064420021443 0ustar drazzibdrazzibpackage test.issues; import javax.swing.*; import javax.swing.table.DefaultTableModel; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; public class Issue414 extends JFrame { public Issue414() { JTable table = new JTable(new DefaultTableModel() { @Override public int getRowCount() { return 100; } @Override public int getColumnCount() { return 10; } @Override public Object getValueAt(int row, int column) { return (row + 1) + ":" + (column + 1); } @Override public String getColumnName(int column) { return "Column " + (column + 1); } }); JScrollPane jsp = new JScrollPane(table); this.add(jsp); this.setSize(500, 400); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Issue414().setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue355.java0000644000175000017500000000730711007573444021470 0ustar drazzibdrazzibpackage test.issues; import java.awt.FlowLayout; import java.awt.event.*; import javax.swing.*; import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuListener; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; public class Issue355 extends JFrame { public class MousePopupListener extends MouseAdapter { /** * The owner component. */ private JComponent owner; /** * Creates a popup listener. * * @param owner * The owner component. */ public MousePopupListener(JComponent owner) { this.owner = owner; } /* * (non-Javadoc) * * @see java.awt.event.MouseAdapter#mousePressed(java.awt.event.MouseEvent) */ public void mousePressed(MouseEvent e) { System.out.println(System.currentTimeMillis() + " - mouse pressed"); checkPopup(e); } /* * (non-Javadoc) * * @see java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent) */ public void mouseClicked(MouseEvent e) { System.out.println(System.currentTimeMillis() + " - mouse clicked"); checkPopup(e); } /* * (non-Javadoc) * * @see java.awt.event.MouseAdapter#mouseReleased(java.awt.event.MouseEvent) */ public void mouseReleased(MouseEvent e) { System.out.println(System.currentTimeMillis() + " - mouse released"); checkPopup(e); } /** * Handles the mouse event, showing the popup menu as necessary. * * @param e * Mouse event. */ void checkPopup(MouseEvent e) { if (e.isPopupTrigger()) { System.out.println(System.currentTimeMillis() + " - popup trigger detected"); JPopupMenu popup = new JPopupMenu(); for (int i = 0; i < 10; i++) popup.add(new JMenuItem("Entry " + i)); popup.addPopupMenuListener(new PopupPrintListener()); popup.show(this.owner, e.getX(), e.getY()); popup.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { System.out.println(System.currentTimeMillis() + " - popup shown"); } }); } } } /** * Custom popup listener. * * @author Kirill Grouchnikov */ protected class PopupPrintListener implements PopupMenuListener { /* * (non-Javadoc) * * @see javax.swing.event.PopupMenuListener#popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent) */ public void popupMenuWillBecomeVisible(PopupMenuEvent e) { System.out.println(System.currentTimeMillis() + " - popup menu will be visible!"); } /* * (non-Javadoc) * * @see javax.swing.event.PopupMenuListener#popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent) */ public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } /* * (non-Javadoc) * * @see javax.swing.event.PopupMenuListener#popupMenuCanceled(javax.swing.event.PopupMenuEvent) */ public void popupMenuCanceled(PopupMenuEvent e) { } } public Issue355() { super("Check popup menu latency"); JButton button = new JButton("Right-click me!"); this.setLayout(new FlowLayout()); this.add(button); button.addMouseListener(new MousePopupListener(button)); this.setSize(200, 100); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); //PopupFactory.setSharedInstance(new PopupFactory()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Issue355().setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue406.java0000644000175000017500000000256011104002242021436 0ustar drazzibdrazzibpackage test.issues; import java.awt.*; import javax.swing.*; import org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel; @SuppressWarnings("serial") public class Issue406 extends JFrame { public static void main(String[] args) { try { UIManager .setLookAndFeel(new SubstanceBusinessBlueSteelLookAndFeel()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { Issue406 testFrame = new Issue406(); testFrame.setVisible(true); } }); } catch (UnsupportedLookAndFeelException exception) { exception.printStackTrace(); } } /** * Constructeur */ public Issue406() { initComponents(); } /** * Initialisation des composants graphiques */ private void initComponents() { this.label1 = new JLabel(); this.checkBox1 = new JCheckBox(); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); Container contentPane = getContentPane(); contentPane.setLayout(new FlowLayout()); this.label1.setText("text"); //$NON-NLS-1$ this.label1.setForeground(Color.orange); contentPane.add(this.label1); this.checkBox1.setText("text"); //$NON-NLS-1$ this.checkBox1.setForeground(Color.orange); contentPane.add(this.checkBox1); pack(); setLocationRelativeTo(getOwner()); } private JLabel label1; private JCheckBox checkBox1; }substance-5.3.orig/src/test/issues/Issue371.java0000644000175000017500000000736411040631400021451 0ustar drazzibdrazzibpackage test.issues; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.*; import java.util.*; import javax.swing.*; import org.jvnet.substance.skin.SubstanceRavenLookAndFeel; public class Issue371 extends JFrame { private final JMenu menu; private final JLabel label; private final JButton button; public Issue371() throws HeadlessException { super("Test"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); menu = new JMenu("File"); menuBar.add(menu); setJMenuBar(menuBar); label = new JLabel("This is a test"); add(label); button = new JButton("Test"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doStuff(); } }); add(button, BorderLayout.SOUTH); setBounds(100, 100, 500, 500); setVisible(true); } private void doStuff() { setChildrenEnabled(menu, false); setChildrenEnabled(label, false); setChildrenEnabled(button, false); final BufferedImage bluredFrame = gaussianBlurImage( getBufferedImageOfFrame(this), 3); JPanel panel = new JPanel() { @Override protected void paintComponent(Graphics g) { g.drawImage(bluredFrame, 0, 0, bluredFrame.getWidth(), bluredFrame.getHeight(), null); } }; setGlassPane(panel); getGlassPane().setVisible(true); } private static void setChildrenEnabled(Component component, boolean enabled, Component... exceptions) { Set excludedSet = new HashSet(Arrays .asList(exceptions)); if (!excludedSet.contains(component)) component.setEnabled(enabled); if (component instanceof Container) { Container container = (Container) component; for (int i = 0; i < container.getComponentCount(); i++) setChildrenEnabled(container.getComponent(i), enabled, exceptions); } } private static ConvolveOp getGaussianBlurFilter(int radius, boolean horizontal) { if (radius < 1) throw new IllegalArgumentException("Radius must be >= 1"); int size = radius * 2 + 1; float[] data = new float[size]; float sigma = radius / 3.0f; float twoSigmaSquare = 2.0f * sigma * sigma; float sigmaRoot = (float) Math.sqrt(twoSigmaSquare * Math.PI); float total = 0.0f; for (int i = -radius; i <= radius; i++) { float distance = i * i; int index = i + radius; data[index] = (float) Math.exp(-distance / twoSigmaSquare) / sigmaRoot; total += data[index]; } for (int i = 0; i < data.length; i++) data[i] /= total; Kernel kernel; if (horizontal) kernel = new Kernel(size, 1, data); else kernel = new Kernel(1, size, data); return new ConvolveOp(kernel, ConvolveOp.EDGE_NO_OP, null); } private static BufferedImage getBufferedImageOfFrame(JFrame frame) { JLayeredPane layeredPane = frame.getRootPane().getLayeredPane(); BufferedImage image = new BufferedImage(layeredPane.getWidth(), layeredPane.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics graphics = image.getGraphics(); layeredPane.paint(graphics); graphics.dispose(); return image; } public static BufferedImage gaussianBlurImage(BufferedImage image, int radius) { BufferedImage bluredImage = getGaussianBlurFilter(radius, true).filter( image, null); bluredImage = getGaussianBlurFilter(radius, false).filter(bluredImage, null); return bluredImage; } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { UIManager.setLookAndFeel(new SubstanceRavenLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } new Issue371(); } }); } } substance-5.3.orig/src/test/issues/Issue416.java0000644000175000017500000000330311136770204021452 0ustar drazzibdrazzibpackage test.issues; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import org.jvnet.substance.skin.SubstanceRavenGraphiteLookAndFeel; public class Issue416 extends JPanel { public Issue416() { setLayout(new BorderLayout()); String string = ""; for (int i = 0; i < 20; i++) { string += "line " + i; if (i < 19) { string += "\n"; } } JTextArea textArea = new JTextArea(string); textArea.setFont(textArea.getFont().deriveFont(60f)); JScrollPane scrollPane = new JScrollPane(textArea); add(scrollPane, BorderLayout.CENTER); setPreferredSize(new Dimension(400, 340)); } public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { UIManager.setLookAndFeel(new SubstanceRavenGraphiteLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } JFrame frame = new JFrame(); Issue416 contentPane = new Issue416(); frame.setContentPane(contentPane); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue360.java0000644000175000017500000000161411017452274021455 0ustar drazzibdrazzibpackage test.issues; import javax.swing.*; import org.jvnet.substance.skin.SubstanceRavenGraphiteLookAndFeel; public class Issue360 { public static void main(String[] args) { try { UIManager.setLookAndFeel(new SubstanceRavenGraphiteLookAndFeel()); } catch (Exception e) { e.printStackTrace(); } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JDialog dlg = new JDialog(); Object[][] data = new Object[0][0]; Object[] columns = new Object[15]; for (int i = 0; i < 15; i++) columns[i] = "Column " + i; JTable table = new JTable(data, columns); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); dlg.add(new JScrollPane(table)); dlg.setPreferredSize(new java.awt.Dimension(200, 200)); dlg.pack(); dlg.setLocationByPlatform(true); dlg.setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue387.java0000644000175000017500000000303611062377542021472 0ustar drazzibdrazzibpackage test.issues; import java.awt.Color; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlueSteelSkin; public class Issue387 extends JFrame { public Issue387() { super("Test setBackground(null)"); this.setLayout(new FlowLayout()); final JSpinner spinner = new JSpinner(new SpinnerNumberModel(50, 0, 100, 10)); spinner.setBackground(null); System.out.println(spinner.getBackground()); this.add(spinner); JButton button = new JButton("set bg to red"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { spinner.setBackground(Color.red); System.out.println(spinner.getBackground()); } }); this.add(button); JButton button2 = new JButton("set bg to null"); button2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { spinner.setBackground(null); System.out.println(spinner.getBackground()); } }); this.add(button2); this.setSize(200, 100); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { SubstanceLookAndFeel.setSkin(new BusinessBlueSteelSkin()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Issue387().setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue399.java0000644000175000017500000000420611076626154021476 0ustar drazzibdrazzibpackage test.issues; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.Transferable; import javax.swing.*; import javax.swing.table.DefaultTableModel; import org.jvnet.substance.skin.SubstanceModerateLookAndFeel; public class Issue399 { boolean useSubstance = true; public Issue399() { SwingUtilities.invokeLater(new Runnable() { public void run() { try { if (useSubstance) { try { UIManager .setLookAndFeel(new SubstanceModerateLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } } else { JFrame.setDefaultLookAndFeelDecorated(true); } initGUI(); } catch (Exception e) { e.printStackTrace(); } } }); return; } private void initGUI() throws ClassNotFoundException { final JTable table = new JTable(); table.setDropMode(DropMode.INSERT_ROWS); table.setDragEnabled(true); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); final DefaultTableModel tm = new DefaultTableModel(); for (int i = 0; i < 10; i++) { tm.addColumn("Column: " + i); } for (int i = 0; i < 10; i++) { String[] text = new String[10]; for (int j = 0; j < 10; j++) { text[j] = i + ":" + j; } tm.addRow(text); } table.setModel(tm); table.setTransferHandler(new TransferHandler() { public boolean canImport(TransferHandler.TransferSupport info) { return true; } public boolean importData(TransferHandler.TransferSupport info) { return true; } public void exportDone(JComponent c, Transferable t, int action) { } public int getSourceActions(JComponent c) { return MOVE; } protected Transferable createTransferable(JComponent c) { return new StringSelection("Test"); } }); JScrollPane scroll = new JScrollPane(table); JFrame frame = new JFrame("DRAG TEST"); frame.add(scroll); frame.setSize(500, 500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } public static void main(String[] args) { new Issue399(); } }substance-5.3.orig/src/test/issues/Issue439.java0000644000175000017500000000327311200000632021444 0ustar drazzibdrazzibpackage test.issues; import java.awt.BorderLayout; import java.awt.Component; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.CremeCoffeeSkin; import org.jvnet.substance.skin.RavenGraphiteGlassSkin; public class Issue439 extends JFrame { JDesktopPane desktop; public Issue439() { JPanel panel = new JPanel(); panel.add(getComboBox()); desktop = new JDesktopPane(); setSize(500, 300); setLocation(150, 150); JInternalFrame iframe = new JInternalFrame(); JPanel panel2 = new JPanel(); panel2.add(getComboBox()); iframe.add(panel2); desktop.add(iframe); iframe.pack(); iframe.getRootPane().putClientProperty( SubstanceLookAndFeel.SKIN_PROPERTY, new RavenGraphiteGlassSkin()); iframe.setVisible(true); this.getContentPane().setLayout(new BorderLayout()); this.getContentPane().add(panel, BorderLayout.SOUTH); this.getContentPane().add(desktop, BorderLayout.CENTER); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } private Component getComboBox() { final JComboBox jcb = new JComboBox(); jcb.addItem("First Item"); jcb.addItem("Second Item"); jcb.addItem("Third Item"); jcb.addItem("Fourth Item"); jcb.addItem("Fifth Item"); jcb.addItem("Sixth Item"); jcb.addItem("Seventh Item"); jcb.addItem("Eighth Item"); jcb.addItem("Ninth Item"); return jcb; } public static void main(final String[] args) { SubstanceLookAndFeel.setSkin(new CremeCoffeeSkin()); SwingUtilities.invokeLater(new Runnable() { public void run() { final Issue439 c = new Issue439(); c.setVisible(true); } }); } } substance-5.3.orig/src/test/issues/button_yellow.gif0000644000175000017500000000172511037270144022665 0ustar drazzibdrazzibGIF89a f3̙f3f3ffffff3f3333f333f3f3̙f3̙̙̙̙f̙3̙ffffff3f3333f333f3̙f3̙̙f3̙f3ff̙ffff3f33̙33f333̙f3ffffff3ffff̙fff3fffffff3ffffffffffff3fff3f3f3f3ff33f3ffffff3f3333f333333̙3f3333333f3333f3f3f3ff3f33f33333333f333333333f333f3̙f3f3ffffff3f3333f333f3!, @ vH#JHq+VŌ;dȑW4Ȓ-]vHPJ/bhҡϟ@,$Ί0 rƤNb3jD7zIί`~]8eгhkkBT9Ur6Ko^rk|{w5Kv)re j0 ;substance-5.3.orig/src/test/issues/Issue442.java0000644000175000017500000000354611203745064021463 0ustar drazzibdrazzibpackage test.issues; import java.awt.*; import javax.swing.*; import javax.swing.table.DefaultTableModel; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.CremeCoffeeSkin; import org.jvnet.substance.skin.RavenGraphiteGlassSkin; public class Issue442 extends JFrame { JDesktopPane desktop; public Issue442() { SubstanceLookAndFeel.setSkin(new CremeCoffeeSkin()); JPanel panel = new JPanel(); panel.add(getTable()); desktop = new JDesktopPane(); setSize(500, 300); setLocation(150, 150); JInternalFrame iframe = new JInternalFrame(); JPanel panel2 = new JPanel(); panel2.add(getTable()); iframe.add(panel2); desktop.add(iframe); iframe.pack(); iframe.getRootPane().putClientProperty( SubstanceLookAndFeel.SKIN_PROPERTY, new RavenGraphiteGlassSkin()); iframe.setVisible(true); this.getContentPane().setLayout(new BorderLayout()); this.getContentPane().add(panel, BorderLayout.SOUTH); this.getContentPane().add(desktop, BorderLayout.CENTER); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } private Component getTable() { final JScrollPane pane = new JScrollPane(); final JTable jtable = new JTable(); jtable.setAutoCreateRowSorter(true); jtable.setModel(new DefaultTableModel(new Object[][] { { "item", "item" }, { "item", "item" }, { "item", "item" }, { "item", "item" } }, new String[] { "Title 1", "Title 2" })); jtable.setColumnSelectionAllowed(true); jtable.setRowSelectionAllowed(true); pane.setViewportView(jtable); pane.setPreferredSize(new Dimension(200, 100)); return pane; } public static void main(final String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { final Issue442 c = new Issue442(); c.setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue379.java0000644000175000017500000000164511057446374021503 0ustar drazzibdrazzibpackage test.issues; import java.awt.HeadlessException; import javax.swing.*; public class Issue379 extends JFrame { private final JMenu mnMenu = new JMenu(); private final JMenuItem mnOpen = new JMenuItem(); private final JMenuItem mnClose = new JMenuItem(); public static void main(String[] args) throws Exception { SwingUtilities.invokeLater(new Runnable() { public void run() { Issue379 frame = new Issue379(); frame.setVisible(true); } }); } public Issue379() throws HeadlessException { mnMenu.add(mnOpen); mnMenu.add(mnClose); JMenuBar mnMain = new JMenuBar(); mnMain.add(mnMenu); setJMenuBar(mnMain); pack(); // It's a reason of the problem mnMenu.setText("mnMenu"); mnOpen.setText("mnOpen"); mnClose.setText("mnClose"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocationRelativeTo(null); setSize(300, 200); } }substance-5.3.orig/src/test/issues/Issue386.java0000644000175000017500000000514111061662670021466 0ustar drazzibdrazzibpackage test.issues; //package test.issues; import java.awt.BorderLayout; import java.awt.Color; import java.awt.datatransfer.*; import java.io.IOException; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.SubstanceCremeCoffeeLookAndFeel; public class Issue386 extends JFrame { public Issue386() { super(); ColorTransferHandler colorHandler = new ColorTransferHandler(); JPanel previewColorPanel = new JPanel(); // Kirill - the next line fixes the visual discrepancy between the // selected color and the painting of the panel. previewColorPanel.putClientProperty( SubstanceLookAndFeel.COLORIZATION_FACTOR, Double.valueOf(1.0)); previewColorPanel.add(new JLabel("Preview Color")); previewColorPanel.setOpaque(true); previewColorPanel.setTransferHandler(colorHandler); JColorChooser chooser = new JColorChooser(); chooser.setDragEnabled(true); this.add(chooser, BorderLayout.NORTH); this.add(previewColorPanel, BorderLayout.SOUTH); this.pack(); this.setVisible(true); } public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SubstanceCremeCoffeeLookAndFeel()); JFrame.setDefaultLookAndFeelDecorated(true); System.setProperty("sun.awt.noerasebackground", "true"); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Issue386(); } }); } class ColorTransferHandler extends TransferHandler { String mimetype = DataFlavor.javaJVMLocalObjectMimeType + ";class=java.awt.Color"; DataFlavor colorFlavor; ColorTransferHandler() { try { colorFlavor = new DataFlavor(mimetype); } catch (ClassNotFoundException e) { e.printStackTrace(); } } @Override public boolean importData(JComponent c, Transferable t) { if (hasColorFlavor(t.getTransferDataFlavors())) { try { Color col = (Color) t.getTransferData(colorFlavor); System.out.println("Setting " + col); c.setBackground(col); return true; } catch (UnsupportedFlavorException ufe) { ufe.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } } return false; } protected boolean hasColorFlavor(DataFlavor[] flavors) { if (colorFlavor == null) { return false; } for (int i = 0; i < flavors.length; i++) { if (colorFlavor.equals(flavors[i])) { return true; } } return false; } @Override public boolean canImport(JComponent c, DataFlavor[] flavors) { return hasColorFlavor(flavors); } } } substance-5.3.orig/src/test/issues/Issue382.java0000644000175000017500000000115711060133060021446 0ustar drazzibdrazzibpackage test.issues; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessSkin; public class Issue382 extends JFrame { Issue382() { super("Test"); setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(400, 200); JTabbedPane tabs = new JTabbedPane(); tabs.addTab("Foo", null); // Exception add(tabs); setVisible(true); } public static void main(String[] args) { SubstanceLookAndFeel.setSkin(new BusinessSkin()); SwingUtilities.invokeLater(new Runnable() { public void run() { new Issue382(); } }); } } substance-5.3.orig/src/test/issues/Issue409.java0000644000175000017500000001361511107426152021461 0ustar drazzibdrazzib/* * NewJDialog.java * * Created on November 16, 2008, 11:23 AM */ package test.issues; import java.awt.EventQueue; import java.util.EventListener; import java.util.EventObject; import javax.swing.UIManager; public class Issue409 extends javax.swing.JDialog { FIActionClass FIA; /** Creates new form NewJDialog */ public Issue409(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); FIA = new FIActionClass(); // FIEventListener FIE = new FIEventListener(); FIA.addFIEventListener(new FIEventListener() { @Override public void fiEventOccurred(FIEvent evt) { System.out.println("Fire event:" + evt.Action + "," + evt.Description+","+EventQueue.isDispatchThread()); javax.swing.JTable JT = new javax.swing.JTable(); JT.setModel(new javax.swing.table.DefaultTableModel( new Object[][]{ {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String[]{ "Title 1", "Title 2", "Title 3", "Title 4" })); jScrollPane1.setViewportView(JT); mainPanel.validate(); } }); new Thread() { @Override public void run() { FIA._fireDialogEvent("ShowTable", 1); } }.start(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { mainPanel = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); mainPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); mainPanel.setLayout(new java.awt.BorderLayout()); mainPanel.add(jScrollPane1, java.awt.BorderLayout.CENTER); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE) .addContainerGap()) ); pack(); }// //GEN-END:initComponents public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { try { UIManager.setLookAndFeel( "org.jvnet.substance.skin.SubstanceBusinessLookAndFeel"); } catch (Exception e) { e.printStackTrace(); } Issue409 dialog = new Issue409(new javax.swing.JFrame(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); dialog.setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane jScrollPane1; private javax.swing.JPanel mainPanel; // End of variables declaration//GEN-END:variables private void _fireDialogEvent(String Description, int Action) { FIEvent event = new FIEvent(this, Description, Action); FIA.fireFIEvent(event); } public class FIEvent extends EventObject { public String Description; public int Action; public FIEvent(Object source, String Description, int Action) { super(source); this.Description = Description; this.Action = Action; } } public interface FIEventListener extends EventListener { public void fiEventOccurred(FIEvent evt); } public class FIActionClass { protected javax.swing.event.EventListenerList listenerList = new javax.swing.event.EventListenerList(); public void addFIEventListener(FIEventListener listener) { listenerList.add(FIEventListener.class, listener); } public void removeFIEventListener(FIEventListener listener) { listenerList.remove(FIEventListener.class, listener); } void fireFIEvent(FIEvent evt) { Object[] listeners = listenerList.getListenerList(); for (int i = 0; i < listeners.length; i += 2) { if (listeners[i] == FIEventListener.class) { ((FIEventListener) listeners[i + 1]).fiEventOccurred(evt); } } } public void _fireDialogEvent(String Description, int Action) { FIEvent event = new FIEvent(this, Description, Action); fireFIEvent(event); } } } substance-5.3.orig/src/test/issues/Issue392.java0000644000175000017500000000130011067410510021442 0ustar drazzibdrazzibpackage test.issues; import java.awt.FlowLayout; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessSkin; public class Issue392 extends JFrame { public Issue392() { super("Issue 392"); this.setLayout(new FlowLayout()); this.add(new JButton("sample")); this.setSize(200, 100); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { SubstanceLookAndFeel.setSkin(new BusinessSkin()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Issue392().setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue369.java0000644000175000017500000000165611030240264021461 0ustar drazzibdrazzibpackage test.issues; import java.awt.BorderLayout; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JDialog; import javax.swing.UIManager; import org.jvnet.substance.skin.SubstanceRavenGraphiteGlassLookAndFeel; class Issue369 extends JDialog { private final static String[] columnsNames = new String[]{ "", "header 2"}; private final static String [][] values = new String[][]{ {"1-01", "1-02"}, {"2-01", "2-02"}, {"3-01", "3-02"}, {"4-01", "4-02"} }; Issue369() { setLayout( new BorderLayout()); add( new JScrollPane( new JTable( values, columnsNames)), BorderLayout.NORTH); setSize( 250,250); } /** * @param args */ public static void main(String[] args) throws Exception { UIManager.setLookAndFeel( new SubstanceRavenGraphiteGlassLookAndFeel()); Issue369 dlg = new Issue369(); dlg.setVisible(true); } }substance-5.3.orig/src/test/issues/Issue362.java0000644000175000017500000000523211021210364021442 0ustar drazzibdrazzibpackage test.issues; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class Issue362 extends JFrame { private static final long serialVersionUID = 1L; private int side = 0; JPanel leftPane, rightPane; JDesktopPane desktopPane; JSplitPane splitPane; public Issue362() { super(); } private void initLAFTest2() { splitPane = new JSplitPane(); leftPane = new JPanel(new BorderLayout()); rightPane = new JPanel(new BorderLayout()); splitPane.setLeftComponent(leftPane); splitPane.setRightComponent(rightPane); splitPane.setDividerLocation(500); desktopPane = new JDesktopPane(); JInternalFrame doc1 = new JInternalFrame("Document 1", true, true, true, true); System.out.println("Done creating buttons."); doc1.setSize(300, 200); doc1.setLocation(10, 10); doc1.setVisible(true); desktopPane.setLayout(null); desktopPane.add(doc1); leftPane.add(desktopPane, BorderLayout.CENTER); JMenuBar menuBar = new JMenuBar(); JMenu menuTest = new JMenu("Test"); JMenuItem menuItemSwap = new JMenuItem("Swap sides"); menuItemSwap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { side = 1 - side; System.out.println("Switching sides..."); if (side == 0) { rightPane.remove(desktopPane); leftPane.add(desktopPane); splitPane.repaint(); } else { leftPane.remove(desktopPane); rightPane.add(desktopPane); splitPane.repaint(); } } }); menuTest.add(menuItemSwap); menuBar.add(menuTest); this.setSize(1000, 500); this.setContentPane(splitPane); this.setJMenuBar(menuBar); this.setTitle("LaF test 2"); } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { try { // UIManager.setLookAndFeel(UIManager .getSystemLookAndFeelClassName()); UIManager .setLookAndFeel("org.jvnet.substance.skin.SubstanceBusinessLookAndFeel"); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } Issue362 thisClass = new Issue362(); thisClass.initLAFTest2(); thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); thisClass.setVisible(true); } }); } }substance-5.3.orig/src/test/issues/Issue383.java0000644000175000017500000000215611060401736021457 0ustar drazzibdrazzibpackage test.issues; import java.awt.BorderLayout; import javax.swing.*; import javax.swing.table.DefaultTableModel; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessSkin; public class Issue383 extends JFrame { public Issue383() { JTable table = new JTable(new DefaultTableModel() { @Override public int getColumnCount() { return 4; } @Override public int getRowCount() { return 10; } @Override public Object getValueAt(int row, int column) { return row + ":" + column; } @Override public boolean isCellEditable(int row, int column) { return false; } }); // table.setShowGrid(false); this.add(table, BorderLayout.CENTER); this.setSize(400, 300); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { SubstanceLookAndFeel.setSkin(new BusinessSkin()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Issue383().setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue358.java0000644000175000017500000000217311015451572021463 0ustar drazzibdrazzibpackage test.issues; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.skin.SubstanceRavenLookAndFeel; public class Issue358 extends JFrame { public Issue358() { super("Substance Test"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JSplitPane splitPane = new JSplitPane(); splitPane.setLeftComponent(new JLabel("Left Label")); splitPane.setRightComponent(new JLabel("Right Label")); JButton button = new JButton("Press Me"); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { splitPane.setEnabled(false); } }); add(button, BorderLayout.WEST); add(splitPane, BorderLayout.CENTER); pack(); setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { UIManager.setLookAndFeel(new SubstanceRavenLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } new Issue358(); } }); } } substance-5.3.orig/src/test/issues/Issue378.java0000644000175000017500000000177311043274752021476 0ustar drazzibdrazzibpackage test.issues; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.SwingUtilities; import javax.swing.UIManager; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; public class Issue378 extends JFrame { public Issue378() { JTable table = new JTable(new String[][] { { "1", "2", "3", "4", "5", "6" }, { "1", "2", "3", "4", "5", "6" } }, new String[] { "1", "2", "3", "4", "5", "6" }); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); JScrollPane scrollPane = new JScrollPane(table); add(scrollPane); setSize(300, 200); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Issue378(); } }); } } substance-5.3.orig/src/test/issues/Issue366.java0000644000175000017500000000241511030750514021454 0ustar drazzibdrazzibpackage test.issues; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; public class Issue366 extends JFrame { public Issue366() { final JScrollPane jsp = new JScrollPane(); this.add(jsp, BorderLayout.CENTER); JButton nullHor = new JButton("scroll -> null"); nullHor.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jsp.setHorizontalScrollBar(null); } }); } }); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); controls.add(nullHor); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 300); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Issue366().setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue449.java0000644000175000017500000000352711221467366021477 0ustar drazzibdrazzibpackage test.issues; import java.awt.Color; import javax.swing.JFrame; import javax.swing.SwingUtilities; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.BaseLightColorScheme; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.skin.BusinessBlackSteelSkin; public class Issue449 extends JFrame { private static class Skin449 extends BusinessBlackSteelSkin { @Override public String getDisplayName() { return "Skin 449"; } public Skin449() { SubstanceColorScheme scheme = new BaseLightColorScheme("Scheme 449") { Color bg = Color.blue; @Override public Color getUltraDarkColor() { return bg; } @Override public Color getDarkColor() { return bg; } @Override public Color getMidColor() { return bg; } @Override public Color getLightColor() { return bg; } @Override public Color getExtraLightColor() { return bg; } @Override public Color getUltraLightColor() { return bg; } @Override public Color getForegroundColor() { return Color.white; } }; this.registerAsDecorationArea(scheme, DecorationAreaType.PRIMARY_TITLE_PANE); } } public Issue449() { super("Issue 449"); this.setSize(300, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } /** * @param args */ public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { SubstanceLookAndFeel.setSkin(new Skin449()); new Issue449().setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue395.java0000644000175000017500000000153111071570410021454 0ustar drazzibdrazzibpackage test.issues; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.CremeSkin; import org.jvnet.substance.skin.SubstanceBusinessLookAndFeel; public class Issue395 extends JFrame { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { SubstanceLookAndFeel feel = new SubstanceBusinessLookAndFeel(); UIManager.setLookAndFeel(feel); } catch (UnsupportedLookAndFeelException e) { } Issue395 thisClass = new Issue395(); thisClass.setLocationRelativeTo(null); // if we comment this line, there will be no exception thisClass.setVisible(true); SubstanceLookAndFeel.setSkin(new CremeSkin()); // if we comment this line, there will be no exception too :) } }); } }substance-5.3.orig/src/test/issues/Issue376.java0000644000175000017500000000430211037270352021456 0ustar drazzibdrazzibpackage test.issues; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.skin.SubstanceRavenGraphiteGlassLookAndFeel; public class Issue376 extends JDialog { private JPanel jContentPane = null; private JScrollPane jScrollPane = null; private JList list = null; private final static ImageIcon LOADING_ICON = new ImageIcon(Issue376.class .getResource("/test/issues/button_yellow.gif")); /** * @param owner */ public Issue376() { setPreferredSize(new java.awt.Dimension(100, 150)); setContentPane(getJContentPane()); this.setLocationRelativeTo(null); } private JPanel getJContentPane() { if (jContentPane == null) { jContentPane = new JPanel(); jContentPane.setLayout(new BorderLayout()); jContentPane.add(getScrollPane(), BorderLayout.CENTER); jContentPane.add(addImage(), BorderLayout.SOUTH); } return jContentPane; } private JButton addImage() { JButton add = new JButton("Add"); add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Adding new element at index " + getList().getModel().getSize()); ((DefaultListModel) getList().getModel()) .addElement(LOADING_ICON); } }); return add; } private JScrollPane getScrollPane() { if (jScrollPane == null) jScrollPane = new JScrollPane(getList()); return jScrollPane; } private JList getList() { if (list == null) { DefaultListModel model = new DefaultListModel(); list = new JList(model) { @Override public void paint(java.awt.Graphics g) { System.out.println("In JList.paint(): visible index0=" + getFirstVisibleIndex() + ", index1=" + getLastVisibleIndex()); super.paint(g); } }; list.setLayoutOrientation(JList.HORIZONTAL_WRAP); list.setVisibleRowCount(1); } return list; } public static void main(String[] argv) throws Exception { UIManager.setLookAndFeel(new SubstanceRavenGraphiteGlassLookAndFeel()); Issue376 dlg = new Issue376(); dlg.pack(); dlg.setVisible(true); } } substance-5.3.orig/src/test/issues/Issue400.java0000644000175000017500000001036211076651450021452 0ustar drazzibdrazzibpackage test.issues; import java.awt.BorderLayout; import java.awt.Color; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenuBar; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JSlider; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; /** * Test application that shows the use of the {@link * SubstanceLookAndFeel#COLORIZATION_FACTOR} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#COLORIZATION_FACTOR */ public class Issue400 extends JFrame { /** * Creates the main frame for this sample. */ public Issue400() { super("Colorization factor"); this.setLayout(new BorderLayout()); // CODE TAKEN DIRECT FROM ColorizationFactor final JPanel panel = new JPanel(new FlowLayout()); JButton button = new JButton("sample"); button.setBackground(Color.yellow); button.setForeground(Color.red); panel.add(button); JCheckBox checkbox = new JCheckBox("sample"); checkbox.setSelected(true); checkbox.setBackground(Color.green.brighter()); checkbox.setForeground(Color.blue.darker()); panel.add(checkbox); JRadioButton radiobutton = new JRadioButton("sample"); radiobutton.setSelected(true); radiobutton.setBackground(Color.yellow); radiobutton.setForeground(Color.green.darker()); panel.add(radiobutton); panel.setBackground(Color.RED); // ADDITION OF MENUBAR AND LABELS final JMenuBar menuBar = new JMenuBar(); menuBar.setBackground(Color.RED); menuBar.setOpaque(true); JCheckBox menuCheckBox = new JCheckBox("Menu Check Box works..."); menuCheckBox.setSelected(true); menuCheckBox.setBackground(Color.green.brighter()); menuCheckBox.setForeground(Color.blue.darker()); menuBar.add(menuCheckBox); JLabel menuLabel = new JLabel("Menu label doesn't work..."); menuLabel.setOpaque(true); menuLabel.setBackground(Color.blue); menuBar.add(menuLabel); JLabel panelLabel = new JLabel("Panel label works..."); panelLabel.setOpaque(true); panelLabel.setBackground(Color.blue); panel.add(panelLabel); this.add(menuBar, BorderLayout.NORTH); this.add(panel, BorderLayout.CENTER); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JSlider colorizationSlider = new JSlider(0, 100, 50); colorizationSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { double val = colorizationSlider.getValue() / 100.0; System.out.println("Current val: " + val); panel.putClientProperty( SubstanceLookAndFeel.COLORIZATION_FACTOR, new Double( val)); panel.repaint(); menuBar.putClientProperty( SubstanceLookAndFeel.COLORIZATION_FACTOR, new Double( val)); menuBar.repaint(); } }); JButton textErrorButton = new JButton("Set colorization to 0.29"); textErrorButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { colorizationSlider.setValue(29); } }); controls.add(textErrorButton); controls.add(colorizationSlider); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are ignored. * * @param args * Ignored. * @throws Exception * If some exception occured. Note that there is no special treatment * of exception conditions in this sample code. */ public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { new Issue400().setVisible(true); } }); } }substance-5.3.orig/src/test/issues/Issue385.java0000644000175000017500000000302411061663044021457 0ustar drazzibdrazzibpackage test.issues; //package test.issues; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.event.*; import javax.swing.*; import org.jvnet.substance.skin.SubstanceCremeCoffeeLookAndFeel; public class Issue385 extends JFrame { JDialog dialog; public Issue385() { super(); this.setSize(new Dimension(200, 200)); dialog = new JDialog(this); dialog.add(new JLabel("I'm a dialog")); dialog.setSize(new Dimension(100, 100)); JButton launchDialogButton = new JButton("Launch Dialog"); launchDialogButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.setLocationRelativeTo(Issue385.this); dialog.setVisible(true); } }); this.setLayout(new FlowLayout(FlowLayout.CENTER)); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.add(launchDialogButton); this.setVisible(true); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent evt) { dialog.setVisible(false); dialog.dispose(); } }); } public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SubstanceCremeCoffeeLookAndFeel()); JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); System.setProperty("sun.awt.noerasebackground", "true"); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Issue385(); } }); } } substance-5.3.orig/src/test/issues/Issue447.java0000644000175000017500000000426611231414450021461 0ustar drazzibdrazzibpackage test.issues; import javax.swing.*; import org.jvnet.substance.skin.SubstanceBusinessLookAndFeel; public class Issue447 extends JFrame { public Issue447() { super("Issue 447"); this.setSize(300, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { UIManager .setLookAndFeel(new SubstanceBusinessLookAndFeel()); } catch (Throwable t) { t.printStackTrace(System.out); } System.out.println("LookAndFeel class : " + UIManager.getLookAndFeel().getClass().getName()); System.out.println("LookAndFeel name : " + UIManager.getLookAndFeel().getName()); try { UIDefaults defaults = UIManager.getDefaults(); Object ui = defaults.get("PanelUI"); System.out.println("PanelUI : " + ui); Object cl = defaults.get("ClassLoader"); System.out.println("ClassLoader : " + cl); ClassLoader loader = (cl != null) ? (ClassLoader) cl : JPanel.class.getClassLoader(); System.out.println("ClassLoader : " + loader); String uiClassName = (String) ui; System.out.println("UIClassName : " + uiClassName); Class cls = (Class) defaults.get(uiClassName); System.out.println("Cached class : " + cls); if (cls == null) { if (loader == null) { System.out.println("Using system loader to load " + uiClassName); cls = Class.forName(uiClassName, true, Thread .currentThread().getContextClassLoader()); System.out.println("Done loading"); } else { System.out.println("Using custom loader to load " + uiClassName); cls = loader.loadClass(uiClassName); System.out.println("Done loading"); } if (cls != null) { System.out.println("Loaded class : " + cls.getName()); } else { System.out.println("Couldn't load the class"); } } } catch (Throwable t) { t.printStackTrace(System.out); } new Issue447().setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue424.java0000644000175000017500000000251411146540400021446 0ustar drazzibdrazzibpackage test.issues; import java.awt.BorderLayout; import java.awt.Font; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.NebulaBrickWallSkin; import com.jgoodies.forms.builder.DefaultFormBuilder; import com.jgoodies.forms.layout.FormLayout; public class Issue424 extends JFrame { public Issue424() { FormLayout lm = new FormLayout("fill:pref"); DefaultFormBuilder builder = new DefaultFormBuilder(lm); JComboBox combo = new JComboBox(new Object[] { "sample" }); combo.setFont(new Font("Tahoma", Font.PLAIN, 11)); combo.setFocusable(false); builder.append(combo); JSpinner spinner = new JSpinner(new SpinnerNumberModel(100, 0, 1000, 10)); spinner.setFont(new Font("Tahoma", Font.PLAIN, 11)); spinner.setFocusable(false); builder.append(spinner); builder.setDefaultDialogBorder(); this.add(builder.getPanel(), BorderLayout.CENTER); this.setSize(300, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } /** * @param args */ public static void main(String[] args) { SubstanceLookAndFeel.setSkin(new NebulaBrickWallSkin()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Issue424().setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue396.java0000644000175000017500000000243611071570642021471 0ustar drazzibdrazzibpackage test.issues; import javax.swing.*; import javax.swing.table.DefaultTableModel; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.preview.DefaultPreviewPainter; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.CremeSkin; import org.jvnet.substance.skin.SubstanceBusinessLookAndFeel; public class Issue396 extends JFrame { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { SubstanceLookAndFeel feel = new SubstanceBusinessLookAndFeel(); UIManager.setLookAndFeel(feel); SubstanceLookAndFeel.setSkin(new CremeSkin()); } catch (UnsupportedLookAndFeelException e) { } Issue396 scrollError = new Issue396(); JScrollPane scrollPane = new JScrollPane(); JTable table = new JTable(); table.setModel(new DefaultTableModel(100, 5)); scrollPane.setViewportView(table); scrollPane.putClientProperty( LafWidget.COMPONENT_PREVIEW_PAINTER, new DefaultPreviewPainter()); scrollError.getContentPane().add(scrollPane); scrollError.pack(); scrollError.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); scrollError.setLocationRelativeTo(null); scrollError.setVisible(true); } }); } }substance-5.3.orig/src/test/issues/Issue408.java0000644000175000017500000000234511117630300021447 0ustar drazzibdrazzibpackage test.issues; import javax.swing.*; import javax.swing.table.DefaultTableColumnModel; import javax.swing.table.DefaultTableModel; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; public class Issue408 extends JFrame { public Issue408() { JTable table = new JTable(new DefaultTableModel() { @Override public int getRowCount() { return 10; } @Override public int getColumnCount() { return 5; } @Override public Object getValueAt(int row, int column) { return row + ":" + column; } @Override public String getColumnName(int column) { return "Column " + column; } }); JScrollPane jsp = new JScrollPane(table); table.setTableHeader(null); table.setColumnModel(new DefaultTableColumnModel()); this.add(jsp); this.setSize(500, 400); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Issue408().setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue450.java0000644000175000017500000000437111225563400021453 0ustar drazzibdrazzibpackage test.issues; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessSkin; public class Issue450 extends JFrame { public Issue450() { super("Issue 450"); final JTable table = new JTable(10, 4); this.add(new JScrollPane(table)); JPanel controls = new JPanel(new FlowLayout(FlowLayout.TRAILING)); JButton tableRed = new JButton("table red"); tableRed.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { table.setBackground(Color.red); } }); JButton tableGreen = new JButton("table green"); tableGreen.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { table.setBackground(Color.green); } }); JButton tableRevert = new JButton("table revert"); tableRevert.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { table.setBackground(UIManager.getColor("Table.background")); } }); JButton tableHeaderBlue = new JButton("header blue"); tableHeaderBlue.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { table.getTableHeader().setBackground(Color.blue); } }); JButton tableHeaderYellow = new JButton("header yellow"); tableHeaderYellow.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { table.getTableHeader().setBackground(Color.yellow); } }); controls.add(tableRed); controls.add(tableGreen); controls.add(tableRevert); controls.add(tableHeaderBlue); controls.add(tableHeaderYellow); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 300); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { SubstanceLookAndFeel.setSkin(new BusinessSkin()); new Issue450().setVisible(true); } }); } } substance-5.3.orig/src/test/issues/Issue361.java0000644000175000017500000000255011017452032021446 0ustar drazzibdrazzibpackage test.issues; import java.awt.BorderLayout; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import javax.swing.*; import org.jvnet.substance.skin.SubstanceRavenGraphiteLookAndFeel; public class Issue361 { public static void main(String[] args) { try { UIManager.setLookAndFeel(new SubstanceRavenGraphiteLookAndFeel()); } catch (Exception e) { e.printStackTrace(); } JDialog dlg = new JDialog(); Object[][] data = new Object[0][0]; Object[] columns = new Object[15]; for (int i = 0; i < 15; i++) columns[i] = "Column " + i; final JTable table = new JTable(data, columns); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); JPanel p = new JPanel(); p.setLayout(new BorderLayout()); final JCheckBox checkEnableTable = new JCheckBox("Enable"); checkEnableTable.setSelected(true); checkEnableTable.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { table.setEnabled(checkEnableTable.isSelected()); table.getTableHeader() .setEnabled(checkEnableTable.isSelected()); } }); p.add(checkEnableTable, BorderLayout.NORTH); p.add(new JScrollPane(table)); dlg.add(p); dlg.setPreferredSize(new java.awt.Dimension(300, 300)); dlg.pack(); dlg.setLocationByPlatform(true); dlg.setVisible(true); } } substance-5.3.orig/src/test/issues/Issue407.java0000644000175000017500000000260611104001130021433 0ustar drazzibdrazzibpackage test.issues; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; public class Issue407 extends JFrame implements ActionListener { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { try { UIManager .setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); // UIManager // .setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); } catch (Exception e) { } UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE); Issue407 frame = new Issue407(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton okbutton = new JButton("OK"); JButton cancelbutton = new JButton("CANCEL"); cancelbutton.addActionListener(frame); okbutton.addActionListener(frame); frame.getContentPane().setLayout(new FlowLayout()); frame.getContentPane().add(okbutton); frame.getContentPane().add(cancelbutton); frame.getRootPane().setDefaultButton(okbutton); frame.setSize(100, 100); frame.setVisible(true); cancelbutton.requestFocus(); } }); } public void actionPerformed(ActionEvent e) { System.out.println(((JButton) e.getSource()).getText()); } }substance-5.3.orig/src/test/EdtViolation.java0000644000175000017500000000056011046364140021215 0ustar drazzibdrazzibpackage test; import javax.swing.JLabel; import javax.swing.UIManager; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; public class EdtViolation { public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); JLabel label = new JLabel("text"); } } substance-5.3.orig/src/test/DecorationAreas.java0000644000175000017500000000330411164744564021673 0ustar drazzibdrazzibpackage test; import java.awt.GridLayout; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.utils.LafConstants.AnimationKind; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.skin.*; public class DecorationAreas extends JFrame { public DecorationAreas() { super("Some simple text"); this.setLayout(new GridLayout(2, 2)); JList list1 = new JList(new Object[] { "entry1", "entry2", "entry3", "entry4" }); SubstanceLookAndFeel .setDecorationType(list1, DecorationAreaType.HEADER); JList list2 = new JList(new Object[] { "entry1", "entry2", "entry3", "entry4" }); SubstanceLookAndFeel.setDecorationType(list2, DecorationAreaType.NONE); JList list3 = new JList(new Object[] { "entry1", "entry2", "entry3", "entry4" }); SubstanceLookAndFeel.setDecorationType(list3, DecorationAreaType.GENERAL); JList list4 = new JList(new Object[] { "entry1", "entry2", "entry3", "entry4" }); SubstanceLookAndFeel .setDecorationType(list4, DecorationAreaType.FOOTER); this.add(list1); this.add(list2); this.add(list3); this.add(list4); this.setSize(650, 400); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); UIManager.put(LafWidget.ANIMATION_KIND, AnimationKind.DEBUG_FAST); SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin()); SwingUtilities.invokeLater(new Runnable() { public void run() { new DecorationAreas().setVisible(true); } }); } } substance-5.3.orig/src/test/ColorPickerIcon.java0000644000175000017500000000424111205530212021631 0ustar drazzibdrazzibpackage test; import java.awt.*; import java.awt.geom.GeneralPath; import java.awt.image.BufferedImage; import javax.swing.*; import org.jvnet.substance.utils.SubstanceCoreUtilities; public class ColorPickerIcon extends JFrame { Icon orig; public ColorPickerIcon() { JPanel panel = new JPanel() { @Override protected void paintComponent(java.awt.Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g.create(); g2d.setColor(Color.black); g2d.translate(-4, -6); int xc = 20; int yc = 22; int r = 15; g2d.setStroke(new BasicStroke(2.5f)); g2d.drawOval(xc - r, yc - r, 2 * r, 2 * r); g2d.setStroke(new BasicStroke(4.0f)); GeneralPath handle = new GeneralPath(); handle.moveTo((float) (xc + r / Math.sqrt(2.0)), (float) (yc + r / Math.sqrt(2.0))); handle.lineTo(45, 47); g2d.draw(handle); g2d.translate(4, 6); g2d.dispose(); } }; this.add(panel, BorderLayout.CENTER); this.setSize(100, 100); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new ColorPickerIcon().setVisible(true); BufferedImage blank = SubstanceCoreUtilities.getBlankImage(48, 48); Graphics2D g2d = blank.createGraphics(); g2d.setColor(Color.black); g2d.translate(-4, -6); int xc = 20; int yc = 22; int r = 15; g2d.setStroke(new BasicStroke(2.5f)); g2d.drawOval(xc - r, yc - r, 2 * r, 2 * r); g2d.setStroke(new BasicStroke(4.0f)); GeneralPath handle = new GeneralPath(); handle.moveTo((float) (xc + r / Math.sqrt(2.0)), (float) (yc + r / Math.sqrt(2.0))); handle.lineTo(45, 47); g2d.draw(handle); g2d.translate(4, 6); // try { // ImageIO // .write( // blank, // "png", // new File( // "C:\\JProjects\\substance\\src\\contrib\\ch\\randelshofer\\quaqua\\images\\zoomer.png")); // } catch (Exception exc) { // exc.printStackTrace(); // } } }); } } substance-5.3.orig/src/test/JaxbwIconDemo.java0000644000175000017500000001121110776636012021311 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test; import java.awt.*; import javax.swing.JFrame; import javax.swing.JPanel; import org.jvnet.substance.colorscheme.AquaColorScheme; import org.jvnet.substance.colorscheme.PurpleColorScheme; /** * Image creator demo. * * @author Kirill Grouchnikov */ public class JaxbwIconDemo { public static final int COLOR_CELL = 30; public static final int NAME_CELL = 120; private static final class IconFrame extends JFrame { /** * Simple constructor. Creates all the icons. */ public IconFrame() { this.setLayout(new BorderLayout()); this.add(new IconPanel(), BorderLayout.CENTER); } } /** * Demo frame. * * @author Kirill Grouchnikov */ private static final class IconPanel extends JPanel { /** * Simple constructor. Creates all the icons. */ public IconPanel() { int width = 50; int height = 50; Dimension dim = new Dimension(width, height); this.setPreferredSize(dim); this.setMinimumSize(dim); this.setSize(dim); } /* * (non-Javadoc) * * @see java.awt.Component#paint(java.awt.Graphics) */ public final void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g.create(); g2.setColor(Color.white); g2.translate(15, 15); // g2.drawImage(SubstanceImageCreator.getRoundedBackground(16, 16, // 2, // ColorSchemeEnum.LIGHT_AQUA, 0, null), 0, 0, null); g2.setColor(new AquaColorScheme().getDarkColor()); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); g2.setColor(new PurpleColorScheme().getDarkColor()); g2.setFont(new Font("Tahoma", Font.BOLD, 17)); g2.drawString("J", 6.0f, 14.0f); g2.setColor(Color.BLACK); g2.setFont(new Font("Tahoma", Font.BOLD, 11)); g2.drawString("w", 2.0f, 11.0f); // Stroke stroke = new BasicStroke(1.8f, BasicStroke.CAP_ROUND, // BasicStroke.JOIN_ROUND); // g2.setStroke(stroke); // GeneralPath path1 = new GeneralPath(); // path1.moveTo(5.0f, 4.0f); // path1.quadTo(3.0f, 4.0f, 3.0f, 8.0f); // path1.quadTo(3.0f, 12.0f, 8.0f, 11.0f); // path1.moveTo(10.0f, 12.0f); // path1.quadTo(12.0f, 12.0f, 12.0f, 8.0f); // path1.quadTo(12.0f, 4.0f, 7.0f, 5.0f); // path1.lineTo(8.0f, 11.0f); // // path1.moveTo(8.0f, 8.0f); // g2.draw(path1); // g2.setColor(Color.BLACK); // g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // RenderingHints.VALUE_ANTIALIAS_OFF); // g2.drawRect(-1, -1, 18, 18); // Stroke stroke2 = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, // BasicStroke.JOIN_ROUND); // g2.setStroke(stroke2); } } /** * Main function for running this demo. * * @param args */ public static void main(String[] args) { IconFrame icf = new IconFrame(); icf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); icf.pack(); icf.setVisible(true); } } substance-5.3.orig/src/test/resource/0000755000175000017500000000000011256731162017604 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/resource/firefox.png0000644000175000017500000005310110703275230021747 0ustar drazzibdrazzibPNG  IHDR !bKGD pHYs  tIME :lQt IDATxw$},]L`0=HPDvV)@=A!` Ʒi_]&3#,3Xډ3tUV7? <.<.<.<.<.<.<.<.!g?mI] j.yj,^gXCR=!×?(+/HW v[@1 {`=if>o?tܽ^`f/UKUXRqzo%E>|`@oq :n^.H_636^r\k{ҾxffV+ b`[!|2~pAZn+jЦJyt=ӎnؿ5Em3SfR ~bvj+p<9&[2?+9}*>Cް)ǖ4[iҞx}R>h,M/3Rfu&j/՘XQ&X #lAaW s+[/ bX7쀫nx߮,nTȥv l`d[\ev|I6TUϬPֱaazKԱE !#Kџ_K Xu{zc-]}]k1C.thP95='j-hÑEezz CX'P~h?+߾`]l~ t%3`5]aZK wb\IO0[`Ut<`kAPq fWn/>#`5[PRnȬs@X@kEj?X0u4 Zs_$r dɾB5$8oI-`ڇ~Ќ%V-u{ᆝӟ x>g\tם03 `450?ȓ 5Xd3}K|nepr~y^Y=vb mR:hNW&d(V{2vu;m{ 8ũɘ3yn?=wN X.s~E'һH">dorS˰!_y;ρ<|\|,TÈS=Epȹ)տX;s9مމeqz0Oq~n;:0lfu3b}巌\yNe/$q~y 1Xھ.x> 3XʯbS0Tf\E+bXc1Q Cz ]a(}窡)zP{=`̂9 vBwovw^ `aΒ~fެ$^-{phv(bE?M{Υvt2&Z'lxZ1:V%UUtfN5[I^&NPuKD:L+ʛv "ũs6 nLH|@ުoڋjāKd/ Jc^ϧv $%.2]:V +-bBZRA*dZzK|1VǠ st3vՑ{-xm@3)tG9 _^h; Cd( ~ #zrL;{ [ދXM1WBx@)<[&ЕM͓mߴH%Bp\mXcAkњ8ZG1qE!QN}x@ѯسAh!XhQ0tC޸gWj^'_* 潐w^Uo)BWonO6|Eoށ X a>#eH3Aev8[Rkr+<>: .+KЧ`E`iJ$Ji$ZxaMlHg99cWiʫg`"jM޹ˇO~x+_Fw[P.D gWon~7|l_։DK dS>?rx+A9@qa9|/W'8d C!}6R"bg[_7B `sV˹2ZXÊbN zaSH]+gx￐^v uֲ?`wcے)+5"x&/j1 Lm Uk$G`,DSdSRMiʵ\1XZ)cgjRe"ǮD"29ѹq8b`^6Dv[aDX@ 0Н{s}ǿ~v$_Z2+!P.dkae5}R|9r+w?=q/}ة1XN+cċ㠧-_ҿ{17K`"a̓*|+uݨ56rѩ4?Xt# L%K#ͯjK޾W{+gks#H9`x,R۷AzSbOR #<)r={՚@ aC@)dCCl1q},35-Q$Y$%bmFh={NQ,#D:Rd3i"}t* Jٲ/(L-3u~ #1OIJ|OPD,zM6GXUQj=>ydWػp7I@ B {=UL/ v#v_L< :Nķ} ?mk&[}`tWB<~쐺noVRȔ@y=]%L*h7o]t,[,_sOw5ޱƛ1U:bqƯGƘXvZ[3lD{{%fgnq3X\t?m e Q cVkӳ%x+ғdjk0 ExR1CuN֨Tc EV&s7D%K D0B,8].pewVp6}v[~kr|~noNIH2cubt:ز0F {~&GP$CP$uᥲH/p)ؠec zDtg0֒=2kM2tOrʞx:Xm&XkP]3iL n41)7W k TsX@MC6Ď+ҁͼbO+^ct|-|g^_"}^]! -Kj6d*xuܓ\/^C¹22Gr` qyα[bԦcoL} W CGTW/ N*؜;ŮkUFgnaյZCow|>L ن;N9q'gN kZDjG&}r4l̠"%l!KC}{sN4 / 6v#`.TM6D2}%r]N?~jtlX[R {vi=fOǕ~[trFT*WdYKV+^Oc&b/ސF0}>gS~6Thq ]]p.%lT#wn|0LD+^m2_^Y~lɝ/'KPQ~!U \ XF6&Zd׭i`0RZ:jk]Zص+p# X@RV^38@bκˠ .dOP҆U-;uw#_10z`i C>@2}PDrX ilT ևB-Ś"ب LcMcNͳ룺Jl2EzV NCnc!^yf:p6z] l``V }L`yvd׫S6+1s\Hd=ǻw1&D%5Pu :)kW$uFd$;^"OCc;=il\O!Tuc(1JSΘKca&fapKû BzMkzKP6"mEsfT}{X9Oqt?tCU#Nz Odi0 ~6IԾ8uܲQ?G{AtwyY'Z]„u!uBHl"@up5MEApNpΐ"x0=r̘Xb3jlp~/zLlJwlmmx3`6WCkr֧ZX 87lD'"dˎ!]6 ZS91b.n4tiKKyK1:GzCPh 4jҞ H%zOg2OϞR.U+,i)I)Llx}yy,xifDt?Z': T*g .>!$?hV .7y`9<~+ a1\"/nޞ J2#''0RV.%dEKg1$Q  RA_8Dʻwn2dmR'MiY/.UV;FFF)xPJ; \%I]Bʀ| <d_20&^( L2?v H#4ca0﹒|> zr_<2+1+2R!4h5/yBYH!Za" HeA6C{Jc[O?"*(Jcث{V!05>Σ?D*k<{%dMp&1*B*~ G!-Du͛;`),gcO~I<^}K(>]R2xDb֖4gWaS9ZX@ D NtJ;X".'?AroyNwOHµZָX4-p%"vјS*cpO'=N ([ ~mHm,0Po=]N>GH}9YH2/= 7`MD杻Kt!Bώ#@(kL k5&qywՐ/nrSv%wOW>s+.cctⷉɩ)&@_?dZ?v ^OSYg{=È % _lKt{υw׈g 9Woic/%a M(Rx^f>!<3!Ʈg3دKzhN|S/%%\ ?ۍ#)lmӦDHZ8s$q[< IDATy|6 dKu"ŞNoek~j^[odw /k-]k9_=evwFߕ͟~?Lۺwz9ML|+=DJ-9@g<G%Bz`uH7EXkSHKeYL M/*dS9JI%xRQ[#=w~s5t:MнAk*e~zx)5.R|]tˠc13I)amlӃ bML> g 0 x2?UcL M|L+bkn2GWjV&ꢔtFXr2 ?SC gn| _vd~ !}X0Ѝk}9|N6_570~I,cJzH)u,es|&:+Ȁj'i'W^kwզ` ϮSu X#is8W;y/^* a0I)%!ͦb*s,?E+d xA&t0#VtX w-mvklKao_ˋ/6*tGsKs() = l<]= #r969qY$ zp`T'S6]<Ӱѳ MQ+RFJۢ\9MRE@k%Ǫ lJ!*TA WLnL?KgP^بٴf[̶f^$ߺ n 'RFE͜Q(0k2W;|vg6`$]BLRp#`5EB/-#p%p-!]4N6kTKyٖ"ʕ2T駜HlڦуBꇥ]bphɳmP'ڶ.>ǰx$qeAf{fGvv(X/[3ڸR$*^1BE+z\6l>̟GI7[6CD sqIoOc{HGt&+gPA E-dKx^*H9hE3 oiw_qdI;֭{M\q#oj-fxvz\Ȇӽ5&N"5vm4L`ۆ'!Sxן_Dh+DvXm[{b'j&Qv֒^~s})8SU!d+J N]ymJ_Xfc\t'k Yfg69T۪ۋA oXv4I-Y?eOکu`ۯZu5XeEDZwr)I"kX"gR&@d GYJ]TDaX:ys2) J*m;6AJ63ef;5fwӔ?CO{b&]yʢ`. ]װLg𒝭MZۚae!bXVfҔUÔzxo}0[G`ĉ8) PFd҃ TA #ݞx/hJ {ùmI?.)1F&9TOl|xoǫ<*5{!5P(>bZh{Y歯_m+Yknem`jБݚGc%i:`q\k^)'^ ̀&aDΝiaH BuSRzvַo~'Fޏ2 `\L:HLFc^i12*Cx>6| ܱ)[5lr73Rt}\]?RO>E+n\KW%$p2j Dr8 z;aog_`w7$dNMjFzM.H*?cc3U޻B]XJ0#P~ ]AH/pNT/~Sv"b^:n">Lb/:Ef{jXwG;L?[FX"qz.,y8t Cˆ5 0 2hěأK8lE੤.hLk?ϯ5'j [ܺFɳ-1i/M1R1*f'8p{;,N\$bd{=7˟b8z]5rkl4ۭ_R{Yq \b;\Emd&, a5|ҁEc90B?*LGչX]/E'D fpt7'X ɕ+KX$ju([6m !r]]\:{Q&d~u"ڄ\bm]#S٦Jbg!D`5@)U<~^M_ҩY9HBmV,S`FڋX{Dp<=7A?i|qm^杻:,;$%z7\9_M5FFLLEN'`` v/^k.N$t-#B&P.DLGu%ؼu}|lȫ`G~-cmAkF4qJms786(fp*[S{kk6P4bn._:ŁԩVI\?nwH1h΅JiPkTV"lP%mۚϵUkK;61(6jo<,.FI L*y4/yidck1*a5*{KQ3 X&uM}̮ij œW(|D&SMRwrSY^lS:mdwQ]]@G:Ez߶H0ûC_J89LFwu{ѬH\O=_$JzlI%Vb*UdʤkU1I'KN$\*Ƕb )tewx˶ !6-(e\D,T(7m9C>#X߶ |l K%αmb2+.ht[5/+򨷉`/75-6nO Ad.XkB԰种PD$ZoF4c۝ifQEjN PÃyGi:sh[?Cj^ ۴X&ր/ $l$)X^0'ՇiQL#+ @a Nt5 R4;Hc}է0&JB.~;>t­~T;`:m#<$V%͈l仧4lTQڇe0:9`C9mzHDcCrWƒ/u훛~sSA^|[zDIKKf5lY0XlH3nAWL]. X&* f ܖ2? SY{x>AWZ>M95uhcX%z#2^v`Ss6;3.=LX :F3 t,(ߜ|>VMDhn kG+?k))]kUa,6Ivt9Ht|iXj̝_(PmAs:,΅,ЗTSkmxZ&ȎN dO3zY*,V eZE氜ks ]) ޱ!o؅iTzdE bKUK)ʔLi6 fkK8ܔ+)Hu@rQ؞grs~B5V"&OV9q¹c,J 3Y Cs ׹#:|\`L|W\Ǽq%"W՞H'N H4r`mͱZj=/a3'9;q# s`/ 5n:nM$<7LSvRHx ҅]h[hxmI%O@ a,Y[5SD?+&NMT^:F_ 3qx1p!tTg8M{΀oLuY=B:XM7j'a9s͟n\Mf_ I[ G %ܡ-5 ̝ uKelD yqYl#LJėa%&tm= ?TB\ R(FG6 ho'K _ZWطޝl۲qfw-c3ytT'<Į-mޛ+#K"֡f3\={`0,!&,Vpn)Չ%K *, t:LݠCXԕoK&*!pDO|x_>:ѵ~(FIF 4j\woπ!7YEK_8pr@/&˵xH UeK T( Lңw&_ewW e2Ee:1(ӂ`'_<-BJ:vןp_wAj6VQ{rlA!1Kh:>(g=tdX6.J3zk|0DD>硫1KOɼ*Pߑ()Dc7]{㈱ևt)Ya:+0JUk((ϷO9t(hU(SiUVF&̋x}Qt,b]GZ=mkյKԉǑāGDMcOwP]Nث\sѿ2>~oJC :2MߡJK\I޳u-w`NЀ Op$Ӧ1 P qOv{xe; sVƈ}MچUәf 0JQM|}>Xl-Y66Dy G \?_ ΪIbdHE#/L^«LN=h)d /*Gu#a( ˟vR{"~=}bJBHhcOV{*ILh;NY>h,l&AS~jYݲ !L?=>_(}ɩ˥&I_ a k Q /?G?{_gB9S]akLxO>W2ˠ~Y3ǩWb!Ĩu,w{+){o;0 X<>T}MTN;%Z{'9n*3s|&_z˿ [FC6 GzF;<泝F«FdOx\V Yڼھ}[qX|߰ulͲW햾 VQF3I3I3wC]Dt[F\fjGh3):};6__$ObSnF)HOw'+i I z&+񅏟?>?Ύ[45~iӔqo{g3M\N=-)F !I3)ڊѺd\&m}RRÑAO{ α XniNT@B瑹5,b7-:6ףN_fd!{%[vJ?V`n"7!K"E 8#Io]ͷԏD3|#=.O&P5v xxlKq#!o 4$ *NPq<~ǨTQ` k>e_܇,*6^BV' Ͽw7^Ip|ek&sL?M @AILT5aF Pd1$xG2~Վ)&ZcW`pixבJoʄcM=ϲvlS=_ ޘcGz-`>K&u ٽ["v v!TK@ !!Bo՜7;vvةgtδAyxr.le 鏅xV>Bqݺ7|=h'={.2FO:mW47Kc`kaX`O :Xq![]9 ʼϰZ $^I8eԂ / Bo$,mWo ,~c7^atalMX`L XEQD%1ٓ[Bt@GYgo@^1%d gmefYNĩ (sB0pWWK@(f#rfX \O2"2^,W ,~m~}@Pǯͤ4!X&OWVBQCϘ3*q i0G MENY\+S릮[0Wҍ` !\3|L9嫿4s23Gv ^ז .(Z'b†Gkh9؄!x;B ,rK|鼮5aA~tc:I`c} Su| 3_^򄠽[;Y~ى{m؝|BQX낅VU kYAڑ9g+4KsF/!a')&=-#5-&C' %ڹɺ-:i2YW.QꟇ1K*<Щ`fs=<#ygxlx;֎e(gs`Yܺhz"3G U½5-i;1&;@#-F>Z{%/SIfaPl†$p1죆}3$Kc .QP~얓klm.7 TjKO@ O!q ' Awe&)k/.Ҙʡ2)7GuQ)hӻ8DHAiwi7 ɍV#6i:cpd$=xh|. b!|]rBrBBք#j(4M+!_{C-⯫c6z-uoIKƓx1udQ$ݭoΩ&k/uOOTzNF>]T ^䏀Ε{rtRg{t TA(o нbģ l8,{1 !0PK%v<bY1޻rd!^'a)CCnLeu?M4F:_:hj}l;k d=J6ޤ<0}дII4_tήӦQ߭ @zs2P߄om+ $ty ;ٚϢtV`%2R7 >47ʭ0|>x0@kv PŖ+T@6P WOo~lחDeǮ$ ޾ЎF@LJ&sc+Wo< ٪5}?[_1 'x5j۲;.Ux} 5=Xx:܋ p^.q3:$!&V|{爛]Qkg[D)$'ҖDc,C&zNW\n^ataQ8j3  &m4 ̄>dǀO%)ipE69(]R؁b⹝+KNqQFd2Kښa Wvbhk%vNL8_r7`'8 ԇT4v~dpMjTJ0S~6 .t_͍W_6,;Q"sp);˜Ŋ3 5CcoVPѸ=yNw 1v&4]i-&S D X]!iϢX_F?V{N\S@y8"ຓ2@w\{8PxdZqo(.& a~^!͢ {1] &뺊NnXdT GA4t C>&8Ɂd~r_^̡U/'7r kYk[tS@nn+&5 S1h d @gI&wҘ}_lu5d\mt;_LB;﾿d͂I?N~qp|`n#k fꂊ[NN&St T_U q)8<֙,rYMVh\v7vF7?Rj, XϳwOgx 'E@ %Okxy8ܢ&cuAB>[_ރAy%moRj_u.DYKGdIENDB`substance-5.3.orig/src/test/resource/computer.png0000644000175000017500000000067310510772046022154 0ustar drazzibdrazzibPNG  IHDRabKGDC pHYs  ~tIME 3HIDAT8˥AKQowKx",AAPo}$E)]A5&l Tv؝${3OS| $2[V$VDvE题4Ny4ິ} F,.!cjah_|LaAPxX  ȩx|xQL =[PXoaxVD ({9$~@_o0ϭOMPո:ߛHh4Fe9=e+gT.vw}ubCu8{%srz R|V6frʕٌӜx;#IENDB`substance-5.3.orig/src/test/ImageWatermark.java0000644000175000017500000000234611027244754021527 0ustar drazzibdrazzibpackage test; import javax.swing.JFrame; import javax.swing.SwingUtilities; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.api.SubstanceConstants.ImageWatermarkKind; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import org.jvnet.substance.watermark.SubstanceImageWatermark; import test.check.SampleFrame; public class ImageWatermark { public static void main(String[] args) { SubstanceImageWatermark watermark = new SubstanceImageWatermark( ImageWatermark.class .getResourceAsStream("/test/samples/substance/api/dukeplug.gif")); watermark.setKind(ImageWatermarkKind.APP_TILE); SubstanceSkin skin = new BusinessBlackSteelSkin().withWatermark(watermark); SubstanceLookAndFeel.setSkin(skin); JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { SampleFrame skinFrame = new SampleFrame(false); SwingUtilities.updateComponentTreeUI(skinFrame); skinFrame.setSize(315, 245); skinFrame.setLocationRelativeTo(null); skinFrame.setVisible(true); skinFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }); } } substance-5.3.orig/src/test/VerticalTextsDefault.java0000644000175000017500000000412110777336110022725 0ustar drazzibdrazzibpackage test; import java.awt.*; import javax.swing.*; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; import org.jvnet.substance.utils.SubstanceTextUtilities; public class VerticalTextsDefault extends JFrame { protected static class VerticalPanel extends JPanel { private Font font; public VerticalPanel(Font font) { this.font = font; } @Override protected void paintComponent(Graphics g) { g.setColor(Color.white); g.fillRect(0, 0, getWidth(), getHeight()); Rectangle[] rectsT2B = new Rectangle[] { new Rectangle(40, 10, 20, 100), new Rectangle(130, 100, 20, 100), new Rectangle(10, 40, 20, 100) }; Rectangle[] rectsB2T = new Rectangle[] { new Rectangle(80, 10, 20, 100), new Rectangle(10, 150, 20, 100), new Rectangle(50, 120, 20, 100) }; int count = 0; g.setColor(Color.blue); for (Rectangle rect : rectsT2B) g.drawRect(rect.x, rect.y, rect.width, rect.height); g.setColor(Color.red); for (Rectangle rect : rectsB2T) g.drawRect(rect.x, rect.y, rect.width, rect.height); for (Rectangle rect : rectsT2B) { SubstanceTextUtilities.paintVerticalText(g, this, rect, "Top to bottom text " + (++count), -1, this.font, Color.red, null, false); } for (Rectangle rect : rectsB2T) { SubstanceTextUtilities.paintVerticalText(g, this, rect, "Bottom to top text " + (++count), -1, this.font, Color.blue, null, true); } } } public VerticalTextsDefault() { super("Vertical Swing texts"); this.setLayout(new BorderLayout()); this.add(new VerticalPanel(new Font("Segoe UI", Font.PLAIN, 12)), BorderLayout.CENTER); this.setSize(400, 400); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); SwingUtilities.invokeLater(new Runnable() { public void run() { new VerticalTextsDefault().setVisible(true); } }); } } substance-5.3.orig/src/test/Fr.java0000644000175000017500000000071111137075306017165 0ustar drazzibdrazzibpackage test; import javax.swing.JFrame; import javax.swing.SwingUtilities; public class Fr extends JFrame { public Fr() { super("Some simple text"); this.setSize(650, 400); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { new Fr().setVisible(true); } }); } } substance-5.3.orig/src/test/Combiner.java0000644000175000017500000000265611246660146020371 0ustar drazzibdrazzibpackage test; import java.io.*; import java.util.ArrayList; import java.util.List; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceColorSchemeUtilities; public class Combiner { public static void main(String[] args) throws Exception { File inputs = new File( "C:\\jprojects\\substance\\src\\org\\jvnet\\substance\\skin"); List schemes = new ArrayList(); for (File input : inputs.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith("office-") && name.endsWith(".colorscheme"); } })) { System.err.println("Processing " + input.getName()); try { SubstanceColorScheme scheme = SubstanceColorSchemeUtilities .getColorScheme(input.toURI().toURL()); schemes.add(scheme); } catch (IllegalArgumentException iae) { System.err.println("Skipped"); } } File output = new File( "C:\\jprojects\\substance\\src\\org\\jvnet\\substance\\skin\\office2007.colorschemes"); PrintStream printStream = new PrintStream(new FileOutputStream(output)); for (int i = 0; i < schemes.size(); i++) { SubstanceColorScheme colorScheme = schemes.get(i); String encodedColorScheme = colorScheme.toString(); printStream.println(encodedColorScheme); printStream.println(); } printStream.close(); } } substance-5.3.orig/src/test/SelectedTabScheme.java0000644000175000017500000000536511240573462022135 0ustar drazzibdrazzibpackage test; import java.awt.BorderLayout; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.MetallicColorScheme; import org.jvnet.substance.colorscheme.SunsetColorScheme; import org.jvnet.substance.painter.border.ClassicBorderPainter; import org.jvnet.substance.painter.decoration.ClassicDecorationPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.gradient.ClassicGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; public class SelectedTabScheme extends JFrame { protected static class CustomSkin extends SubstanceSkin { public CustomSkin() { SubstanceColorScheme activeScheme = new MetallicColorScheme().tint( 0.15).named("Custom Active"); SubstanceColorScheme defaultScheme = new MetallicColorScheme() .shade(0.1).named("Custom Default"); SubstanceColorScheme disabledScheme = defaultScheme; SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); defaultSchemeBundle.registerColorScheme(disabledScheme, 0.4f, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(activeScheme, 0.4f, ComponentState.DISABLED_SELECTED); defaultSchemeBundle.registerColorScheme(new SunsetColorScheme(), ColorSchemeAssociationKind.TAB, ComponentState.SELECTED); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new ClassicGradientPainter(); this.borderPainter = new ClassicBorderPainter(); this.decorationPainter = new ClassicDecorationPainter(); this.highlightPainter = new ClassicHighlightPainter(); // note the fade start / end for selected tabs this.selectedTabFadeStart = 1.0f; this.selectedTabFadeEnd = 1.0f; } @Override public String getDisplayName() { return "Custom"; } } public SelectedTabScheme() { super("Selected tab"); JTabbedPane jtp = new JTabbedPane(); jtp.addTab("tab0", new JPanel()); jtp.addTab("tab1", new JPanel()); jtp.addTab("tab2", new JPanel()); this.add(jtp, BorderLayout.CENTER); this.setSize(300, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { SubstanceLookAndFeel.setSkin(new CustomSkin()); new SelectedTabScheme().setVisible(true); } }); } } substance-5.3.orig/src/test/Crayons.java0000644000175000017500000000154211020544120020221 0ustar drazzibdrazzibpackage test; import java.awt.*; import javax.swing.*; import org.jvnet.substance.utils.SubstanceImageCreator; public class Crayons extends JPanel { private Image crayons; public Crayons() { this.crayons = SubstanceImageCreator.getCrayonsImage(); } @Override protected void paintComponent(Graphics g) { g.setColor(Color.white); g.fillRect(0, 0, getWidth(), getHeight()); g.drawImage(this.crayons, 0, 0, null); } /** * @param args */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JFrame frame = new JFrame("Crayons"); frame.add(new Crayons()); frame.setSize(400, 400); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }); } } substance-5.3.orig/src/test/Label.java0000644000175000017500000000141311152713676017643 0ustar drazzibdrazzibpackage test; import java.awt.Color; import java.awt.FlowLayout; import javax.swing.*; public class Label extends JFrame { public Label() { super("Some simple text"); this.setLayout(new FlowLayout()); JLabel label = new JLabel("sample"); label.setForeground(Color.blue.darker()); label.setBackground(Color.yellow); label.setOpaque(true); this.add(label); this.setSize(200, 100); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); SwingUtilities.invokeLater(new Runnable() { public void run() { new Label().setVisible(true); } }); } } substance-5.3.orig/src/test/CloseIcon.java0000644000175000017500000000304011133236376020474 0ustar drazzibdrazzibpackage test; import java.awt.*; import javax.swing.*; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.AquaColorScheme; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; import org.jvnet.substance.utils.SubstanceImageCreator; public class CloseIcon extends JFrame { public CloseIcon() { this.add(new CPanel(), BorderLayout.CENTER); setSize(800, 400); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static class CPanel extends JPanel { @Override protected void paintComponent(Graphics g) { g.setColor(Color.lightGray.brighter()); g.fillRect(0, 0, getWidth(), getHeight()); SubstanceColorScheme st = new AquaColorScheme(); int x = 0; for (int i = 12; i < 36; i++) { Icon icon = SubstanceImageCreator.getCloseIcon(i, st, st); icon.paintIcon(CPanel.this, g, x, 100); g.setColor(Color.blue); g.drawRect(x, 100, icon.getIconWidth(), icon.getIconHeight()); icon = SubstanceImageCreator.getMaximizeIcon(i, st, st); icon.paintIcon(CPanel.this, g, x, 140); icon = SubstanceImageCreator.getMinimizeIcon(i, st, st); icon.paintIcon(CPanel.this, g, x, 180); x += (i + 2); } } } public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new CloseIcon().setVisible(true); } }); } } substance-5.3.orig/src/test/ArrowIcons.java0000644000175000017500000000531211112154372020700 0ustar drazzibdrazzibpackage test; import java.awt.*; import javax.swing.*; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.AquaColorScheme; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; import org.jvnet.substance.utils.SubstanceImageCreator; import org.jvnet.substance.utils.SubstanceSizeUtils; public class ArrowIcons extends JFrame { public ArrowIcons() { this.add(new CPanel(), BorderLayout.CENTER); setSize(800, 400); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static class CPanel extends JPanel { @Override protected void paintComponent(Graphics g) { g.setColor(Color.lightGray.brighter()); g.fillRect(0, 0, getWidth(), getHeight()); SubstanceColorScheme st = new AquaColorScheme(); int x = 0; for (int i = 11; i < 35; i += 2) { Icon icon = SubstanceImageCreator.getArrowIcon( SubstanceSizeUtils.getSmallArrowIconWidth(i), SubstanceSizeUtils.getSmallArrowIconHeight(i), SubstanceSizeUtils.getDoubleArrowStrokeWidth(i), SwingConstants.SOUTH, st); icon.paintIcon(CPanel.this, g, x, 100); g.setColor(Color.blue); g.drawRect(x, 100, icon.getIconWidth(), icon.getIconHeight()); icon = SubstanceImageCreator.getDoubleArrowIcon(i, SubstanceSizeUtils.getSmallArrowIconWidth(i), SubstanceSizeUtils.getSmallArrowIconHeight(i) + 3, SubstanceSizeUtils.getDoubleArrowStrokeWidth(i), SwingConstants.SOUTH, st); icon.paintIcon(CPanel.this, g, x, 140); g.setColor(Color.blue); g.drawRect(x, 140, icon.getIconWidth(), icon.getIconHeight()); icon = SubstanceImageCreator.getArrowIcon(SubstanceSizeUtils .getArrowIconWidth(i), SubstanceSizeUtils .getArrowIconHeight(i), SubstanceSizeUtils .getArrowStrokeWidth(i), SwingConstants.SOUTH, st); icon.paintIcon(CPanel.this, g, x, 180); g.setColor(Color.blue); g.drawRect(x, 180, icon.getIconWidth(), icon.getIconHeight()); icon = SubstanceImageCreator.getDoubleArrowIcon(i, SubstanceSizeUtils.getArrowIconWidth(i), SubstanceSizeUtils.getArrowIconHeight(i) + 3, SubstanceSizeUtils.getDoubleArrowStrokeWidth(i), SwingConstants.SOUTH, st); icon.paintIcon(CPanel.this, g, x, 220); g.setColor(Color.blue); g.drawRect(x, 220, icon.getIconWidth(), icon.getIconHeight()); x += (i + 2); } } } public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new ArrowIcons().setVisible(true); } }); } } substance-5.3.orig/src/test/MultipleSkins.java0000644000175000017500000000764611023212572021427 0ustar drazzibdrazzib/* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package test; import java.awt.*; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceSkin; import org.jvnet.substance.skin.*; import test.check.SampleFrame; public class MultipleSkins { public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); Rectangle screenBounds = gc.getBounds(); screenBounds.x = 0; screenBounds.y = 0; Insets screenInsets = Toolkit.getDefaultToolkit() .getScreenInsets(gc); Rectangle maxBounds = new Rectangle(screenBounds.x + screenInsets.left, screenBounds.y + screenInsets.top, screenBounds.width - ((screenInsets.left + screenInsets.right)), screenBounds.height - ((screenInsets.top + screenInsets.bottom))); SubstanceSkin[][] skinGrid = new SubstanceSkin[][] { { new AutumnSkin(), new BusinessSkin(), new BusinessBlueSteelSkin(), new BusinessBlackSteelSkin() }, { new NebulaSkin(), new CremeSkin(), new CremeCoffeeSkin(), new ModerateSkin() }, { new OfficeSilver2007Skin(), new SaharaSkin(), new MistAquaSkin(), new NebulaBrickWallSkin() }, { new RavenSkin(), new RavenGraphiteSkin(), new RavenGraphiteGlassSkin(), new MagmaSkin() } }; int x = maxBounds.x; for (int i = 0; i < 4; i++) { int y = maxBounds.y; for (int j = 0; j < 3; j++) { SampleFrame skinFrame = new SampleFrame(false); skinFrame.getRootPane().putClientProperty( SubstanceLookAndFeel.SKIN_PROPERTY, skinGrid[i][j]); SwingUtilities.updateComponentTreeUI(skinFrame); skinFrame.setBounds(x, y, maxBounds.width / 4, maxBounds.height / 3); skinFrame.setVisible(true); skinFrame .setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); y += maxBounds.height / 3; } x += maxBounds.width / 4; } } }); } } substance-5.3.orig/src/test/contrib/0000755000175000017500000000000011257637224017422 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/contrib/GradientPaintTestPanel.java0000644000175000017500000000436511144753456024647 0ustar drazzibdrazzibpackage test.contrib; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.Shape; import java.awt.geom.Ellipse2D; import javax.swing.JFrame; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.ComponentState; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.painter.gradient.SubduedGradientPainter; import org.jvnet.substance.painter.gradient.SubstanceGradientPainter; import org.jvnet.substance.skin.MagmaSkin; public class GradientPaintTestPanel extends javax.swing.JPanel { public static void main(String[] args) { SubstanceLookAndFeel.setSkin(new MagmaSkin()); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JFrame frame = new JFrame(); frame.setSize(450,250); frame.getContentPane().add(new GradientPaintTestPanel()); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setVisible(true); } }); } public GradientPaintTestPanel() { super(); } @Override protected void paintComponent(Graphics g) { Shape leftShape=new Ellipse2D.Float(10,10,200,200); Shape RightShape=new Ellipse2D.Float(220,10,200,200); Graphics2D g2 = (Graphics2D) g.create(); SubstanceGradientPainter painter = new SubduedGradientPainter(); SubstanceColorScheme activeColor = SubstanceLookAndFeel.getCurrentSkin().getColorScheme(this, ComponentState.ACTIVE); SubstanceColorScheme defaultColor = SubstanceLookAndFeel.getCurrentSkin().getColorScheme(this, ComponentState.DEFAULT); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //background painter.paintContourBackground(g2, this, getWidth(), getHeight(), getBounds(), false, defaultColor, activeColor, 0, true, true); //left shape painter.paintContourBackground(g2, this, getWidth(), getHeight(), leftShape, false, activeColor, defaultColor, 0, true, true); //right shape painter = new MyGradientPainter(); painter.paintContourBackground(g2, this, getWidth(), getHeight(), RightShape, false, activeColor, defaultColor, 0, true, true); g2.dispose(); } }substance-5.3.orig/src/test/contrib/TreeColoring.java0000644000175000017500000000330511066151410022644 0ustar drazzibdrazzibpackage test.contrib; import java.awt.Color; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.*; /** * * @author decoteaud */ public class TreeColoring extends JFrame { public TreeColoring() { this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); JTree jTree1 = new JTree(); JScrollPane jScrollPane1 = new JScrollPane(jTree1); add(jScrollPane1); pack(); setLocation(100, 100); setSize(400, 400); // DefaultTreeCellRenderer r = new DefaultTreeCellRenderer() { // // @Override // public Component getTreeCellRendererComponent(JTree tree, // Object value, boolean sel, boolean expanded, boolean leaf, // int row, boolean hasFocus) { // super.getTreeCellRendererComponent(tree, value, sel, expanded, // leaf, row, hasFocus); // // this.setOpaque(true); // return this; // } // }; // jTree1.setCellRenderer(r); // test 1 colorization issue jTree1.setBackground(Color.red); // end test 1 // test 2 set opaque on the tree and cant see view port background // jTree1.setOpaque(false); // jTree1.setBackground(Color.red); // set so render can pick up // jScrollPane1.setBackground(Color.green); // jScrollPane1.getViewport().setBackground(Color.blue); // end test 2 } public static void main(String[] args) { try { UIManager .setLookAndFeel(new org.jvnet.substance.skin.SubstanceSaharaLookAndFeel()); } catch (Exception ex) { Logger.getLogger(TreeColoring.class.getName()).log(Level.SEVERE, null, ex); } Runnable r = new Runnable() { public void run() { new TreeColoring().setVisible(true); } }; SwingUtilities.invokeLater(r); } } substance-5.3.orig/src/test/contrib/TabCloseProblem.java0000644000175000017500000000714311150407634023277 0ustar drazzibdrazzibpackage test.contrib; import java.awt.*; import java.awt.event.MouseEvent; import java.util.Random; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.TabCloseKind; import org.jvnet.substance.api.tabbed.TabCloseCallback; import org.jvnet.substance.api.tabbed.TabCloseListener; import org.jvnet.substance.skin.SubstanceModerateLookAndFeel; public class TabCloseProblem implements TabCloseListener { public TabCloseProblem() { SwingUtilities.invokeLater(new Runnable() { public void run() { try { try { UIManager .setLookAndFeel(new SubstanceModerateLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); System.exit(0); } initGUI(); } catch (Exception e) { e.printStackTrace(); } } }); return; } private void initGUI() throws ClassNotFoundException { // Set up Tab Pane JTabbedPane tabPane = new JTabbedPane(); SubstanceLookAndFeel.registerTabCloseChangeListener(tabPane, this); SubstanceLookAndFeel.registerTabCloseChangeListener(this); tabPane.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); setupTabCloseOptions(tabPane); // Populate Tab Pane Random r = new Random(); for (int i = 0; i < 5; i++) { JPanel p = new JPanel(); p.setBackground(new Color(r.nextInt(255), r.nextInt(255), r .nextInt(255))); tabPane.addTab("TAB#" + (i + 1), p); } // Display Tab Pane JPanel panel = new JPanel(new BorderLayout()); panel.add(tabPane, BorderLayout.CENTER); JFrame frame = new JFrame("TAB TEST"); frame.add(panel); frame.setSize(500, 500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } public static void main(String[] args) { new TabCloseProblem(); } private void setupTabCloseOptions(JTabbedPane tabPane) { // create a custom implementation of TabCloseCallback interface. TabCloseCallback closeCallback = new TabCloseCallback() { public TabCloseKind onAreaClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { return TabCloseKind.NONE; } public TabCloseKind onCloseButtonClick(JTabbedPane tabbedPane, int tabIndex, MouseEvent mouseEvent) { if (mouseEvent.isPopupTrigger()) { return TabCloseKind.NONE; } else { if (mouseEvent.isAltDown()) { return TabCloseKind.ALL_BUT_THIS; } else if (mouseEvent.isShiftDown()) { return TabCloseKind.ALL; } else { return TabCloseKind.THIS; } } } public String getAreaTooltip(JTabbedPane tabbedPane, int tabIndex) { return null; } public String getCloseButtonTooltip(JTabbedPane tabbedPane, int tabIndex) { StringBuffer result = new StringBuffer(); result .append("[L-click] Close this plot (Fires tabClosed() method).
"); result .append("[Shift+L-click] Close all plots (Does not fire tabClosed() method).
"); result .append("[Alt+L-click] Close all other plots (Does not fire tabClosed() method)."); return result.toString(); } }; // register the callback on the tabbed pane tabPane.putClientProperty( SubstanceLookAndFeel.TABBED_PANE_CLOSE_CALLBACK, closeCallback); } public void tabClosed(JTabbedPane arg0, Component arg1) { System.out.println("TAB CLOSED!"); } public void tabClosing(JTabbedPane arg0, Component arg1) { System.out.println("Tab closing..."); } }substance-5.3.orig/src/test/contrib/WhiteFlash.java0000644000175000017500000000301211131605616022306 0ustar drazzibdrazzibpackage test.contrib; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.RavenGraphiteGlassSkin; public class WhiteFlash extends JFrame implements ActionListener { JDialog dialog = null; JButton btn = null; public WhiteFlash() { init(); } private void init() { this.setUndecorated(true); this.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); setupDialog(); btn = new JButton("Open"); btn.addActionListener(this); JPanel holdPanel = new JPanel(new BorderLayout()); holdPanel.add(btn, BorderLayout.SOUTH); getContentPane().add(holdPanel, java.awt.BorderLayout.CENTER); this.setSize(1024, 768); this.setResizable(false); this.setVisible(true); } private void setupDialog() { dialog = new JDialog(this, false); dialog.setTitle("TEST"); dialog.setSize(150, 150); setResizable(false); } public static void main(String[] args) { SubstanceLookAndFeel.setSkin(new RavenGraphiteGlassSkin()); UIManager.put(SubstanceLookAndFeel.COLORIZATION_FACTOR, new Double(1.0)); SwingUtilities.invokeLater(new Runnable() { public void run() { WhiteFlash flash = new WhiteFlash(); flash.setVisible(true); } }); } @Override public void actionPerformed(ActionEvent e) { if (e.getSource() == btn) { dialog.setVisible(true); dialog.toFront(); } } } substance-5.3.orig/src/test/contrib/Skin.java0000644000175000017500000000313111112651142021150 0ustar drazzibdrazzibpackage test.contrib; import javax.swing.*; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; public class Skin extends javax.swing.JFrame { public Skin() { initComponents(); } private void initComponents() { jButton1 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jButton1.setText("jButton1"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout( getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING).addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap(302, Short.MAX_VALUE).addComponent(jButton1).addGap(25, 25, 25))); layout.setVerticalGroup(layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING).addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap(254, Short.MAX_VALUE).addComponent(jButton1).addGap(23, 23, 23))); pack(); } public static void main(String args[]) { try { setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); UIManager .setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); } catch (UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Skin().setVisible(true); } }); } private javax.swing.JButton jButton1; }substance-5.3.orig/src/test/contrib/ParameterColorScheme.java0000644000175000017500000000527711213150204024320 0ustar drazzibdrazzibpackage test.contrib; import java.awt.Color; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.colorscheme.*; public class ParameterColorScheme implements SubstanceColorScheme { protected Color[] colors; public ParameterColorScheme(Color[] colors) { super(); this.colors = colors; } public SubstanceColorScheme hueShift(double arg0) { return new HueShiftColorScheme(this, arg0); } public SubstanceColorScheme invert() { return new InvertedColorScheme(this); } public boolean isDark() { return true; } public SubstanceColorScheme negate() { return new NegatedColorScheme(this); } // public SubstanceColorScheme protanopia() { // return new ProtanopiaColorScheme(this); // } public SubstanceColorScheme saturate(double arg0) { return new SaturatedColorScheme(this, arg0); } public SubstanceColorScheme shade(double arg0) { return new ShadeColorScheme(this, arg0); } public SubstanceColorScheme shift(Color arg0, double arg1, Color arg2, double arg3) { return new ShiftColorScheme(this, arg0, arg1, arg2, arg3, false); } public SubstanceColorScheme shiftBackground(Color arg0, double arg1) { return new ShiftColorScheme(this, arg0, arg1); } public SubstanceColorScheme tint(double arg0) { return new TintColorScheme(this, 0); // 0.2 } public SubstanceColorScheme tone(double arg0) { return new ToneColorScheme(this, 0); // 0.35 } // public SubstanceColorScheme tritanopia() { // return new TritanopiaColorScheme(this); // } public String getDisplayName() { return "ORDefaultSkin"; } public Color getDarkColor() { return colors[5]; } public Color getExtraLightColor() { return colors[2]; } public Color getForegroundColor() { return colors[0]; } public Color getLightColor() { return colors[1]; // return colors[3]; } public Color getMidColor() { return colors[4]; } public Color getUltraDarkColor() { return colors[5]; // return colors[6]; } public Color getUltraLightColor() { return colors[2]; // return colors[1]; } public Color getBackgroundFillColor() { return colors[7]; } public Color getFocusRingColor() { return colors[7]; } public Color getTextBackgroundFillColor() { return colors[2]; } public Color getLineColor() { return colors[5]; } public Color getSelectionBackgroundColor() { return colors[8]; } public Color getSelectionForegroundColor() { return colors[0]; } public Color getWatermarkDarkColor() { return colors[5]; } public Color getWatermarkLightColor() { return colors[2]; } public Color getWatermarkStampColor() { return colors[3]; } @Override public SubstanceColorScheme named(String colorSchemeDisplayName) { return this; } } substance-5.3.orig/src/test/contrib/SmallDialogSubstance.java0000644000175000017500000000213211046751104024311 0ustar drazzibdrazzibpackage test.contrib; import java.awt.BorderLayout; import java.awt.Window; import javax.swing.*; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; public class SmallDialogSubstance { private JDialog dlgMain; public SmallDialogSubstance() { try { UIManager .setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); JDialog.setDefaultLookAndFeelDecorated(true); JFrame.setDefaultLookAndFeelDecorated(true); UIDefaults uiDef = UIManager.getDefaults(); uiDef.put("RootPaneUI", "test.contrib.RootPaneUI"); dlgMain = new JDialog((Window) null, "this title isn't shown."); dlgMain.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dlgMain.setLayout(new BorderLayout()); dlgMain.add(new JLabel("Hello world!"), BorderLayout.CENTER); dlgMain.pack(); dlgMain.setVisible(true); } catch (Exception ex) { ex.printStackTrace(); } } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { new SmallDialogSubstance(); } }); } }substance-5.3.orig/src/test/contrib/LNF.java0000644000175000017500000000237011107022210020657 0ustar drazzibdrazzibpackage test.contrib; import java.awt.*; import java.awt.event.ActionEvent; import javax.swing.*; import org.jvnet.substance.skin.SubstanceNebulaLookAndFeel; public class LNF extends JFrame { public LNF() { setSize(500, 500); setDefaultCloseOperation(EXIT_ON_CLOSE); getContentPane() .add( new JButton( new AbstractAction( "you should see the yellow rectangle near the left edge") { public void actionPerformed(ActionEvent e) { setExtendedState(NORMAL); setExtendedState(MAXIMIZED_BOTH); } }) { @Override public void paint(Graphics gg) { super.paint(gg); final Graphics2D g = (Graphics2D) gg; g.setColor(Color.YELLOW); g.fillRect(0, 0, 4, 100); g.dispose(); } }); } public static void main(String[] args) { try { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); UIManager.setLookAndFeel(new SubstanceNebulaLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } SwingUtilities.invokeLater(new Runnable() { public void run() { new LNF().setVisible(true); } }); } } substance-5.3.orig/src/test/contrib/colorcombo/0000755000175000017500000000000011256731160021551 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/contrib/colorcombo/ColorPickerComboBox.java0000644000175000017500000000325611031137262026261 0ustar drazzibdrazzibpackage test.contrib.colorcombo; import java.awt.Color; import java.util.Enumeration; import java.util.Hashtable; import javax.swing.JComboBox; public class ColorPickerComboBox extends JComboBox { public static Hashtable AWT_COLOR_TO_STRING; public static Hashtable STRING_TO_AWT_COLORS; public static Color DEFAULT_COLOR; { AWT_COLOR_TO_STRING = new Hashtable(); STRING_TO_AWT_COLORS = new Hashtable(); AWT_COLOR_TO_STRING.put(Color.RED, "Red"); AWT_COLOR_TO_STRING.put(Color.CYAN, "Cyan"); AWT_COLOR_TO_STRING.put(Color.YELLOW, "Yellow"); AWT_COLOR_TO_STRING.put(Color.BLUE, "Blue"); AWT_COLOR_TO_STRING.put(Color.GRAY, "Gray"); AWT_COLOR_TO_STRING.put(Color.GREEN, "Green"); AWT_COLOR_TO_STRING.put(Color.ORANGE, "Orange"); AWT_COLOR_TO_STRING.put(Color.PINK, "Pink"); AWT_COLOR_TO_STRING.put(DEFAULT_COLOR = Color.DARK_GRAY, "Black"); AWT_COLOR_TO_STRING.put(Color.WHITE, "White"); Enumeration keys = AWT_COLOR_TO_STRING.keys(); while (keys.hasMoreElements()) { Color currentColor = (Color) keys.nextElement(); STRING_TO_AWT_COLORS.put(AWT_COLOR_TO_STRING.get(currentColor), currentColor); } } public ColorPickerComboBox() { for (Color color : AWT_COLOR_TO_STRING.keySet()) super.addItem(AWT_COLOR_TO_STRING.get(color)); setRenderer(new ColorPickerComboBoxRenderer()); } public void setSelectedColor(Color color) { String colorString = AWT_COLOR_TO_STRING.get(color); if (colorString == null) colorString = AWT_COLOR_TO_STRING.get(DEFAULT_COLOR); setSelectedItem(colorString); } public Color getSelectedColor() { return STRING_TO_AWT_COLORS.get(getSelectedItem()); } } substance-5.3.orig/src/test/contrib/colorcombo/ColorPickerComboBoxRenderer.java0000644000175000017500000000215511031137472027750 0ustar drazzibdrazzibpackage test.contrib.colorcombo; import java.awt.Component; import java.util.Hashtable; import javax.swing.*; public class ColorPickerComboBoxRenderer extends JLabel implements ListCellRenderer { private Hashtable _colorStringToColorIcon; public ColorPickerComboBoxRenderer() { setOpaque(false); _colorStringToColorIcon = new Hashtable(); fillColorTable(); } private void fillColorTable() { for (String colorString : ColorPickerComboBox.STRING_TO_AWT_COLORS .keySet()) _colorStringToColorIcon.put(colorString, new ColorIcon( ColorPickerComboBox.STRING_TO_AWT_COLORS.get(colorString))); } /* * This method finds the image and text corresponding to the selected value * and returns the label, set up to display the text and image. */ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { ColorIcon icon = _colorStringToColorIcon.get(value); icon.setHeight(10); icon.setWidth(10); setIcon(icon); setText((String) value); setFont(list.getFont()); return this; } } substance-5.3.orig/src/test/contrib/colorcombo/ColorIcon.java0000644000175000017500000000153111031137254024276 0ustar drazzibdrazzibpackage test.contrib.colorcombo; import java.awt.*; import javax.swing.Icon; import javax.swing.JComponent; public class ColorIcon extends JComponent implements Icon { private int _width; private int _height; private Color _color; public ColorIcon(Color color) { _color = color; } public Color getColor() { return _color; } public void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D g2d = (Graphics2D) g.create(); g2d.setColor(_color); g2d.fillRect(x + 1, y + 1, _width - 2, _height - 2); g2d.setColor(Color.black); g2d.drawRect(x + 1, y + 1, _width - 2, _height - 2); g2d.dispose(); } public int getIconWidth() { return _width; } public int getIconHeight() { return _height; } public void setHeight(int height) { _height = height; } public void setWidth(int width) { _width = width; } } substance-5.3.orig/src/test/contrib/colorcombo/ComboBoxRollOverApp.java0000644000175000017500000000137511031137274026255 0ustar drazzibdrazzibpackage test.contrib.colorcombo; import javax.swing.*; import org.jvnet.substance.skin.SubstanceCremeLookAndFeel; public class ComboBoxRollOverApp { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame.setDefaultLookAndFeelDecorated(true); try { UIManager.setLookAndFeel(new SubstanceCremeLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { System.out.println("ERROR: Substance failed to load"); } JFrame frame = new JFrame(); JPanel panel = new JPanel(); ColorPickerComboBox colorPickerComboBox = new ColorPickerComboBox(); panel.add(colorPickerComboBox); frame.add(panel); frame.pack(); frame.setVisible(true); } }); } } substance-5.3.orig/src/test/contrib/BackgroundColorTest.java0000644000175000017500000001250011040022232024152 0ustar drazzibdrazzib/** * */ package test.contrib; import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.*; import org.jvnet.substance.painter.border.GlassBorderPainter; import org.jvnet.substance.painter.decoration.ArcDecorationPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.gradient.SimplisticGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; /** * @author waligora * */ public class BackgroundColorTest extends JFrame { public static void main(String[] args) { try { initLaF(); } catch (Exception e) { System.out.println(e); } SwingUtilities.invokeLater(new Runnable() { public void run() { new BackgroundColorTest("Test"); } }); } protected static class CustomSkin extends SubstanceSkin { public CustomSkin() { super(); // DefaultColorScheme Color[] colors = { Color.white, new Color(150, 150, 150), new Color(170, 170, 170), new Color(130, 130, 130), new Color(100, 100, 100), new Color(76, 76, 76), new Color(101, 101, 101), new Color(108, 108, 108), new Color(170, 170, 232) }; ParameterColorScheme defaultScheme = new ParameterColorScheme( colors); // active ColorScheme Color[] activeColors = { Color.white, new Color(170, 170, 232), new Color(165, 165, 212), new Color(117, 120, 232), new Color(100, 100, 100), new Color(76, 76, 76), new Color(101, 101, 101), new Color(108, 108, 108), new Color(170, 170, 232) }; ParameterColorScheme activeScheme = new ParameterColorScheme( activeColors); // disabled ColorScheme: Color[] disabledColors = { new Color(167, 167, 167), new Color(150, 150, 150), new Color(170, 170, 170), new Color(130, 130, 130), new Color(100, 100, 100), new Color(76, 76, 76), new Color(101, 101, 101), new Color(108, 108, 108), new Color(170, 170, 232) }; ParameterColorScheme disabledScheme = new ParameterColorScheme( disabledColors); SubstanceColorSchemeBundle bundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); // bundle.registerColorScheme(disabledScheme, // ComponentState.DISABLED_UNSELECTED); // // bundle.registerColorScheme(defaultScheme, // ComponentState.DEFAULT); // bundle.registerColorScheme(activeScheme, ComponentState.ACTIVE); // bundle.registerColorScheme(disabledScheme, // ComponentState.DISABLED_SELECTED); // bundle.registerColorScheme(activeScheme, // ComponentState.SELECTED); // // bundle.registerColorScheme(activeScheme, // ComponentState.ROLLOVER_SELECTED); // bundle.registerColorScheme(activeScheme, // ComponentState.ROLLOVER_UNSELECTED); // // bundle.registerHighlightColorScheme(activeScheme, // ComponentState.SELECTED); // bundle.registerHighlightColorScheme(activeScheme, // ComponentState.ROLLOVER_SELECTED); // bundle.registerHighlightColorScheme(activeScheme, // ComponentState.ROLLOVER_UNSELECTED); this.registerDecorationAreaSchemeBundle(bundle, DecorationAreaType.NONE); this.registerAsDecorationArea(activeScheme, DecorationAreaType.PRIMARY_TITLE_PANE, DecorationAreaType.SECONDARY_TITLE_PANE, DecorationAreaType.HEADER, DecorationAreaType.FOOTER, DecorationAreaType.GENERAL, DecorationAreaType.TOOLBAR); setSelectedTabFadeStart(0.3); setSelectedTabFadeEnd(0.6); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new SimplisticGradientPainter(); this.decorationPainter = new ArcDecorationPainter(); this.highlightPainter = new ClassicHighlightPainter(); this.borderPainter = new GlassBorderPainter(); } public String getDisplayName() { return "Custom"; } } protected static class MyCustomLookAndFeel extends SubstanceLookAndFeel { public MyCustomLookAndFeel() { super(new CustomSkin()); } } public static void initLaF() throws Exception { UIManager.setLookAndFeel(new MyCustomLookAndFeel()); UIManager.put(SubstanceLookAndFeel.FOCUS_KIND, SubstanceConstants.FocusKind.NONE); UIManager.put(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE); } public BackgroundColorTest(String title) { super(title); initGUI(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.exit(0); } }); pack(); setLocationRelativeTo(null); setVisible(true); } private void initGUI() { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(new JButton("Test"), BorderLayout.NORTH); JPanel p = new JPanel() { @Override protected void paintComponent(Graphics g) { super.paintComponent(g); } }; JLabel label = new JLabel("Label"); // set label new background --> doesn't work label.setBackground(Color.green); p.add(label); // set panel p new background --> doesn't work p.setBackground(Color.BLUE); p.setPreferredSize(new Dimension(200, 200)); p.setBorder(BorderFactory.createLineBorder(Color.red)); panel.add(p, BorderLayout.SOUTH); panel.setPreferredSize(new Dimension(600, 600)); getContentPane().add(panel); } } substance-5.3.orig/src/test/contrib/InternalFrameDemo.java0000644000175000017500000000233711235654714023625 0ustar drazzibdrazzibpackage test.contrib; import javax.swing.*; public class InternalFrameDemo extends JFrame { private static final long serialVersionUID = 1L; private JDesktopPane pane; public InternalFrameDemo() { pane = new JDesktopPane(); pane.add(createFrame("Test", 200, 150)); pane.add(createFrame("Test 2", 300, 200)); setContentPane(pane); } private JInternalFrame createFrame(String title, int width, int height) { JInternalFrame f = new JInternalFrame(title, true, true, true, true); f.add(new JButton("Test")); f.setLocation(0, 0); f.setSize(width, height); f.setVisible(true); f.addComponentListener(new SnapListener(pane)); return f; } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { // try { // UIManager // .setLookAndFeel(new SubstanceBusinessLookAndFeel()); // } catch (UnsupportedLookAndFeelException e) { // e.printStackTrace(); // } InternalFrameDemo demo = new InternalFrameDemo(); demo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); demo.setSize(800, 600); demo.setVisible(true); } }); } } substance-5.3.orig/src/test/contrib/ListPanelRenderer.java0000644000175000017500000000225311071611134023633 0ustar drazzibdrazzibpackage test.contrib; import java.awt.Color; import java.awt.Component; import javax.swing.*; import org.jvnet.substance.skin.SubstanceBusinessLookAndFeel; public class ListPanelRenderer extends JFrame { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { UIManager .setLookAndFeel(new SubstanceBusinessLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } JList oList = new JList(new Object[] { "hi1", "hi2" }); oList.setCellRenderer(new JPanelRenderer()); JFrame oFrame = new ListPanelRenderer(); oFrame.getContentPane().add(oList); oFrame.pack(); oFrame.setVisible(true); oFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }); } } class JPanelRenderer extends JPanel implements ListCellRenderer { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { setOpaque(true); removeAll(); add(new JLabel(value.toString())); setBackground(Color.RED); return this; } } substance-5.3.orig/src/test/contrib/JTableIssue.java0000644000175000017500000000303711057307160022431 0ustar drazzibdrazzibpackage test.contrib; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; @SuppressWarnings("serial") public class JTableIssue extends JFrame { private final Object[][] testData = new Object[0][2]; private final String[] columns = { "Column 1", "Column 2" }; private JButton btnChange = new JButton("Change"); private JTable tblData = new JTable(testData, columns) { @Override @SuppressWarnings("unchecked") public Class getColumnClass(int c) { return getValueAt(0, c).getClass(); } }; private JScrollPane scrpnData = new JScrollPane(tblData); private JTableIssue() { setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new FlowLayout(FlowLayout.CENTER)); btnChange.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println(tblData.getColumnClass(0)); } }); add(scrpnData); add(btnChange); pack(); } private void refreshTable() { Object[][] testData2 = { { "1", Boolean.TRUE }, { "2", Boolean.FALSE } }; JTable tblData2 = new JTable(testData2, columns) { @Override @SuppressWarnings("unchecked") public Class getColumnClass(int c) { return getValueAt(0, c).getClass(); } }; tblData.setModel(tblData2.getModel()); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new JTableIssue().setVisible(true); } }); } }substance-5.3.orig/src/test/contrib/JProgressBar_Substance.java0000644000175000017500000000753611237644026024646 0ustar drazzibdrazzibpackage test.contrib; import java.io.IOException; import java.text.ParseException; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JFrame; import javax.swing.JProgressBar; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.MetallicColorScheme; import org.jvnet.substance.colorscheme.SunsetColorScheme; import org.jvnet.substance.painter.border.ClassicBorderPainter; import org.jvnet.substance.painter.decoration.ClassicDecorationPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.gradient.ClassicGradientPainter; import org.jvnet.substance.painter.highlight.ClassicHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; public class JProgressBar_Substance { private static JProgressBar progressBar; protected static class CustomSkin extends SubstanceSkin { public CustomSkin() { SubstanceColorScheme activeScheme = new MetallicColorScheme().tint( 0.15).named("Custom Active"); SubstanceColorScheme defaultScheme = new MetallicColorScheme() .shade(0.1).named("Custom Default"); SubstanceColorScheme disabledScheme = defaultScheme; SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); defaultSchemeBundle.registerColorScheme(disabledScheme, 0.4f, ComponentState.DISABLED_UNSELECTED); defaultSchemeBundle.registerColorScheme(activeScheme, 0.4f, ComponentState.DISABLED_SELECTED); defaultSchemeBundle.registerColorScheme(new SunsetColorScheme(), ComponentState.SELECTED); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.buttonShaper = new ClassicButtonShaper(); this.gradientPainter = new ClassicGradientPainter(); this.borderPainter = new ClassicBorderPainter(); this.decorationPainter = new ClassicDecorationPainter(); this.highlightPainter = new ClassicHighlightPainter(); } @Override public String getDisplayName() { return "Custom"; } } private static void initLookAndFeel() throws IOException { if (!SubstanceLookAndFeel.setSkin(new CustomSkin())) { System.err.println("Failed to set skin"); } } /** * Create the GUI and show it. */ private static void createAndShowGUI() throws ParseException, IOException { // Set the look and feel. initLookAndFeel(); // make sure we have nice window decorations for the heck of it JFrame.setDefaultLookAndFeelDecorated(true); // Create and set up the window. JFrame frame = new JFrame("JProgressBar_Substance"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Set up progress bar, initial foreground color red JProgressBar progressBar = new JProgressBar(0, 100); // progressBar.putClientProperty(SubstanceLookAndFeel.COLORIZATION_FACTOR, // 1.0); // progressBar.setForeground(Color.RED); // progressBar.setBackground(Color.BLUE); progressBar.setValue(50); progressBar.setStringPainted(true); // Put progress bar on the frame frame.add(progressBar); // Display the window. frame.pack(); frame.setVisible(true); } public static void main(String[] args) { // Schedule a job for the event-dispatching thread: // creating and showing this application's GUI. javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { try { try { createAndShowGUI(); } catch (IOException ex) { Logger .getLogger( JProgressBar_Substance.class.getName()) .log(Level.SEVERE, null, ex); } } catch (ParseException ex) { Logger.getLogger(JProgressBar_Substance.class.getName()) .log(Level.SEVERE, null, ex); } } }); } } substance-5.3.orig/src/test/contrib/setskin/0000755000175000017500000000000011257637754021112 5ustar drazzibdrazzibsubstance-5.3.orig/src/test/contrib/setskin/Loader.java0000644000175000017500000000031011257637266023153 0ustar drazzibdrazzibpackage test.contrib.setskin; public class Loader { /** * @param args */ public static void main(String[] args) { MainClass obj = new MainClass(); obj.setVisible(true); } } substance-5.3.orig/src/test/contrib/setskin/MainClass.java0000644000175000017500000001741211257640670023623 0ustar drazzibdrazzib/* * Created by JFormDesigner on Mon Sep 21 23:17:18 GMT+02:00 2009 */ package test.contrib.setskin; import java.awt.Container; import java.awt.Window; import java.awt.event.*; import javax.swing.*; import javax.swing.border.BevelBorder; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.MistSilverSkin; import org.jvnet.substance.skin.SubstanceMistSilverLookAndFeel; import com.jgoodies.forms.factories.FormFactory; import com.jgoodies.forms.layout.*; /** * @author Hesham G. */ /** * @author Hesham G. */ public class MainClass extends JFrame { private int origionalPanelHeight = 0; public MainClass() { initComponents(); origionalPanelHeight = panel1.getHeight(); } private void button1MouseReleased() { new TimerThread(panel1, origionalPanelHeight); } private void thisWindowClosing() { System.exit(0); } private void button2MouseReleased() { SubstanceLookAndFeel.setSkin(new MistSilverSkin()); } private void button3MouseReleased() { try { UIManager.setLookAndFeel(new SubstanceMistSilverLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } for (Window w : Window.getWindows()) { SwingUtilities.updateComponentTreeUI(w); } } private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY // //GEN-BEGIN:initComponents // Generated using JFormDesigner non-commercial license button1 = new JButton(); panel1 = new JPanel(); label1 = new JLabel(); label2 = new JLabel(); button2 = new JButton(); button3 = new JButton(); CellConstraints cc = new CellConstraints(); // ======== this ======== addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { thisWindowClosing(); } }); Container contentPane = getContentPane(); contentPane.setLayout(new FormLayout(new ColumnSpec[] { new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)) }, new RowSpec[] { new RowSpec(RowSpec.FILL, Sizes.DLUY7, FormSpec.NO_GROW), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.FILL, Sizes.dluY(13), FormSpec.NO_GROW), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.FILL, Sizes.DLUY7, FormSpec.NO_GROW), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.FILL, Sizes.dluY(13), FormSpec.NO_GROW), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.FILL, Sizes.dluY(13), FormSpec.NO_GROW), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.FILL, Sizes.dluY(13), FormSpec.NO_GROW), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.FILL, Sizes.dluY(13), FormSpec.NO_GROW) })); // ---- button1 ---- button1.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { button1MouseReleased(); } }); contentPane.add(button1, cc.xywh(5, 3, 7, 1)); // ======== panel1 ======== { panel1.setBorder(new BevelBorder(BevelBorder.LOWERED)); panel1.setLayout(new FormLayout(new ColumnSpec[] { new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)), FormFactory.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(13)) }, new RowSpec[] { new RowSpec(RowSpec.FILL, Sizes.dluY(13), FormSpec.NO_GROW), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.FILL, Sizes.dluY(13), FormSpec.NO_GROW), FormFactory.LINE_GAP_ROWSPEC, new RowSpec(RowSpec.FILL, Sizes.dluY(13), FormSpec.NO_GROW) })); panel1.add(label1, cc.xywh(1, 1, 11, 1)); panel1.add(label2, cc.xywh(1, 3, 11, 1)); } contentPane.add(panel1, cc.xywh(3, 7, 13, 5)); // ---- button2 ---- button2.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { button2MouseReleased(); } }); contentPane.add(button2, cc.xywh(17, 9, 9, 1)); // ---- button3 ---- button3.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { button3MouseReleased(); } }); contentPane.add(button3, cc.xywh(17, 11, 9, 1)); pack(); setLocationRelativeTo(getOwner()); initComponentsI18n(); // JFormDesigner - End of component initialization // //GEN-END:initComponents } private void initComponentsI18n() { // JFormDesigner - Component i18n initialization - DO NOT MODIFY // //GEN-BEGIN:initI18n // Generated using JFormDesigner non-commercial license button1.setText("Show / Hide"); label1.setText("Click on the button above"); label2.setText("to show / hide this box"); button2.setText("setSkin theme"); button3.setText("UIManager theme"); // JFormDesigner - End of component i18n initialization // //GEN-END:initI18n } // JFormDesigner - Variables declaration - DO NOT MODIFY // //GEN-BEGIN:variables // Generated using JFormDesigner non-commercial license private JButton button1; private JPanel panel1; private JLabel label1; private JLabel label2; private JButton button2; private JButton button3; // JFormDesigner - End of variables declaration //GEN-END:variables } class TimerThread extends Thread { private JPanel panelToCollapse; private int origionalPanelHeight; public TimerThread(JPanel panelToCollapse, int origionalPanelHeight) { this.panelToCollapse = panelToCollapse; this.origionalPanelHeight = origionalPanelHeight; start(); } @Override public void run() { if (panelToCollapse.getHeight() <= 0) { while (panelToCollapse.getHeight() < origionalPanelHeight) { synchronized (panelToCollapse) { panelToCollapse.setSize(panelToCollapse.getWidth(), panelToCollapse.getHeight() + 1); panelToCollapse.repaint(); panelToCollapse.getParent().repaint(); try { Thread.sleep(1); // Run this thread every (5) sec. to // reduce memory reserved. } catch (InterruptedException e) { e.printStackTrace(); } } } } else { while (panelToCollapse.getHeight() > 0) { synchronized (panelToCollapse) { panelToCollapse.setSize(panelToCollapse.getWidth(), panelToCollapse.getHeight() - 1); panelToCollapse.repaint(); panelToCollapse.getParent().repaint(); try { Thread.sleep(1); // Run this thread every (5) sec. to // reduce memory reserved. } catch (InterruptedException e) { e.printStackTrace(); } } } } } } substance-5.3.orig/src/test/contrib/TabInsetProblem.java0000644000175000017500000000321211253727200023303 0ustar drazzibdrazzibpackage test.contrib; import java.awt.*; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.LafWidgetRepository; import org.jvnet.lafwidget.tabbed.DefaultTabPreviewPainter; import org.jvnet.substance.SubstanceLookAndFeel; public class TabInsetProblem { public static void main(String... args) { EventQueue.invokeLater(new Runnable() { @Override public void run() { createAndShowGUI(); } }); } protected static void createAndShowGUI() { UIManager.put(SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS, Boolean.TRUE); UIManager.put(LafWidget.TABBED_PANE_PREVIEW_PAINTER, new DefaultTabPreviewPainter()); try { UIManager .setLookAndFeel("org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel"); JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); System.out.println("Using substance"); } catch (Exception ex) { ex.printStackTrace(); } // option 1: with this it works fine // UIManager.put("TabbedPane.tabAreaInsets", new Insets(30, 0, 0, 0)); JFrame frame = new JFrame("test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(createtabs()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } private static JTabbedPane createtabs() { JTabbedPane tabs = new JTabbedPane(); tabs.add("tab 1", new JPanel()); tabs.setPreferredSize(new Dimension(300, 100)); // option 2 it need the propagateChange() LafWidgetRepository.getRepository().getLafSupport().setTabAreaInsets( tabs, new Insets(12, 20, 0, 2)); return tabs; } }substance-5.3.orig/src/test/contrib/CustomSkin.java0000644000175000017500000000510211172044572022354 0ustar drazzibdrazzibpackage test.contrib; import javax.swing.*; import org.jvnet.substance.api.*; import org.jvnet.substance.colorscheme.*; import org.jvnet.substance.painter.border.ClassicBorderPainter; import org.jvnet.substance.painter.decoration.DecorationAreaType; import org.jvnet.substance.painter.gradient.GlassGradientPainter; import org.jvnet.substance.painter.highlight.GlassHighlightPainter; import org.jvnet.substance.shaper.ClassicButtonShaper; import org.jvnet.substance.skin.ModerateSkin; import org.jvnet.substance.skin.SubstanceModerateLookAndFeel; import test.check.SampleFrame; public class CustomSkin extends ModerateSkin { private String Skin_NAME = "Custom Skin"; public static void main(String[] args) throws UnsupportedLookAndFeelException { UIManager.setLookAndFeel(new SubstanceModerateLookAndFeel()); SubstanceModerateLookAndFeel.setSkin(new CustomSkin()); JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame sf = new SampleFrame(false); sf.setSize(315, 245); sf.setLocationRelativeTo(null); sf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); sf.setVisible(true); } }); } public CustomSkin() { try { SubstanceColorScheme activeScheme = new SteelBlueColorScheme(); SubstanceColorScheme defaultScheme = new MetallicColorScheme(); SubstanceColorScheme disabledScheme = new LightGrayColorScheme(); SubstanceColorSchemeBundle defaultSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, defaultScheme, disabledScheme); // Here I am trying to set the // default color of Button to Brown but It is picking the color // which is stored in defaultScheme. defaultSchemeBundle.registerColorScheme(new BrownColorScheme(), ComponentState.DEFAULT); this.registerDecorationAreaSchemeBundle(defaultSchemeBundle, DecorationAreaType.NONE); this.borderPainter = new ClassicBorderPainter(); this.gradientPainter = new GlassGradientPainter(); this.buttonShaper = new ClassicButtonShaper(); this.highlightPainter = new GlassHighlightPainter(); SubstanceColorSchemeBundle headerSchemeBundle = new SubstanceColorSchemeBundle( activeScheme, new BottleGreenColorScheme().tint(0.60), disabledScheme); this.registerDecorationAreaSchemeBundle(headerSchemeBundle, DecorationAreaType.HEADER); } catch (Exception e) { e.printStackTrace(); } } @Override public String getDisplayName() { return Skin_NAME; } } substance-5.3.orig/src/test/contrib/TestSubstance.java0000644000175000017500000001226211146532120023041 0ustar drazzibdrazzibpackage test.contrib; /* * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of Substance Kirill Grouchnikov nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessBlackSteelSkin; import org.jvnet.substance.watermark.SubstanceCrosshatchWatermark; /** * Test application that shows the use of the * {@link SubstanceLookAndFeel#WATERMARK_VISIBLE} client property. * * @author Kirill Grouchnikov * @see SubstanceLookAndFeel#WATERMARK_VISIBLE */ public class TestSubstance extends JFrame { /** * Creates the main frame for this sample. */ public TestSubstance() { super("Watermark visibility"); this.setLayout(new GridLayout(1, 2)); JPanel listPanel = new JPanel(new BorderLayout()); JPanel coloredPanel = new JPanel(new BorderLayout()); this.add(listPanel); this.add(coloredPanel); // create list with a few values final JList jlist = new JList(new Object[] { "value1", "value2", "value3", "value4" }); listPanel.add(jlist, BorderLayout.CENTER); JPanel listControls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox isListWatermarkVisible = new JCheckBox( "watermark visible"); isListWatermarkVisible.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { // based on checkbox selection, mark the list to // show the watermark jlist.putClientProperty( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean .valueOf(isListWatermarkVisible .isSelected())); repaint(); } }); } }); listControls.add(isListWatermarkVisible); listPanel.add(listControls, BorderLayout.SOUTH); final JPanel colorPanel = new JPanel(); colorPanel.setBackground(new Color(0, 0, 64)); coloredPanel.add(colorPanel, BorderLayout.CENTER); JPanel panelControls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox isPanelWatermarkVisible = new JCheckBox( "watermark visible"); isPanelWatermarkVisible.setSelected(true); isPanelWatermarkVisible.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { // based on checkbox selection, mark the panel to // show the watermark colorPanel.putClientProperty( SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean .valueOf(isPanelWatermarkVisible .isSelected())); repaint(); } }); } }); panelControls.add(isPanelWatermarkVisible); coloredPanel.add(panelControls, BorderLayout.SOUTH); this.setSize(400, 200); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } /** * The main method for this sample. The arguments are * ignored. * * @param args * Ignored. * @throws Exception * If some exception occured. Note that there is no special * treatment of exception conditions in this * sample code. */ public static void main(String[] args) throws Exception { SubstanceLookAndFeel.setSkin(new BusinessBlackSteelSkin() .withWatermark(new SubstanceCrosshatchWatermark())); JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { new TestSubstance().setVisible(true); } }); } } substance-5.3.orig/src/test/contrib/BigFontTextArea.java0000644000175000017500000000334011134003202023224 0ustar drazzibdrazzibpackage test.contrib; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import org.jvnet.substance.skin.SubstanceRavenGraphiteLookAndFeel; public class BigFontTextArea extends JPanel { public BigFontTextArea() { setLayout(new BorderLayout()); String string = ""; for (int i = 0; i < 20; i++) { string += "line " + i; if (i < 19) { string += "\n"; } } JTextArea textArea = new JTextArea(string); textArea.setFont(textArea.getFont().deriveFont(60f)); JScrollPane scrollPane = new JScrollPane(textArea); add(scrollPane, BorderLayout.CENTER); setPreferredSize(new Dimension(400, 340)); } public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { UIManager.setLookAndFeel(new SubstanceRavenGraphiteLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } JFrame frame = new JFrame(); BigFontTextArea contentPane = new BigFontTextArea(); frame.setContentPane(contentPane); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } } substance-5.3.orig/src/test/contrib/RootPaneUI.java0000644000175000017500000000075311046747656022266 0ustar drazzibdrazzibpackage test.contrib; import javax.swing.*; import javax.swing.plaf.ComponentUI; import org.jvnet.substance.SubstanceRootPaneUI; public class RootPaneUI extends SubstanceRootPaneUI { public static ComponentUI createUI(JComponent c) { return new RootPaneUI(); } /** * custom titlepane */ @Override public JComponent createTitlePane(JRootPane root) { return new JLabel( "This is a very-very-very-very-very-very-very wide title pane component."); } }substance-5.3.orig/src/test/contrib/PerformanceSubstanceLnF.java0000644000175000017500000000464511223727614025003 0ustar drazzibdrazzibpackage test.contrib; import java.awt.BorderLayout; import java.text.SimpleDateFormat; import javax.swing.*; import org.jvnet.substance.skin.SubstanceAutumnLookAndFeel; /** * @author quangvu.cao * */ public class PerformanceSubstanceLnF extends JFrame { private String rows[][]; /** * @param args */ public void initialize(int r, int c) { SimpleDateFormat sdf = new SimpleDateFormat("mm:ss.SSS"); // System.out.println(sdf.format(new Date()) + " - begin"); rows = new String[r][c]; for (int row = 0; row < r; row++) { for (int col = 0; col < c; col++) { rows[row][col] = "Row: " + row + " - col:" + col; } } // System.out.println(sdf.format(new Date()) + " - row creation"); String[] colHeaders = new String[c]; for (int col = 0; col < c; col++) { colHeaders[col] = "Header " + col; } // System.out.println(sdf.format(new Date()) + " - header creation"); JTable table = new JTable(rows, colHeaders); // System.out.println(sdf.format(new Date()) + " - table creation"); JScrollPane pane = new JScrollPane(table); // System.out.println(sdf.format(new Date()) + // " - scroll pane creation"); this.getContentPane().add(pane, BorderLayout.CENTER); // System.out.println(sdf.format(new Date()) + " - add"); this.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); // System.out.println(sdf.format(new Date()) + " - decoration style"); this.setExtendedState(JFrame.MAXIMIZED_BOTH); // System.out.println(sdf.format(new Date()) + " - extended ste"); this.setVisible(true); // System.out.println(sdf.format(new Date()) + " - visible"); this.pack(); // System.out.println(sdf.format(new Date()) + " - pack"); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { PerformanceSubstanceLnF app = new PerformanceSubstanceLnF(); System.out.println("START"); try { UIManager.setLookAndFeel(new SubstanceAutumnLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { // TODO Auto-generated catch block e.printStackTrace(); } long startTime = System.currentTimeMillis(); app.initialize(1000, 60); app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); long endTime = System.currentTimeMillis(); System.out.println("END"); System.out.println("Time: " + (endTime - startTime) + "ms"); } }); } } substance-5.3.orig/src/test/contrib/TableRenderDemo.java0000644000175000017500000002012211160516762023252 0ustar drazzibdrazzibpackage test.contrib; import java.awt.*; import java.util.Date; import javax.swing.*; import javax.swing.table.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.renderers.SubstanceDefaultTableCellRenderer; public class TableRenderDemo extends JPanel { private boolean DEBUG = false; public static void main(String[] args) { // Schedule a job for the event-dispatching thread: // creating and showing this application's GUI. javax.swing.SwingUtilities.invokeLater(new Runnable() { // KIRILL: Setting LAF public void run() { String LAFName = "org.jvnet.substance.skin.SubstanceCremeCoffeeLookAndFeel"; try { UIManager.setLookAndFeel(LAFName); } catch (Exception e) { e.printStackTrace(); } //SubstanceLookAndFeel.setSkin(new CookbookSkin()); createAndShowGUI(); } }); } // KIRILL Test Renderer setting foreground to blue public class TestRenderer extends SubstanceDefaultTableCellRenderer { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { // TODO Auto-generated method stub Component a = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); a.setForeground(Color.blue); return a; } }; public TableRenderDemo() { super(new GridLayout(1, 0)); JTable table = new JTable(new MyTableModel()); // KIRILL: font setting, even before than default renderers setting table.setFont(new Font("Arial Black", Font.BOLD, 16)); table.setPreferredScrollableViewportSize(new Dimension(500, 70)); table.setFillsViewportHeight(true); // Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(table); // Set up column sizes. initColumnSizes(table); // Fiddle with the Sport column's cell editors/renderers. setrenderers(table, table.getColumnModel().getColumn(2)); // Add the scroll pane to this panel. add(scrollPane); } /* * * This method picks good column sizes. If all column heads are wider than * * the column's cells' contents, then you can just use * * column.sizeWidthToFit(). */ private void initColumnSizes(JTable table) { MyTableModel model = (MyTableModel) table.getModel(); TableColumn column = null; Component comp = null; int headerWidth = 0; int cellWidth = 0; Object[] longValues = model.longValues; TableCellRenderer headerRenderer = table.getTableHeader() .getDefaultRenderer(); for (int i = 0; i < 5; i++) { column = table.getColumnModel().getColumn(i); comp = headerRenderer.getTableCellRendererComponent(null, column .getHeaderValue(), false, false, 0, 0); headerWidth = comp.getPreferredSize().width; comp = table.getDefaultRenderer(model.getColumnClass(i)) .getTableCellRendererComponent( table, longValues[i], false, false, 0, i); cellWidth = comp.getPreferredSize().width; if (DEBUG) { System.out.println("Initializing width of column " + i + ". " + "headerWidth = " + headerWidth + "; cellWidth = " + cellWidth); } column.setPreferredWidth(Math.max(headerWidth, cellWidth)); } } public void setrenderers(JTable table, TableColumn sportColumn) { // Set up the editor for the sport cells. JComboBox comboBox = new JComboBox(); comboBox.addItem("Snowboarding"); comboBox.addItem("Rowing"); comboBox.addItem("Knitting"); comboBox.addItem("Speed reading"); comboBox.addItem("Pool"); comboBox.addItem("None of the above"); sportColumn.setCellEditor(new DefaultCellEditor(comboBox)); // Set up tool tips for the sport cells. DefaultTableCellRenderer renderer = new SubstanceDefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { // TODO Auto-generated method stub Component a = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); a.setForeground(Color.blue); a.setBackground(Color.yellow); return a; } }; renderer.setToolTipText("Click for combo box"); sportColumn.setCellRenderer(renderer); renderer = new TestRenderer(); table.setDefaultRenderer(Date.class, renderer); // renderer.setToolTipText("Click for combo box"); // table.getColumnModel().getColumn(table.getColumnCount() - // 1).setCellRenderer(renderer); } class MyTableModel extends AbstractTableModel { private String[] columnNames = { "First Name", "Last Name", "Sport", "# of Years", "Vegetarian", "DATE" }; private Object[][] data = { { "Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false), new Date() }, { "Alison", "Huml", "Rowing", new Integer(3), new Boolean(true), new Date() }, { "Kathy", "Walrath", "Knitting", new Integer(2), new Boolean(false), new Date() }, { "Sharon", "Zakhour", "Speed reading", new Integer(20), new Boolean(true), new Date() }, { "Philip", "Milne", "Pool", new Integer(10), new Boolean(false), new Date() } }; public final Object[] longValues = { "Sharon", "Campione", "None of the above", new Integer(20), Boolean.TRUE, new Date() }; public int getColumnCount() { return columnNames.length; } public int getRowCount() { return data.length; } public String getColumnName(int col) { return columnNames[col]; } public Object getValueAt(int row, int col) { return data[row][col]; } /* * * JTable uses this method to determine the default renderer/ editor for * * each cell. If we didn't implement this method, then the last column * * would contain text ("true"/"false"), rather than a check box. */ public Class getColumnClass(int c) { return getValueAt(0, c).getClass(); } /* * * Don't need to implement this method unless your table's editable. */ public boolean isCellEditable(int row, int col) { // Note that the data/cell address is constant, // no matter where the cell appears onscreen. if (col < 2) { return false; } else { return true; } } /* * * Don't need to implement this method unless your table's data can * * change. */ public void setValueAt(Object value, int row, int col) { if (DEBUG) { System.out.println("Setting value at " + row + "," + col + " to " + value + " (an instance of " + value.getClass() + ")"); } data[row][col] = value; fireTableCellUpdated(row, col); if (DEBUG) { System.out.println("New value of data:"); printDebugData(); } } private void printDebugData() { int numRows = getRowCount(); int numCols = getColumnCount(); for (int i = 0; i < numRows; i++) { System.out.print(" row " + i + ":"); for (int j = 0; j < numCols; j++) { System.out.print(" " + data[i][j]); } System.out.println(); } System.out.println("--------------------------"); } } /** * * Create the GUI and show it. For thread safety, this method should be * * invoked from the event-dispatching thread. */ private static void createAndShowGUI() { // Create and set up the window. JFrame frame = new JFrame("TableRenderDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create and set up the content pane. TableRenderDemo newContentPane = new TableRenderDemo(); newContentPane.setOpaque(true); // content panes must be opaque frame.setContentPane(newContentPane); // Display the window. frame.setSize(1000, 400); frame.setLocationRelativeTo(null); frame.setVisible(true); } } substance-5.3.orig/src/test/contrib/SubstanceTestDialog2.java0000644000175000017500000000511011210744664024247 0ustar drazzibdrazzibpackage test.contrib; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.SubstanceMistSilverLookAndFeel; /** * * @author blongstr */ public class SubstanceTestDialog2 { public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { public void run() { UIManager.getDefaults().put( SubstanceLookAndFeel.COLORIZATION_FACTOR, new Double(1.0d)); try { UIManager .setLookAndFeel(new SubstanceMistSilverLookAndFeel()); } catch (UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); final JFrame appFrame = new JFrame("Substance Test Application"); appFrame.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); } }); appFrame.setSize(400, 400); appFrame.setLocationRelativeTo(null); appFrame.setVisible(true); // Example of a component returning a null background color and // how it effects component UI initialization. final JPanel mainPanel = new JPanel() { @Override public Color getBackground() { return null; } }; mainPanel.setLayout(new BorderLayout()); final JPanel panel = new JPanel(); panel.setBackground(Color.white); panel.setLayout(new FlowLayout(FlowLayout.CENTER)); final JButton button = new JButton( "Click this button to get error"); button.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { final JPanel panel = new JPanel(); panel.setLayout(new GridLayout(2, 1)); panel.add(new JLabel("Testing 1,2, 3")); panel.add(new JTable(4, 3)); panel.setSize(400, 600); panel.addNotify(); panel.validate(); // create image final BufferedImage image = new BufferedImage(400, 600, BufferedImage.TYPE_INT_ARGB); // render image final Graphics2D g2 = image.createGraphics(); g2.setColor(Color.WHITE); g2.fillRect(0, 0, 400, 600); // print panel.printAll(g2); g2.dispose(); } }); panel.add(button); mainPanel.add(new JScrollPane(panel)); appFrame.add(mainPanel); } }); } } substance-5.3.orig/src/test/contrib/LAFDemo.java0000644000175000017500000000455311223632124021466 0ustar drazzibdrazzibpackage test.contrib; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.UIManager; import org.jvnet.lafwidget.LafWidget; import org.jvnet.substance.SubstanceLookAndFeel; public class LAFDemo extends JFrame { private JTextField textfield; private JCheckBox checkbox; public LAFDemo() { super("LAF-Demo"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPasswordField password = new JPasswordField(10); textfield = new JTextField("Hallo, iX", 10); textfield.putClientProperty(LafWidget.TEXT_EDIT_CONTEXT_MENU, Boolean.TRUE); textfield.putClientProperty(LafWidget.TEXT_SELECT_ON_FOCUS, Boolean.TRUE); textfield.putClientProperty(LafWidget.TEXT_FLIP_SELECT_ON_ESCAPE, Boolean.TRUE); checkbox = new JCheckBox("editierbar"); checkbox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateTextfield(); } }); updateTextfield(); JPanel p = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 10)); p.add(password); p.add(checkbox); p.add(textfield); setContentPane(p); pack(); } private void updateTextfield() { boolean selected = checkbox.isSelected(); textfield.setEditable(selected); if (selected) { textfield.requestFocus(); } } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame.setDefaultLookAndFeelDecorated(true); try { UIManager .setLookAndFeel("org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel"); } catch (Throwable thr) { thr.printStackTrace(); } UIManager.put(SubstanceLookAndFeel.SHOW_EXTRA_WIDGETS, Boolean.TRUE); new LAFDemo().setVisible(true); } }); } } substance-5.3.orig/src/test/contrib/JToggleButtonStress.java0000644000175000017500000000224011230342514024200 0ustar drazzibdrazzibpackage test.contrib; import javax.swing.*; import org.jvnet.substance.skin.SubstanceOfficeSilver2007LookAndFeel; public class JToggleButtonStress extends JFrame { ButtonGroup buttonGroup = new ButtonGroup(); public JToggleButtonStress() { setLayout(null); int y = 0; for (int i = 0; i < 25; i++) { JToggleButton toogleButton = new JToggleButton( "A test toggle button!"); toogleButton.setBounds(0, y, 1280, 30); // toogleButton.putClientProperty(LafWidget.ANIMATION_KIND, // AnimationKind.NONE); y += 30; buttonGroup.add(toogleButton); add(toogleButton); } setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(1280, 768); setVisible(true); } public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); try { UIManager .setLookAndFeel(new SubstanceOfficeSilver2007LookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } new JToggleButtonStress(); } }); } } substance-5.3.orig/src/test/contrib/SnapListener.java0000644000175000017500000000430311235655072022671 0ustar drazzibdrazzibpackage test.contrib; import java.awt.Component; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import javax.swing.JDesktopPane; public class SnapListener implements ComponentListener { private static final int THRESHOLD = 8; private JDesktopPane pane; private boolean snapToBorder = true; private boolean locked = false; public SnapListener(JDesktopPane pane) { this.pane = pane; this.pane.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); } private static int getLeft(Component c) { return c.getX(); } private static int getRight(Component c) { return getLeft(c) + c.getWidth(); } private static int getTop(Component c) { return c.getY(); } private static int getBottom(Component c) { return getTop(c) + c.getHeight(); } private boolean isNear(int p1, int p2) { return Math.abs(p1 - p2) < THRESHOLD; } @Override public void componentHidden(ComponentEvent event) { } @Override public void componentMoved(ComponentEvent event) { if (locked) { return; } Component c = event.getComponent(); locked = true; if (snapToBorder) { // left border if (getLeft(c) < THRESHOLD) { c.setLocation(0, c.getLocation().y); } // upper border if (c.getLocation().y < THRESHOLD) { c.setLocation(c.getLocation().x, 0); } // right border if (isNear(getRight(c), pane.getWidth())) { setRight(c, pane.getWidth()); } // lower border if (isNear(getBottom(c), pane.getHeight())) { setBottom(c, pane.getHeight()); } // c.getParent().repaint(); } locked = false; } private static void setTop(Component c, int y) { c.setLocation(c.getLocation().x, y); } private static void setLeft(Component c, int x) { c.setLocation(x, c.getLocation().y); } private static void setBottom(Component c, int y) { c.setLocation(c.getLocation().x, y - c.getHeight()); } private static void setRight(Component c, int x) { c.setLocation(x - c.getWidth(), c.getLocation().y); } @Override public void componentResized(ComponentEvent event) { } @Override public void componentShown(ComponentEvent event) { } }substance-5.3.orig/src/test/contrib/SubstanceTreeTest.java0000644000175000017500000000244611034344344023671 0ustar drazzibdrazzibpackage test.contrib; import java.awt.*; import javax.swing.*; import javax.swing.tree.*; public class SubstanceTreeTest extends JFrame { SubstanceTreeTest() { getContentPane().add(createList()); pack(); setVisible(true); } JScrollPane createList() { JTree jTree = new JTree(); jTree.setModel(createTreeModel()); // This line causes the exception jTree.setFont(new Font(jTree.getFont().getName(), Font.PLAIN, 18)); JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportView(jTree); /* All done. */ return scrollPane; } DefaultTreeModel createTreeModel() { DefaultMutableTreeNode root = new DefaultMutableTreeNode("Movies"); //$NON-NLS-1$ DefaultTreeModel model = new DefaultTreeModel(root, false); Object[] data = new String[] { "Predator", "Terminator", "Conan", "Rambo" }; for (int i = 0; i < data.length; i++) { root.add(new DefaultMutableTreeNode(data[i])); } return model; } public static void main(String args[]) { try { UIManager .setLookAndFeel("org.jvnet.substance.skin.SubstanceCremeLookAndFeel"); } catch (Exception e) { e.printStackTrace(); } EventQueue.invokeLater(new Runnable() { public final void run() { new SubstanceTreeTest(); } }); } } substance-5.3.orig/src/test/contrib/SubstanceJComboBoxTest.java0000644000175000017500000000375311177322336024623 0ustar drazzibdrazzibpackage test.contrib; import java.awt.*; import java.util.Vector; import javax.swing.*; public class SubstanceJComboBoxTest extends JFrame { public static void main(String[] args) { // First set the look and feel - Substance based or system default. int selection = JOptionPane.showConfirmDialog(null, "Use a Substance-based look and feel?", "Select a Look And Feel", JOptionPane.YES_NO_OPTION); try { if (JOptionPane.YES_OPTION == selection) { UIManager .setLookAndFeel("org.jvnet.substance.skin.SubstanceRavenGraphiteGlassLookAndFeel"); } else { // UIManager.setLookAndFeel(UIManager. // getSystemLookAndFeelClassName()); UIManager .setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); } } catch (Exception e) { e.printStackTrace(); System.exit(1); } // Open the screen. try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { new SubstanceJComboBoxTest(); } }); } catch (Exception e) { e.printStackTrace(); System.exit(1); } } //========================================================================== // ==== private SubstanceJComboBoxTest() { setDefaultCloseOperation(DISPOSE_ON_CLOSE); Container theContainer = getContentPane(); theContainer.setLayout(new BorderLayout()); // Add an editable combo box. Vector tempData = new Vector(); tempData.add("uuuuvvvvwwwwxxxxyyyyzzzz"); tempData.add("uuuuvvvvwwwwxxxxyyyyzzzz"); JComboBox theAppURLField = new JComboBox(tempData); theAppURLField.setEditable(true); theAppURLField .getEditor() .setItem( "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789zxywvutsrqponmlkjihgfedcba9876543210"); theContainer.add(theAppURLField, BorderLayout.EAST); // System.out.println(((Component) theAppURLField.getEditor()) // .getPreferredSize()); pack(); setResizable(false); setLocationRelativeTo(null); setVisible(true); } } substance-5.3.orig/src/test/contrib/MyGradientPainter.java0000644000175000017500000001416011144753120023642 0ustar drazzibdrazzibpackage test.contrib; import java.awt.*; import java.awt.MultipleGradientPaint.CycleMethod; import java.awt.image.BufferedImage; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.painter.gradient.BaseGradientPainter; import org.jvnet.substance.utils.SubstanceColorUtilities; import org.jvnet.substance.utils.SubstanceCoreUtilities; public class MyGradientPainter extends BaseGradientPainter { public String getDisplayName() { return "subdue antialias"; } public void paintContourBackground(Graphics g, Component comp, int width, int height, Shape contour, boolean isFocused, SubstanceColorScheme colorScheme1, SubstanceColorScheme colorScheme2, float cyclePos, boolean hasShine, boolean useCyclePosAsInterpolation) { Graphics2D graphics = (Graphics2D) g.create(); SubstanceColorScheme interpolationScheme1 = colorScheme1; SubstanceColorScheme interpolationScheme2 = useCyclePosAsInterpolation ? colorScheme2 : colorScheme1; double cycleCoef = 1.0 - cyclePos; Color topFillColor = this.getTopFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); Color midFillColorTop = this.getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); Color midFillColorBottom = this.getMidFillColorBottom(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); Color bottomFillColor = this.getBottomFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); Color topShineColor = this.getTopShineColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); Color bottomShineColor = this.getBottomShineColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); // Fill background // graphics.setClip(contour); old code MultipleGradientPaint gradient = new LinearGradientPaint(0, 0, 0, height, new float[] { 0.0f, 0.4999999f, 0.5f, 1.0f }, new Color[] { topFillColor, midFillColorTop, midFillColorBottom, bottomFillColor }, CycleMethod.REPEAT); graphics.setPaint(gradient); graphics.fill(contour); graphics.setClip(contour);// fix for antialias if (hasShine && (topShineColor != null) && (bottomShineColor != null)) { int shineHeight = (int) (height / 1.8); int kernelSize = (int) Math.min(12, Math.pow(Math.min(width, height), 0.8) / 4); if (kernelSize < 3) kernelSize = 3; BufferedImage blurredGhostContour = SubstanceCoreUtilities.getBlankImage(width + 2 * kernelSize, height + 2 * kernelSize); Graphics2D blurredGhostGraphics = (Graphics2D) blurredGhostContour.getGraphics().create(); blurredGhostGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); blurredGhostGraphics.setColor(Color.black); blurredGhostGraphics.translate(kernelSize, kernelSize); int step = kernelSize > 5 ? 2 : 1; for (int strokeSize = 2 * kernelSize - 1; strokeSize > 0; strokeSize -= step) { float transp = 1.0f - strokeSize / (2.0f * kernelSize); blurredGhostGraphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, transp)); blurredGhostGraphics.setStroke(new BasicStroke(strokeSize)); blurredGhostGraphics.draw(contour); } blurredGhostGraphics.dispose(); BufferedImage reverseGhostContour = SubstanceCoreUtilities.getBlankImage(width + 2 * kernelSize, height + 2 * kernelSize); Graphics2D reverseGraphics = (Graphics2D) reverseGhostContour.getGraphics(); Color bottomShineColorTransp = new Color(bottomShineColor.getRed(), bottomShineColor.getGreen(), bottomShineColor.getBlue(), 64); GradientPaint gradientShine = new GradientPaint(0, kernelSize, topShineColor, 0, kernelSize + shineHeight, bottomShineColorTransp); reverseGraphics.setPaint(gradientShine); reverseGraphics.fillRect(0, kernelSize, width + 2 * kernelSize, kernelSize + shineHeight); reverseGraphics.setComposite(AlphaComposite.DstOut); reverseGraphics.drawImage(blurredGhostContour, 0, 0, null); graphics.drawImage(reverseGhostContour, 0, 0, width - 1, shineHeight, kernelSize, kernelSize, kernelSize + width - 1, kernelSize + shineHeight, null); } graphics.dispose(); } public Color getTopFillColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getTopFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } public Color getMidFillColorTop(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getMidFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } public Color getMidFillColorBottom(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return this.getMidFillColorTop(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } public Color getBottomFillColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getBottomFillColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } public Color getTopShineColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getTopShineColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } public Color getBottomShineColor(SubstanceColorScheme interpolationScheme1, SubstanceColorScheme interpolationScheme2, double cycleCoef, boolean useCyclePosAsInterpolation) { return SubstanceColorUtilities.getBottomShineColor(interpolationScheme1, interpolationScheme2, cycleCoef, useCyclePosAsInterpolation); } }substance-5.3.orig/src/test/contrib/SLeakTest.java0000644000175000017500000001760711035431326022124 0ustar drazzibdrazzibpackage test.contrib; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; import java.lang.ref.WeakReference; import java.util.HashSet; import java.util.Set; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.ScrollPaneConstants; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.WindowConstants; import javax.swing.table.AbstractTableModel; import org.jvnet.substance.skin.SubstanceMagmaLookAndFeel; import org.jvnet.substance.skin.SubstanceMistAquaLookAndFeel; import org.jvnet.substance.skin.SubstanceMistSilverLookAndFeel; import org.jvnet.substance.skin.SubstanceModerateLookAndFeel; /** * Every time you hit the "swap" button, it replaces the current contents of the * content pane with a new instance of SLeakTest. The former one is supposed to * get garbage collected. I have a LeakWatcher class that watches for previous * instances getting garbage collected and prints a message to System.err. If * the previous components are getting garbage collected, you will see a message * saying so each time you hit the "swap" button. *

* Here's what actually happens: For every LF except the Substance LFs, the * discarded components get garbage collected. For the Substance LFs, they * don't. */ public class SLeakTest extends JPanel { private static JFrame mFrame = new JFrame( "Leak Test" ); private static int counter = 0; private static LeakWatcher watcher = new LeakWatcher( "SLeakTestQueue" ); public static void main(String[] args) { Runnable doRun = new Runnable() { public void run() { createApplication(); } }; SwingUtilities.invokeLater( doRun ); } private static void createApplication() { // Choose a L&F. The last four cause memory leaks. // LF.Platform.set(); // LF.Ocean.set(); // LF.Motif.set(); // LF.Nimbus.set(); // LF.WindowsClassic.set(); // LF.Magma.set(); // LF.MistAfqua.set(); // LF.MistSilver.set(); LF.Moderate.set(); mFrame.setSize( 500, 300 ); mFrame.setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE ); addControlButton(); swap(); mFrame.setVisible( true ); } private static void addControlButton() { JPanel cPanel = new JPanel( new FlowLayout() ); JButton cButton = new JButton( "Swap" ); ActionListener al = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { swap(); } }; cButton.addActionListener( al ); cPanel.add( cButton ); mFrame.getContentPane().add( cPanel, BorderLayout.SOUTH ); } private static void swap() { if ( mFrame.getContentPane().getComponentCount() > 1 ) mFrame.getContentPane().remove( 1 ); mFrame.getContentPane().add( new SLeakTest(), BorderLayout.CENTER ); mFrame.getContentPane().validate(); System.gc(); } private SLeakTest() { super( new BorderLayout() ); // The label doesn't cause a memory leak JLabel label = new JLabel( "Instance " + counter++ ); add( label, BorderLayout.NORTH ); // Almost any other components I add cause a memory leak. JTextArea ta = new JTextArea(); JScrollPane scroll = new JScrollPane( ta, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER ); JSplitPane splitter = new JSplitPane(); splitter.setTopComponent( scroll ); splitter.setBottomComponent( new JTable( new LeakTableModel() ) ); splitter.setDividerLocation( 0.5 ); splitter.setResizeWeight( 0.5 ); add( splitter, BorderLayout.CENTER ); // // Replacing the Splitter above with this causes a leak // JScrollPane scroll = new JScrollPane( new JTable( new LeakTableModel() ), // ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, // ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER ); // add( scroll, BorderLayout.CENTER ); // // But replace it with this and it no longer leaks. // add( new JButton( "Does Nothing" ), BorderLayout.CENTER ); watcher.watch( this ); } private class LeakTableModel extends AbstractTableModel { @Override public int getColumnCount() { return 10; } @Override public int getRowCount() { return 10; } @Override public Object getValueAt(int rowIndex, int columnIndex) { return new Dimension( rowIndex, columnIndex ).hashCode(); } } private static class LeakWatcher { Set> refs = new HashSet>(); ReferenceQueue mQueue = new ReferenceQueue(); private final String mQueueName; public LeakWatcher(String queueName) { mQueueName = queueName; launchPoller( mQueue, queueName ); } public void watch(T object) { WeakReference ref = new WeakReference( object, mQueue ); // System.err.println(" <) " + ref + " on " + mQueueName ); System.err.println( String.format( " <) %-36s on %s", ref.toString(), mQueueName ) ); refs.add( ref ); } private int getValidCount() { int count = 0; for ( WeakReference ref : refs ) { if ( ref.get() != null ) { count++; } } return count; } private void launchPoller(final ReferenceQueue queue, final String name) { System.err.println( "Launching " + queue ); Runnable poller = new Runnable() { public void run() { System.err.println( "Looking at " + name + ": " + queue + "..." ); // noinspection InfiniteLoopStatement while ( true ) { try { Reference ref = queue.remove(); // blocks until // available refs.remove( ref ); // System.err.println( "GC of " + ref + " from " + name // + ". (Watching " + refs.size() + " refs, of which " // + getValidCount() + " are valid.)" ); String fmt = "GC of %-36s from %s. (Watching %d refs, of which %d are valid.)"; System.err.println( String.format( fmt, ref.toString(), name, refs.size(), getValidCount() ) ); } catch ( InterruptedException e ) { e.printStackTrace(); break; } } System.err.println( "Queue done." ); } }; Thread pollThread = new Thread( poller, name ); pollThread.setDaemon( true ); pollThread.start(); } } private static enum LF { Platform(UIManager.getSystemLookAndFeelClassName()), // Metal("javax.swing.plaf.metal.MetalLookAndFeel", "metalTheme"), Ocean("javax.swing.plaf.metal.MetalLookAndFeel"), // "oceanTheme"), WindowsClassic("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"), Motif("com.sun.java.swing.plaf.motif.MotifLookAndFeel"), // Motif Nimbus("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"), // NImbus Magma(SubstanceMagmaLookAndFeel.class.getName()), // Substance LFs MistAqua(SubstanceMistAquaLookAndFeel.class.getName()), // Aqua MistSilver(SubstanceMistSilverLookAndFeel.class.getName()), // Silver Moderate(SubstanceModerateLookAndFeel.class.getName()), // Moderate ; private String path; LF(String name) { path = name; } public void set() { try { UIManager.setLookAndFeel( path ); } catch ( Exception e ) { e.printStackTrace(); } } } } substance-5.3.orig/src/test/contrib/GhostingDemo.java0000644000175000017500000000317411207250742022650 0ustar drazzibdrazzibpackage test.contrib; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Locale; import javax.swing.*; import org.jvnet.lafwidget.animation.FadeConfigurationManager; import org.jvnet.lafwidget.animation.FadeKind; import org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel; public class GhostingDemo extends javax.swing.JFrame { public static void main(final String[] args) { Locale.setDefault(Locale.ENGLISH); try { UIManager .setLookAndFeel(new SubstanceBusinessBlueSteelLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } FadeConfigurationManager.getInstance().allowFades( FadeKind.GHOSTING_BUTTON_PRESS); SwingUtilities.invokeLater(new Runnable() { public void run() { GhostingDemo inst = new GhostingDemo(); inst.setLocationRelativeTo(null); inst.setVisible(true); } }); } private JButton buttonExit; public GhostingDemo() { super("Ghost demo"); initGUI(); } private void initGUI() { setLayout(new FlowLayout()); add(getButtonExit()); setSize(300, 300); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } public JButton getButtonExit() { if (this.buttonExit == null) { this.buttonExit = new JButton("Button"); this.buttonExit.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { JOptionPane.showConfirmDialog(GhostingDemo.this, "some text ?", "title", JOptionPane.YES_NO_OPTION); } }); } return this.buttonExit; } } substance-5.3.orig/src/test/contrib/TreeEditor.java0000644000175000017500000000467311177400320022327 0ustar drazzibdrazzibpackage test.contrib; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JFrame; import javax.swing.JTree; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellEditor; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeModel; import org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel; public class TreeEditor { public static void main(String[] args) { // apply substance LaF to all Frames and Dialogs JFrame.setDefaultLookAndFeelDecorated(true); try { UIManager.setLookAndFeel(new SubstanceBusinessBlueSteelLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } Runnable substanceTest = new Runnable() { class CustomTreeCellEditor extends DefaultTreeCellEditor { public CustomTreeCellEditor(final JTree tree, final DefaultTreeCellRenderer renderer) { super(tree, renderer); } } @Override public void run() { // create frame JFrame mainFrame = new JFrame(); mainFrame.setTitle("Substance Test"); mainFrame.setBounds(0, 0, 800, 600); DefaultMutableTreeNode top = new DefaultMutableTreeNode("top"); DefaultTreeModel projectModel = new DefaultTreeModel(top); final JTree jTree = new JTree(projectModel); projectModel.insertNodeInto(new DefaultMutableTreeNode("child1"), top, top.getChildCount()); projectModel.insertNodeInto(new DefaultMutableTreeNode("child2"), top, top.getChildCount()); projectModel.insertNodeInto(new DefaultMutableTreeNode("child3"), top, top.getChildCount()); // Custom Tree Cell Editor CustomTreeCellEditor treeCellEditor = new CustomTreeCellEditor(jTree, new DefaultTreeCellRenderer()); jTree.setCellEditor(treeCellEditor); jTree.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { super.mousePressed(e); if (e.getClickCount() == 3) { jTree.setEditable(true); jTree.startEditingAtPath(jTree.getSelectionPath()); } } }); mainFrame.add(jTree); mainFrame.setVisible(true); } }; // create the UI in event dispatch thread SwingUtilities.invokeLater(substanceTest); } } substance-5.3.orig/src/test/contrib/ProgressBarInListTest.java0000644000175000017500000000715611062400352024472 0ustar drazzibdrazzibpackage test.contrib; import java.awt.Component; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.FocusKind; import org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel; public class ProgressBarInListTest extends JFrame { private JList jList1; private JScrollPane jScrollPane1; public ProgressBarInListTest() { jScrollPane1 = new JScrollPane(); jList1 = new JList(); jScrollPane1.setViewportView(jList1); getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER); pack(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); // Test-data ListItem f1 = new ListItem("Test_1", 100); ListItem f2 = new ListItem("Test_2", 15); ListItem f3 = new ListItem("Test_3", 0); // Add test-data to Model DefaultListModel listModel = new DefaultListModel(); listModel.addElement(f1); listModel.addElement(f2); listModel.addElement(f3); // Set custom CellRenderer jList1.setCellRenderer(new FileTransferListCellRenderer()); jList1.setModel(listModel); // jList1.putClientProperty(LafWidget.ANIMATION_KIND, // AnimationKind.NONE); } public static void main(String args[]) { // Set up Substance try { UIManager .setLookAndFeel(new SubstanceBusinessBlueSteelLookAndFeel()); UIManager.put(SubstanceLookAndFeel.FOCUS_KIND, FocusKind.NONE); JFrame.setDefaultLookAndFeelDecorated(true); } catch (UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } // Show Gui java.awt.EventQueue.invokeLater(new Runnable() { public void run() { ProgressBarInListTest listTest = new ProgressBarInListTest(); listTest.setTitle("JProgressBar in JList"); listTest.setSize(300, 500); listTest.setLocationRelativeTo(null); listTest.setVisible(true); } }); } /** * Represents an item in the list */ public class ListItem { private String text; private int progress; public ListItem(String text, int progress) { this.text = text; this.progress = progress; } public String getText() { return text; } public void setText(String text) { this.text = text; } public int getProgress() { return progress; } public void setProgress(int progress) { this.progress = progress; } } /** * Custom panel with JLabel and JProgressBar on it. Used to visualize * ListItem objects in an JList. */ public class ProgressTaskPanel extends JPanel { private JLabel label; private JProgressBar progressBar; public ProgressTaskPanel() { // initComponents(); label = new javax.swing.JLabel(); progressBar = new javax.swing.JProgressBar(); setLayout(new java.awt.BorderLayout()); add(label, java.awt.BorderLayout.PAGE_START); add(progressBar, java.awt.BorderLayout.PAGE_END); } public void setText(String text) { label.setText(text); } public void setProgress(int progress) { progressBar.setValue(progress); } } /** * Custom CellRenderer to render ListItem objects */ public class FileTransferListCellRenderer extends ProgressTaskPanel implements ListCellRenderer { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { ListItem item = (ListItem) value; if (cellHasFocus) setText("*" + item.getText() + "*"); else setText(item.getText()); setProgress(item.getProgress()); setBorder(javax.swing.BorderFactory.createEmptyBorder(2, 2, 2, 2)); return this; } } } substance-5.3.orig/src/test/contrib/BasicLayouts.java0000644000175000017500000002130511140073622022653 0ustar drazzibdrazzibpackage test.contrib; import static java.awt.GridBagConstraints.BOTH; import static java.awt.GridBagConstraints.CENTER; import static java.awt.GridBagConstraints.HORIZONTAL; import static java.awt.GridBagConstraints.NONE; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import javax.swing.AbstractAction; import javax.swing.Box; import javax.swing.GroupLayout; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSpinner; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.GroupLayout.ParallelGroup; import javax.swing.GroupLayout.SequentialGroup; import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.SubstanceConstants.SubstanceWidgetType; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; @SuppressWarnings("serial") public class BasicLayouts extends JFrame { public BasicLayouts() { super("Basic layouts"); // create components of window createMenuBar(); Container horizontalLayout = createHorizontalGroupBox(); Container gridLayout = createGridLayout(); Container formLayout = createFormLayout(); Container textArea = createTextArea(); Container dialogButtons = createDialogButtons(); // set group layout to content pane Container contentPane = getContentPane(); GroupLayout mainLayout = new GroupLayout(contentPane); contentPane.setLayout(mainLayout); mainLayout.setAutoCreateContainerGaps(true); mainLayout.setAutoCreateGaps(true); // add components of window to group layout mainLayout.setHorizontalGroup(mainLayout.createParallelGroup() .addComponent(horizontalLayout).addComponent(gridLayout) .addComponent(formLayout).addComponent(textArea).addComponent( dialogButtons)); mainLayout.setVerticalGroup(mainLayout.createSequentialGroup() .addComponent(horizontalLayout).addComponent(gridLayout) .addComponent(formLayout).addComponent(textArea).addComponent( dialogButtons)); // setDefaultCloseOperation(EXIT_ON_CLOSE); SubstanceLookAndFeel.setWidgetVisible(getRootPane(), true, SubstanceWidgetType.TITLE_PANE_HEAP_STATUS); pack(); setMinimumSize(getSize()); setVisible(true); } private void createMenuBar() { JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); JMenuItem exitItem = new JMenuItem(new AbstractAction() { { putValue(NAME, "Exit"); putValue(MNEMONIC_KEY, KeyEvent.VK_X); } @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); fileMenu.add(exitItem); menuBar.add(fileMenu); setJMenuBar(menuBar); } private Container createHorizontalGroupBox() { JPanel panel = new JPanel(); GroupLayout groupLayout = new GroupLayout(panel); groupLayout.setAutoCreateGaps(true); final int nButtons = 4; SequentialGroup horizontalGroup = groupLayout.createSequentialGroup(); ParallelGroup verticalGroup = groupLayout.createParallelGroup(); for (int i = 1; i <= nButtons; i++) { JButton button = new JButton("Button " + i); horizontalGroup.addComponent(button, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE); verticalGroup.addComponent(button); } groupLayout.setHorizontalGroup(horizontalGroup); groupLayout.setVerticalGroup(verticalGroup); panel.setLayout(groupLayout); Insets insets = new Insets(2, 2, 2, 2); panel .setBorder(new CompoundBorder(new TitledBorder( "Horizontal layout"), new EmptyBorder(insets))); return panel; } private Container createGridLayout() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); JLabel label1st = new JLabel("Line 1:"); JLabel label2nd = new JLabel("Line 2:"); JLabel label3rd = new JLabel("Line 3:"); JTextField textField1st = new JTextField(); JTextField textField2nd = new JTextField(); JTextField textField3rd = new JTextField(); JTextArea textArea = new JTextArea( "This widget takes up about two thirds of the grid layout."); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); JScrollPane scrollPane = new JScrollPane(textArea); Insets insets = new Insets(2, 2, 2, 2); panel.setBorder(new CompoundBorder(new TitledBorder("Grid layout"), new EmptyBorder(insets))); Component glue = Box.createGlue(); panel.add(glue, new GridBagConstraints(0, 0, 2, 1, 0.5, 1.0, CENTER, BOTH, insets, 0, 0)); panel.add(label1st, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, CENTER, NONE, insets, 0, 0)); panel.add(label2nd, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, CENTER, NONE, insets, 0, 0)); panel.add(label3rd, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, CENTER, NONE, insets, 0, 0)); panel.add(textField1st, new GridBagConstraints(1, 1, 1, 1, 0.5, 0.0, CENTER, HORIZONTAL, insets, 0, 0)); panel.add(textField2nd, new GridBagConstraints(1, 2, 1, 1, 0.5, 0.0, CENTER, HORIZONTAL, insets, 0, 0)); panel.add(textField3rd, new GridBagConstraints(1, 3, 1, 1, 0.5, 0.0, CENTER, HORIZONTAL, insets, 0, 0)); panel.add(scrollPane, new GridBagConstraints(2, 0, 1, 4, 1.0, 1.0, CENTER, BOTH, insets, 0, 0)); Dimension zeroSize = new Dimension(0, textField1st.getPreferredSize().height); textField1st.setPreferredSize(zeroSize); textField2nd.setPreferredSize(zeroSize); textField3rd.setPreferredSize(zeroSize); scrollPane.setPreferredSize(zeroSize); return panel; } private Container createFormLayout() { JPanel panel = new JPanel(); GroupLayout groupLayout = new GroupLayout(panel); groupLayout.setAutoCreateGaps(true); JLabel label1st = new JLabel("Line 1:"); JLabel label2nd = new JLabel("Line 2, long text:"); JLabel label3rd = new JLabel("Line 3:"); JTextField textField = new JTextField(); JComboBox comboBox = new JComboBox(); JSpinner spinner = new JSpinner(); groupLayout.setHorizontalGroup(groupLayout.createSequentialGroup() .addGroup( groupLayout.createParallelGroup() .addComponent(label1st).addComponent(label2nd) .addComponent(label3rd)).addGroup( groupLayout.createParallelGroup().addComponent( textField).addComponent(comboBox).addComponent( spinner))); groupLayout.setVerticalGroup(groupLayout.createSequentialGroup() .addGroup( groupLayout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( label1st).addComponent(textField)).addGroup( groupLayout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( label2nd).addComponent(comboBox)).addGroup( groupLayout.createParallelGroup( GroupLayout.Alignment.BASELINE).addComponent( label3rd).addComponent(spinner))); panel.setLayout(groupLayout); Insets insets = new Insets(2, 2, 2, 2); panel.setBorder(new CompoundBorder(new TitledBorder("Form layout"), new EmptyBorder(insets))); return panel; } private Container createTextArea() { JTextArea textArea = new JTextArea( "This widget takes up all the remaining space " + "in the top-level layout."); textArea.setLineWrap(true); textArea.setRows(4); return new JScrollPane(textArea); } private Container createDialogButtons() { JPanel panel = new JPanel(); JButton ok = new JButton("OK"); JButton cancel = new JButton("Cancel"); GroupLayout groupLayout = new GroupLayout(panel); groupLayout.setAutoCreateGaps(true); groupLayout.setHorizontalGroup(groupLayout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE).addComponent(ok).addComponent( cancel)); groupLayout.setVerticalGroup(groupLayout.createParallelGroup() .addComponent(ok).addComponent(cancel)); groupLayout.linkSize(ok, cancel); panel.setLayout(groupLayout); return panel; } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); try { UIManager .setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); } catch (Exception e) { e.printStackTrace(); } SwingUtilities.invokeLater(new Runnable() { public void run() { new BasicLayouts(); } }); } } substance-5.3.orig/src/test/contrib/SkinSetBackgroundTest.java0000644000175000017500000000250611216664330024501 0ustar drazzibdrazzibpackage test.contrib; import java.awt.Color; import javax.swing.*; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.SubstanceOfficeBlue2007LookAndFeel; public class SkinSetBackgroundTest extends JFrame { public SkinSetBackgroundTest() { JPanel panel1 = new JPanel(); JTable jTable1 = new JTable(); jTable1.setModel(new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); jTable1.setSize(220, 360); JTree jTree1 = new JTree(); jTree1.setSize(220, 360); jTable1.setBackground(Color.WHITE); jTree1.setBackground(Color.white); panel1.add(jTable1); panel1.add(jTree1); UIManager .put(SubstanceLookAndFeel.COLORIZATION_FACTOR, new Double(1.0)); this.add(panel1); this.setSize(500, 400); } public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { try { UIManager .setLookAndFeel(new SubstanceOfficeBlue2007LookAndFeel()); } catch (UnsupportedLookAndFeelException ex) { } new SkinSetBackgroundTest().setVisible(true); } }); } } substance-5.3.orig/src/test/contrib/A0.java0000644000175000017500000000456111204334220020511 0ustar drazzibdrazzibpackage test.contrib; import java.awt.event.*; import javax.swing.JButton; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.api.*; import org.jvnet.substance.skin.MistSilverSkin; public class A0 extends javax.swing.JFrame { /** Creates new form A0 */ public A0() { initMyCmpnts(); } /** This method is called from within the constructor to * initialize the form. */ private void initMyCmpnts() { setTitle("Substance LAF Test"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); getContentPane().setLayout(null); add(jBtn1).setBounds(20, 20, 150, 25); add(jBtn2).setBounds(190, 20, 150, 25); jBtn2.setEnabled(false); jBtn1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { SubstanceLookAndFeel.setSkin(new MistSilverSkin()); jBtn2.setEnabled(true); } }); jBtn2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // "I don't know in this part..." SubstanceSkin newSkin = SubstanceLookAndFeel.getCurrentSkin().transform( new ColorSchemeTransform() { @Override public SubstanceColorScheme transform(SubstanceColorScheme scheme) { return scheme.hueShift(0.1).saturate(0.5); }; }, "hueShifted Skin?"); SubstanceLookAndFeel.setSkin(newSkin); // "Please help..." } }); pack(); setSize(380, 100); } /** * @param args the command line arguments */ public static void main(String args[]) { try { javax.swing.UIManager.setLookAndFeel (javax.swing.UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new A0().setVisible(true); } }); } // Variables declaration private JButton jBtn1 = new JButton("MistSilverSkin"); private JButton jBtn2 = new JButton("hueShift 10%"); // End of variables declaration }substance-5.3.orig/src/test/contrib/WalkThrough.java0000644000175000017500000000202611254110352022505 0ustar drazzibdrazzibpackage test.contrib; import java.awt.Dimension; import java.awt.FlowLayout; import javax.swing.*; import org.jvnet.substance.skin.SubstanceRavenGraphiteLookAndFeel; public class WalkThrough extends JFrame { public WalkThrough() { super("Sample app"); this.setLayout(new FlowLayout()); this.add(new JButton("button")); this.add(new JCheckBox("check")); this.add(new JLabel("label")); this.setSize(new Dimension(250, 80)); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { try { UIManager .setLookAndFeel(new SubstanceRavenGraphiteLookAndFeel()); } catch (Exception e) { e.printStackTrace(); System.out .println("Substance Raven Graphite failed to initialize"); } WalkThrough w = new WalkThrough(); w.setVisible(true); } }); } } substance-5.3.orig/src/test/contrib/TestApp.java0000644000175000017500000000701411126610172021633 0ustar drazzibdrazzibpackage test.contrib; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.tree.*; public class TestApp extends JFrame { // L&F class names static final String metal = "javax.swing.plaf.metal.MetalLookAndFeel"; static final String motif = "com.sun.java.swing.plaf.motif.MotifLookAndFeel"; static final String nimbus = "sun.swing.plaf.nimbus.NimbusLookAndFeel"; static final String windows = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; static final String gtk = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"; static final String mac = "com.sun.java.swing.plaf.mac.MacLookAndFeel"; // jgoodies static final String jgoodies = "com.jgoodies.looks.windows.WindowsLookAndFeel"; static final String plastic = "com.jgoodies.looks.plastic.PlasticLookAndFeel"; static final String plastic3D = "com.jgoodies.looks.plastic.Plastic3DLookAndFeel"; static final String plasticXP = "com.jgoodies.looks.plastic.PlasticXPLookAndFeel"; static final String liquid = "com.birosoft.liquid.LiquidLookAndFeel"; static final String substance = "org.jvnet.substance.skin.SubstanceCremeLookAndFeel"; static final String napkin = "net.sourceforge.napkinlaf.NapkinLookAndFeel"; static final String office = "org.fife.plaf.Office2003.Office2003LookAndFeel"; public static void main(String[] args) { try { // UIManager.setLookAndFeel(gtk); UIManager.setLookAndFeel(substance); // UIManager.put(org.jvnet.substance.SubstanceLookAndFeel. // SHOW_EXTRA_WIDGETS, Boolean.TRUE); SwingUtilities.invokeLater(new Runnable() { public void run() { TestApp frame = new TestApp("Test App"); frame.setupFrame(); } }); } catch (Exception e) { e.printStackTrace(); } } TestApp(String title) { super(title); } JTree tree; JTabbedPane tabbed; JComboBox box; void setupFrame() { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); JPanel west = new JPanel(); west.setLayout(new BorderLayout()); add(panel); panel.add(west, BorderLayout.WEST); tree = new JTree(); tree.setCellRenderer(new DefaultTreeCellRenderer()); JScrollPane sc = new JScrollPane(tree); west.add(sc, BorderLayout.CENTER); tabbed = new JTabbedPane(); tabbed.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); // tabbed.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT); panel.add(tabbed, BorderLayout.CENTER); box = new JComboBox(); west.add(box, BorderLayout.NORTH); for (int i = 0; i < 10; i++) { tabbed.add(new JButton("Tab " + i), "Tab " + i); box.addItem("Tab " + i); } panel.add(tabbed, BorderLayout.CENTER); box.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { int i = box.getSelectedIndex(); tabbed.setSelectedIndex(i); } } }); // tabbed.putClientProperty(org.jvnet.substance.SubstanceLookAndFeel. // TABBED_PANE_CLOSE_BUTTONS_PROPERTY, Boolean.TRUE); org.jvnet.lafwidget.tabbed.DefaultTabPreviewPainter previewPainter = new org.jvnet.lafwidget.tabbed.DefaultTabPreviewPainter(); tabbed.putClientProperty( org.jvnet.lafwidget.LafWidget.TABBED_PANE_PREVIEW_PAINTER, previewPainter); int width = 400, height = 300; setSize(width, height); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int x = screenSize.width / 2 - width / 2; int y = screenSize.height / 2 - height / 2; setLocation(x, y); setVisible(true); } }substance-5.3.orig/src/test/contrib/TestSpinnerBackgroundColor.java0000644000175000017500000000242011052213634025524 0ustar drazzibdrazzibpackage test.contrib; import java.awt.BorderLayout; import java.awt.Color; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JSpinner; import javax.swing.SwingUtilities; import javax.swing.UIManager; import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel; public class TestSpinnerBackgroundColor { public TestSpinnerBackgroundColor() { try { UIManager .setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel()); JDialog.setDefaultLookAndFeelDecorated(true); JFrame.setDefaultLookAndFeelDecorated(true); JFrame frame = new JFrame("Test spinner backgroundcolor"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new JLabel("Spinner"), BorderLayout.WEST); JSpinner spinner = new JSpinner(); spinner.setBackground(Color.YELLOW); spinner.setBackground(Color.RED); frame.add(spinner, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); } catch (Exception ex) { ex.printStackTrace(); } } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { new TestSpinnerBackgroundColor(); } }); } }substance-5.3.orig/src/test/contrib/Main.java0000644000175000017500000000330611126716602021144 0ustar drazzibdrazzibpackage test.contrib; import java.awt.Color; import java.awt.Container; import java.awt.EventQueue; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.UIManager; import org.jvnet.substance.SubstanceLookAndFeel; import org.jvnet.substance.skin.BusinessSkin; public class Main extends JFrame { public static void main(String[] args) throws Throwable { setLookAndFeel(); EventQueue.invokeLater(new Runnable() { public void run() { new Main().setVisible(true); } }); } private static void setLookAndFeel() throws Throwable { //UIManager.setLookAndFeel(new MyLookAndFeel()); SubstanceLookAndFeel.setSkin(new BusinessSkin()); UIManager.put("TextField.inactiveBackground", Color.green); UIManager.put("TextField.disabledBackground", Color.green); // UIManager.put("TextField.background", Color.white); } private JTextField field01; private JTextField field02; private JButton button01; public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(0, 0, 800, 600); field01 = new JTextField("Click to change \"Editable\" property"); field02 = new JTextField("Click to change \"Enabled\" property"); button01 = new JButton("Switch to NOT editable/enabled"); button01.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { field01.setEditable(!field01.isEditable()); field02.setEnabled(!field02.isEnabled()); } }); Container pane = getContentPane(); pane.setLayout(new FlowLayout()); pane.add(field01); pane.add(field02); pane.add(button01); } } substance-5.3.orig/src/Looks.license0000644000175000017500000000306510634343440017432 0ustar drazzibdrazzibCopyright (c) 2001-2005 JGoodies Karsten Lentzsch and contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the JGoodies Karsten Lentzsch and contributors nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.substance-5.3.orig/src/contrib/0000755000175000017500000000000010570313710016427 5ustar drazzibdrazzibsubstance-5.3.orig/src/contrib/net/0000755000175000017500000000000010570313710017215 5ustar drazzibdrazzibsubstance-5.3.orig/src/contrib/net/xoetrope/0000755000175000017500000000000010570313710021062 5ustar drazzibdrazzibsubstance-5.3.orig/src/contrib/net/xoetrope/editor/0000755000175000017500000000000010570313710022350 5ustar drazzibdrazzibsubstance-5.3.orig/src/contrib/net/xoetrope/editor/color/0000755000175000017500000000000011256731144023475 5ustar drazzibdrazzibsubstance-5.3.orig/src/contrib/net/xoetrope/editor/color/ColorWheelPanel.java0000644000175000017500000012523410735521574027377 0ustar drazzibdrazzibpackage contrib.net.xoetrope.editor.color; import java.awt.*; import java.awt.event.*; import java.awt.font.TextAttribute; import java.awt.geom.*; import java.awt.image.BufferedImage; import java.text.AttributedString; import java.util.*; import javax.swing.*; import javax.swing.colorchooser.AbstractColorChooserPanel; import javax.swing.event.*; /** * A color wheel showing a Red, Yellow, Blue color model traditionally used by * graphic artists. $Revision: 1.23 $ */ public class ColorWheelPanel extends AbstractColorChooserPanel implements ActionListener, MouseListener, MouseMotionListener, MouseWheelListener, ChangeListener { public static final int MONOCHROMATIC_SCHEME = 0; public static final int CONTRASTING_SCHEME = 1; public static final int SOFT_CONTRAST_SCHEME = 2; public static final int DOUBLE_CONTRAST_SCHEME = 3; public static final int ANALOGIC_SCHEME = 4; public static final int CTRL_ADJUST = 0; public static final int ALWAYS_ADJUST = 1; public static final int NEVER_ADJUST = 2; protected JTextField hueEdit, satEdit, brightEdit, baseColorEdit; protected BufferedImage pickerImage; protected ColorWheel imagePicker; protected JPanel fixedPanel; protected JButton resetBtn; protected JSlider brightnessSlider, saturationSlider; protected JLabel baseColorLabel; protected Ellipse2D innerCircle, outerCircle, borderCircle; protected JCheckBox useWebColors, decimalRGB; protected Font font9pt; protected ModelColor chooserColor; protected ModelColor[] selectedIttenColours; private float values[] = new float[3]; private double h, s, b; private int colorScheme = 0; private boolean busy = false; private boolean displayScheme = false; private boolean hasChooser = false; private ArrayList changeListeners; private static double[] arcDelta = { -7.5, -7.5, -7.5, -7.5, -7.5, -1.0, 4.0, 7.5 }; private double ringThickness; private GeneralPath[] paths; private static ResourceBundle labelBundle; // Rollover related variables private GeneralPath rolloverPath, selectedPath; private boolean showRollovers; private Color rolloverColor, selectedColor; private Color systemColor; private String fontFamily; private int adjustWheel; private boolean adjustRollover; private boolean ctrlKeyDown; private double saturationMultipler, brightnessMultipler; /** * Creates a new instance of ColorWheelPanel */ public ColorWheelPanel() { saturationMultipler = brightnessMultipler = 1.0; changeListeners = new ArrayList(); adjustWheel = CTRL_ADJUST; adjustRollover = true; ctrlKeyDown = false; font9pt = UIManager.getFont("ColorChooser.smallFont"); if (font9pt == null) font9pt = new Font("Arial", 0, 9); fontFamily = font9pt.getFamily(); showRollovers = true; innerCircle = new Ellipse2D.Double(96, 96, 36, 36); outerCircle = new Ellipse2D.Double(6, 6, 214, 214); borderCircle = new Ellipse2D.Double(0, 0, 227, 227); fixedPanel = new JPanel(); fixedPanel.setLayout(null); fixedPanel.setOpaque(false); // fixedPanel.setBackground( Color.white ); fixedPanel.setBounds(0, 0, 255, 328); fixedPanel.setPreferredSize(new Dimension(255, 328)); setLayout(new LayoutManager() { public void addLayoutComponent(String name, Component comp) { } public void removeLayoutComponent(Component comp) { } public void layoutContainer(Container parent) { Dimension fpp = fixedPanel.getPreferredSize(); int dx = (parent.getWidth() - fpp.width) / 2; int dy = (parent.getHeight() - fpp.height) / 2; fixedPanel.setBounds(dx, dy, fpp.width, fpp.height); } public Dimension minimumLayoutSize(Container parent) { return preferredLayoutSize(parent); } public Dimension preferredLayoutSize(Container parent) { return fixedPanel.getPreferredSize(); } }); imagePicker = new ColorWheel(); imagePicker.setBounds(0, 0, 228, 228); imagePicker.addMouseListener(this); imagePicker.addMouseMotionListener(this); imagePicker.setOpaque(false); imagePicker.addMouseWheelListener(this); fixedPanel.add(imagePicker); brightnessSlider = new JSlider(JSlider.VERTICAL); brightnessSlider.setBounds(230, 0, 25, 108); brightnessSlider.setMinimum(0); brightnessSlider.setMaximum(100); brightnessSlider.setValue(100); brightnessSlider.setOpaque(false); // brightnessSlider.setBackground( Color.white ); brightnessSlider.setPaintLabels(true); brightnessSlider.addChangeListener(this); brightnessSlider.addMouseWheelListener(this); brightnessSlider.addMouseMotionListener(this); brightnessSlider.setToolTipText(getLabel("Xoetrope.ctrlDrag", "CTRL+drag to adjust the color wheel")); fixedPanel.add(brightnessSlider); resetBtn = new JButton(); resetBtn.setBounds(237, 109, 10, 10); resetBtn.setBackground(getBackground()); resetBtn.addActionListener(this); resetBtn.setToolTipText(getLabel("Xoetrope.reset", "Reset the color wheel sauturation and brightness")); fixedPanel.add(resetBtn); saturationSlider = new JSlider(JSlider.VERTICAL); saturationSlider.setBounds(230, 120, 25, 110); saturationSlider.setMinimum(0); saturationSlider.setMaximum(100); saturationSlider.setValue(100); saturationSlider.setOpaque(false); // saturationSlider.setBackground( Color.white ); saturationSlider.setInverted(true); saturationSlider.setPaintLabels(true); saturationSlider.addChangeListener(this); saturationSlider.addMouseWheelListener(this); saturationSlider.addMouseMotionListener(this); saturationSlider.setToolTipText(getLabel("Xoetrope.ctrlDrag", "CTRL+drag to adjust the color wheel")); fixedPanel.add(saturationSlider); useWebColors = new JCheckBox(getLabel("Xoetrope.webSafeColors", "Use web safe colors")); useWebColors.setBounds(8, 248, 160, 18); useWebColors.addActionListener(this); useWebColors.setOpaque(false); useWebColors.setFont(font9pt); fixedPanel.add(useWebColors); decimalRGB = new JCheckBox(getLabel("Xoetrope.decimalRGB", "Decimal RGB")); decimalRGB.setBounds(173, 248, 88, 18); decimalRGB.addActionListener(this); decimalRGB.setOpaque(false); decimalRGB.setFont(font9pt); fixedPanel.add(decimalRGB); baseColorLabel = new JLabel(); baseColorLabel.setBounds(10, 268, 160, 18); baseColorLabel.setBackground(Color.red); baseColorLabel.setOpaque(true); baseColorLabel.setToolTipText(getLabel("Xoetrope.systemColorsTooltip", "Right click for system colours")); fixedPanel.add(baseColorLabel); baseColorLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { showSystemColorList(me.getPoint()); } }); baseColorEdit = new JTextField(); baseColorEdit.setBounds(180, 268, 75, 18); baseColorEdit.setOpaque(true); fixedPanel.add(baseColorEdit); baseColorEdit.addActionListener(this); hueEdit = new JTextField(); hueEdit.setBounds(10, 288, 75, 20); fixedPanel.add(hueEdit); hueEdit.setText("0"); hueEdit.getDocument().addDocumentListener( new ColorDocumentListener(hueEdit)); JLabel hueLabel = new JLabel(getLabel("Xoetrope.hue", "Hue") + " \u00B0"); hueLabel.setBounds(10, 308, 75, 20); hueLabel.setFont(font9pt); fixedPanel.add(hueLabel); satEdit = new JTextField(); satEdit.setBounds(95, 288, 75, 20); fixedPanel.add(satEdit); satEdit.setText("0"); satEdit.getDocument().addDocumentListener( new ColorDocumentListener(satEdit)); JLabel satLabel = new JLabel(getLabel("Xoetrope.saturation", "Saturation") + " %"); satLabel.setBounds(95, 308, 75, 20); satLabel.setFont(font9pt); fixedPanel.add(satLabel); brightEdit = new JTextField(); brightEdit.setBounds(180, 288, 75, 20); fixedPanel.add(brightEdit); brightEdit.setText("0"); brightEdit.getDocument().addDocumentListener( new ColorDocumentListener(brightEdit)); JLabel brightLabel = new JLabel(getLabel("Xoetrope.brightness", "Brightness") + " %"); brightLabel.setBounds(180, 308, 75, 20); brightLabel.setFont(font9pt); fixedPanel.add(brightLabel); add(fixedPanel); } /** * Set the reference to the selected colours for the colour scheme * * @param clrs * the colors */ public void setSelectedColors(ModelColor[] clrs) { selectedIttenColours = clrs; } /** * Add a listener for changes in the selected color * * @param l * the change listener to add */ public void addChangeListener(ChangeListener l) { changeListeners.add(l); } /** * Remove a change listener * * @param l * the change listener to remove */ public void removeChangeListener(ChangeListener l) { changeListeners.remove(l); } /** * Has the user selected the use decimal rgb checkbox? * * @return true if decimal rgb values are to be shown */ public boolean useDecimalRGB() { return decimalRGB.isSelected(); } /** * Has the user selected the use web safe colors checkbox? * * @return true if only web safe colors are to be shown */ public boolean useWebColors() { return useWebColors.isSelected(); } /** * Set the display of the color scheme markers. * * @param disp * true to display the color scheme markers. */ public void setDisplayScheme(boolean disp) { displayScheme = disp; } /** * Get the selected colors hue * * @return the selected hue in the range 0-255 */ public int getHue() { try { return Integer.parseInt(hueEdit.getText()); } catch (NumberFormatException e) { } return 128; } /** * Set the selected hue * * @param h * the selected hue in the range 0-255 */ public void setHue(int h) { try { if (h < 0) h = 360 + h; int selHue = Math.max(0, Math.min(h, 360)); hueEdit.setText(Integer.toString(selHue)); resetColor(); } catch (NumberFormatException e) { } } /** * Get the selected colors saturation * * @return the selected saturation in the range 0-255 */ public int getSaturation() { try { return Integer.parseInt(satEdit.getText()); } catch (NumberFormatException e) { } return 128; } /** * Get the selected colors brightness * * @return the selected brightness in the range 0-255 */ public int getBrightness() { try { return Integer.parseInt(brightEdit.getText()); } catch (NumberFormatException e) { } return 128; } /** * Set the Itten color scheme to use * * @param scheme *

    *
  • -1 for no scheme display
  • *
  • 0 for a monchromatic color scheme: MONOCHROMATIC_SCHEME
  • *
  • 1 for a contrasting color scheme: CONTRASTING_SCHEME
  • *
  • 2 for a soft-contrasting color scheme: * SOFT_CONTRAST_SCHEME
  • *
  • 3 for a double contrasting color scheme: * DOUBLE_CONTRAST_SCHEME
  • *
  • 4 for a analogical color scheme: ANALOGIC_SCHEME
  • *
*/ public void setColorScheme(int scheme) { colorScheme = scheme; } /** * Change the hue to match the angle identified by the point (in the inner * circle). * * @param pt * the point within the inner circle */ boolean moveHue(Point pt) { if ((borderCircle.contains(pt) && !outerCircle.contains(pt)) || innerCircle.contains(pt)) { int h = getAngle(pt); hueEdit.setText(Integer.toString(h)); selectedPath = null; resetColor(); return true; } return false; } private int getAngle(Point pt) { int eX = (pt.x > 0) ? pt.x : 96; int eY = (pt.y > 0) ? pt.y : 96; int x = eX - 112; int y = eY - 114; return (int) (Math .round(((Math.atan2(-x, y) * 180.0 / Math.PI) + 180.0) % 360.0)); } public void setColor(Color c) { systemColor = null; if (c != null) { int r = c.getRed(); int g = c.getGreen(); int b = c.getBlue(); if (useWebColors.isSelected()) { r = Math.round(r / 51) * 51; g = Math.round(g / 51) * 51; b = Math.round(b / 51) * 51; } chooserColor = new ModelColor(r, g, b); } // else c = new Color(chooserColor.R, chooserColor.G, chooserColor.B); float[] oldValues = values; values = c.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), values); if (values[1] == 0.0F) { s = values[1]; b = values[2]; } else if (values[2] == 0.0F) { b = values[2]; } else { h = values[0]; s = values[1]; b = values[2]; } h = Math.min(Math.max(h, 0.0), 1.0); s = Math.min(Math.max(s, 0.0), 1.0); b = Math.min(Math.max(b, 0.0), 1.0); if (values[1] != 0.0F) { if (values[1] != 0.0F) setHue(); setSaturation(); } setBrightness(); busy = true; brightnessSlider.setValue(Integer.parseInt(brightEdit.getText())); saturationSlider.setValue(Integer.parseInt(satEdit.getText())); busy = false; baseColorLabel.setBackground(new Color(chooserColor.R, chooserColor.G, chooserColor.B)); if ((0.5 * c.getRed() + c.getGreen() + 0.3 * c.getBlue()) < 220.0) baseColorLabel.setForeground(Color.white); else baseColorLabel.setForeground(Color.black); String colorStr; if (decimalRGB.isSelected()) { // Output decimal values colorStr = " " + Integer.toString(c.getRed()) + "." + Integer.toString(c.getGreen()) + "." + Integer.toString(c.getBlue()); } else { // Output HEX values colorStr = " " + ModelColor.toHexString(c.getRed()) + ModelColor.toHexString(c.getGreen()) + ModelColor.toHexString(c.getBlue()); } baseColorLabel.setText(colorStr); baseColorEdit.setText(colorStr); ChangeEvent evt = new ChangeEvent(this); int numListeners = changeListeners.size(); for (int i = 0; i < numListeners; i++) { ChangeListener l = changeListeners.get(i); l.stateChanged(evt); } if (hasChooser) getColorSelectionModel().setSelectedColor(c); } /** * Get the selected color * * @return the color */ public Color getColor() { return new Color(chooserColor.R, chooserColor.G, chooserColor.B); } /** * Get the chooser color * * @param return * the chooser color */ public ModelColor getChooserColour() { return chooserColor; } /** * Set the value of the hue edit to match the current color */ private void setHue() { hueEdit.setText(Integer.toString(chooserColor.getHue())); } /** * Set the value of the saturartion edit to match the current color */ private void setSaturation() { satEdit.setText(Integer.toString((int) (100.0 * chooserColor.S))); } /** * Set the value of the brightness edit to match the current color */ private void setBrightness() { brightEdit.setText(Integer.toString((int) (100.0 * chooserColor.V))); } /** * Respond to action events for the edit fields */ public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == resetBtn) resetColorWheel(); else if (source instanceof JMenuItem) { // A popup menu item has been selected Color sysColor = getSystemColor(((JMenuItem) source).getText()); if (sysColor != null) setColor(sysColor); resetColor(); systemColor = sysColor; if (hasChooser) { hasChooser = false; getColorSelectionModel().setSelectedColor(systemColor); hasChooser = true; } return; } else if (source == useWebColors) { boolean snap = useWebColors.isSelected(); chooserColor.setWebSnap(snap); if (snap) resetColor(); else { // Drop through to the next block to reset the internal color values source = baseColorEdit; } } else if (source == baseColorEdit) { String hex = baseColorEdit.getText().trim(); if (hex.length() == 0) resetColor(); else if (decimalRGB.isSelected()) { int pos = 0; try { int r = 255; int g = 0; int b = 0; int pos2 = hex.indexOf('.', pos); if (pos2 > 0) { r = Integer.parseInt(hex.substring(pos, pos2)); pos = ++pos2; pos2 = hex.indexOf('.', pos); if (pos2 > 0) { g = Integer.parseInt(hex.substring(pos, pos2)); pos = ++pos2; if (pos2 < hex.length()) b = Integer.parseInt(hex.substring(pos)); } } setColor(new Color(r, g, b)); } catch (NumberFormatException nfe) { setColor(Color.red); baseColorEdit.setText("255.0.0"); } } else { for (int i = hex.length(); i < 6; i++) hex += "0"; try { setColor(new Color(ModelColor.hex2dec(hex.substring(0, 2)), ModelColor.hex2dec(hex.substring(2, 4)), ModelColor .hex2dec(hex.substring(4, 6)))); } catch (NumberFormatException nfe) { setColor(Color.red); baseColorEdit.setText("FF0000"); } } } else resetColor(); } /** * Reset the displayed color to the color specified by the edit fields */ private void resetColor() { if (chooserColor != null) { if (!busy) { busy = true; int h = 0; try { h = Integer.parseInt(hueEdit.getText()); selectedPath = null; } catch (NumberFormatException nfe) { hueEdit.setText("0"); } if (h >= 360) { h = h % 360; hueEdit.setText(Integer.toString(h)); } if (h < 0) { h = (int) ((h + (Math.floor(-h / 360) + 1) * 360) % 360); hueEdit.setText(Integer.toString(h)); } double s = 1.0; try { s = Integer.parseInt(satEdit.getText()) / 100.0; } catch (NumberFormatException nfe) { satEdit.setText("100"); } if (s > 1 || s < 0) { s = (s < 0) ? 0 : 1; satEdit.setText(Integer.toString((int) (s * 100.0))); } double v = 1.0; try { v = Integer.parseInt(brightEdit.getText()) / 100.0; } catch (NumberFormatException nfe) { brightEdit.setText("100"); } if (v > 1 || v < 0) { v = (v < 0) ? 0 : 1; brightEdit.setText(Integer.toString((int) (v * 100.0))); } if (shouldAdjustWheel()) { saturationMultipler = s; brightnessMultipler = v; } if (selectedIttenColours != null) selectedIttenColours[0].setHSV(h, s, v); chooserColor.setHSV(h, s, v); busy = false; } setColor(null); } } /** * Invoked when the mouse button has been clicked (pressed and released) on * a component. */ public void mouseClicked(MouseEvent e) { Object src = e.getSource(); if (src == imagePicker) { Point pt = e.getPoint(); if (borderCircle.contains(pt)) { selectedColor = rolloverColor; selectedPath = rolloverPath; if (!moveHue(pt)) { if (outerCircle.contains(pt)) { int width = imagePicker.getWidth(); int center = width / 2; int dx = Math.abs(pt.x - center); int dy = Math.abs(pt.y - center); double dr = Math.pow((dx * dx + dy * dy), 0.5); dr -= ringThickness * 1.5; int bandIdx = (int) (dr / ringThickness); int hue = 0; int bandOffset = bandIdx * ModelColor.NUM_SEGMENTS; for (int i = 0; i < ModelColor.NUM_SEGMENTS; i++) { if (paths[bandOffset + i].contains(pt)) hue = i * 15; } int hueInc = (hue / 15) % 2; // hue -= hue % 15; ModelColor mc = new ModelColor(hue, ModelColor.SATURATION_BANDS[bandIdx], ModelColor.BRIGHTNESS_BANDS[bandIdx + 1 - hueInc]); mc = new ModelColor(mc.H, saturationMultipler * mc.S, brightnessMultipler * mc.V); Color pixelColor = new Color(mc.getRed(), mc.getGreen(), mc.getBlue()); if (!pixelColor.equals(Color.white)) setColor(pixelColor); } } } } // repaint for synchronizing the hue marker if (displayScheme) imagePicker.repaint(); } /** * Invoked when a mouse button has been pressed on a component. */ public void mousePressed(MouseEvent e) { imagePicker.repaint(); } /** * Invoked when a mouse button has been released on a component. */ public void mouseReleased(MouseEvent e) { } /** * Invoked when the mouse enters a component. */ public void mouseEntered(MouseEvent e) { } /** * Invoked when the mouse exits a component. */ public void mouseExited(MouseEvent e) { rolloverPath = null; repaint(); } /** * Invoked when the mouse exits a component. */ public void mouseMoved(MouseEvent e) { GeneralPath oldPath = rolloverPath; rolloverPath = null; if (e.getSource() == imagePicker) { Point pt = e.getPoint(); if (paths != null) { int numPaths = paths.length; for (int i = 0; i < numPaths; i++) { if (paths[i].contains(pt.x, pt.y)) { rolloverPath = paths[i]; ModelColor[][] baseColors = ModelColor.getBaseColors(); int ring = i / ModelColor.NUM_SEGMENTS; ModelColor modelColor = baseColors[i % ModelColor.NUM_SEGMENTS][ring]; if (adjustRollover) modelColor = new ModelColor(modelColor.H, saturationMultipler * modelColor.S, brightnessMultipler * modelColor.V); rolloverColor = new Color(modelColor.getRed(), modelColor.getGreen(), modelColor.getBlue()); if (ring < 4) rolloverColor = rolloverColor.darker(); else rolloverColor = rolloverColor.brighter().brighter(); break; } } } } if (rolloverPath != oldPath) repaint(); } /** * Move the sliders in rsponse to the mouse wheel */ public void mouseWheelMoved(MouseWheelEvent e) { Object src = e.getSource(); ctrlKeyDown = e.isControlDown(); int notches = e.getWheelRotation(); if (src == brightnessSlider) { brightnessSlider .setValue(brightnessSlider.getValue() - 2 * notches); } else if (src == saturationSlider) { saturationSlider .setValue(saturationSlider.getValue() + 2 * notches); } else if (src == imagePicker) { setHue(getHue() + 2 * notches); } ctrlKeyDown = false; } /** * Invoked when the mouse exits a component. */ public void mouseDragged(MouseEvent e) { ctrlKeyDown = e.isControlDown(); } /** * Invoked when the target of the listener has changed its state. * * @param e * a ChangeEvent object */ public void stateChanged(ChangeEvent e) { Object source = e.getSource(); if (source == saturationSlider) { satEdit.setText(Integer.toString(saturationSlider.getValue())); resetColor(); } else if (source == brightnessSlider) { brightEdit.setText(Integer.toString(brightnessSlider.getValue())); resetColor(); } if (hasChooser) { getColorSelectionModel().setSelectedColor( new Color(chooserColor.getRed(), chooserColor.getGreen(), chooserColor.getBlue())); } ctrlKeyDown = false; } @Override protected void buildChooser() { } @Override public String getDisplayName() { return "Xoetrope Color Wheel"; } @Override public Icon getLargeDisplayIcon() { return UIManager.getIcon("ColorChooser.colorWheelIcon"); } @Override public Icon getSmallDisplayIcon() { return getLargeDisplayIcon(); } @Override public Dimension getPreferredSize() { return new Dimension(255, 328); } @Override public void updateChooser() { if (hasChooser) { Color selected = getColorFromModel(); ModelColor selectedModelColor = new ModelColor(selected.getRed(), selected.getGreen(), selected.getBlue()); setSelectedColors(new ModelColor[] { selectedModelColor }); setColor(selected); } } @Override public void installChooserPanel(JColorChooser enclosingChooser) { hasChooser = (enclosingChooser != null); super.installChooserPanel(enclosingChooser); // if runs in the color chooser, set the hue marker this.setDisplayScheme(true); } // -ColorWheel inner // class------------------------------------------------------ /** * A class that wraps the image of the color wheel and draws markers for the * selected color scheme */ class ColorWheel extends JLabel { public ColorWheel() { } /** * Draw markers for the selected color scheme */ @Override public void paintComponent(Graphics g) { super.paintComponent(g); paintWheel((Graphics2D) g); if (displayScheme) { double x, y; int selIdx = colorScheme;// > 0 ? 1 : 0; int numColours = Math.min(selIdx + 1, 4); for (int i = 0; i < numColours; i++) { double r = (selectedIttenColours[i].H - 90.0) / 360.0 * 2.0 * Math.PI; x = Math.round(111.0 + 110.0 * Math.cos(r)); y = Math.round(111.0 + 110.0 * Math.sin(r)); g.setColor(Color.gray); g.fillOval((int) x, (int) y, 4, 4); g.setColor(Color.darkGray); g.drawOval((int) x, (int) y, 4, 4); } } } public void paintWheel(Graphics2D g2d) { // Store the paths for detecting the area with the mouse click. if (paths == null) paths = new GeneralPath[ModelColor.NUM_COLOR_RINGS * ModelColor.NUM_SEGMENTS]; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); ModelColor[][] baseColors = ModelColor.getBaseColors(); int idx = 0; double width = getWidth() - 1; double center = width / 2.0; ringThickness = width / ((ModelColor.NUM_COLOR_RINGS + 2) * 2); double fontHeight = ringThickness / 2.0; double inset = ringThickness / 2.0; // Paint the outer band g2d.setColor(new Color(228, 228, 228)); Arc2D.Double innerArc = new Arc2D.Double(inset, inset, width - inset - inset, width - inset - inset, 0.0, 360.0, Arc2D.OPEN); Arc2D.Double outerArc = new Arc2D.Double(0.0, 0.0, width, width, 360.0, -360.0, Arc2D.OPEN); GeneralPath gp = new GeneralPath(); gp.append(innerArc, true); gp.append(outerArc, true); gp.closePath(); g2d.fill(gp); g2d.setColor(Color.black); g2d.setStroke(new BasicStroke(0.3F)); g2d.draw(outerArc); // Paint the inner yellow arc g2d.setColor(new Color(255, 253, 220)); innerArc = new Arc2D.Double(center - ringThickness / 2.0, center - ringThickness / 2.0, ringThickness, ringThickness, -30.0, 180.0, Arc2D.OPEN); outerArc = new Arc2D.Double(center - ringThickness, center - ringThickness, ringThickness * 2, ringThickness * 2, 150.0, -180.0, Arc2D.OPEN); gp = new GeneralPath(); gp.append(innerArc, true); gp.append(outerArc, true); gp.closePath(); g2d.fill(gp); // Paint the inner blue arc g2d.setColor(new Color(202, 230, 252)); innerArc = new Arc2D.Double(center - ringThickness / 2.0, center - ringThickness / 2.0, ringThickness, ringThickness, 150.0, 180.0, Arc2D.OPEN); outerArc = new Arc2D.Double(center - ringThickness, center - ringThickness, ringThickness * 2, ringThickness * 2, 330.0, -180.0, Arc2D.OPEN); gp = new GeneralPath(); gp.append(innerArc, true); gp.append(outerArc, true); gp.closePath(); g2d.fill(gp); // Draw the 'dial' g2d.setColor(Color.black); AffineTransform identityTransform = g2d.getTransform(); AffineTransform at = ((AffineTransform) identityTransform.clone()); at.translate(center, center); at.rotate(Math.PI / 6.0); g2d.setTransform(at); gp = new GeneralPath(); gp.moveTo((float) (-ringThickness / 2.0), 0.0F); gp.lineTo((float) (-ringThickness * 1.2), 0.0F); gp.lineTo((float) (-ringThickness * 1.2), (float) (-fontHeight)); gp.lineTo((float) (-ringThickness * 1.4), (float) (-fontHeight + ringThickness * 0.2)); gp.moveTo((float) (-ringThickness * 1.2), (float) (-fontHeight)); gp.lineTo((float) (-ringThickness), (float) (-fontHeight + ringThickness * 0.2)); g2d.draw(gp); gp = new GeneralPath(); gp.moveTo((float) (ringThickness / 2.0), 0.0F); gp.lineTo((float) (ringThickness * 1.2), 0.0F); gp.lineTo((float) (ringThickness * 1.2), (float) (fontHeight)); gp.lineTo((float) (ringThickness * 1.4), (float) (fontHeight - ringThickness * 0.2)); gp.moveTo((float) (ringThickness * 1.2), (float) (fontHeight)); gp.lineTo((float) (ringThickness), (float) (fontHeight - ringThickness * 0.2)); g2d.draw(gp); // Draw the tick marks double r1 = center; double r2 = r1 - fontHeight; double r3 = r1 - ringThickness / 2.3; double r4 = r1 + ringThickness / 2.7; // The angles for cos and sin are in radians double inc = Math.PI / 12.0; // double fullArc = Math.PI * 2.0; g2d.setColor(Color.black); for (int i = 0; i < ModelColor.NUM_SEGMENTS; i++) { double angle = i * inc; double sin = Math.sin(angle); double cos = Math.cos(angle); gp = new GeneralPath(); if ((width > 200) && (i % 2 == 0)) { AttributedString as = new AttributedString("" + (((i * 15) + 90) % 360) + "�"); as.addAttribute(TextAttribute.FAMILY, fontFamily); as.addAttribute(TextAttribute.SIZE, (float) (fontHeight)); as.addAttribute(TextAttribute.FOREGROUND, Color.black); at = ((AffineTransform) identityTransform.clone()); at.translate((center + fontHeight / 5.0 + r3 * cos), (center + r3 * sin)); at.rotate(angle + Math.PI / 2.0); g2d.setTransform(at); g2d.drawString(as.getIterator(), 0.0F, 0.0F); } else { g2d.setTransform(identityTransform); gp.moveTo((float) (center + r1 * cos), (float) (center + r1 * sin)); gp.lineTo((float) (center + r2 * cos), (float) (center + r2 * sin)); g2d.draw(gp); } } // Paint the rings / star // int pathIdx = 0; for (int i = 0; i < ModelColor.NUM_COLOR_RINGS; i++) { double outerX = inset + (ModelColor.NUM_COLOR_RINGS - (i + 1)) * ringThickness; double outerW = width - outerX - outerX; double innerX = outerX + ringThickness; double innerW = outerW - 2 * ringThickness; for (int j = 0; j < ModelColor.NUM_SEGMENTS; j++) { ModelColor modelColor = baseColors[j][i]; modelColor = new ModelColor(modelColor.H, saturationMultipler * modelColor.S, brightnessMultipler * modelColor.V); Color c = new Color(modelColor.getRed(), modelColor .getGreen(), modelColor.getBlue()); g2d.setColor(c); double startAngle = ((82.5 - (j * 15.0)) + 360) % 360.0; double delta1 = j % 2 == 0 ? arcDelta[i] : -arcDelta[i]; double delta2 = j % 2 == 0 ? arcDelta[i + 1] : -arcDelta[i + 1]; innerArc = new Arc2D.Double(innerX, innerX, innerW, innerW, startAngle + delta1, 15.0 - 2.0 * delta1, Arc2D.OPEN); outerArc = new Arc2D.Double(outerX, outerX, outerW, outerW, startAngle + 15.0 - delta2, -15.0 + 2.0 * delta2, Arc2D.OPEN); gp = new GeneralPath(); gp.append(innerArc, true); gp.append(outerArc, true); gp.closePath(); g2d.fill(gp); paths[idx++] = gp; } } // Paint the labels g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); if (width > 200) { double angle = (Math.PI / 6.0) - (Math.PI / 2.0); double angle2 = angle - 0.055; double sin = Math.sin(angle2); double cos = Math.cos(angle2); AttributedString as = new AttributedString(getLabel( "Xoetrope.warm", "WARM")); as.addAttribute(TextAttribute.FAMILY, fontFamily); as.addAttribute(TextAttribute.SIZE, (float) (ringThickness / 1.5)); as.addAttribute(TextAttribute.FOREGROUND, new Color(92, 0, 0)); at = ((AffineTransform) identityTransform.clone()); at.translate((center + fontHeight / 5.0 + r4 * cos), (center + r4 * sin)); at.rotate(angle + Math.PI / 2.0 + 0.05); g2d.setTransform(at); g2d.drawString(as.getIterator(), 0.0F, 0.0F); angle += Math.PI; sin = Math.sin(angle); cos = Math.cos(angle); as = new AttributedString(getLabel("Xoetrope.cold", "COLD")); as.addAttribute(TextAttribute.FAMILY, fontFamily); as.addAttribute(TextAttribute.SIZE, (float) (ringThickness / 1.5)); as.addAttribute(TextAttribute.FOREGROUND, new Color(0, 0, 92)); at = ((AffineTransform) identityTransform.clone()); at.translate((center + fontHeight / 5.0 + r4 * cos), (center + r4 * sin)); at.rotate(angle + Math.PI / 2.0 + 0.05); g2d.setTransform(at); g2d.drawString(as.getIterator(), 0.0F, 0.0F); angle = Math.PI; sin = Math.sin(angle); cos = Math.cos(angle); as = new AttributedString(getLabel("Xoetrope.saturation", "Saturation")); as.addAttribute(TextAttribute.FAMILY, fontFamily); as.addAttribute(TextAttribute.SIZE, (float) (ringThickness / 1.3)); as.addAttribute(TextAttribute.FOREGROUND, UIManager .getColor("Label.foreground")); at = ((AffineTransform) identityTransform.clone()); at.translate((width - fontHeight), (width)); at.rotate(angle + Math.PI / 2.0); g2d.setTransform(at); g2d.drawString(as.getIterator(), 0.0F, 0.0F); String brightnessText = getLabel("Xoetrope.brightness", "Brightness"); as = new AttributedString(brightnessText); as.addAttribute(TextAttribute.FAMILY, fontFamily); as.addAttribute(TextAttribute.SIZE, (float) (ringThickness / 1.3)); as.addAttribute(TextAttribute.FOREGROUND, UIManager .getColor("Label.foreground")); at = ((AffineTransform) identityTransform.clone()); at.translate((width - fontHeight), (ringThickness * brightnessText.length() / 2.3)); at.rotate(angle + Math.PI / 2.0); g2d.setTransform(at); g2d.drawString(as.getIterator(), 0.0F, 0.0F); } g2d.setTransform(identityTransform); if (showRollovers) { g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); if (rolloverPath != null) { g2d.setColor(rolloverColor); g2d.setStroke(new BasicStroke(1.5F)); g2d.draw(rolloverPath); } if (selectedPath != null) { g2d.setColor(selectedColor); g2d.setStroke(new BasicStroke(1.0F)); g2d.draw(selectedPath); } } } } // End ColorWheel inner class // ------------------------------------------------ // ---------------------------------------------------------------------------- private class ColorDocumentListener implements DocumentListener { private JTextField originator; private static final String MARKER = "Xoetrope.XUI.ColorWheel.DocumentEvent"; public ColorDocumentListener(JTextField originator) { this.originator = originator; } /** * This method is called after an insert into the document */ public void insertUpdate(DocumentEvent evt) { synchronize(evt); } /** * This method is called after a removal from the document */ public void removeUpdate(DocumentEvent evt) { synchronize(evt); } /** * This method is called after one or more attributes have changed. This * method is not called when characters are inserted with attributes. */ public void changedUpdate(DocumentEvent evt) { synchronize(evt); } public void synchronize(DocumentEvent evt) { boolean _hasAllValues = true; if (hueEdit.getText().length() == 0) _hasAllValues = false; if (brightEdit.getText().length() == 0) _hasAllValues = false; if (satEdit.getText().length() == 0) _hasAllValues = false; final boolean hasAllValues = _hasAllValues; SwingUtilities.invokeLater(new Runnable() { public void run() { useWebColors.setEnabled(hasAllValues); decimalRGB.setEnabled(hasAllValues); } }); SwingUtilities.invokeLater(new Runnable() { public void run() { // the below use of client property is to prevent // infinite event loop (resetColor evetually changes // the text boxes) if (hasAllValues && originator.hasFocus()) { if (Boolean.TRUE.equals(originator .getClientProperty(MARKER))) { originator.putClientProperty(MARKER, null); } else { originator.putClientProperty(MARKER, Boolean.TRUE); resetColor(); } } // repaint for synchronizing the hue marker if (displayScheme) imagePicker.repaint(); } }); } } // ---------------------------------------------------------------------------- public static void setLabelBundle(ResourceBundle labelBundle) { ColorWheelPanel.labelBundle = labelBundle; } private static String getLabel(String labelName, String defaultValue) { if (ColorWheelPanel.labelBundle == null) return defaultValue; try { return ColorWheelPanel.labelBundle.getString(labelName); } catch (MissingResourceException mre) { return defaultValue; } } /** * Show a popup menu with the list of system colors * * @param p * the location to display the popup */ private void showSystemColorList(Point p) { JPopupMenu popupMenu = new JPopupMenu(); String[] systemColors = { "activeCaption", "desktop", "activeCaptionText", "activeCaptionBorder", "inactiveCaption", "inactiveCaptionText", "inactiveCaptionBorder", "window", "windowBorder", "windowText", "menu", "menuText", "text", "textText", "textHighlight", "textHighlightText", "textInactiveText", "control", "controlText", "controlHighlight", "controlLtHighlight", "controlShadow", "controlDkShadow", "scrollbar", "info", "infoText", "white", "lightGray", "gray", "darkGray", "black", "red", "pink", "orange", "yellow", "green", "magenta", "cyan", "blue" }; for (int i = 0; i < systemColors.length; i++) { if (systemColors[i].equals("white")) { popupMenu.addSeparator(); continue; } JMenuItem mi = new JMenuItem(systemColors[i]); mi.addActionListener(this); BufferedImage image = new BufferedImage(8, 8, BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); g.setColor(getSystemColor(systemColors[i])); g.fillRect(0, 0, 8, 8); g.setColor(SystemColor.windowBorder); g.drawRect(0, 0, 7, 7); g.dispose(); Icon icon = new ImageIcon(image); mi.setIcon(icon); popupMenu.add(mi); } popupMenu.show(this, p.x, p.y); } /** * Get the named system color * * @param name * the color name * @retrun the color value or null if the name is not recognized */ public Color getSystemColor(String temp) { Color clr = null; if (temp.equals("activeCaption")) clr = SystemColor.activeCaption; else if (temp.equals("desktop")) clr = SystemColor.desktop; else if (temp.equals("activeCaptionText")) clr = SystemColor.activeCaptionText; else if (temp.equals("activeCaptionBorder")) clr = SystemColor.activeCaptionBorder; else if (temp.equals("inactiveCaption")) clr = SystemColor.inactiveCaption; else if (temp.equals("inactiveCaptionText")) clr = SystemColor.inactiveCaptionText; else if (temp.equals("inactiveCaptionBorder")) clr = SystemColor.inactiveCaptionBorder; else if (temp.equals("window")) clr = SystemColor.window; else if (temp.equals("windowBorder")) clr = SystemColor.windowBorder; else if (temp.equals("windowText")) clr = SystemColor.windowText; else if (temp.equals("menu")) clr = SystemColor.menu; else if (temp.equals("menuText")) clr = SystemColor.menuText; else if (temp.equals("text")) clr = SystemColor.text; else if (temp.equals("textText")) clr = SystemColor.textText; else if (temp.equals("textHighlight")) clr = SystemColor.textHighlight; else if (temp.equals("textHighlightText")) clr = SystemColor.textHighlightText; else if (temp.equals("textInactiveText")) clr = SystemColor.textInactiveText; else if (temp.equals("control")) clr = SystemColor.control; else if (temp.equals("controlText")) clr = SystemColor.controlText; else if (temp.equals("controlHighlight")) clr = SystemColor.controlHighlight; else if (temp.equals("controlLtHighlight")) clr = SystemColor.controlLtHighlight; else if (temp.equals("controlShadow")) clr = SystemColor.controlShadow; else if (temp.equals("controlDkShadow")) clr = SystemColor.controlDkShadow; else if (temp.equals("scrollbar")) clr = SystemColor.scrollbar; else if (temp.equals("info")) clr = SystemColor.info; else if (temp.equals("infoText")) clr = SystemColor.infoText; else if (temp.equals("white")) clr = Color.white; else if (temp.equals("lightGray")) clr = Color.lightGray; else if (temp.equals("gray")) clr = Color.gray; else if (temp.equals("darkGray")) clr = Color.darkGray; else if (temp.equals("black")) clr = Color.black; else if (temp.equals("red")) clr = Color.red; else if (temp.equals("pink")) clr = Color.pink; else if (temp.equals("orange")) clr = Color.orange; else if (temp.equals("yellow")) clr = Color.yellow; else if (temp.equals("green")) clr = Color.green; else if (temp.equals("magenta")) clr = Color.magenta; else if (temp.equals("cyan")) clr = Color.green; else if (temp.equals("blue")) clr = Color.blue; return clr; } /** * Should the color wheeel's colors be adjusted * * @return true if the colors should change to match the brightness and * saturation */ private boolean shouldAdjustWheel() { if (adjustWheel == NEVER_ADJUST) return false; else if (adjustWheel == ALWAYS_ADJUST) return true; else if (ctrlKeyDown) return true; return false; } /** * Get the adjust color wheel flag. * * @return the adjustment mode */ public int getAdjustWheel() { return adjustWheel; } /** * Set the adjust color wheel flag. * * @param state * the color wheel's new adjustment mode ( CTRL_ADJUST | * ALWAYS_ADJUST | NEVER_ADJUST ); */ public void setAdjustWheel(int state) { adjustWheel = state; } /** * Get the adjust rollover color flag. * * @return the adjustment mode */ public boolean getRollover() { return adjustRollover; } /** * Set the adjust rollover color flag. * * @param state * the rollover's new adjustment mode ( true | false ); */ public void setRollover(boolean state) { adjustRollover = state; } /** * Reset the brightness and saturation multipliers for the ColorWheel. */ public void resetColorWheel() { saturationMultipler = brightnessMultipler = 1.0; resetColor(); } }substance-5.3.orig/src/contrib/net/xoetrope/editor/color/ModelColor.java0000644000175000017500000002117311213253274026377 0ustar drazzibdrazzibpackage contrib.net.xoetrope.editor.color; import java.awt.Color; /** * A RYB Color model $Revision: 1.11 $ */ public class ModelColor { public static final int NUM_COLOR_RINGS = 7; public static final int NUM_SEGMENTS = 24; protected boolean webSnap = false; private static ModelColor[][] baseColors; protected int R, G, B; protected double H, S, V; protected double rgbMinValue, rgbMaxValue; public static double[] SATURATION_BANDS = { 0.4, 0.6, 0.8, 1.0, 1.0, 1.0, 1.0 }; public static double[] BRIGHTNESS_BANDS = { 1.0, 1.0, 1.0, 1.0, 1.0, 0.85, 0.65, 0.45 }; /** * Create a new ModelColor * * @param R * the red value in the range 0-255 * @param G * the green value in the range 0-255 * @param B * the blue value in the range 0-255 */ public ModelColor(int R, int G, int B) { this(R, G, B, -1); } public ModelColor(double H, double S, double V) { setHSV(H, S, V); } /** * Create a new ModelColor * * @param R * the red value in the range 0-255 * @param G * the green value in the range 0-255 * @param B * the blue value in the range 0-255 * @param H * the hue value in the range 0-255 */ public ModelColor(int R, int G, int B, int H) { initColorWheel(); setRGB(R, G, B, H); } /** * Creates a copy of an ModelColor * * @param c * the ModelColor to copy */ public ModelColor(ModelColor c) { initColorWheel(); R = c.R; G = c.G; B = c.B; H = c.H; S = c.S; V = c.V; getRgbMinMaxValues(); } /** * Get the red value * * @return the red value in the range 0-255 */ public int getRed() { return R; } /** * Get the green value * * @return the green value in the range 0-255 */ public int getGreen() { return G; } /** * Get the blue value * * @return the blue value in the range 0-255 */ public int getBlue() { return B; } /** * Get the hue value * * @return the hue value in the range 0-255 */ public int getHue() { return (int) Math.floor(H + 0.5); } /** * Get the hue value * * @return the hue value in the range 0-255 */ public double getH() { return H; } /** * Get the saturation value * * @return the saturation value in the range 0.0-1.0 */ public double getSaturation() { return S; } /** * Get the brightness value * * @return the brightness value in the range 0.0-1.0 */ public double getBrightness() { return V; } /** * Set an RGB color * * @param R * the red value in the range 0-255 * @param G * the green value in the range 0-255 * @param B * the blue value in the range 0-255 */ public void setRGB(int R, int G, int B) { setRGB(R, G, B, -1); } /** * Set an RGB color * * @param R * the red value in the range 0-255 * @param G * the green value in the range 0-255 * @param B * the blue value in the range 0-255 * @param H * the hue value in the range 0-255 */ public void setRGB(int r, int g, int b, int h) { if (webSnap) { R = Math.round(r / 51) * 51; G = Math.round(g / 51) * 51; B = Math.round(b / 51) * 51; } else { R = r; G = g; B = b; } checkRange(); getRgbMinMaxValues(); if (h > -1) { H = h; S = (rgbMaxValue > 0) ? (rgbMaxValue - rgbMinValue) / rgbMaxValue : 0; V = rgbMaxValue / 255; } else if ((R == G) && (G == B)) { H = 0; S = 0; V = rgbMaxValue / 255; } else calculateHSVfromRGB(); } /** * Set the color to a HSV value * * @param _h * the hue * @param _s * the saturation * @param _v * the value */ public void setHSV(double _h, double _s, double _v) { if (Math.abs(H - _h) > 0.499999) H = _h; if (Math.abs(S - _s) > 0.009999) S = _s; if (Math.abs(V - _v) > 0.009999) V = _v; if ((S > 1.0) || (S < 0.0)) S = (S < 0.0) ? 0.0 : 1.0; if ((V > 1.0) || (V < 0.0)) V = (V < 0.0) ? 0.0 : 1.0; calculateRGBfromHSV(); } /** * Check that the RGB values are in range */ private void checkRange() { if (R > 255) R = 255; if (G > 255) G = 255; if (B > 255) B = 255; if (webSnap) { R = Math.round(R / 51) * 51; G = Math.round(G / 51) * 51; B = Math.round(B / 51) * 51; } } /** * Get the minimum and maximum of the RGB values. */ private void getRgbMinMaxValues() { rgbMaxValue = Math.max(Math.max(R, G), B); rgbMinValue = Math.min(Math.min(R, G), B); } private void calculateHSVfromRGB() { // Find the two base colors boolean exactMatch = false; outer: for (int j = 0; j < NUM_COLOR_RINGS; j++) { if (j == 6) j = 6; for (int i = 0; i < 360; i += 15) { ModelColor c = baseColors[i / 15][j]; if ((R == c.R) && (G == c.G) && (B == c.B)) { exactMatch = true; H = c.H; S = (rgbMaxValue > 0) ? 1.0 * (rgbMaxValue - rgbMinValue) / rgbMaxValue : 0.0; V = rgbMaxValue / 255.0; break outer; } } } if (!exactMatch) { // Red-Green-Blue to Red-Yellow-Blue // degrees // R = 0 R = 0 // Y = 60 Y = 120 // G = 120 G = 180 // B == 240 B = 240 // Fractional values = degrees / 360.0 float values[] = new float[3]; values = Color.RGBtoHSB(R, G, B, values); float h = values[0]; S = (rgbMaxValue > 0) ? 1.0 * (rgbMaxValue - rgbMinValue) / rgbMaxValue : 0.0; V = rgbMaxValue / 255.0; if (h < 0.1666668f) h *= 2.0f; else if (h < 0.3333334f) h += 0.1666667f; else if (h < 0.6666668f) h = h + 0.1666667f * ((0.6666667f - h) / 0.3333334f); H = 360.0 * h; } } private void calculateRGBfromHSV() { // Red-Green-Blue to Red-Yellow-Blue // degrees degrees // R = 0 R = 0 // Y = 60 Y = 120 // G = 120 G = 180 // B == 240 B = 240 // Fractional values = degrees / 360.0 double h = H / 360.0; if (h < 0.3333334) h /= 2.0; else if (h < 0.5000001) h -= 0.1666667; else if (h < 0.6666668) h = 2.0 * h - 0.6666667; Color c = new Color(Color.HSBtoRGB((float) h, (float) S, (float) V)); R = c.getRed(); G = c.getGreen(); B = c.getBlue(); checkRange(); getRgbMinMaxValues(); } /** * Rotate this color by a specified amount * * @param angle * the angle by which to move this color (hue) */ public void rotate(int angle) { if ((S > 0) && (V > 0)) { double newHue = (H + angle) % 360.0; setHSV(newHue, S, V);// S * S1 / S2, V * V1 / V2 ); } } /** * Set the snap to web colors setting * * @param snapTo * true to snap to web colors */ public void setWebSnap(boolean snapTo) { webSnap = snapTo; } /** * Convert a decimal rgb value to a hexadecimal value * * @param n * the decimal value * @return the hex value */ public static String dec2hex(int n) { String s = Integer.toHexString(n); if (s.length() < 2) s = "0" + s; return s.toUpperCase(); } /** * Convert a hexadecimal rgb value to a decimal value * * @param n * the hex value * @return the decimal value */ public static int hex2dec(String n) { if (n.length() == 0) return 0; return Integer.parseInt(n, 16); } /** * Get a two letter hex string for the decimal value in the range 0-255 */ public static String toHexString(int value) { String hex = Integer.toHexString(value).toUpperCase(); if (hex.length() < 2) return "0" + hex; return hex; } /** * Get a grayscale hex value for an rgb color * * @param r * the red value * @param g * the green value * @param b * the blue value * @return the hex value */ public static String col2Gray(double r, double g, double b) { double lum = Math.round(r * 0.299 + g * 0.587 + b * 0.114); return dec2hex((int) lum) + dec2hex((int) lum) + dec2hex((int) lum); } public static ModelColor[][] getBaseColors() { initColorWheel(); return baseColors; } private static void initColorWheel() { if (baseColors == null) { baseColors = new ModelColor[24][NUM_COLOR_RINGS]; int idx = 0; for (int i = 0; i < NUM_COLOR_RINGS; i++) { for (int j = 0; j < 24; j++) { baseColors[j][i] = new ModelColor(15.0 * j, SATURATION_BANDS[i], BRIGHTNESS_BANDS[i + 1 - (j % 2)]); idx++; } } } } } substance-5.3.orig/src/contrib/ch/0000755000175000017500000000000010570313706017026 5ustar drazzibdrazzibsubstance-5.3.orig/src/contrib/ch/randelshofer/0000755000175000017500000000000010570313706021502 5ustar drazzibdrazzibsubstance-5.3.orig/src/contrib/ch/randelshofer/quaqua/0000755000175000017500000000000011256731144023001 5ustar drazzibdrazzibsubstance-5.3.orig/src/contrib/ch/randelshofer/quaqua/QuaquaUtilities.java0000644000175000017500000007031310564356426027010 0ustar drazzibdrazzib/* * @(#)QuaquaUtilities.java 3.1 2006-09-04 * * Copyright (c) 2003-2006 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua; import java.applet.*; import java.awt.*; import java.awt.event.*; import java.awt.font.*; import java.awt.image.*; import java.awt.peer.*; import java.net.*; import javax.swing.*; import javax.swing.text.*; import javax.swing.border.*; import javax.swing.plaf.*; import javax.swing.plaf.basic.*; import contrib.ch.randelshofer.quaqua.util.*; /** * Utility class for the Quaqua LAF. * * @author Werner Randelshofer, Staldenmattweg 2, CH-6405 Immensee, Switzerland * @version 3.1 2006-09-04 Added method compositeRequestFocus. *
3.0.5 2006-08-20 Method endGraphics must not set * KEY_TEXT_ANTIALIASING to null. *
3.0.4 2006-02-19 Catch Throwable in method setWindowAlpha instead * of catching NoSuchMethodException. *
3.0.3 2006-01-08 Don't set Window alpha, when running on * Java 1.4.2_05 on Mac OS X 10.3.5. Because this only has the effect of turning * the background color of the Window to white. *
3.0.2 2005-12-10 Method isOnActiveWindow() did not reliably * return true. *
3.0.1 2005-11-12 Fixed NPE in method repaint border. *
3.0 2005-09-24 Removed all reflection helper methods. Moved Sheet * helper methods out into class Sheets. *
2.6 2005-09-17 Method isOnFocusedWindow returns true, if * the window returns false on "getFocusableWindowState". *
2.5 2005-03-13 Renamed method isFrameActive to isOnActiveFrame. *
2.4 2004-12-28 Method createBufferdImage added. Method * isOnActiveWindow() renamed to isFrameActive(). *
2.3 2004-12-14 Method getUI added. *
2.2.1 2004-12-01 Methods setDragEnabled and getDragEnabled never * worked because the attempted to get method objects on the wrong class. *
2.2 2004-09-19 Refined algorithm of method isFrameActive. *
2.1 2004-07-04 Methods repaintBorder, beginFont, endFont and * isFocused added. *
2.0 2004-04-27 Renamed from QuaquaGraphicUtils to QuaquaUtilities. * Added method isFrameActive(Component). *
1.1.1 2003-10-08 Diagnostic output to System.out removed. *
1.1 2003-10-05 Methods getModifiersText and getModifiersUnicode * added. *
1.0 2003-07-19 Created. */ public class QuaquaUtilities extends BasicGraphicsUtils implements SwingConstants { /** Prevent instance creation. */ private QuaquaUtilities() { } /* * Convenience function for determining ComponentOrientation. Helps us * avoid having Munge directives throughout the code. */ public static boolean isLeftToRight( Component c ) { return c.getComponentOrientation().isLeftToRight(); } /** * Draw a string with the graphics g at location * (x, y) * just like g.drawString would. * The character at index underlinedIndex * in text will be underlined. If index is beyond the * bounds of text (including < 0), nothing will be * underlined. * * @param g Graphics to draw with * @param text String to draw * @param underlinedIndex Index of character in text to underline * @param x x coordinate to draw at * @param y y coordinate to draw at * @since 1.4 */ public static void drawStringUnderlineCharAt(Graphics g, String text, int underlinedIndex, int x,int y) { g.drawString(text,x,y); if (underlinedIndex >= 0 && underlinedIndex < text.length() ) { FontMetrics fm = g.getFontMetrics(); int underlineRectX = x + fm.stringWidth(text.substring(0,underlinedIndex)); int underlineRectY = y; int underlineRectWidth = fm.charWidth(text.charAt(underlinedIndex)); int underlineRectHeight = 1; g.fillRect(underlineRectX, underlineRectY + fm.getDescent() - 1, underlineRectWidth, underlineRectHeight); } } /** * Returns index of the first occurrence of mnemonic * within string text. Matching algorithm is not * case-sensitive. * * @param text The text to search through, may be null * @param mnemonic The mnemonic to find the character for. * @return index into the string if exists, otherwise -1 */ static int findDisplayedMnemonicIndex(String text, int mnemonic) { if (text == null || mnemonic == '\0') { return -1; } char uc = Character.toUpperCase((char)mnemonic); char lc = Character.toLowerCase((char)mnemonic); int uci = text.indexOf(uc); int lci = text.indexOf(lc); if (uci == -1) { return lci; } else if(lci == -1) { return uci; } else { return (lci < uci) ? lci : uci; } } /** * Returns true if the component is on a Dialog or a Frame, which is active, * or if it is on a Window, which is focused. * Always returns true, if the component has no parent window. */ public static boolean isOnActiveWindow(Component c) { // In the RootPaneUI, we set a client property on the whole component // tree, if the ancestor Frame gets activated or deactivated. if (c instanceof JComponent) { Boolean value = (Boolean) ((JComponent) c).getClientProperty("Frame.active"); // Unfortunately, the value is not always reliable. // Therefore we can only do a short circuit, if the value is true. if (value != null && value.booleanValue()) { return true; //return value.booleanValue(); } } /* // This is how I would have implemented the code, if Quaqua would // not be required to work an a Java 1.3 VM. Window window = SwingUtilities.getWindowAncestor(c); if (window == null) { return true; } else if ((window instanceof Frame) || (window instanceof Dialog)) { return window.isActive(); } else { if (window.getFocusableWindowState()) { return window.isFocused(); } else { return true; } } */ // If we missed the client property or if it was false, we have to // figure out the activation state on our own. // The following code works from Java 1.3 onwards. Window window = SwingUtilities.getWindowAncestor(c); boolean isOnActiveWindow; if (window == null) { isOnActiveWindow = true; } else if ((window instanceof Frame) || (window instanceof Dialog)) { isOnActiveWindow = Methods.invokeGetter(window, "isActive", true); } else { if (Methods.invokeGetter(window, "getFocusableWindowState", true)) { isOnActiveWindow = Methods.invokeGetter(window, "isFocused", true); } else { isOnActiveWindow = true; } } // In case the activation property is true, we fix the value of the // client property, so that we can do a short circuit next time. if (isOnActiveWindow && (c instanceof JComponent)) { ((JComponent) c).putClientProperty("Frame.active", new Boolean(isOnActiveWindow)); } return isOnActiveWindow; } /** * Returns a Mac OS X specific String describing the modifier key(s), * such as "Shift", or "Ctrl+Shift". * * @return string a text description of the combination of modifier * keys that were held down during the event */ public static String getKeyModifiersText(int modifiers, boolean leftToRight) { return getKeyModifiersUnicode(modifiers, leftToRight); } static String getKeyModifiersUnicode(int modifiers, boolean leftToRight) { char[] cs = new char[4]; int count = 0; if (leftToRight) { if ((modifiers & InputEvent.CTRL_MASK) != 0) cs[count++] = '\u2303'; // Unicode: UP ARROWHEAD if ((modifiers & (InputEvent.ALT_MASK | InputEvent.ALT_GRAPH_MASK)) != 0) cs[count++] = '\u2325'; // Unicode: OPTION KEY if ((modifiers & InputEvent.SHIFT_MASK) != 0) cs[count++] = '\u21e7'; // Unicode: UPWARDS WHITE ARROW if ((modifiers & InputEvent.META_MASK) != 0) cs[count++] = '\u2318'; // Unicode: PLACE OF INTEREST SIGN } else { if ((modifiers & InputEvent.META_MASK) != 0) cs[count++] = '\u2318'; // Unicode: PLACE OF INTEREST SIGN if ((modifiers & InputEvent.SHIFT_MASK) != 0) cs[count++] = '\u21e7'; // Unicode: UPWARDS WHITE ARROW if ((modifiers & (InputEvent.ALT_MASK | InputEvent.ALT_GRAPH_MASK)) != 0) cs[count++] = '\u2325'; // Unicode: OPTION KEY if ((modifiers & InputEvent.CTRL_MASK) != 0) cs[count++] = '\u2303'; // Unicode: UP ARROWHEAD } return new String(cs, 0, count); } public static void repaintBorder(JComponent component) { JComponent c = component; Border border = null; Container container = component.getParent(); if (container instanceof JViewport) { c = (JComponent) container.getParent(); if (c != null) { border = c.getBorder(); } } if (border == null) { border = component.getBorder(); c = component; } if (border != null && c != null) { int w = c.getWidth(); int h = c.getHeight(); Insets insets = c.getInsets(); c.repaint(0, 0, w, insets.top); c.repaint(0, 0, insets.left, h); c.repaint(0, h - insets.bottom, w, insets.bottom); c.repaint(w - insets.right, 0, insets.right, h); } } public static final Object beginGraphics(Graphics2D graphics2d) { Object object = graphics2d.getRenderingHint(RenderingHints .KEY_TEXT_ANTIALIASING); graphics2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); return object; } public static final void endGraphics(Graphics2D graphics2d, Object oldHints) { if (oldHints != null) { graphics2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, oldHints); } } public static final boolean isFocused(Component component) { if (QuaquaUtilities.isOnActiveWindow(component)) { Component c = component; if (c instanceof JComponent) { if (c instanceof JScrollPane) { JViewport viewport = ((JScrollPane) component).getViewport(); if (viewport != null) { c = viewport.getView(); } } if (c instanceof JTextComponent && !((JTextComponent) c).isEditable()) { return false; } return c != null && (((JComponent) c).hasFocus() || ((JComponent) c).getClientProperty("Quaqua.drawFocusBorder") == Boolean.TRUE); } } return false; } static boolean isHeadless() { return Methods.invokeStaticGetter(GraphicsEnvironment.class, "isHeadless", false); } public static int getLeftSideBearing(Font f, String string) { return ((Integer) Methods.invokeStatic( "com.sun.java.swing.SwingUtilities2", "getLeftSideBearing", new Class[] {Font.class, String.class}, new Object[] {f, string}, new Integer(0))).intValue(); } /** * Invoked when the user attempts an invalid operation, * such as pasting into an uneditable JTextField * that has focus. The default implementation beeps. Subclasses * that wish different behavior should override this and provide * the additional feedback. * * @param component Component the error occured in, may be null * indicating the error condition is not directly * associated with a Component. */ static void provideErrorFeedback(Component component) { Toolkit toolkit = null; if (component != null) { toolkit = component.getToolkit(); } else { toolkit = Toolkit.getDefaultToolkit(); } toolkit.beep(); } // provideErrorFeedback() public static BufferedImage createBufferedImage(URL location) { Image image = Toolkit.getDefaultToolkit().createImage(location); BufferedImage buf; if (image instanceof BufferedImage) { buf = (BufferedImage) image; } else { loadImage(image); //buf = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB); buf = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(image.getWidth(null), image.getHeight(null), Transparency.OPAQUE); Graphics g = buf.getGraphics(); g.drawImage(image, 0, 0, null); g.dispose(); image.flush(); } return buf; } public static TexturePaint createTexturePaint(URL location) { BufferedImage texture = createBufferedImage(location); TexturePaint paint = new TexturePaint(texture, new Rectangle(0, 0, texture.getWidth(), texture.getHeight())); return paint; } /** * Loads the image, returning only when the image is loaded. * @param image the image */ private static void loadImage(Image image) { Component component = new Component() {}; MediaTracker tracker = new MediaTracker(component); synchronized (tracker) { int id = 0; tracker.addImage(image, id); try { tracker.waitForID(id, 0); } catch (InterruptedException e) { System.out.println("INTERRUPTED while loading Image"); } int loadStatus = tracker.statusID(id, false); tracker.removeImage(image, id); } } /** * Compute and return the location of the icons origin, the * location of origin of the text baseline, and a possibly clipped * version of the compound labels string. Locations are computed * relative to the viewR rectangle. * The JComponents orientation (LEADING/TRAILING) will also be taken * into account and translated into LEFT/RIGHT values accordingly. */ public static String layoutCompoundLabel(JComponent c, FontMetrics fm, String text, Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, Rectangle viewR, Rectangle iconR, Rectangle textR, int textIconGap) { boolean orientationIsLeftToRight = true; int hAlign = horizontalAlignment; int hTextPos = horizontalTextPosition; if (c != null) { if (!(c.getComponentOrientation().isLeftToRight())) { orientationIsLeftToRight = false; } } // Translate LEADING/TRAILING values in horizontalAlignment // to LEFT/RIGHT values depending on the components orientation switch (horizontalAlignment) { case LEADING: hAlign = (orientationIsLeftToRight) ? LEFT : RIGHT; break; case TRAILING: hAlign = (orientationIsLeftToRight) ? RIGHT : LEFT; break; } // Translate LEADING/TRAILING values in horizontalTextPosition // to LEFT/RIGHT values depending on the components orientation switch (horizontalTextPosition) { case LEADING: hTextPos = (orientationIsLeftToRight) ? LEFT : RIGHT; break; case TRAILING: hTextPos = (orientationIsLeftToRight) ? RIGHT : LEFT; break; } return layoutCompoundLabelImpl(c, fm, text, icon, verticalAlignment, hAlign, verticalTextPosition, hTextPos, viewR, iconR, textR, textIconGap); } /** * Compute and return the location of the icons origin, the * location of origin of the text baseline, and a possibly clipped * version of the compound labels string. Locations are computed * relative to the viewR rectangle. * This layoutCompoundLabel() does not know how to handle LEADING/TRAILING * values in horizontalTextPosition (they will default to RIGHT) and in * horizontalAlignment (they will default to CENTER). * Use the other version of layoutCompoundLabel() instead. */ public static String layoutCompoundLabel( FontMetrics fm, String text, Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, Rectangle viewR, Rectangle iconR, Rectangle textR, int textIconGap) { return layoutCompoundLabelImpl(null, fm, text, icon, verticalAlignment, horizontalAlignment, verticalTextPosition, horizontalTextPosition, viewR, iconR, textR, textIconGap); } /** * Compute and return the location of the icons origin, the * location of origin of the text baseline, and a possibly clipped * version of the compound labels string. Locations are computed * relative to the viewR rectangle. * This layoutCompoundLabel() does not know how to handle LEADING/TRAILING * values in horizontalTextPosition (they will default to RIGHT) and in * horizontalAlignment (they will default to CENTER). * Use the other version of layoutCompoundLabel() instead. * * This is the same as SwingUtilities.layoutCompoundLabelImpl, except for * the algorithm for clipping the text. If a text is too long, "..." are * inserted at the middle of the text instead of at the end. */ private static String layoutCompoundLabelImpl( JComponent c, FontMetrics fm, String text, Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, Rectangle viewR, Rectangle iconR, Rectangle textR, int textIconGap) { /* Initialize the icon bounds rectangle iconR. */ if (icon != null) { iconR.width = icon.getIconWidth(); iconR.height = icon.getIconHeight(); } else { iconR.width = iconR.height = 0; } /* Initialize the text bounds rectangle textR. If a null * or and empty String was specified we substitute "" here * and use 0,0,0,0 for textR. */ boolean textIsEmpty = (text == null) || text.equals(""); int lsb = 0; View v = null; if (textIsEmpty) { textR.width = textR.height = 0; text = ""; } else { v = (c != null) ? (View) c.getClientProperty("html") : null; if (v != null) { textR.width = (int) v.getPreferredSpan(View.X_AXIS); textR.height = (int) v.getPreferredSpan(View.Y_AXIS); } else { textR.width = SwingUtilities.computeStringWidth(fm,text); lsb = getLeftSideBearing(fm.getFont(), text); if (lsb < 0) { // If lsb is negative, add it to the width, the // text bounds will later be adjusted accordingly. textR.width -= lsb; } textR.height = fm.getHeight(); } } /* Unless both text and icon are non-null, we effectively ignore * the value of textIconGap. The code that follows uses the * value of gap instead of textIconGap. */ int gap = (textIsEmpty || (icon == null)) ? 0 : textIconGap; if (!textIsEmpty) { /* If the label text string is too wide to fit within the available * space "..." and as many characters as will fit will be * displayed instead. */ int availTextWidth; if (horizontalTextPosition == CENTER) { availTextWidth = viewR.width; } else { availTextWidth = viewR.width - (iconR.width + gap); } if (textR.width > availTextWidth) { if (v != null) { textR.width = availTextWidth; } else { String clipString = "..."; int totalWidth = SwingUtilities.computeStringWidth(fm,clipString); int nChars; int len = text.length(); for(nChars = 0; nChars < len; nChars++) { int charIndex = (nChars % 2 == 0) ? nChars / 2 : len - 1 - nChars / 2; totalWidth += fm.charWidth(text.charAt(charIndex)); if (totalWidth > availTextWidth) { break; } } text = text.substring(0, nChars / 2) + clipString + text.substring(len - nChars / 2); textR.width = SwingUtilities.computeStringWidth(fm,text); } } } /* Compute textR.x,y given the verticalTextPosition and * horizontalTextPosition properties */ if (verticalTextPosition == TOP) { if (horizontalTextPosition != CENTER) { textR.y = 0; } else { textR.y = -(textR.height + gap); } } else if (verticalTextPosition == CENTER) { textR.y = (iconR.height / 2) - (textR.height / 2); } else { // (verticalTextPosition == BOTTOM) if (horizontalTextPosition != CENTER) { textR.y = iconR.height - textR.height; } else { textR.y = (iconR.height + gap); } } if (horizontalTextPosition == LEFT) { textR.x = -(textR.width + gap); } else if (horizontalTextPosition == CENTER) { textR.x = (iconR.width / 2) - (textR.width / 2); } else { // (horizontalTextPosition == RIGHT) textR.x = (iconR.width + gap); } /* labelR is the rectangle that contains iconR and textR. * Move it to its proper position given the labelAlignment * properties. * * To avoid actually allocating a Rectangle, Rectangle.union * has been inlined below. */ int labelR_x = Math.min(iconR.x, textR.x); int labelR_width = Math.max(iconR.x + iconR.width, textR.x + textR.width) - labelR_x; int labelR_y = Math.min(iconR.y, textR.y); int labelR_height = Math.max(iconR.y + iconR.height, textR.y + textR.height) - labelR_y; int dx, dy; if (verticalAlignment == TOP) { dy = viewR.y - labelR_y; } else if (verticalAlignment == CENTER) { dy = (viewR.y + (viewR.height / 2)) - (labelR_y + (labelR_height / 2)); } else { // (verticalAlignment == BOTTOM) dy = (viewR.y + viewR.height) - (labelR_y + labelR_height); } if (horizontalAlignment == LEFT) { dx = viewR.x - labelR_x; } else if (horizontalAlignment == RIGHT) { dx = (viewR.x + viewR.width) - (labelR_x + labelR_width); } else { // (horizontalAlignment == CENTER) dx = (viewR.x + (viewR.width / 2)) - (labelR_x + (labelR_width / 2)); } /* Translate textR and glypyR by dx,dy. */ textR.x += dx; textR.y += dy; iconR.x += dx; iconR.y += dy; if (lsb < 0) { // lsb is negative. We previously adjusted the bounds by lsb, // we now need to shift the x location so that the text is // drawn at the right location. The result is textR does not // line up with the actual bounds (on the left side), but we will // have provided enough space for the text. textR.width += lsb; textR.x -= lsb; } return text; } public static void configureGraphics(Graphics gr) { Graphics2D g = (Graphics2D) gr; g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); } /** Copied from BasicLookAndFeel. */ public static Component compositeRequestFocus(Component component) { try { if (component instanceof Container) { Container container = (Container)component; if (Methods.invokeGetter(container,"isFocusCycleRoot", false)) { Object policy = Methods.invokeGetter(container,"getFocusTraversalPolicy", null); Component comp = (Component) Methods.invoke(policy,"getDefaultComponent", Container.class, container); if (comp!=null) { comp.requestFocus(); return comp; } } Container rootAncestor = (Container) Methods.invokeGetter(container, "getFocusCycleRootAncestor", null); if (rootAncestor!=null) { Object policy = Methods.invokeGetter(rootAncestor,"getFocusTraversalPolicy", null); Component comp = (Component) Methods.invoke(policy,"getComponentAfter", new Class[] {Container.class, Component.class}, new Object[] {rootAncestor, container}); if (comp!=null && SwingUtilities.isDescendingFrom(comp, container)) { comp.requestFocus(); return comp; } } } } catch (NoSuchMethodException e) { // ignore } if (Methods.invokeGetter(component,"isFocusable", true)) { component.requestFocus(); return component; } return null; } }substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/Quaqua14ColorChooserUI.java0000644000175000017500000001272310564356426030042 0ustar drazzibdrazzib/* * @(#)QuaquaColorChooserUI.java 1.1 2005-12-18 * * Copyright (c) 2004 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua; import java.awt.*; import java.awt.event.*; import java.beans.*; import java.util.*; import javax.swing.*; import javax.swing.colorchooser.*; import javax.swing.event.*; import javax.swing.plaf.*; import javax.swing.plaf.basic.*; import contrib.ch.randelshofer.quaqua.colorchooser.*; /** * QuaquaColorChooserUI with enhancements for Java 1.4. * * @author Werner Randelshofer * @version 1.1 2005-12-18 Gracefully handle instantiation failures of * color chooser panels. *
1.0 29 March 2005 Created. */ public class Quaqua14ColorChooserUI extends Quaqua13ColorChooserUI { private static TransferHandler defaultTransferHandler = new ColorTransferHandler(); private MouseListener previewMouseListener; public static ComponentUI createUI(JComponent c) { return new Quaqua14ColorChooserUI(); } public void installUI(JComponent c) { super.installUI(c); chooser.applyComponentOrientation(c.getComponentOrientation()); } protected void installDefaults() { super.installDefaults(); TransferHandler th = chooser.getTransferHandler(); if (th == null || th instanceof UIResource) { chooser.setTransferHandler(defaultTransferHandler); } } protected void uninstallDefaults() { if (chooser.getTransferHandler() instanceof UIResource) { chooser.setTransferHandler(null); } } protected void installListeners() { super.installListeners(); previewMouseListener = new MouseAdapter() { public void mousePressed(MouseEvent e) { if (chooser.getDragEnabled()) { TransferHandler th = chooser.getTransferHandler(); th.exportAsDrag(chooser, e, TransferHandler.COPY); } } }; } protected void uninstallListeners() { super.uninstallListeners(); previewPanel.removeMouseListener(previewMouseListener); } protected void installPreviewPanel() { if (previewPanel != null) { previewPanel.removeMouseListener(previewMouseListener); } super.installPreviewPanel(); previewPanel.addMouseListener(previewMouseListener); } protected PropertyChangeListener createPropertyChangeListener() { return new PropertyHandler(); } public class PropertyHandler implements PropertyChangeListener { public void propertyChange(PropertyChangeEvent e) { if ( e.getPropertyName().equals( JColorChooser.CHOOSER_PANELS_PROPERTY ) ) { AbstractColorChooserPanel[] oldPanels = (AbstractColorChooserPanel[]) e.getOldValue(); AbstractColorChooserPanel[] newPanels = (AbstractColorChooserPanel[]) e.getNewValue(); for (int i = 0; i < oldPanels.length; i++) { // remove old panels if (oldPanels[i] != null) { Container wrapper = oldPanels[i].getParent(); if (wrapper != null) { Container parent = wrapper.getParent(); if (parent != null) parent.remove(wrapper); // remove from hierarchy oldPanels[i].uninstallChooserPanel(chooser); // uninstall } } } mainPanel.removeAllColorChooserPanels(); for (int i = 0; i < newPanels.length; i++) { if (newPanels[i] != null) { mainPanel.addColorChooserPanel(newPanels[i]); } } chooser.applyComponentOrientation(chooser.getComponentOrientation()); for (int i = 0; i < newPanels.length; i++) { if (newPanels[i] != null) { newPanels[i].installChooserPanel(chooser); } } } if ( e.getPropertyName().equals( JColorChooser.PREVIEW_PANEL_PROPERTY ) ) { if (e.getNewValue() != previewPanel) { installPreviewPanel(); } } if (e.getPropertyName().equals("componentOrientation")) { ComponentOrientation o = (ComponentOrientation)e.getNewValue(); JColorChooser cc = (JColorChooser)e.getSource(); if (o != (ComponentOrientation)e.getOldValue()) { cc.applyComponentOrientation(o); cc.updateUI(); } } } } static class ColorTransferHandler extends TransferHandler implements UIResource { ColorTransferHandler() { super("color"); } } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/QuaquaIconFactory.java0000644000175000017500000001107610564356426027256 0ustar drazzibdrazzib/* * @(#)QuaquaIconFactory.java 3.2 2007-01-05 * * Copyright (c) 2005-2006 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua; import java.net.*; import java.awt.*; import java.awt.image.*; import javax.swing.*; import javax.swing.plaf.*; import contrib.ch.randelshofer.quaqua.util.*; //import javax.imageio.*; //import javax.imageio.stream.*; import java.io.*; import java.util.*; /** * QuaquaIconFactory. * * @author Werner Randelshofer, Christopher Atlan * @version 3.2 2007-01-05 Issue #1: Changed LazyOptionPaneIcon to load image * asynchronously before paintIcon is invoked. *
3.1 2006-12-24 by Karl von Randow: Use Images class to create artwork. *
3.0.2 2006-11-01 Use Graphics2D.drawImage() to scale application * image icon instead of using Image.getScaledInstance(). *
3.0.1 2006-05-14 Application icon was unnecessarily created multiple * times. *
3.0 2006-05-12 Added support for file icon images. Renamed some * methods. *
2.1 2006-02-14 Added method createFrameButtonStateIcon. *
2.0 2006-02-12 Added methods createApplicationIcon, compose, * createOptionPaneIcon. These methods were contributed by Christopher Atlan. *
1.0 December 4, 2005 Created. */ public class QuaquaIconFactory { private static BufferedImage applicationImage; /** * Prevent instance creation. */ private QuaquaIconFactory() { } public static URL getResource(String location) { URL url = QuaquaIconFactory.class.getResource(location); if (url == null) { throw new InternalError("image resource missing: "+location); } return url; } public static Image createImage(String location) { return createImage(QuaquaIconFactory.class, location); } public static Image createImage(Class baseClass, String location) { return Images.createImage(baseClass.getResource(location)); } public static Image createBufferedImage(String location) { return Images.toBufferedImage(createImage(location)); } public static Icon[] createIcons(String location, int count, boolean horizontal) { Icon[] icons = new Icon[count]; BufferedImage[] images = Images.split( (Image) createImage(location), count, horizontal ); for (int i=0; i < count; i++) { icons[i] = new IconUIResource(new ImageIcon(images[i])); } return icons; } public static Icon createIcon(String location, int count, boolean horizontal, int index) { return createIcons(location, count, horizontal)[index]; } public static Icon createButtonStateIcon(String location, int states) { return new ButtonStateIcon( (Image) createImage(location), states, true ); } public static Icon createButtonStateIcon(String location, int states, Point shift) { return new ShiftedIcon( new ButtonStateIcon( (Image) createImage(location), states, true ), shift ); } public static Icon createButtonStateIcon(String location, int states, Rectangle shift) { return new ShiftedIcon( new ButtonStateIcon( (Image) createImage(location), states, true ), shift ); } public static Icon createIcon(Class baseClass, String location) { return new ImageIcon(createImage(baseClass, location)); } public static Icon createIcon(Class baseClass, String location, Point shift) { return new ShiftedIcon( new ImageIcon(createImage(baseClass, location)), shift ); } public static Icon createIcon(Class baseClass, String location, Rectangle shiftAndSize) { return new ShiftedIcon( new ImageIcon(createImage(baseClass, location)), shiftAndSize ); } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/Labels_en.properties0000644000175000017500000001441410666404474027016 0ustar drazzibdrazzib ColorChooser.grayScaleSlider=Gray Scale Slider ColorChooser.rgbSliders=RGB Sliders ColorChooser.cmykSliders=CMYK Sliders ColorChooser.htmlSliders=HTML Sliders ColorChooser.rgbRedText=Red ColorChooser.rgbGreenText=Green ColorChooser.rgbBlueText=Blue ColorChooser.cmykCyanText=Cyan ColorChooser.cmykMagentaText=Magenta ColorChooser.cmykYellowText=Yellow ColorChooser.cmykBlackText=Black ColorChooser.hsbHueText=Hue ColorChooser.hsbSaturationText=Saturation ColorChooser.hsbBrightnessText=Brightness ColorChooser.htmlText=HTML\: ColorChooser.htmlChooseOnlyWebSaveColorsText=Choose only web-safe colors ColorChooser.colorSliders=Color Sliders ColorChooser.colorSwatches=Color Swatches ColorChooser.hsbSliders=HSB Sliders ColorChooser.colorWheel=Color Wheel ColorChooser.crayon.800000=Cayenne ColorChooser.crayon.808000=Asparagus ColorChooser.crayon.008000=Clover ColorChooser.crayon.008080=Teal ColorChooser.crayon.000080=Midnight ColorChooser.crayon.800080=Plum ColorChooser.crayon.7f7f7f=Tin ColorChooser.crayon.808080=Nickel ColorChooser.crayon.804000=Mocha ColorChooser.crayon.408000=Fern ColorChooser.crayon.008040=Moss ColorChooser.crayon.004080=Ocean ColorChooser.crayon.400080=Eggplant ColorChooser.crayon.800040=Maroon ColorChooser.crayon.666666=Steel ColorChooser.crayon.999999=Aluminium ColorChooser.crayon.ff0000=Maraschino ColorChooser.crayon.ffff00=Lemon ColorChooser.crayon.00ff00=Spring ColorChooser.crayon.00ffff=Turquoise ColorChooser.crayon.0000ff=Blueberry ColorChooser.crayon.ff00ff=Magenta ColorChooser.crayon.4c4c4c=Iron ColorChooser.crayon.b3b3b3=Magnesium ColorChooser.crayon.ff8000=Tangerine ColorChooser.crayon.80ff00=Lime ColorChooser.crayon.00ff80=Sea Foam ColorChooser.crayon.0080ff=Aqua ColorChooser.crayon.8000ff=Grape ColorChooser.crayon.ff0080=Strawberry ColorChooser.crayon.333333=Tungsten ColorChooser.crayon.cccccc=Silver ColorChooser.crayon.ff6666=Salmon ColorChooser.crayon.ffff66=Banana ColorChooser.crayon.66ff66=Flora ColorChooser.crayon.66ffff=Ice ColorChooser.crayon.6666ff=Orchid ColorChooser.crayon.ff66ff=Bubblegum ColorChooser.crayon.191919=Lead ColorChooser.crayon.e6e6e6=Mercury ColorChooser.crayon.ffcc66=Cantaloupe ColorChooser.crayon.ccff66=Honeydew ColorChooser.crayon.66ffcc=Spindrift ColorChooser.crayon.66ccff=Sky ColorChooser.crayon.cc66ff=Lavender ColorChooser.crayon.ff6fcf=Carnation ColorChooser.crayon.000000=Licorice ColorChooser.crayon.ffffff=Snow ColorChooser.crayons=Crayons ColorChooser.apple.000000=Black ColorChooser.apple.0000ff=Blue ColorChooser.apple.996633=Brown ColorChooser.apple.00ffff=Cyan ColorChooser.apple.00ff00=Green ColorChooser.apple.ff00ff=Magenta ColorChooser.apple.ff8000=Orange ColorChooser.apple.800080=Purple ColorChooser.apple.ff0000=Red ColorChooser.apple.ffff00=Yellow ColorChooser.apple.ffffff=White ColorChooser.appleColors=Apple ColorChooser.windowsBasicColors=Windows Basic Colors ColorChooser.color=Color ColorChooser.list=List\: ColorChooser.colorPalettes=Color Palettes ColorChooser.webSafeColors=Web Safe Colors ColorChooser.profileContainsNColors=The profile "{0}" contains {1} colors. OptionPane.cancel=Cancel OptionPane.css= ColorChooser.colorPicker=Color Picker TextComponent.cut=Cut TextComponent.copy=Copy TextComponent.paste=Paste FileChooser.fromLabelText=From\: FileChooser.widget=Widget FileChooser.widgetCount={0,choice,1\#{0,number}\u00A0folder|1<{0,number}\u00A0widgets} FileChooser.replaceAlert=\u201C{0}\u201D already exists. Do you want to replace it?

A file or folder with the same name already exists in {1}. Replacing it will overwrite its current contents. #Replace FileChooser.replace=Replace FileChooser.computerName=Computer FileChooser.cancelButtonText=Cancel FileChooser.newFolderButtonText=New Folder FileChooser.openButtonText=Open FileChooser.size=Size FileChooser.created=Created FileChooser.modified=Modified FileChooser.sizeBytes={1,choice,0#Zero bytes|1#1 byte|1<{1,number} bytes}{2,choice,1#|1< for {2,number} items} FileChooser.name=Name FileChooser.whereLabelText=Where FileChooser.original=Original FileChooser.sizeKBytes={0,number,#,##0.#} KB\n({1,number} bytes){2,choice,1#|1< for {2,number} items} FileChooser.sizeMBytes={0,number,#,##0.#} MB\n({1,number} bytes){2,choice,1#|1< for {2,number} items} FileChooser.sizeGBytes={0,number,#,##0.#} GB\n({1,number} bytes){2,choice,1#|1< for {2,number} items} FileChooser.items={0} items FileChooser.sizeUnknown=-- FileChooser.alias=Alias FileChooser.document=Document FileChooser.folder=Folder FileChooser.application=Application FileChooser.aliasCount={0,choice,1#{0,number}\u00a0alias|1<{0,number}\u00a0aliases} FileChooser.documentCount={0,choice,1#{0,number}\u00a0document|1<{0,number}\u00a0documents} FileChooser.folderCount={0,choice,1#{0,number}\u00a0folder|1<{0,number}\u00a0folders} FileChooser.applicationCount={0,choice,1#{0,number}\u00a0application|1<{0,number}\u00a0applications} FileChooser.kind=Kind FileChooser.lookInLabelText=Look In: FileChooser.saveInLabelText=Save In: FileChooser.fileNameLabelText=File Name: FileChooser.filesOfTypeLabelText=Files of Type: FileChooser.upFolderToolTipText=Up One Level FileChooser.upFolderAccessibleName=Up FileChooser.homeFolderToolTipText=Home FileChooser.homeFolderAccessibleName=Home FileChooser.newFolderToolTipText=Create New Folder FileChooser.newFolderAccessibleName=New Folder FileChooser.newFolderActionLabelText=New Folder FileChooser.listViewButtonToolTipText=List FileChooser.listViewButtonAccessibleName=List FileChooser.listViewActionLabelText=List FileChooser.detailsViewButtonToolTipText=Details FileChooser.detailsViewButtonAccessibleName=Details FileChooser.detailsViewActionLabelText=Details FileChooser.refreshActionLabelText=Refresh FileChooser.viewMenuLabelText=View FileChooser.fileNameHeaderText=Name FileChooser.fileSizeHeaderText=Size FileChooser.fileTypeHeaderText=Type FileChooser.fileDateHeaderText=Modified FileChooser.fileAttrHeaderText=Attributes substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/Labels_zh_CN.properties0000644000175000017500000001675210666404716027423 0ustar drazzibdrazzib#Chinese translation by Qil Wong FileChooser.size=\u5927\u5c0f FileChooser.created=\u521b\u5efa FileChooser.modified=\u4fee\u6539 FileChooser.sizeBytes={1,choice,0#Zero bytes|1#1 byte|1<{1,number} bytes}{2,choice,1#|1< for {2,number} items} FileChooser.name=\u540d\u79f0 FileChooser.whereLabelText=\u6765\u81ea FileChooser.original=\u8d77\u59cb FileChooser.sizeKBytes={0,number,#,##0.#} KB\n({1,number} bytes){2,choice,1#|1< for {2,number} items} FileChooser.sizeMBytes={0,number,#,##0.#} MB\n({1,number} bytes){2,choice,1#|1< for {2,number} items} FileChooser.sizeGBytes={0,number,#,##0.#} GB\n({1,number} bytes){2,choice,1#|1< for {2,number} items} FileChooser.items={0} items FileChooser.sizeUnknown=-- FileChooser.alias=\u522b\u540d FileChooser.document=\u6587\u6863 FileChooser.folder=\u6587\u4ef6\u5939 FileChooser.upFolderToolTipText=\u5411\u4e0a FileChooser.desktopFolderToolTipText=\u684c\u9762 FileChooser.newFolderToolTipText=\u65b0\u6587\u4ef6\u5939 FileChooser.homeFolderToolTipText=\u684c\u9762 FileChooser.listViewButtonToolTipText=\u5217\u8868\u89c6\u56fe FileChooser.detailsViewButtonToolTipText=\u8be6\u7ec6\u89c6\u56fe FileChooser.application=\u5e94\u7528\u7a0b\u5e8f FileChooser.aliasCount={0,choice,1#{0,number}\u00a0alias|1<{0,number}\u00a0aliases} FileChooser.documentCount={0,choice,1#{0,number}\u00a0document|1<{0,number}\u00a0documents} FileChooser.folderCount={0,choice,1#{0,number}\u00a0folder|1<{0,number}\u00a0folders} FileChooser.applicationCount={0,choice,1#{0,number}\u00a0application|1<{0,number}\u00a0applications} FileChooser.kind=\u7c7b\u522b ColorChooser.grayScaleSlider=\u7070\u5ea6\u6ed1\u5757 ColorChooser.rgbSliders=RGB\u6ed1\u5757 ColorChooser.cmykSliders=CMYK\u6ed1\u5757 ColorChooser.htmlSliders=HTML\u6ed1\u5757 ColorChooser.rgbRedText=\u7ea2\u8272 ColorChooser.rgbGreenText=\u7eff\u8272 ColorChooser.rgbBlueText=\u84dd\u8272 ColorChooser.cmykCyanText=\u9752\u8272 ColorChooser.cmykMagentaText=\u7d2b\u7ea2\u8272 ColorChooser.cmykYellowText=\u9ec4\u8272 ColorChooser.cmykBlackText=\u9ed1\u8272 ColorChooser.hsbHueText=\u8272\u8c03 ColorChooser.hsbSaturationText=\u9971\u548c\u5ea6 ColorChooser.hsbBrightnessText=\u4eae\u5ea6 ColorChooser.htmlText=HTML\: ColorChooser.htmlChooseOnlyWebSaveColorsText=\u9009\u62e9\u7f51\u7edc\u5b89\u5168\u989c\u8272 ColorChooser.colorSliders=\u989c\u8272\u6ed1\u5757 ColorChooser.colorSwatches=\u989c\u8272\u6837\u672c ColorChooser.hsbSliders=HSB\u6ed1\u5757 FileChooser.fromLabelText=\u6765\u81ea\: FileChooser.newFolderButtonText=\u65b0\u6587\u4ef6\u5939 FileChooser.cancelButtonText=\u53d6\u6d88 FileChooser.openButtonText=\u6253\u5f00 FileChooser.widget=\u56fe\u6807 FileChooser.widgetCount={0,choice,1\#{0,number}\u00A0folder|1<{0,number}\u00A0widgets} ColorChooser.colorWheel=\u989c\u8272\u6eda\u8f6e ColorChooser.crayon.800000=Cayenne ColorChooser.crayon.808000=Asparagus ColorChooser.crayon.008000=Clover ColorChooser.crayon.008080=Teal ColorChooser.crayon.000080=Midnight ColorChooser.crayon.800080=Plum ColorChooser.crayon.7f7f7f=Tin ColorChooser.crayon.808080=Nickel ColorChooser.crayon.804000=Mocha ColorChooser.crayon.408000=Fern ColorChooser.crayon.008040=Moss ColorChooser.crayon.004080=Ocean ColorChooser.crayon.400080=Eggplant ColorChooser.crayon.800040=Maroon ColorChooser.crayon.666666=Steel ColorChooser.crayon.999999=Aluminium ColorChooser.crayon.ff0000=Maraschino ColorChooser.crayon.ffff00=Lemon ColorChooser.crayon.00ff00=Spring ColorChooser.crayon.00ffff=Turquoise ColorChooser.crayon.0000ff=Blueberry ColorChooser.crayon.ff00ff=Magenta ColorChooser.crayon.4c4c4c=Iron ColorChooser.crayon.b3b3b3=Magnesium ColorChooser.crayon.ff8000=Tangerine ColorChooser.crayon.80ff00=Lime ColorChooser.crayon.00ff80=Sea Foam ColorChooser.crayon.0080ff=Aqua ColorChooser.crayon.8000ff=Grape ColorChooser.crayon.ff0080=Strawberry ColorChooser.crayon.333333=Tungsten ColorChooser.crayon.cccccc=Silver ColorChooser.crayon.ff6666=Salmon ColorChooser.crayon.ffff66=Banana ColorChooser.crayon.66ff66=Flora ColorChooser.crayon.66ffff=Ice ColorChooser.crayon.6666ff=Orchid ColorChooser.crayon.ff66ff=Bubblegum ColorChooser.crayon.191919=Lead ColorChooser.crayon.e6e6e6=Mercury ColorChooser.crayon.ffcc66=Cantaloupe ColorChooser.crayon.ccff66=Honeydew ColorChooser.crayon.66ffcc=Spindrift ColorChooser.crayon.66ccff=Sky ColorChooser.crayon.cc66ff=Lavender ColorChooser.crayon.ff6fcf=Carnation ColorChooser.crayon.000000=Licorice ColorChooser.crayon.ffffff=Snow ColorChooser.crayons=\u6709\u8272\u7b14 ColorChooser.color=\u989c\u8272 ColorChooser.list=\u5217\u8868\: ColorChooser.apple.000000=\u9ed1\u8272 ColorChooser.apple.0000ff=\u84dd\u8272 ColorChooser.apple.996633=\u8910\u8272 ColorChooser.apple.00ffff=\u9752\u8272 ColorChooser.apple.00ff00=\u7eff\u8272 ColorChooser.apple.ff00ff=\u7d2b\u7ea2\u8272 ColorChooser.apple.ff8000=\u6a59\u8272 ColorChooser.apple.800080=\u7d2b\u8272 ColorChooser.apple.ff0000=\u7ea2\u8272 ColorChooser.apple.ffff00=\u9ec4\u8272 ColorChooser.apple.ffffff=\u767d\u8272 ColorChooser.appleColors=Apple\u8272 ColorChooser.windowsBasicColors=Windows\u57fa\u672c\u989c\u8272 ColorChooser.colorPalettes=\u8c03\u8272\u677f ColorChooser.webSafeColors=\u7f51\u7edc\u5b89\u5168\u8272 ColorChooser.profileContainsNColors=The profile "{0}" contains {1} colors. FileChooser.replaceAlert=\u201C{0}\u201D \u5df2\u7ecf\u5b58\u5728.
\u66ff\u6362\u5df2\u6709\u6587\u4ef6\u5417\uff1f

\u540c\u540d\u7684\u6587\u4ef6\u6216\u76ee\u5f55\u5df2\u7ecf\u5b58\u5728
{1}.
\u66ff\u6362\u64cd\u4f5c\u5c06\u8986\u76d6\u5f53\u524d\u5185\u5bb9. #Replace FileChooser.replace=\u66ff\u6362 OptionPane.cancel=\u53d6\u6d88 OptionPane.css= ColorChooser.colorPicker=\u989c\u8272\u9009\u62e9\u5668 TextComponent.cut=\u526a\u5207 TextComponent.copy=\u590d\u5236 TextComponent.paste=\u7c98\u8d34 FileChooser.computerName=\u8ba1\u7b97\u673a FileChooser.lookInLabelText=\u67e5\u770b\uff1a FileChooser.saveInLabelText=\u4fdd\u5b58\uff1a FileChooser.fileNameLabelText=\u6587\u4ef6\u540d\uff1a FileChooser.filesOfTypeLabelText=\u6587\u4ef6\u7c7b\u578b\uff1a FileChooser.upFolderToolTipText=\u5411\u4e0a\u4e00\u5c42 FileChooser.upFolderAccessibleName=\u5411\u4e0a FileChooser.homeFolderToolTipText=\u8d77\u59cb\u76ee\u5f55 FileChooser.homeFolderAccessibleName=\u8d77\u59cb\u76ee\u5f55 FileChooser.newFolderToolTipText=\u521b\u5efa\u65b0\u7684\u6587\u4ef6\u5939 FileChooser.newFolderAccessibleName=\u65b0\u5efa\u6587\u4ef6\u5939 FileChooser.newFolderActionLabelText=\u65b0\u5efa\u6587\u4ef6\u5939 FileChooser.listViewButtonToolTipText=\u5217\u8868 FileChooser.listViewButtonAccessibleName=\u5217\u8868 FileChooser.listViewActionLabelText=\u5217\u8868 FileChooser.detailsViewButtonToolTipText=\u8be6\u7ec6\u4fe1\u606f FileChooser.detailsViewButtonAccessibleName=\u8be6\u7ec6\u4fe1\u606f FileChooser.detailsViewActionLabelText=\u8be6\u7ec6\u4fe1\u606f FileChooser.refreshActionLabelText=\u5237\u65b0 FileChooser.viewMenuLabelText=\u89c6\u56fe FileChooser.fileNameHeaderText=\u540d\u79f0 FileChooser.fileSizeHeaderText=\u5927\u5c0f FileChooser.fileTypeHeaderText=\u7c7b\u578b FileChooser.fileDateHeaderText=\u4fee\u6b63\u7248 FileChooser.fileAttrHeaderText=\u5c5e\u6027 substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/ButtonStateIcon.java0000644000175000017500000001402510564356426026742 0ustar drazzibdrazzib/* * @(#)ButtonStateIcon.java 3.1 2005-12-08 * * Copyright (c) 2003-2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua; import java.awt.*; import javax.swing.*; import javax.swing.plaf.*; import contrib.ch.randelshofer.quaqua.util.*; /** * An Icon with different visuals reflecting the state of the AbstractButton * on which it draws on. * * @author Werner Randelshofer * @version 3.1 2005-12-08 Draw pressed state if model is armed, instead of * drawing pressed state if model is armed and pressed. *
3.0 2005-10-17 Changed superclass to MultiIcon. *
2.0.1 2005-10-02 Used Enabled image for Pressed-Unarmed state. *
2.0.1 2005-09-11 generateMissing icons can now deal with only one * provided icon image. *
2.0 2005-03-19 Reworked. *
1.0 October 5, 2003 Create.. */ public class ButtonStateIcon extends MultiIcon { private final static int E = 0; private final static int EP = 1; private final static int ES = 2; private final static int EPS = 3; private final static int D = 4; private final static int DS = 5; private final static int I = 6; private final static int IS = 7; private final static int DI = 8; private final static int DIS = 9; /** * Creates a new instance. * All icons must have the same dimensions. * If an icon is null, an icon is derived for the state from the * other icons. */ public ButtonStateIcon(Icon e, Icon ep, Icon es, Icon eps, Icon d, Icon ds) { super(new Icon[] {e, ep, es, eps, d, ds}); } /** * Creates a new instance. * All icons must have the same dimensions. * * The array indices are used to represente the following states: * [0] Enabled * [1] Enabled Pressed * [2] Enabled Selected * [3] Enabled Pressed Selected * [4] Disabled * [5] Disabled Selected * [6] Enabled Inactive * [7] Enabled Inactive Selected * [8] Disabled Inactive * [9] Disabled Inactive Selected * * If an array element is null, an icon is derived for the state from the * other icons. */ public ButtonStateIcon(Image[] images) { super(images); } /** * Creates a new instance. * All icons must have the same dimensions. * If an icon is null, nothing is drawn for this state. */ public ButtonStateIcon(Icon[] icons) { super(icons); } /** * Creates a new instance. * The icon representations are created lazily from the image. */ public ButtonStateIcon(Image tiledImage, int tileCount, boolean isTiledHorizontally) { super(tiledImage, tileCount, isTiledHorizontally); } protected Icon getIcon(Component c) { Icon icon; boolean isActive = QuaquaUtilities.isOnActiveWindow(c); if (c instanceof AbstractButton) { ButtonModel model = ((AbstractButton) c).getModel(); if (isActive) { if (model.isEnabled()) { if (/*model.isPressed() && */model.isArmed()) { if (model.isSelected()) { icon = icons[EPS]; } else { icon = icons[EP]; } } else if (model.isSelected()) { icon = icons[ES]; } else { icon = icons[E]; } } else { if (model.isSelected()) { icon = icons[DS]; } else { icon = icons[D]; } } } else { if (model.isEnabled()) { if (model.isSelected()) { icon = icons[IS]; } else { icon = icons[I]; } } else { if (model.isSelected()) { icon = icons[DIS]; } else { icon = icons[DI]; } } } } else { if (isActive) { if (c.isEnabled()) { icon = icons[E]; } else { icon = icons[D]; } } else { if (c.isEnabled()) { icon = icons[I]; } else { icon = icons[DI]; } } } return icon; } protected void generateMissingIcons() { if (icons.length != 10) { Icon[] helper = icons; icons = new Icon[10]; System.arraycopy(helper, 0, icons, 0, Math.min(helper.length, icons.length)); } if (icons[EP] == null) { icons[EP] = icons[E]; } if (icons[ES] == null) { icons[ES] = icons[EP]; } if (icons[EPS] == null) { icons[EPS] = icons[EP]; } if (icons[D] == null) { icons[D] = icons[E]; } if (icons[DS] == null) { icons[DS] = icons[ES]; } if (icons[I] == null) { icons[I] = icons[E]; } if (icons[IS] == null) { icons[IS] = icons[ES]; } if (icons[DI] == null) { icons[DI] = icons[D]; } if (icons[DIS] == null) { icons[DIS] = icons[DS]; } } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/Labels.properties0000644000175000017500000001520310666404750026326 0ustar drazzibdrazzib# # Some of the strings defined here have the same keys as found in # com.sun.swing.internal.plaf.basic.resource.basic.properties # apple.laf.resources.aqua.properties # # We can not rely on the presence of these properties though, because these # property files contain warnings stating this. # # @author Werner Randelshofer # @version 3.0 Reworked. # FileChooser.size=Size FileChooser.created=Created FileChooser.modified=Modified FileChooser.sizeBytes={1,choice,0#Zero bytes|1#1 byte|1<{1,number} bytes}{2,choice,1#|1< for {2,number} items} FileChooser.name=Name FileChooser.whereLabelText=Where FileChooser.original=Original FileChooser.sizeKBytes={0,number,#,##0.#} KB\n({1,number} bytes){2,choice,1#|1< for {2,number} items} FileChooser.sizeMBytes={0,number,#,##0.#} MB\n({1,number} bytes){2,choice,1#|1< for {2,number} items} FileChooser.sizeGBytes={0,number,#,##0.#} GB\n({1,number} bytes){2,choice,1#|1< for {2,number} items} FileChooser.items={0} items FileChooser.sizeUnknown=-- FileChooser.alias=Alias FileChooser.document=Document FileChooser.folder=Folder FileChooser.application=Application FileChooser.aliasCount={0,choice,1#{0,number}\u00a0alias|1<{0,number}\u00a0aliases} FileChooser.documentCount={0,choice,1#{0,number}\u00a0document|1<{0,number}\u00a0documents} FileChooser.folderCount={0,choice,1#{0,number}\u00a0folder|1<{0,number}\u00a0folders} FileChooser.applicationCount={0,choice,1#{0,number}\u00a0application|1<{0,number}\u00a0applications} FileChooser.kind=Kind ColorChooser.grayScaleSlider=Gray Scale Slider ColorChooser.rgbSliders=RGB Sliders ColorChooser.cmykSliders=CMYK Sliders ColorChooser.htmlSliders=HTML Sliders ColorChooser.rgbRedText=Red ColorChooser.rgbGreenText=Green ColorChooser.rgbBlueText=Blue ColorChooser.cmykCyanText=Cyan ColorChooser.cmykMagentaText=Magenta ColorChooser.cmykYellowText=Yellow ColorChooser.cmykBlackText=Black ColorChooser.hsbHueText=Hue ColorChooser.hsbSaturationText=Saturation ColorChooser.hsbBrightnessText=Brightness ColorChooser.htmlText=HTML\: ColorChooser.htmlChooseOnlyWebSaveColorsText=Choose only web-safe colors ColorChooser.colorSliders=Color Sliders ColorChooser.colorSwatches=Color Swatches ColorChooser.hsbSliders=HSB Sliders FileChooser.fromLabelText=From\: FileChooser.newFolderButtonText=New Folder FileChooser.cancelButtonText=Cancel FileChooser.openButtonText=Open FileChooser.widget=Widget FileChooser.widgetCount={0,choice,1\#{0,number}\u00A0folder|1<{0,number}\u00A0widgets} ColorChooser.colorWheel=Color Wheel ColorChooser.crayon.800000=Cayenne ColorChooser.crayon.808000=Asparagus ColorChooser.crayon.008000=Clover ColorChooser.crayon.008080=Teal ColorChooser.crayon.000080=Midnight ColorChooser.crayon.800080=Plum ColorChooser.crayon.7f7f7f=Tin ColorChooser.crayon.808080=Nickel ColorChooser.crayon.804000=Mocha ColorChooser.crayon.408000=Fern ColorChooser.crayon.008040=Moss ColorChooser.crayon.004080=Ocean ColorChooser.crayon.400080=Eggplant ColorChooser.crayon.800040=Maroon ColorChooser.crayon.666666=Steel ColorChooser.crayon.999999=Aluminium ColorChooser.crayon.ff0000=Maraschino ColorChooser.crayon.ffff00=Lemon ColorChooser.crayon.00ff00=Spring ColorChooser.crayon.00ffff=Turquoise ColorChooser.crayon.0000ff=Blueberry ColorChooser.crayon.ff00ff=Magenta ColorChooser.crayon.4c4c4c=Iron ColorChooser.crayon.b3b3b3=Magnesium ColorChooser.crayon.ff8000=Tangerine ColorChooser.crayon.80ff00=Lime ColorChooser.crayon.00ff80=Sea Foam ColorChooser.crayon.0080ff=Aqua ColorChooser.crayon.8000ff=Grape ColorChooser.crayon.ff0080=Strawberry ColorChooser.crayon.333333=Tungsten ColorChooser.crayon.cccccc=Silver ColorChooser.crayon.ff6666=Salmon ColorChooser.crayon.ffff66=Banana ColorChooser.crayon.66ff66=Flora ColorChooser.crayon.66ffff=Ice ColorChooser.crayon.6666ff=Orchid ColorChooser.crayon.ff66ff=Bubblegum ColorChooser.crayon.191919=Lead ColorChooser.crayon.e6e6e6=Mercury ColorChooser.crayon.ffcc66=Cantaloupe ColorChooser.crayon.ccff66=Honeydew ColorChooser.crayon.66ffcc=Spindrift ColorChooser.crayon.66ccff=Sky ColorChooser.crayon.cc66ff=Lavender ColorChooser.crayon.ff6fcf=Carnation ColorChooser.crayon.000000=Licorice ColorChooser.crayon.ffffff=Snow ColorChooser.crayons=Crayons ColorChooser.color=Color ColorChooser.list=List\: ColorChooser.apple.000000=Black ColorChooser.apple.0000ff=Blue ColorChooser.apple.996633=Brown ColorChooser.apple.00ffff=Cyan ColorChooser.apple.00ff00=Green ColorChooser.apple.ff00ff=Magenta ColorChooser.apple.ff8000=Orange ColorChooser.apple.800080=Purple ColorChooser.apple.ff0000=Red ColorChooser.apple.ffff00=Yellow ColorChooser.apple.ffffff=White ColorChooser.appleColors=Apple ColorChooser.windowsBasicColors=Windows Basic Colors ColorChooser.colorPalettes=Color Palettes ColorChooser.webSafeColors=Web Safe Colors ColorChooser.profileContainsNColors=The profile "{0}" contains {1} colors. FileChooser.replaceAlert=\u201C{0}\u201D already exists.
Do you want to replace it?

A file or folder with the same name already exists in
{1}.
Replacing it will overwrite its current contents. #Replace FileChooser.replace=Replace OptionPane.cancel=Cancel OptionPane.css= ColorChooser.colorPicker=Color Picker TextComponent.cut=Cut TextComponent.copy=Copy TextComponent.paste=Paste FileChooser.computerName=Computer FileChooser.lookInLabelText=Look In: FileChooser.saveInLabelText=Save In: FileChooser.fileNameLabelText=File Name: FileChooser.filesOfTypeLabelText=Files of Type: FileChooser.upFolderToolTipText=Up One Level FileChooser.upFolderAccessibleName=Up FileChooser.homeFolderToolTipText=Home FileChooser.homeFolderAccessibleName=Home FileChooser.newFolderToolTipText=Create New Folder FileChooser.newFolderAccessibleName=New Folder FileChooser.newFolderActionLabelText=New Folder FileChooser.listViewButtonToolTipText=List FileChooser.listViewButtonAccessibleName=List FileChooser.listViewActionLabelText=List FileChooser.detailsViewButtonToolTipText=Details FileChooser.detailsViewButtonAccessibleName=Details FileChooser.detailsViewActionLabelText=Details FileChooser.refreshActionLabelText=Refresh FileChooser.viewMenuLabelText=View FileChooser.fileNameHeaderText=Name FileChooser.fileSizeHeaderText=Size FileChooser.fileTypeHeaderText=Type FileChooser.fileDateHeaderText=Modified FileChooser.fileAttrHeaderText=Attributes substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/VisualMargin.java0000644000175000017500000001544510564356426026265 0ustar drazzibdrazzib/* * @(#)VisualMargin.java 2.2 2005-10-01 * * Copyright (c) 2004-2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua; import java.awt.*; import javax.swing.*; import javax.swing.border.*; import javax.swing.plaf.*; /** * The VisualMargin is used to visually align components using bounds * based on other criterias than the clip bounds of the component. * * For example: The clip bounds of a JButton includes its cast shadow and its * focus ring. When we align the JButton with a JLabel, we want to align the * baseline of the Text of the JButton with the text in the JLabel. * * The visual margin may be quite large. We allow to programmatically set a * smaller margin using the client property "Quaqua.Component.margin". * * @author Werner Randelshofer * @version 2.2 2005-10-01 Added method getVisualMargin. *
2.1 2005-06-21 Implements UIResource. *
2.0 2005-05-08 Renamed from BorderMargin to VisualMargin. Reworked * API. *
1.0 31 March 2005 Created. */ public class VisualMargin extends AbstractBorder implements UIResource { /** * Defines the margin from the clip bounds of the * component to its visually perceived borderline. */ private Insets layoutMargin; /** * The UIManager Property to be used for the default margin. */ private String uiManagerPropertyName = "Component.visualMargin"; /** * The Client Property to be used for the default margin. */ private String propertyName = "Quaqua.Component.visualMargin"; private boolean isTopFixed, isLeftFixed, isBottomFixed, isRightFixed; /** * Creates a new VisualMargin. */ public VisualMargin() { layoutMargin = new Insets(0, 0, 0, 0); } /** * The UIManager Property to be used for the default margin. */ public void setPropertyName(String propertyName) { // this.propertyName = propertyName; } /* * Specifies SwingConstants.TOP, LEFT, BOTTOM, RIGHT to be fixed. * Set to false to unfix. */ public void setFixed(boolean top, boolean left, boolean bottom, boolean right) { isTopFixed = top; isLeftFixed = left; isBottomFixed = bottom; isRightFixed = right; } /** * Creates a new VisualMargin. * * @param top Defines the margin from the clip bounds of the * component to its visual bounds. * @param left Defines the margin from the clip bounds of the * component to its visual bounds. * @param bottom Defines the margin from the clip bounds of the * component to its visual bounds. * @param right Defines the margin from the clip bounds of the * component to its visual bounds. */ public VisualMargin(int top, int left, int bottom, int right) { layoutMargin = new Insets(top, left, bottom, right); } public VisualMargin(int top, int left, int bottom, int right, boolean ftop, boolean fleft, boolean fbottom, boolean fright) { layoutMargin = new Insets(top, left, bottom, right); isTopFixed = ftop; isLeftFixed = fleft; isBottomFixed = fbottom; isRightFixed = fright; } public VisualMargin(boolean ftop, boolean fleft, boolean fbottom, boolean fright) { layoutMargin = new Insets(0, 0, 0, 0); isTopFixed = ftop; isLeftFixed = fleft; isBottomFixed = fbottom; isRightFixed = fright; } /** * Creates a new VisualMargin. * * @param layoutMargin Defines the margin from the clip bounds of the * component to its visual bounds. The margin has usually negative values! */ public VisualMargin(Insets layoutMargin) { this.layoutMargin = layoutMargin; } public Insets getVisualMargin(Component c) { Insets insets = new Insets( layoutMargin.top, layoutMargin.left, layoutMargin.bottom, layoutMargin.right ); if (c instanceof JComponent) { Insets componentMargin = (Insets) ((JComponent) c).getClientProperty(propertyName); if (componentMargin == null && propertyName != null) { componentMargin = UIManager.getInsets(uiManagerPropertyName); } if (componentMargin != null) { if (! isTopFixed) insets.top = componentMargin.top; if (! isLeftFixed) insets.left = componentMargin.left; if (! isBottomFixed) insets.bottom = componentMargin.bottom; if (! isRightFixed) insets.right = componentMargin.right; } } return insets; } public Insets getBorderInsets(Component c) { return getBorderInsets(c, new Insets(0, 0, 0, 0)); } /** * Reinitializes the insets parameter with this Border's current Insets. * @param c the component for which this border insets value applies * @param insets the object to be reinitialized * @return the insets object */ public Insets getBorderInsets(Component c, Insets insets) { return getVisualMargin(c, insets); } /** * Reinitializes the insets parameter with this Border's current Insets. * @param c the component for which this border insets value applies * @param insets the object to be reinitialized * @return the insets object */ protected Insets getVisualMargin(Component c, Insets insets) { insets.top = -layoutMargin.top; insets.left = -layoutMargin.left; insets.bottom = -layoutMargin.bottom; insets.right = -layoutMargin.right; if (c instanceof JComponent) { Insets componentMargin = (Insets) ((JComponent) c).getClientProperty(propertyName); if (componentMargin == null && propertyName != null) { componentMargin = UIManager.getInsets(uiManagerPropertyName); } if (componentMargin != null) { if (! isTopFixed) insets.top += componentMargin.top; if (! isLeftFixed) insets.left += componentMargin.left; if (! isBottomFixed) insets.bottom += componentMargin.bottom; if (! isRightFixed) insets.right += componentMargin.right; } } return insets; } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/Labels_it.properties0000644000175000017500000001500310666404664027024 0ustar drazzibdrazzib FileChooser.size=Dimens. FileChooser.created=Creato FileChooser.modified=Modificato FileChooser.name=Nome FileChooser.whereLabelText=Situato FileChooser.original=Originale FileChooser.sizeBytes={1,choice,0\#Zero byte|1\#1 byte|1<{1,number} byte}{2,choice,1\#|1< per {2,number} elementi} FileChooser.sizeKBytes={0,number,\#,\#\#0.\#} KB ({1,number} byte){2,choice,1\#|1< per {2,number} elementi} FileChooser.sizeMBytes={0,number,\#,\#\#0.\#} MB ({1,number} byte){2,choice,1\#|1< per {2,number} elementi} FileChooser.sizeGBytes={0,number,\#,\#\#0.\#} GB ({1,number} byte){2,choice,1\#|1< per {2,number} elementi} FileChooser.items={0} elementi FileChooser.sizeUnknown=-- FileChooser.alias=Alias FileChooser.document=Documento FileChooser.folder=Cartella FileChooser.application=Applicazione FileChooser.aliasCount={0,choice,1#{0,number}\u00a0alias|1<{0,number}\u00a0alias} FileChooser.documentCount={0,choice,1#{0,number}\u00a0documento|1<{0,number}\u00a0documenti} FileChooser.folderCount={0,choice,1#{0,number}\u00a0cartella|1<{0,number}\u00a0cartelle} FileChooser.applicationCount={0,choice,1#{0,number}\u00a0applicazione|1<{0,number}\u00a0applicazioni} FileChooser.kind=Tipo ColorChooser.grayScaleSlider=Cursore Scala di grigi ColorChooser.rgbSliders=Cursori RGB ColorChooser.cmykSliders=Cursori CMYK ColorChooser.htmlSliders=Cursori HTML ColorChooser.rgbRedText=Rosso ColorChooser.rgbGreenText=Verde ColorChooser.rgbBlueText=Blu ColorChooser.cmykCyanText=Ciano ColorChooser.cmykMagentaText=Magenta ColorChooser.cmykYellowText=Giallo ColorChooser.cmykBlackText=Nero ColorChooser.hsbHueText=Tonalit\u00E0 ColorChooser.hsbSaturationText=Saturazione ColorChooser.hsbBrightnessText=Luminosit\u00E0 ColorChooser.htmlText=HTML\: ColorChooser.htmlChooseOnlyWebSaveColorsText=Solamente scellere i colori "Web-save" ColorChooser.colorSliders=Cursori Colore ColorChooser.colorSwatches=Face Colori ColorChooser.hsbSliders=Cursori HSB FileChooser.fromLabelText=Situato\: FileChooser.widget=Widget FileChooser.widgetCount={0,choice,1\#{0,number}\u00A0folder|1<{0,number}\u00A0widgets} ColorChooser.colorWheel=Ruota Colori ColorChooser.crayon.66ccff=Cielo ColorChooser.crayon.ffffff=Neve ColorChooser.crayon.ffff66=Banana ColorChooser.crayon.ffff00=Limone ColorChooser.crayon.ffcc66=Melone ColorChooser.crayon.ff8000=Mandarancio ColorChooser.crayon.ff6fcf=Garofano ColorChooser.crayon.ff66ff=Bubblegum ColorChooser.crayon.ff6666=Salmone ColorChooser.crayon.ff00ff=Magenta ColorChooser.crayon.ff0080=Fragola ColorChooser.crayon.ff0000=Maraschino ColorChooser.crayon.e6e6e6=Mercurio ColorChooser.crayon.ccff66=Miele ColorChooser.crayon.cccccc=Argento ColorChooser.crayon.cc66ff=Lavanda ColorChooser.crayon.b3b3b3=Magnesio ColorChooser.crayon.999999=Alluminio ColorChooser.crayon.80ff00=Lima ColorChooser.crayon.808080=Nichel ColorChooser.crayon.808000=Asparago ColorChooser.crayon.804000=Moka ColorChooser.crayon.8000ff=Uva ColorChooser.crayon.800080=Prugna ColorChooser.crayon.800000=Cayenne ColorChooser.crayon.800040=Granata ColorChooser.crayon.7f7f7f=Stagno ColorChooser.crayon.66ffff=Ghiaccio ColorChooser.crayon.66ffcc=Verde acqua ColorChooser.crayon.66ff66=Flora ColorChooser.crayon.0080ff=Aqua ColorChooser.crayon.6666ff=Orchidea ColorChooser.crayon.666666=Accaio ColorChooser.crayon.4c4c4c=Ferro ColorChooser.crayon.408000=Felce ColorChooser.crayon.400080=Melanzana ColorChooser.crayon.333333=Tungsteno ColorChooser.crayon.191919=Grafite ColorChooser.crayon.00ffff=Turchese ColorChooser.crayon.00ff80=Schiuma marina ColorChooser.crayon.00ff00=Primavera ColorChooser.crayon.008080=Blu petrolio ColorChooser.crayon.008040=Muschio ColorChooser.crayon.008000=Trifoglio ColorChooser.crayon.004080=Oceano ColorChooser.crayon.0000ff=Mirtillo ColorChooser.crayon.000080=Blu notte ColorChooser.crayon.000000=Liquirizia ColorChooser.crayons=Pastelli ColorChooser.apple.000000=Nero ColorChooser.apple.0000ff=Blu ColorChooser.apple.996633=Marrone ColorChooser.apple.00ffff=Ciano ColorChooser.apple.00ff00=Verde ColorChooser.apple.ff00ff=Magenta ColorChooser.apple.ff8000=Arancio ColorChooser.apple.800080=Viola ColorChooser.apple.ff0000=Rosso ColorChooser.apple.ffff00=Giallo ColorChooser.apple.ffffff=Bianco ColorChooser.appleColors=Apple ColorChooser.windowsBasicColors=Windows Basic Colors ColorChooser.color=Colore ColorChooser.list=Elenco\: ColorChooser.colorPalettes=Tavolozze Colori ColorChooser.webSafeColors=Web Safe Colors ColorChooser.profileContainsNColors=Il profilo "$0" contiene $1 colori. FileChooser.replaceAlert=\u201C{0}\u201D esiste gi\u00E0.
Vuoi sostituirlo?

\u00C8 gi\u00E0 presente un documento o una cartella con lo stesso nome in {1}. Sostituendolo verr\u00E0 sostituito il suo contenuto. FileChooser.replace=Sostituisci OptionPane.cancel=Annulla OptionPane.css= ColorChooser.colorPicker=Color Picker TextComponent.cut=Taglia TextComponent.copy=Copia TextComponent.paste=Incolla FileChooser.computerName=Calcolatore FileChooser.cancelButtonText=Annulla FileChooser.newFolderButtonText=Nuova Cartella FileChooser.openButtonText=Apri FileChooser.lookInLabelText=Cerca in: FileChooser.saveInLabelText=Salva in: FileChooser.fileNameLabelText=Nome file: FileChooser.filesOfTypeLabelText=Tipo file: FileChooser.upFolderToolTipText=Cartella superiore FileChooser.upFolderAccessibleName=Superiore FileChooser.homeFolderToolTipText=Principale FileChooser.homeFolderAccessibleName=Principale FileChooser.newFolderToolTipText=Crea nuova cartella FileChooser.newFolderAccessibleName=Nuova cartella FileChooser.newFolderActionLabelText=Nuova cartella FileChooser.listViewButtonToolTipText=Elenco FileChooser.listViewButtonAccessibleName=Elenco FileChooser.listViewActionLabelText=Elenco FileChooser.detailsViewButtonToolTipText=Dettagli FileChooser.detailsViewButtonAccessibleName=Dettagli FileChooser.detailsViewActionLabelText=Dettagli FileChooser.refreshActionLabelText=Aggiorna FileChooser.viewMenuLabelText=Visualizza FileChooser.fileNameHeaderText=Nome FileChooser.fileSizeHeaderText=Dimensioni FileChooser.fileTypeHeaderText=Tipo FileChooser.fileDateHeaderText=Modificato FileChooser.fileAttrHeaderText=Attributi substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/MultiIcon.java0000644000175000017500000000762010564356426025563 0ustar drazzibdrazzib/* * @(#)MultiIcon.java 1.0.1 2006-02-14 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua; import java.awt.*; import javax.swing.*; import javax.swing.plaf.*; import contrib.ch.randelshofer.quaqua.util.*; /** * An icon which paints one out of multiple icons depending on the state * of the component. * MultiIcon can lazily create the icons from a tiled image. * * @author Werner Randelshofer * @version 1.0.1 2006-02-14 Created tileCount icons from image. *
1.0 October 17, 2005 Created. */ public abstract class MultiIcon implements Icon { /** * The icons from which we choose from. * This variable is null, if we are using a tiled image as our base. */ protected Icon[] icons; /** Holds the icon pictures in a single image. This variable is used only *until we create the icons array. Then it is set to null. */ private Image tiledImage; /** * The number of icons in the tiledImage. */ private int tileCount; /** * Whether the tiledImage needs to be tiled horizontaly or vertically * to get the icons out of it. */ private boolean isTiledHorizontaly; /** * Creates a new instance from an array of icons. * All icons must have the same dimensions. * If an icon is null, an icon is derived for the state from the * other icons. */ public MultiIcon(Icon[] icons) { this.icons = icons; generateMissingIcons(); } /** * Creates a new instance from an array of images. * All icons must have the same dimensions. * If an icon is null, an icon is derived for the state from the * other icons. */ public MultiIcon(Image[] images) { this.icons = new Icon[images.length]; for (int i=0, n = icons.length; i < n; i++) { if (images[i] != null) { icons[i] = new ImageIcon(images[i]); } } generateMissingIcons(); } /** * Creates a new instance. * The icon representations are created lazily from the tiled image. */ public MultiIcon(Image tiledImage, int tileCount, boolean isTiledHorizontaly) { this.tiledImage = tiledImage; this.tileCount = tileCount; this.isTiledHorizontaly = isTiledHorizontaly; } public int getIconHeight() { generateIconsFromTiledImage(); return icons[0].getIconHeight(); } public int getIconWidth() { generateIconsFromTiledImage(); return icons[0].getIconWidth(); } public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y) { generateIconsFromTiledImage(); Icon icon = getIcon(c); if (icon != null) { icon.paintIcon(c, g, x, y); } } private void generateIconsFromTiledImage() { if (icons == null) { icons = new Icon[tileCount]; Image[] images = Images.split(tiledImage, tileCount, isTiledHorizontaly); for (int i=0, n = Math.min(images.length, icons.length); i < n; i++) { if (images[i] != null) { icons[i] = new ImageIcon(images[i]); } } generateMissingIcons(); tiledImage = null; } } protected abstract Icon getIcon(Component c); protected abstract void generateMissingIcons(); } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/Quaqua13ColorChooserUI.java0000644000175000017500000001774310564356426030050 0ustar drazzibdrazzib/* * @(#)QuaquaColorChooserUI.java 1.2.1 2006-05-10 * * Copyright (c) 2005-2006 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua; import java.awt.*; import java.awt.event.*; import java.beans.*; import javax.swing.*; import javax.swing.colorchooser.*; import javax.swing.event.*; import javax.swing.plaf.*; import javax.swing.plaf.basic.*; import contrib.ch.randelshofer.quaqua.colorchooser.*; import java.security.*; import java.util.*; /** * QuaquaColorChooserUI. * * @author Werner Randelshofer * @version 1.2.1 2006-05-10 Method createDefaultChoosers mustn't return an * an array with null entries in it. *
1.2 2005-09-18 Read class names of default choosers from UIManager. *
1.1 2005-08-28 ColorWheelChooser and CrayonsChooser added. *
1.0 29 March 2005 Created. */ public class Quaqua13ColorChooserUI extends ColorChooserUI { protected ColorChooserMainPanel mainPanel; protected JColorChooser chooser; protected ChangeListener previewListener; protected PropertyChangeListener propertyChangeListener; protected AbstractColorChooserPanel[] defaultChoosers; protected JComponent previewPanel; public static ComponentUI createUI(JComponent c) { return new Quaqua13ColorChooserUI(); } public void installUI( JComponent c ) { chooser = (JColorChooser)c; installDefaults(); installListeners(); chooser.setLayout( new BorderLayout() ); mainPanel = new ColorChooserMainPanel(); chooser.add(mainPanel); defaultChoosers = createDefaultChoosers(); chooser.setChooserPanels(defaultChoosers); installPreviewPanel(); } protected AbstractColorChooserPanel[] createDefaultChoosers() { String[] defaultChoosers = (String[]) UIManager.get("ColorChooser.defaultChoosers"); ArrayList panels = new ArrayList(defaultChoosers.length); for (int i=0; i < defaultChoosers.length; i++) { try { panels.add(Class.forName(defaultChoosers[i]).newInstance()); } catch (AccessControlException e) { // suppress System.err.println("Quaqua13ColorChooserUI warning: unable to instantiate "+defaultChoosers[i]); } catch (Exception e) { throw new InternalError("Unable to instantiate "+defaultChoosers[i]); } catch (UnsupportedClassVersionError e) { // suppress System.err.println("Quaqua13ColorChooserUI warning: unable to instantiate "+defaultChoosers[i]); } } //AbstractColorChooserPanel[] panels = new AbstractColorChooserPanel[defaultChoosers.length]; return (AbstractColorChooserPanel[]) panels.toArray(new AbstractColorChooserPanel[panels.size()]); } public void uninstallUI( JComponent c ) { chooser.remove(mainPanel); uninstallListeners(); uninstallDefaultChoosers(); uninstallDefaults(); mainPanel.setPreviewPanel(null); if (previewPanel instanceof UIResource) { chooser.setPreviewPanel(null); } mainPanel = null; previewPanel = null; defaultChoosers = null; chooser = null; } protected void installDefaults() { LookAndFeel.installColorsAndFont(chooser, "ColorChooser.background", "ColorChooser.foreground", "ColorChooser.font"); } protected void uninstallDefaults() { } protected void installListeners() { propertyChangeListener = createPropertyChangeListener(); chooser.addPropertyChangeListener( propertyChangeListener ); previewListener = new PreviewListener(); chooser.getSelectionModel().addChangeListener(previewListener); } protected void uninstallListeners() { chooser.removePropertyChangeListener( propertyChangeListener ); chooser.getSelectionModel().removeChangeListener(previewListener); } protected PropertyChangeListener createPropertyChangeListener() { return new PropertyHandler(); } protected void installPreviewPanel() { if (previewPanel != null) { mainPanel.setPreviewPanel(null); } previewPanel = chooser.getPreviewPanel(); if ((previewPanel != null) && (mainPanel != null) && (chooser != null) && (previewPanel.getSize().getHeight()+previewPanel.getSize().getWidth() == 0)) { mainPanel.setPreviewPanel(null); return; } if (previewPanel == null || previewPanel instanceof UIResource) { //previewPanel = ColorChooserComponentFactory.getPreviewPanel(); // get from table? previewPanel = new QuaquaColorPreviewPanel(); chooser.setPreviewPanel(previewPanel); } previewPanel.setForeground(chooser.getColor()); mainPanel.setPreviewPanel(previewPanel); } class PreviewListener implements ChangeListener { public void stateChanged( ChangeEvent e ) { ColorSelectionModel model = (ColorSelectionModel)e.getSource(); if (previewPanel != null) { previewPanel.setForeground(model.getSelectedColor()); previewPanel.repaint(); } } } protected void uninstallDefaultChoosers() { for( int i = 0 ; i < defaultChoosers.length; i++) { chooser.removeChooserPanel( defaultChoosers[i] ); } } /** * This inner class is marked "public" due to a compiler bug. * This class should be treated as a "protected" inner class. * Instantiate it only within subclasses of . */ public class PropertyHandler implements PropertyChangeListener { public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals( JColorChooser.CHOOSER_PANELS_PROPERTY)) { AbstractColorChooserPanel[] oldPanels = (AbstractColorChooserPanel[]) e.getOldValue(); AbstractColorChooserPanel[] newPanels = (AbstractColorChooserPanel[]) e.getNewValue(); for (int i = 0; i < oldPanels.length; i++) { // remove old panels Container wrapper = oldPanels[i].getParent(); if (wrapper != null) { Container parent = wrapper.getParent(); if (parent != null) parent.remove(wrapper); // remove from hierarchy oldPanels[i].uninstallChooserPanel(chooser); // uninstall } } mainPanel.removeAllColorChooserPanels(); for (int i = 0; i < newPanels.length; i++) { if (newPanels[i] != null) { mainPanel.addColorChooserPanel(newPanels[i]); } } for (int i = 0; i < newPanels.length; i++) { if (newPanels[i] != null) { newPanels[i].installChooserPanel(chooser); } } } if ( e.getPropertyName().equals( JColorChooser.PREVIEW_PANEL_PROPERTY)) { if (e.getNewValue() != previewPanel) { installPreviewPanel(); } } } } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/Labels_fr.properties0000644000175000017500000001526310666404636027026 0ustar drazzibdrazzib FileChooser.size=Taille FileChooser.created=Cr\u00E9\u00E9 le FileChooser.modified=Modifi\u00E9 le FileChooser.name=Nom FileChooser.kind=Type FileChooser.whereLabelText=Chemin FileChooser.original=Original FileChooser.sizeBytes={1,choice,0#Zro octets|1#1 octet|1<{1,number} octets}{2,choice,1#|1< pour {2,number} lments} FileChooser.sizeKBytes={0,number,#,##0.#} Ko\n({1,number} octets){2,choice,1#|1< pour {2,number} lments} FileChooser.sizeMBytes={0,number,\#,\#\#0.\#} Mo ({1,number} octets){2,choice,1\#|1< pour {2,number} \u00E9l\u00E9ments} FileChooser.sizeGBytes={0,number,#,##0.#} Go\n({1,number} octets){2,choice,1#|1< pour {2,number} lments} FileChooser.items={0} lments FileChooser.sizeUnknown=-- FileChooser.alias=Alias FileChooser.document=Document FileChooser.folder=Dossier FileChooser.application=Application FileChooser.aliasCount={0,choice,1#{0,number}\u00a0alias|1<{0,number}\u00a0alias} FileChooser.documentCount={0,choice,1#{0,number}\u00a0document|1<{0,number}\u00a0documents} FileChooser.folderCount={0,choice,1#{0,number}\u00a0dossier|1<{0,number}\u00a0dossiers} FileChooser.applicationCount={0,choice,1#{0,number}\u00a0application|1<{0,number}\u00a0applications} ColorChooser.grayScaleSlider=Curseur d'\u00E9chelle de gris ColorChooser.rgbSliders=Curseurs RVB ColorChooser.cmykSliders=Curseurs CMJN ColorChooser.htmlSliders=Curseurs HTML ColorChooser.rgbRedText=Rouge ColorChooser.rgbGreenText=Vert ColorChooser.rgbBlueText=Bleu ColorChooser.cmykCyanText=Cyan ColorChooser.cmykMagentaText=Magenta ColorChooser.cmykYellowText=Jaune ColorChooser.cmykBlackText=Noir ColorChooser.hsbHueText=Teinte ColorChooser.hsbSaturationText=Saturation ColorChooser.hsbBrightnessText=Luminosit\u00E9 ColorChooser.htmlText=HTML\: ColorChooser.htmlChooseOnlyWebSaveColorsText=Choisir que les couleurs "Web-save" ColorChooser.colorSliders=Curseurs de couleur ColorChooser.colorSwatches=Faces de couleur ColorChooser.hsbSliders=Curseurs TSL FileChooser.fromLabelText=Location\: FileChooser.widget=Widget FileChooser.widgetCount={0,choice,1\#{0,number}\u00A0folder|1<{0,number}\u00A0widgets} ColorChooser.colorWheel=Roue des couleurs ColorChooser.crayon.000000=R\u00E9glisse ColorChooser.crayon.000080=Minuit ColorChooser.crayon.004080=Oc\u00E9an ColorChooser.crayon.008040=Mousse ColorChooser.crayon.008000=Tr\u00E8fle ColorChooser.crayon.0000ff=Myrtille ColorChooser.crayon.0080ff=Aqua ColorChooser.crayon.00ff00=Printemps ColorChooser.crayon.00ffff=Turquoise ColorChooser.crayon.808000=Asperge ColorChooser.crayon.008080=Sarcelle ColorChooser.crayon.800080=Prune ColorChooser.crayon.7f7f7f=\u00C9tain ColorChooser.crayon.808080=Nickel ColorChooser.crayon.804000=Moka ColorChooser.crayon.408000=Foug\u00E8re ColorChooser.crayon.400080=Aubergine ColorChooser.crayon.800040=Bordeaux ColorChooser.crayon.666666=Acier ColorChooser.crayon.999999=Aluminium ColorChooser.crayon.ff0000=Marasquin ColorChooser.crayon.ffff00=Citron ColorChooser.crayon.ffffff=Neige ColorChooser.crayon.ff00ff=Magenta ColorChooser.crayon.4c4c4c=Fer ColorChooser.crayon.b3b3b3=Magn\u00E9sium ColorChooser.crayon.ff8000=Mandarine ColorChooser.crayon.80ff00=Citron vert ColorChooser.crayon.00ff80=\u00C9cume ColorChooser.crayon.8000ff=Raisin ColorChooser.crayon.ff0080=Fraise ColorChooser.crayon.333333=Tungst\u00E8ne ColorChooser.crayon.cccccc=Argent ColorChooser.crayon.ff6666=Saumon ColorChooser.crayon.ffff66=Banane ColorChooser.crayon.66ff66=Flore ColorChooser.crayon.66ffff=Glace ColorChooser.crayon.6666ff=Orchid\u00E9e ColorChooser.crayon.ff66ff=Chewing gum ColorChooser.crayon.191919=Plomb ColorChooser.crayon.e6e6e6=Mercure ColorChooser.crayon.ffcc66=Cantaloup ColorChooser.crayon.ccff66=Miell\u00E9e ColorChooser.crayon.66ffcc=Embruns ColorChooser.crayon.66ccff=Ciel ColorChooser.crayon.cc66ff=Lavande ColorChooser.crayon.ff6fcf=\u0152illet ColorChooser.crayon.800000=Cayenne ColorChooser.crayons=Crayons ColorChooser.apple.000000=Noir ColorChooser.apple.0000ff=Bleu ColorChooser.apple.996633=Brun ColorChooser.apple.00ffff=Cyan ColorChooser.apple.00ff00=Vert ColorChooser.apple.ff00ff=Magenta ColorChooser.apple.ff8000=Orange ColorChooser.apple.800080=Violet ColorChooser.apple.ff0000=Rouge ColorChooser.apple.ffff00=Jaune ColorChooser.apple.ffffff=Blanc ColorChooser.appleColors=Apple ColorChooser.windowsBasicColors=Windows couleurs de base ColorChooser.color=Couleur ColorChooser.list=Liste\: ColorChooser.colorPalettes=Palettes de couleurs ColorChooser.webSafeColors=Web Safe Colors ColorChooser.profileContainsNColors=Le profile "{0}" contient {1} couleurs. FileChooser.replaceAlert=\u201C{0}\u201D existe d\u00E9j\u00E0. Souhaitez-vous le remplacer?

Un fichier ou dossier portant le m\u00EAme nom existe d\u00E9j\u00E0 dans {1}. Le remplacer aura pour effet d'\u00E9craser son contenu actuel. #Replace FileChooser.replace=Remplacer OptionPane.cancel=Annuler OptionPane.css= ColorChooser.colorPicker=Color Picker TextComponent.cut=Couper TextComponent.copy=Copier TextComponent.paste=Coller FileChooser.computerName=Ordinateur FileChooser.openButtonText=Ouvrir FileChooser.newFolderButtonText=Nouveau dossier FileChooser.cancelButtonText=Annuler FileChooser.lookInLabelText=Rechercher dans : FileChooser.saveInLabelText=Enregistrer dans : FileChooser.fileNameLabelText=Nom de fichier : FileChooser.filesOfTypeLabelText=Fichiers du type : FileChooser.upFolderToolTipText=Remonte d'un niveau. FileChooser.upFolderAccessibleName=Vers le haut FileChooser.homeFolderToolTipText=R\u00e9pertoire d'accueil FileChooser.homeFolderAccessibleName=Accueil FileChooser.newFolderToolTipText=Cr\u00e9e un nouveau dossier. FileChooser.newFolderAccessibleName=Nouveau dossier FileChooser.newFolderActionLabelText=Nouveau dossier FileChooser.listViewButtonToolTipText=Liste FileChooser.listViewButtonAccessibleName=Liste FileChooser.listViewActionLabelText=Liste FileChooser.detailsViewButtonToolTipText=D\u00e9tails FileChooser.detailsViewButtonAccessibleName=D\u00e9tails FileChooser.detailsViewActionLabelText=D\u00e9tails FileChooser.refreshActionLabelText=Actualiser FileChooser.viewMenuLabelText=Affichage FileChooser.fileNameHeaderText=Nom FileChooser.fileSizeHeaderText=Taille FileChooser.fileTypeHeaderText=Type FileChooser.fileDateHeaderText=Modifi\u00e9 FileChooser.fileAttrHeaderText=Attributs substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/Labels_de.properties0000644000175000017500000001474610666404570027011 0ustar drazzibdrazzib FileChooser.size=Gr\u00F6sse FileChooser.created=Erstellt FileChooser.modified=Ge\u00E4ndert FileChooser.sizeBytes={1,choice,0#0 Bytes|1#1 Byte|1<{1,number} Bytes}{2,choice,1#|1< fr {2,number} Objekte} FileChooser.name=Name FileChooser.whereLabelText=Ort FileChooser.original=Original FileChooser.sizeKBytes={0,number,#,##0.#} KB\n({1,number} Bytes){2,choice,1#|1< fr {2,number} Objekte} FileChooser.sizeMBytes={0,number,#,##0.#} MB\n({1,number} Bytes){2,choice,1#|1< fr {2,number} Objekte} FileChooser.sizeGBytes={0,number,#,##0.#} GB\n({1,number} Bytes){2,choice,1#|1< fr {2,number} Objekte} FileChooser.items={0} Objekte FileChooser.sizeUnknown=-- FileChooser.alias=Alias FileChooser.document=Dokument FileChooser.folder=Ordner FileChooser.application=Programm FileChooser.aliasCount={0,choice,1#{0,number}\u00a0Alias|1<{0,number}\u00a0Alias-Dateien} FileChooser.documentCount={0,choice,1#{0,number}\u00a0Dokument|1<{0,number}\u00a0Dokumente} FileChooser.folderCount={0,choice,1#{0,number}\u00a0Ordner|1<{0,number}\u00a0Ordner} FileChooser.applicationCount={0,choice,1#{0,number}\u00a0Programm|1<{0,number}\u00a0Programme} FileChooser.kind=Art ColorChooser.grayScaleSlider=Graustufen ColorChooser.rgbSliders=RGB ColorChooser.cmykSliders=CMYK ColorChooser.htmlSliders=HTML ColorChooser.rgbRedText=Rot ColorChooser.rgbGreenText=Gr\u00FCn ColorChooser.rgbBlueText=Blau ColorChooser.cmykCyanText=Zyan ColorChooser.cmykMagentaText=Magenta ColorChooser.cmykYellowText=Gelb ColorChooser.cmykBlackText=Schwarz ColorChooser.hsbHueText=Farbton ColorChooser.hsbSaturationText=S\u00E4ttigung ColorChooser.hsbBrightnessText=Helligkeit ColorChooser.htmlText=HTML\: ColorChooser.htmlChooseOnlyWebSaveColorsText=Nur web-sichere Farben w\u00E4hlen ColorChooser.colorSliders=Farbregler ColorChooser.colorSwatches=Farbfelder ColorChooser.hsbSliders=HSV FileChooser.fromLabelText=Ort\: FileChooser.widget=Widget FileChooser.widgetCount={0,choice,1\#{0,number}\u00A0folder|1<{0,number}\u00A0Widgets} ColorChooser.colorWheel=Farbrad ColorChooser.crayon.000000=Lakritze ColorChooser.crayon.000080=Mitternacht ColorChooser.crayon.800000=Cayenne ColorChooser.crayon.808000=Spargel ColorChooser.crayon.0000ff=Blaubeere ColorChooser.crayon.004080=Ozean ColorChooser.crayon.008040=Moos ColorChooser.crayon.0080ff=Wasser ColorChooser.crayon.00ff00=Fr\u00FChling ColorChooser.crayon.00ff80=Gischt ColorChooser.crayon.00ffff=T\u00FCrkis ColorChooser.crayon.191919=Blei ColorChooser.crayon.400080=Aubergine ColorChooser.crayon.408000=Farn ColorChooser.crayon.4c4c4c=Eisen ColorChooser.crayon.666666=Stahl ColorChooser.crayon.6666ff=Orchidee ColorChooser.crayon.66ccff=Himmel ColorChooser.crayon.66ffff=Eis ColorChooser.crayon.800080=Pflaume ColorChooser.crayon.804000=Mokka ColorChooser.crayon.808080=Nickel ColorChooser.crayon.999999=Aluminium ColorChooser.crayon.b3b3b3=Magnesium ColorChooser.crayon.cc66ff=Lavendel ColorChooser.crayon.cccccc=Silber ColorChooser.crayon.ff0080=Erdbeere ColorChooser.crayon.ff00ff=Magenta ColorChooser.crayon.ff6666=Lachs ColorChooser.crayon.ff66ff=Kaugummi ColorChooser.crayon.ffff00=Zitrone ColorChooser.crayon.ffff66=Banane ColorChooser.crayon.ffffff=Schnee ColorChooser.crayon.008000=Klee ColorChooser.crayon.008080=Seegras ColorChooser.crayon.7f7f7f=Zinn ColorChooser.crayon.800040=Dunkelrot ColorChooser.crayon.ff0000=Apfel ColorChooser.crayon.ff8000=Mandarine ColorChooser.crayon.80ff00=Limone ColorChooser.crayon.8000ff=Traube ColorChooser.crayon.333333=Basalt ColorChooser.crayon.66ff66=Pflanzen ColorChooser.crayon.e6e6e6=Quecksilber ColorChooser.crayon.ffcc66=Netzmelone ColorChooser.crayon.ccff66=Zuckermelone ColorChooser.crayon.66ffcc=Meeresgr\u00FCn ColorChooser.crayon.ff6fcf=Nelke ColorChooser.crayons=Farbstifte ColorChooser.apple.000000=Schwarz ColorChooser.apple.0000ff=Blau ColorChooser.apple.996633=Braun ColorChooser.apple.00ffff=Zyan ColorChooser.apple.00ff00=Gr\u00FCn ColorChooser.apple.ff00ff=Magenta ColorChooser.apple.ff8000=Orange ColorChooser.apple.800080=Lila ColorChooser.apple.ff0000=Rot ColorChooser.apple.ffff00=Gelb ColorChooser.apple.ffffff=Weiss ColorChooser.appleColors=Apple ColorChooser.windowsBasicColors=Windows Grundfarben ColorChooser.color=Farbe ColorChooser.list=Palette\: ColorChooser.colorPalettes=Farbpalette ColorChooser.webSafeColors=Web Safe Colors ColorChooser.profileContainsNColors=Das Profil "{0}" enth\u00E4lt {1} Farben. FileChooser.replaceAlert=\u201E{0}\u201C existiert bereits.
M\u00F6chten Sie das Objekt ersetzen?

Es existiert bereits eine Datei oder ein Ordner mit demselben Namen im Ordner \u201E{1}\u201C. Beim Ersetzen wird der Inhalt \u00FCberschrieben. #Replace FileChooser.replace=Ersetzen OptionPane.cancel=Abbrechen OptionPane.css= ColorChooser.colorPicker=Pipette TextComponent.cut=Ausschneiden TextComponent.copy=Kopieren TextComponent.paste=Einsetzen FileChooser.computerName=Computer FileChooser.cancelButtonText=Abbrechen FileChooser.newFolderButtonText=Neuer Ordner FileChooser.openButtonText=\u00D6ffnen FileChooser.lookInLabelText=Suchen in: FileChooser.saveInLabelText=Speichern in: FileChooser.fileNameLabelText=Dateiname: FileChooser.filesOfTypeLabelText=Dateityp: FileChooser.upFolderToolTipText=Eine Ebene h\u00f6her FileChooser.upFolderAccessibleName=H\u00f6her FileChooser.homeFolderToolTipText=Home FileChooser.homeFolderAccessibleName=Home FileChooser.newFolderToolTipText=Neuen Ordner erstellen FileChooser.newFolderAccessibleName=Neuer Ordner FileChooser.newFolderActionLabelText=Neuer Ordner FileChooser.listViewButtonToolTipText=Liste FileChooser.listViewButtonAccessibleName=Liste FileChooser.listViewActionLabelText=Liste FileChooser.detailsViewButtonToolTipText=Einzelheiten FileChooser.detailsViewButtonAccessibleName=Einzelheiten FileChooser.detailsViewActionLabelText=Einzelheiten FileChooser.refreshActionLabelText=Aktualisieren FileChooser.viewMenuLabelText=Ansicht FileChooser.fileNameHeaderText=Dateiname FileChooser.fileSizeHeaderText=Gr\u00f6\u00dfe FileChooser.fileTypeHeaderText=Typ FileChooser.fileDateHeaderText=Ge\u00e4ndert FileChooser.fileAttrHeaderText=Attribut substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/images/0000755000175000017500000000000011256731144024246 5ustar drazzibdrazzibsubstance-5.3.orig/src/contrib/ch/randelshofer/quaqua/images/color_wheel.png0000644000175000017500000000200011205240334027234 0ustar drazzibdrazzibPNG  IHDRw=sRGBgAMA a cHRMz&u0`:pQ<tEXtSoftwarePaint.NET v3.36%ZIDATHK]L[e_7@Dɲ3܅$f7Kdse>@>R6d U0,1R"g'X`|J_*=myW ?=?Nq5l=Q/ eou]ꬱoo 펍n7n4ӧ|o}?pole c}p" w5T[M=%'|\Cqbߏ)/ϯ2z6 ~NQJNICrt(TA/N*$f!KxEV~OZ?i2$9a#:{%Dĩ{vqתޛ;&fyR&L\:MR̥`iU^]ٴ~Z+(֧ w&Oen/aJf\/77oT0lx<Uo^w^m=ϘmI7C4[F˫Olt?l5>=IENDB`substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/images/color_swatch.png0000644000175000017500000000240611205240230027426 0ustar drazzibdrazzibPNG  IHDRשsRGBgAMA a cHRMz&u0`:pQ<PLTEXzPm`okwsgٛ-hx5tRNSS%tEXtSoftwarePaint.NET v3.36%HIDAT(S͏)1 ;`UPUa5c/4Y/U#"9{\wvUU!"cZ!3afcZ[#ƴIENDB`substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/images/big_crayons.png0000644000175000017500000006205610322471744027264 0ustar drazzibdrazzibPNG  IHDR5_B IDATx[sW&+27(BHDV::#P0w䉉jrXj+vW0lU)DɢH 5/r6L |bЊ D?\ַW@/_o.̶k׮~ʊeYym_`Sv_赽J^Ob~{ͤk&^30I퇱Lzm?fka5^c~{ͤk&^30I퇱Lzm?fka5^c~{ͤk&ƾfQm2nhvE٥#..{!.{xu S/no}nkoϩng7o_ztZ{S}g7n|gwګ9~wzժ9n73ӻwkj~vo;#<~ݯ[{-ӯj9s*^aڔ^^^>ZY_;|sy?mo~;|=>򣏶?Z_Y;h{{}e坛7M7`si; |GmMEF_~G++7߹)7K /WVVn޼i7|K*^a^x8'=[w\ڊm!?tw0ȟ99{[\mǹ^*?]_q.wكܺuu;I|zw /pكwnںzJ޿z8B;wںnׯ;>ﮇNN|֝[WعH]w.pr[n]z5cqJם]ū#̲:|}kFcKpF\EiXXT48<(s.VD1kK5w@hp!#JcbjKKi/Z",Y=xpQb}kFŌlvxqFCNGiᅯ"c}WYI;;+,i8GG_o쬬l0SQ#£"ll,hw@8XY;0]a`cc%Y. 4 Ǐ/psb  +++ .|y̾,[$$_}!I,ˎ/%_AHi1\v}!#$,j0#3No ! \f)M.b}~08fSor%l ra,feo 0Arl6& ΃jU2IV7E~:t Ѯ<IQ~u04vvՠ:derΠ!#.D5cc29U}37v8j$&Sw:GG:dn4~t  !2d9`иU:[gaȓD(I*qٳArHe9IU n4#v? „'Cb_Y CU_ ? IFC'8#<,pI,'B <{眎(pSUsl|4I$i{_Tz (9)ʴb/|A4|+}|!'GNH>^_œ q'$|{x1“/O#"&_Y4{ #4ad/J"uBF!z'\p<$Ju=`B=9|T*Pu0t X`~W݇2# T:`~WÇkÇ+ a/Do3[lZkW'FTmYsonn] $A lۚ|kvvڕDhBmY5V}emmJ=@Ȳ9˷fj\YͅY=gmvۭڕ0\msonniDsBmϑP#,L:4TLd0y-;K*hfJteuCV;K*hJs"f1Fj*[YRi@441cX#d˻,si9Ma,Y#*gIML䶬n#@ R*w볤iaA\별D0Mڲaͬn;;mg ǝǶaĽ^`q,zُmqk6vvl>k`aw0v8* c1m,F9m'WxcqL ⃃bvz~mq/nB88pgZ!mێ9*&&z I,Iw4c[QW  ɓb޸c1B"ION LbfɜsN$b'OLB`T,n?,"[R> BU3bQEٳg s.vU2 6ID~Lί~Et=h$6t$4vv~EUflv3$i2jW:ѣq'ͤaŊ 4~;o&eV1ALWu;o&e_Q &ίvN6L i2ض=+&{BTR^nO3L,D䤓4MK㫶aN}Ulݢ"GW{VvN[iJcQNbW.TEQq\wz-iVm`e-F*GGW^)ه4MR)rOÈ֣ѕ \:=.i(h x@0z=zʕsil:L:Q:ٓ"1zddr7UӝUs媮+ѩd$861Mxt_߭N,W]N$#q94m;w^^seE)BPʅ8趉j흧w^U:U(:h* s𶉪ϟ7vV\uEGM .2eMLl+;FC!8SVޜ-zͭVuˣO? 0*A۷l^m]5_<ߟ~x \L!2!!@rGwnuuMU?zO?r <9s ˼r[[Wգ/?ߟ Iب<Bh[[WX7՗G/?.ed e~W6v_5G/?'PŊvBtsm~7666(RU˗KRO#`WVVnܸ(2 d{{{}𰵷?{lfãZ'm7w7h4F-]]ꪏ~v6`*O?no4JYTI} aAX߆fDӘ孵+j=QnLNz`6ף)C./mZ{ny?0z4f˵+[k꣮ZOΦ`GZڤQ!T|VoڶM,+;9==}ɵk4MVWW$"LX?>>^[[I0u0&nJ4u4^oqqn`l&!AYY`iL1McA5d()@o84nزLBAg}e#eqB)W`(UIkشLBA4IL$IVN94*`w5YTCD4h$fi\&N 4A(QB)IQS1l5qsh)QA]BVs!e 7a McFr_pFAXͅ!aqZvHz/W/$_ !q_dLst k/!jG3i'M !W,/y:DL !TA /FhvGcIDYBU,UqApZ3m1m$YB͗AFn!Z e \E)Ǵ3B(&YngAA0w_5'Ճ 4IF!px-D88AHy2L,*lk_P?9 4IsT_N H(``um#ЬŏO0 ry] bm1I P%,NFaHU 0^W*ƘIYuSE.DhZgKlY( t*XDL$y4=g}!YF l誚)fNnt|ЛX}`ACTSraHXx{3UUu]ϗ6="a`0rrS,JLrAe`dW@O#4duM)Kd7R"lCՁ ASBgıy&" k. $ kH$ zJ%_@-MI%(JL&1eUE2)vABZ*5]&L:k_ÀZ j2_FI4'quc=4hL;cښX,r 9\Zx:|OR1m?ejKZ\sQ${iDјv6B}XCB^7O:h( zgcA3?ˇDӖ'ZLP4v T .C-tʉѠw62BUJ zY$i IDAT2dM,3Uaas]1&z($[ir'sRɶ0$2!ˤ\??tiѸ;Vw>I4I,aB1E E 5eRkjwuM?t")J҄20&@*J*TLDHU5Zh_{RpgFkK%c(UVR(()BZkKAX]wO_׺ǝ)KR&!5 * P*j,qKFcQ]Që`HU JT@Z䛵k`z㞦wǣ0HD2BBAT!8ѩ}vf/pԒk~ɉ4M5MSU!df\^__T*V#t:@\F&Eϟ[`ѱ9۵xI_wԶl}ч0Pf zKP)˫wj-6hxA0&SwVlն6 Ǵ:I.3C]y^Xnv݋<&YaY "2\o[e`0!gLc޶, h ōDXD3߃6-BQIҰәoeYEa$adb0Aos˲ dI0 Ӌ3:N:cc9 r,T9q۶j>!eyׁ,m8L]pY/E %1`k3&̥\Ad iB*ao\oAP6͍sG_.A0# yi{o fLl^xuW k4M[ZZ!D&<7 c!|V#dLX5{oyc$ĪXm[#yy4*X"2{Tcc]`BH yf.O,cXŏ6C#q 3Z6F`[&0=oBa]p$NCЃ d (gzs7d< Di{ֶk!۶3&M);QU5 f0)s0c68( )*\̦ R({* Ȩ3M#I@ E7W 0|$ E7臭ap8( PtwT!w44SryBnOh&|=wqugYv4ۤSw[UmTY}yΨ?hSﶭE,ϑAG`4m]AΨ=նX0ڨ(LQk{jVAN:3eylI!{ F#Lֶdϊ@T9I4u- g!Ʉ)47E &rY%(15u麖1)SKZYS(`k'=eEWJAi\݂T@Pߘ\=DY++^*pيJ iIcywZa(@&Rd,n7MSobՖnRzYqs4M=ObRAG4+WsQ4MO򠠱DMrqG[ʝΕDOTQ (5CpxԼrq#90!͍iO$0!xBU4MlZVK9ZbP:(׾W[UWn}^wIthV Ys m?YZFYqVt:Dx^U[`^?$3V:E BOVkaD4g)>m9(5.PU+0:$t+:Al^'{FKS||Z!}嫮W\,PQ9M;1y\˲,2 1~JӴncO0&ǘ0}ou;L!1HsP,z?^Z=m<8;W9P @S)LQLU{\:]m|j:LV'P f:C:jko] ӏ^sB ]o7ߪ]Տ?yWns0B Ln~z)8m|`OOv; HZo6j${(r'$I$4|&DZVwj޶m )k`t6BHk8ZZmZ_<ϳ,k0(;f58B rm3ŀ)P ˫ԮnAܶFɅ @  W7d@,ZsC۱ŗBJ\pFRH)Pkܼzkv uQpߣ/) D @mrZ;2>ŗ|B0;1 \&^ݪmpۥ_6D_SaN ;j[Wם |Dv:܊8KKr;\~mnnB_UQ4!BKKKrB׶m0꫅t퍿{8m~_tgV22y}%&D/M"uG$:0>_*4r=w$ ,'1=|(M\`zzhTEIޘ#'\|$z$J]+ x{wK^e%B>NE/q5q]s~ӥM83+1m˲ v&b1),AټgږeL'1UxBe!C5&)!~޲, FD$t,2ӝqv˲,EaIys˲ B,9b^Zq#Җ$InZiDNݜJLРR.#Ա%6:ԥ %#X7mkc3wȺbbS߰ۙP"S7PqrWgB б)6wB)*3@MY]_^RL(\ퟜ[|0Ƥ0 _~3)nyerd ʉE@cb[nBV#4IZUNp&^y:@-b[vVOޘte23c[2fl4 [maIJ137izvvFu-2bY5R9=Q"Y}~RKhfʹ6wGeqD i@4R29qk]n,/B4MmwdWrˤqE7iiE9'b6'JV% AK4Sfʖ{D TZ=M,ńNVy[FNd]Bȋ/f4M+J9Iv9>>%NjkױQгc4Vfkak[~cT bA[]GvG(_aX plƥx~vܘ0 b &-Gmvl( ؆Y*Fh]A:c>/~l\~A@ei);RiVZr.&M%'8{r p6\Hz`~r ڗ-Hah?nEfzd܃L:Z7WRrI12?rB } VXӛ@BOc Lsz]Ob0X5Q.mXUK[~$;e~`&uJRs(pH~8񍜼1rR(yA> B_t'(%/ 8$( 2# N)Q3>E4BHRLwA̾NjgfG2lS}Y$m19?8P4"ZyYw8A<@1mzY ٷ- [jV4a- [sj7sȰ= [5+E5(K4M` $X]{KT>E-ʦe0%oW*t3)[eEgJ0D0o.Ɲ7"M%ϾNh܉|3)YVtV &_o}J9QX47 \bj{SRR:Du皦50Q&JM;1I ضOp^i|ՖW4MKت-/8Y.cZ@ى}╢)'r:AMbENv`!q?MSESN}#'(6W~d9 $l;Xnъu@ ؉4\ e1&$aڄTLNWN89.'aI2W~7XukZ_0VZ ~sQ*Psѩd/aXalS}|ΪϑAz}aM[j,bOۧ]>_֩<|c4! 6?x|u ;i=eI(p1|rjٍci[ 2jqguWi[tOESa(vVo,E4MEz9= <}빮+[7IMʾ)]C\ Gq7{Y$I ф@IAŠ PT#d(۵{AP=;k{I5q;h}ј LTRT`HGm~^56Ϛ< @J *@a"{Z5gg{Vn:I ƴUH* @B 6{V>y0pNs0B:эmޫy{[t;p1'tOu}]o~r$r•&_T\":>t:ZAo~e4(a&oQ"p_nN1\Mjm؎m!!:޻qL m˿q(zC;אָj5!p}>{'kC*77Ó?9QqhFz4~r|( TY}3LN,;ӶS-Ju2`Gǟ߻qCZy||n_\zAdBe1Rj4M17h5M4Mu-g7YRͷF@r znzʧvFGƖ AD;a=BVd+v Sc96 &:+ ET>I"?֧&Ac #GN爮!EǑ+AF2+3+]U.TM_5k{ }Lcg̋~Z`ma/ƍmmnke\FD2bBɤDJJW0fT~L\Y\<,I&ЦƐUG$0B:r0Yd#$ Bk +˧%$aW8g :%I20ΆQY>Q|:Lc頥zsЦyޟ0bi,=I MmgRUߡ'2Beig-)ZRg5Y%!48'Mm=dU!D lJuy֪"#hUem*Lx$G4 @mx p_ :Rvt+ض 1 bfC~qD `A1מaP쮐0 b=m۸Bnpp+sgM W1ikAm߼BvWYo A,1ݺI* ;[ l&7 mEH_|YF.o&:m;I2iQrםK! J@(B$i-/0Ea-&I nPK# 0\Ηj@( Y4 #PY*8Qq/7PB`i"U] m nI- Y&Ah/R%q^'-b:1V(=[PLc 1K'c;BU.n&1B[5 etT"Y=3{X7 PƶSd.4EI+ x\R 9^jic-ݝ<RaNJed"ּE~aT$])li"d7GbШV mi}$4)![RD7mY~bjڴ*4@yݬ @BG#JJ3BUS `"ӾyuTOFL&)K*ڵkI v7a(.j&>!sʖU&ݡnH'–AU&QhI'TP ʤ u @|^T&VJ T&ݺT&22{ne5I*s(RmSpT;îqJQY+I[u eU%=pNmZuDZ f(+&$XgKcGэLy6*4'p*ɰG)2 `Y *$)GZgp,(xk8*iHӴԒ-oJ~@#%a4bCZ]KRtctV8w5lċ5Ȃqkܵ alZ旊#B邙IQ•k#ft3SrǶm|&I}땩һロeR]tTpTڜжC[["ޛ# [w$‘I$. nu7$>uē$IbsAEtC6zx#BoKD"3I ~u흕iS$DI6!{ݙ",M%Im~3lmofIG=C!,kySJmGd٬iJj ΰ7Ӵ'sBe3޻Ihӕ&!eAa|MλuǺ|=ホ$Π;1|Fʴ^cw_H{AwA4wXօ4tI?H.f,x%>:݁$1w,.fp,{L&A852bi[G!,kZF<@.!d<m;j@)Ab>:==~_/H& vww ߧ꺮:q_7z/ڻʼn97v/_1vϲȧxZB?n@ 7.^0v-O? TT$ ݢoؿzu8IJ>Ïc Zyy7:&Вw޻sfho7W]qQ\)OZT@su덛t )*O8$F& )F =?}{  /`[i9_^m۶뺾?yիTʟӧOo٠tzwdz~2 6 "HH8Ir?QmD@$ ǡtMљ <2F $O7]Qx9@'kj@f"Γ䴲DݓWC*!J;r]dR!MӃ;w3I=}"B(T\+qu>jE~{^woV'եLNE~ Drfdj蚭p='>o" HhJHuC۳V^Iw~PrF#fm[ѪʡnBQ@*AӍ-/P=>M24o5Coۡ@?CH+37"kv4-Ye}yaMt] 4&zypyh1oKg,mE%娻^AC[Q =ٸ@w?dU8̻TB*=]8>>V_~Vx<^6F1.-ӆQЍI<ʞjs%cC7٘Py+(\+FXȊ\' C04M[ȵ!=R}áZTϠQ,K^7W RucDi1]]SWK e^t^ sQhj4:K%*f q=ڒn0x.)Znp/Ai-=:a1AN<qkUJ=P9YEaB穪ʿh?n$G<ጞHLMxk4LȣQ8 &f\B芽*$Hv`b~Rf"9Bhi0?'ts늍i#)x2b4[WF1,n.X˯/U| )UNS2RzO+Iա L$l7HV%ώU&ݝp OC۹gʏ~U&ݓKⳤ_^W&ݓN(qAeҍ'!H`_g2];<=P <~RR=h~I)L9.\ e h?n}= I@ `bpaEl:=Ne8* "G=r/CP m Ў*G=\hK9l`VM[jA&aԓYW^ᜟx"{x3Y/HLY+>w<48j% # @=ޭw>{Nћ,^tfj Z ~"YrXb_~}(M[n]wJW^Lqo}[O?ݸu^wĤ+']1)i.6(.6\dpjYů>[7dЋDt';)i5055k @]Kc>CsVNwŤ+'8W"bÝWiV&ܹuA'κѝNk j`w^ fiY&> uFփMΔX.2(6]0 JXL2y Iv:MDo(r @ LuD 14f )>oϞ={ѓ'OCϷ?ƍeYKɢ)S.4MӟR?(SX2ң` C2m!fY [|2 }h1lH#E"bdLD`bB&b&ɨ? N  4dt'!Sæ6)6869Fq0`jf*!"+?0fbB S3 qs Ɠ~ SF L@- lRl1drlq<MA m)bMDX7ebbbDܚjFA)U]J$)oqvH۶M)}n ej.Ž^IDAT XԡfO3uX#qw qDZ:88׵q]:B%:q8.]*>^Ĺ]ץ΅$(Jp} u+$`͜%}9Sb*QuRuUQq\>hbT]Y PGAͤ()T- 8iBJi8/aU2K(1T!+Ծ8&yz!C񱈏x=蓟ϼwnݖF8X,J0U=&>?Q+nz'4䱈Hb1l%J&?ns+q,(JxDx?~˜[24 f(j RevVOWmc(8-Z-`s+뇇 X[>ϟ{w֭^: j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j& j&xAxWfR͠fRSJ(sQ_18v=|p8\ru:?&5EPi/\nIENDB`substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/images/chart_bar.png0000644000175000017500000000164711205240076026702 0ustar drazzibdrazzibPNG  IHDRw=sRGBgAMA a cHRMz&u0`:pQ<tEXtSoftwarePaint.NET v3.36%IDATHKKQ_YVvB- %+4KR3ټl93]Y9MԙJôJNro| k~C//w߳b4 =,c>8{1||Əp,^%:Ud0&y>2 5XmغZ4շXOcL7oD\ IAJ)Y uO*c JÃ΂p/@~@`hC>2@$Ɣa TUE4*oc)&2=s|~!po=vwpIl9)Ij5sDX0iz?B,Q jgU?[- P?"4OL|H3pxd^O{'(ЀȒiiH"C7M oNxj3vw1G9y+Fyݧm]:c^]ds7Uj#f `yG(P+2X =Xԋ5tp>۞& xCpd6 82`䴗O~thzgNl qgC69%7p(c[=BZJ AJt&K[fB\n M i8|FDJC.݅(-w!w[xfg=vIsI5'Xc'y2Nx8IENDB`substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/images/palette.png0000644000175000017500000000164611205240274026412 0ustar drazzibdrazzibPNG  IHDRw=sRGBgAMA a cHRMz&u0`:pQ<tEXtSoftwarePaint.NET v3.36%IDATHKKQ{?@25,L/a4uxNt)ԥ.WsF9Ϧ~;jw@0۔i2jA%ᜩ-A,K΀3A,wP.AR+dW[aQbg +V:?avJ]fSH LKD~`<"ǘlɅ$Vk@蛂`-# 77,0C= * 36LW|TG7Ǩ>1 PQˉ"RhJ@|X"# 8ŗ‹_}Q88nϺ[u4bYYPo+M ,Wkl5? _2Au SL 8tP %*dɘ%8Ј|>y8)D5eUWL)K0%8<_L00+g5 QbɴHő,_|ͧc i=!͂!r ,żG6 7O;NݎSǦYI?p7+ÏŒ)Y- =. >K8ݐn3'QXIENDB`substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/images/pencil.png0000644000175000017500000000077711205240366026234 0ustar drazzibdrazzibPNG  IHDRw=sRGBgAMA a cHRMz&u0`:pQ<tEXtSoftwarePaint.NET v3.36%YIDATHKc`!+缽թOLi{KL%b7W4'x|N5@re  )dxu9_ NON0|͌07ONO=$rw}mz:8BmT>>#YAdXN}OΕ_ᙆ~&E((, ̝oV%1to)ӡpNB̉oίۃz,p$N*]k)Dw%)*EIENDB`substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/util/0000755000175000017500000000000011256731144023756 5ustar drazzibdrazzibsubstance-5.3.orig/src/contrib/ch/randelshofer/quaqua/util/Images.java0000644000175000017500000002543710564356432026045 0ustar drazzibdrazzib/* * @(#)Images.java 2.0 2006-12-24 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.util; import java.awt.*; import java.awt.image.*; import java.io.*; import java.net.*; import java.util.*; import javax.swing.*; import contrib.ch.randelshofer.quaqua.*; /** * Image processing methods. * * @author Werner Randelshofer, Karl von Randow * @version 2.0 2006-12-24 by Karl von Randow: On the fly conversion from Aqua * Blue to Aqua Graphite appearance added. *
1.0.2 2005-09-12 Brought my work-around for Java 1.4.1 back to * live. *
1.0.1 2005-05-21 Accidentaly used bitmask transparency * instead of translucent transparency. *
1.0 13 March 2005 Created. */ public class Images { /** Prevent instance creation. */ private Images() { } private static GraphiteFilter graphiteFilter = new GraphiteFilter(); public static Image createImage(URL resource) { Image image = Toolkit.getDefaultToolkit().createImage(resource); // if (Preferences.getString("AppleAquaColorVariant").equals("6")) { // if (canGraphite(resource)) { // image = toGraphite(image); // } // } return image; } private static Properties canGraphite; private static boolean canGraphite(URL resource) { if (canGraphite == null) { synchronized (Images.class) { if (canGraphite == null) { Properties p = new Properties(); try { p.load(Images.class.getResourceAsStream("graphiteable.properties")); } catch (IOException e) { System.err.println("Failed to load graphiteable.properties: " + e); } canGraphite = p; } } } String file = resource.getFile(); int i = file.lastIndexOf(File.separatorChar); if (i != -1) { file = file.substring(i + 1); } return canGraphite.containsKey(file); } /** * This method returns a buffered image with the contents of an image. * * Code derived from the Java Developers Almanac 1.4 * http://javaalmanac.com/egs/java.awt.image/Image2Buf.html?l=rel */ private static Image toGraphite(Image image) { return Toolkit.getDefaultToolkit(). createImage(new FilteredImageSource(image.getSource(), graphiteFilter)); } /** * Based on a code example from: * http://tams-www.informatik.uni-hamburg.de/applets/hades/webdemos/00-intro/02-imageprocessing/saturation.html * @author karlvr * */ public static class GraphiteFilter extends RGBImageFilter { private final static float saturationAdjust = 0.179f; private static float hueAdjust = 0.0052f; private static float brightnessAdjust = 0.09f; private float[] hsb = new float[3]; public int filterRGB(int x, int y, int rgb) { int alpha = rgb & 0xff000000; int red = (rgb >> 16) & 0xff; int green = (rgb >> 8) & 0xff; int blue = rgb & 0xff; /* float RW = (1f - saturationAdjust) * 0.3086f; // or 0.299 for YIV values float RG = (1f - saturationAdjust) * 0.6084f; // or 0.587 for YIV values float RB = (1f - saturationAdjust) * 0.0820f; // or 0.114 for YIV values */ float RW = (1f - saturationAdjust) * 0.333f; // or 0.299 for YIV values float RG = (1f - saturationAdjust) * 0.333f; // or 0.587 for YIV values float RB = (1f - saturationAdjust) * 0.333f; // or 0.114 for YIV values float a = RW + saturationAdjust; float b = RW; float c = RW; float d = RG; float e = RG + saturationAdjust; float f = RG; float g = RB; float h = RB; float i = RB + saturationAdjust; int outputRed = (int) (a*red + d*green + g*blue); int outputGreen = (int) (b*red + e*green + h*blue); int outputBlue = (int) (c*red + f*green + i*blue); return alpha | (outputRed << 16) | (outputGreen << 8) | (outputBlue); } } public static BufferedImage toBufferedImage(Image image) { if (image instanceof BufferedImage) { return (BufferedImage)image; } // This code ensures that all the pixels in the image are loaded image = new ImageIcon(image).getImage(); // Create a buffered image with a format that's compatible with the screen BufferedImage bimage = null; if (System.getProperty("java.version").startsWith("1.4.1_")) { // Workaround for Java 1.4.1 on Mac OS X. // For this JVM, we always create an ARGB image to prevent a class // cast exception in // sun.awt.image.BufImgSurfaceData.createData(BufImgSurfaceData.java:434) // when we attempt to draw the buffered image. bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); } else { // Determine if the image has transparent pixels; for this method's // implementation, see e661 Determining If an Image Has Transparent Pixels boolean hasAlpha; try { hasAlpha = hasAlpha(image); } catch (IllegalAccessError e) { // If we can't determine this, we assume that we have an alpha, // in order not to loose data. hasAlpha = true; } GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { // Determine the type of transparency of the new buffered image int transparency = Transparency.OPAQUE; if (hasAlpha) { transparency = Transparency.TRANSLUCENT; } // Create the buffered image GraphicsDevice gs = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gs.getDefaultConfiguration(); bimage = gc.createCompatibleImage( image.getWidth(null), image.getHeight(null), transparency); } catch (Exception e) { //} catch (HeadlessException e) { // The system does not have a screen } if (bimage == null) { // Create a buffered image using the default color model int type = BufferedImage.TYPE_INT_RGB; if (hasAlpha) { type = BufferedImage.TYPE_INT_ARGB; } bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); } } // Copy image to buffered image Graphics g = bimage.createGraphics(); // Paint the image onto the buffered image g.drawImage(image, 0, 0, null); g.dispose(); return bimage; // My own implementation: /* if (image instanceof BufferedImage) { return (BufferedImage) image; } else { BufferedImage bufImg; Frame f = new Frame(); f.pack(); MediaTracker t = new MediaTracker(f); t.addImage(image, 0); try { t.waitForAll(); } catch (InterruptedException e) {} // Workaround for Java 1.4.1 on Mac OS X. if (System.getProperty("java.version").startsWith("1.4.1_")) { bufImg = new BufferedImage(image.getWidth(f), image.getHeight(f), BufferedImage.TYPE_INT_ARGB); } else { bufImg = GraphicsEnvironment .getLocalGraphicsEnvironment() .getDefaultScreenDevice() .getDefaultConfiguration() .createCompatibleImage(image.getWidth(null), image.getHeight(null), Transparency.TRANSLUCENT); } Graphics2D imgGraphics = bufImg.createGraphics(); imgGraphics.drawImage(image, 0, 0, f); imgGraphics.dispose(); f.dispose(); return bufImg; }*/ } /** * This method returns true if the specified image has transparent pixels * * Code taken from the Java Developers Almanac 1.4 * http://javaalmanac.com/egs/java.awt.image/HasAlpha.html */ public static boolean hasAlpha(Image image) { // If buffered image, the color model is readily available if (image instanceof BufferedImage) { BufferedImage bimage = (BufferedImage)image; return bimage.getColorModel().hasAlpha(); } // Use a pixel grabber to retrieve the image's color model; // grabbing a single pixel is usually sufficient PixelGrabber pg = new PixelGrabber(image, 0, 0, 1, 1, false); try { pg.grabPixels(); } catch (InterruptedException e) { } // Get the image's color model ColorModel cm = pg.getColorModel(); return cm.hasAlpha(); } /** * Splits an image into count subimages. */ public static BufferedImage[] split(Image image, int count, boolean isHorizontal) { BufferedImage src = Images.toBufferedImage(image); if (count == 1) { return new BufferedImage[] { src }; } BufferedImage[] parts = new BufferedImage[count]; for (int i=0; i < count; i++) { if (isHorizontal) { parts[i] = src.getSubimage( src.getWidth() / count * i, 0, src.getWidth() / count, src.getHeight() ); } else { parts[i] = src.getSubimage( 0, src.getHeight() / count * i, src.getWidth(), src.getHeight() / count ); } } return parts; } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/util/package.html0000644000175000017500000000125210322471750026234 0ustar drazzibdrazzib Contains utility classes which are used by the Quaqua Look and Feel. substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/util/ShiftedIcon.java0000644000175000017500000000314110564356670027027 0ustar drazzibdrazzib/* * @(#)ShiftedIcon.java 1.0 May 12, 2006 * * Copyright (c) 2006 Werner Randelshofer * Staldenmattweg 2, CH-6405 Immensee, Switzerland * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.util; import java.awt.*; import javax.swing.*; /** * ShiftedIcon renders a target icon at a different location and can return * different width and height values than the target. * * @author Werner Randelshofer. * @version 1.0 May 12, 2006 Created. */ public class ShiftedIcon implements Icon { private Icon target; private Rectangle shift; /** Creates a new instance. */ public ShiftedIcon(Icon target, Point shift) { this.target = target; this.shift = new Rectangle( shift.x, shift.y, target.getIconWidth(), target.getIconHeight() ); } public ShiftedIcon(Icon target, Rectangle shiftAndSize) { this.target = target; this.shift = shiftAndSize; } public void paintIcon(Component c, Graphics g, int x, int y) { target.paintIcon(c, g, x + shift.x, y + shift.y); } public int getIconWidth() { return shift.width; } public int getIconHeight() { return shift.height; } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/util/ResourceBundleUtil.java0000644000175000017500000001550710564356432030414 0ustar drazzibdrazzib/* * @(#)ResourceBundleUtil.java 1.3.3 2005-11-07 * * Copyright (c) 2000-2005 Werner Randelshofer * Staldenmattweg 2, CH-6405 Immensee, Switzerland * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.util; import java.util.*; import javax.swing.KeyStroke; import javax.swing.UIManager; import javax.swing.ImageIcon; import java.text.MessageFormat; import java.net.URL; /** * This is a convenience wrapper for accessing resources stored in a ResourceBundle. * * @author Werner Randelshofer, Staldenmattweg 2, CH-6405 Immensee, Switzerland * @version 1,3.3 2005-11-07 Method getLocale added. *
1.3.2 2004-05-02 Method getLAFBundle without Locale as parameter * added. *
1.3.1 2002-07-30 Method getLAFBundle now takes a Locale as * an additional parameter. *
1.3 2001-10-10 The default resource name changed from 'name_Metal' * to 'name'. *
1.2 2001-07-23 Adaptation to JDK 1.3 in progress. *
1.0 2000-06-10 Created. */ public class ResourceBundleUtil { /** The wrapped resource bundle. */ private ResourceBundle resource; /** * Creates a new ResouceBundleUtil which wraps * the provided resource bundle. */ public ResourceBundleUtil(ResourceBundle r) { resource = r; } /** * Get a String from the ResourceBundle. *
Convenience method to save casting. * * @param key The key of the property. * @return The value of the property. Returns the key * if the property is missing. */ public String getString(String key) { try { return resource.getString(key); } catch (MissingResourceException e) { return '-'+key+'-'; } } /** * Get an image icon from the ResourceBundle. *
Convenience method . * * @param key The key of the property. * @return The value of the property. Returns null * if the property is missing. */ public ImageIcon getImageIcon(String key, Class baseClass) { try { String rsrcName = resource.getString(key); if (rsrcName.equals("")) { return null; } URL url = baseClass.getResource(rsrcName); return (url == null) ? null : new ImageIcon(url); } catch (MissingResourceException e) { return null; } } /** * Get a Mnemonic from the ResourceBundle. *
Convenience method. * * @param key The key of the property. * @return The first char of the value of the property. * Returns '\0' if the property is missing. */ public char getMnemonic(String key) { String s = resource.getString(key); return (s == null || s.length() == 0) ? '\0' : s.charAt(0); } /** * Get a Mnemonic from the ResourceBundle. *
Convenience method. * * @param key The key of the property. This method appends "Mnem" to the key. * @return The first char of the value of the property. * Returns '\0' if the property is missing. */ public char getMnem(String key) { String s = resource.getString(key+"Mnem"); return (s == null || s.length() == 0) ? '\0' : s.charAt(0); } /** * Get a KeyStroke from the ResourceBundle. *
Convenience method. * * @param key The key of the property. * @return javax.swing.KeyStroke.getKeyStroke(value). * Returns null if the property is missing. */ public KeyStroke getKeyStroke(String key) { KeyStroke ks = null; try { String s = resource.getString(key); ks = (s == null) ? (KeyStroke) null : KeyStroke.getKeyStroke(s); } catch (NoSuchElementException e) { } return ks; } /** * Get a KeyStroke from the ResourceBundle. *
Convenience method. * * @param key The key of the property. This method adds "Acc" to the key. * @return javax.swing.KeyStroke.getKeyStroke(value). * Returns null if the property is missing. */ public KeyStroke getAcc(String key) { KeyStroke ks = null; try { String s = resource.getString(key+"Acc"); ks = (s == null) ? (KeyStroke) null : KeyStroke.getKeyStroke(s); } catch (NoSuchElementException e) { } return ks; } public String getFormatted(String key, Object argument) { return MessageFormat.format(resource.getString(key), new Object[] {argument}); } public String getFormatted(String key, Object[] arguments) { return MessageFormat.format(resource.getString(key), arguments); } public Locale getLocale() { return resource.getLocale(); } /** * Get the appropriate ResourceBundle subclass. * * @see java.util.ResourceBundle */ public static ResourceBundleUtil getBundle(String baseName) throws MissingResourceException { return new ResourceBundleUtil(ResourceBundle.getBundle(baseName, Locale.getDefault())); } /** * Get the appropriate ResourceBundle subclass. * The baseName is extended by the Swing Look and Feel ID * and by the Locale code returned by Locale.getDefault(). * * The default Look and Feel ID is Metal. * * @see java.util.ResourceBundle */ public static ResourceBundleUtil getLAFBundle(String baseName) throws MissingResourceException { return getLAFBundle(baseName, Locale.getDefault()); } /** * Get the appropriate ResourceBundle subclass. * The baseName is extended by the Swing Look and Feel ID * and by the Locale code. * * The default Look and Feel ID is Metal. * * @see java.util.ResourceBundle */ public static ResourceBundleUtil getLAFBundle(String baseName, Locale locale) throws MissingResourceException { ResourceBundleUtil r; try { r = new ResourceBundleUtil( ResourceBundle.getBundle( baseName + "_" + UIManager.getLookAndFeel().getID(), locale ) ); } catch (MissingResourceException e) { r = new ResourceBundleUtil( ResourceBundle.getBundle(baseName, locale) ); } return r; } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/util/Methods.java0000644000175000017500000005171410564356432026240 0ustar drazzibdrazzib/* * @(#)Methods.java 1.3.1 2006-09-18 * * Copyright (c) 2005-2006 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.util; import java.lang.reflect.*; /** * Methods contains convenience methods for method invocations using * java.lang.reflect. * * @author Werner Randelshofer * @version 1.3.1 2006-09-18 Fixed javadoc warnings. *
1.2 2006-08-20 Additional invokeIfExists method added. *
1.2 2006-05-07 Added invokeNew method. *
1.1 2006-02-18 Added more convenience methods. *
1.0 September 24, 2005 Created. */ public class Methods { /** * Prevent instance creation. */ private Methods() { } /** * Invokes the specified accessible parameterless method if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. * @return The return value of the method. * @return NoSuchMethodException if the method does not exist or is not * accessible. */ public static Object invoke(Object obj, String methodName) throws NoSuchMethodException { try { Method method = obj.getClass().getMethod(methodName, new Class[0]); Object result = method.invoke(obj, new Object[0]); return result; } catch (IllegalAccessException e) { throw new NoSuchMethodException(methodName+" is not accessible"); } catch (InvocationTargetException e) { // The method is not supposed to throw exceptions throw new InternalError(e.getMessage()); } } /** * Invokes the specified accessible method with a string parameter if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. * @param stringParameter The String parameter * @return The return value of the method or METHOD_NOT_FOUND. * @return NoSuchMethodException if the method does not exist or is not accessible. */ public static Object invoke(Object obj, String methodName, String stringParameter) throws NoSuchMethodException { try { Method method = obj.getClass().getMethod(methodName, new Class[] { String.class }); Object result = method.invoke(obj, new Object[] { stringParameter }); return result; } catch (IllegalAccessException e) { throw new NoSuchMethodException(methodName+" is not accessible"); } catch (InvocationTargetException e) { // The method is not supposed to throw exceptions throw new InternalError(e.getMessage()); } } /** * Invokes the specified method if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. * @param types The parameter types. * @param values The parameter values. * @return The return value of the method. * @return NoSuchMethodException if the method does not exist or is not accessible. */ public static Object invoke(Object obj, String methodName, Class[] types, Object[] values) throws NoSuchMethodException { try { Method method = obj.getClass().getMethod(methodName, types); Object result = method.invoke(obj, values); return result; } catch (IllegalAccessException e) { throw new NoSuchMethodException(methodName+" is not accessible"); } catch (InvocationTargetException e) { // The method is not supposed to throw exceptions throw new InternalError(e.getMessage()); } } /** * Invokes the specified accessible parameterless method if it exists. * * @param clazz The class on which to invoke the method. * @param methodName The name of the method. * @return The return value of the method or METHOD_NOT_FOUND. * @return NoSuchMethodException if the method does not exist or is not accessible. */ public static Object invokeStatic(Class clazz, String methodName) throws NoSuchMethodException { try { Method method = clazz.getMethod(methodName, new Class[0]); Object result = method.invoke(null, new Object[0]); return result; } catch (IllegalAccessException e) { throw new NoSuchMethodException(methodName+" is not accessible"); } catch (InvocationTargetException e) { // The method is not supposed to throw exceptions throw new InternalError(e.getMessage()); } } /** * Invokes the specified static parameterless method if it exists. * * @param clazz The class on which to invoke the method. * @param methodName The name of the method. * @return The return value of the method. * @return NoSuchMethodException if the method does not exist or is not accessible. */ public static Object invokeStatic(String clazz, String methodName) throws NoSuchMethodException { try { return invokeStatic(Class.forName(clazz), methodName); } catch (ClassNotFoundException e) { throw new NoSuchMethodException("class "+clazz+" not found"); } } /** * Invokes the specified static method if it exists. * * @param clazz The class on which to invoke the method. * @param methodName The name of the method. * @param types The parameter types. * @param values The parameter values. * @return The return value of the method. * @return NoSuchMethodException if the method does not exist or is not accessible. */ public static Object invokeStatic(Class clazz, String methodName, Class[] types, Object[] values) throws NoSuchMethodException { try { Method method = clazz.getMethod(methodName, types); Object result = method.invoke(null, values); return result; } catch (IllegalAccessException e) { throw new NoSuchMethodException(methodName+" is not accessible"); } catch (InvocationTargetException e) { // The method is not supposed to throw exceptions throw new InternalError(e.getMessage()); } } /** * Invokes the specified static method if it exists. * * @param clazz The class on which to invoke the method. * @param methodName The name of the method. * @param types The parameter types. * @param values The parameter values. * @return The return value of the method. * @return NoSuchMethodException if the method does not exist or is not accessible. */ public static Object invokeStatic(String clazz, String methodName, Class[] types, Object[] values) throws NoSuchMethodException { try { return invokeStatic(Class.forName(clazz), methodName, types, values); } catch (ClassNotFoundException e) { throw new NoSuchMethodException("class "+clazz+" not found"); } } /** * Invokes the specified static method if it exists. * * @param clazz The class on which to invoke the method. * @param methodName The name of the method. * @param type The parameter types. * @param value The parameter values. * @return The return value of the method. * @return NoSuchMethodException if the method does not exist or is not accessible. */ public static Object invokeStatic(String clazz, String methodName, Class type, Object value) throws NoSuchMethodException { try { return invokeStatic(Class.forName(clazz), methodName, new Class[] {type}, new Object[] {value}); } catch (ClassNotFoundException e) { throw new NoSuchMethodException("class "+clazz+" not found"); } } /** * Invokes the specified static method if it exists. * * @param clazz The class on which to invoke the method. * @param methodName The name of the method. * @param types The parameter types. * @param values The parameter values. * @param defaultValue The default value. * @return The return value of the method or the default value if the method * does not exist or is not accessible. */ public static Object invokeStatic(String clazz, String methodName, Class[] types, Object[] values, Object defaultValue) { try { return invokeStatic(Class.forName(clazz), methodName, types, values); } catch (ClassNotFoundException e) { return defaultValue; } catch (NoSuchMethodException e) { return defaultValue; } } /** * Invokes the specified static method if it exists. * * @param clazz The class on which to invoke the method. * @param methodName The name of the method. * @param type The parameter type. * @param value The parameter value. * @return The return value of the method or the default value if the method * does not exist or is not accessible. */ public static Object invokeStatic(Class clazz, String methodName, Class type, Object value) throws NoSuchMethodException { return invokeStatic(clazz, methodName, new Class[] {type}, new Object[] {value}); } /** * Invokes the specified getter method if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. * @param defaultValue This value is returned, if the method does not exist. * @return The value returned by the getter method or the default value. */ public static int invokeGetter(Object obj, String methodName, int defaultValue) { try { Method method = obj.getClass().getMethod(methodName, new Class[0]); Object result = method.invoke(obj, new Object[0]); return ((Integer) result).intValue(); } catch (NoSuchMethodException e) { return defaultValue; } catch (IllegalAccessException e) { return defaultValue; } catch (InvocationTargetException e) { return defaultValue; } } /** * Invokes the specified getter method if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. * @param defaultValue This value is returned, if the method does not exist. * @return The value returned by the getter method or the default value. */ public static long invokeGetter(Object obj, String methodName, long defaultValue) { try { Method method = obj.getClass().getMethod(methodName, new Class[0]); Object result = method.invoke(obj, new Object[0]); return ((Long) result).longValue(); } catch (NoSuchMethodException e) { return defaultValue; } catch (IllegalAccessException e) { return defaultValue; } catch (InvocationTargetException e) { return defaultValue; } } /** * Invokes the specified getter method if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. * @param defaultValue This value is returned, if the method does not exist. * @return The value returned by the getter method or the default value. */ public static boolean invokeGetter(Object obj, String methodName, boolean defaultValue) { try { Method method = obj.getClass().getMethod(methodName, new Class[0]); Object result = method.invoke(obj, new Object[0]); return ((Boolean) result).booleanValue(); } catch (NoSuchMethodException e) { return defaultValue; } catch (IllegalAccessException e) { return defaultValue; } catch (InvocationTargetException e) { return defaultValue; } } /** * Invokes the specified getter method if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. * @param defaultValue This value is returned, if the method does not exist. * @return The value returned by the getter method or the default value. */ public static Object invokeGetter(Object obj, String methodName, Object defaultValue) { try { Method method = obj.getClass().getMethod(methodName, new Class[0]); Object result = method.invoke(obj, new Object[0]); return result; } catch (NoSuchMethodException e) { return defaultValue; } catch (IllegalAccessException e) { return defaultValue; } catch (InvocationTargetException e) { return defaultValue; } } /** * Invokes the specified getter method if it exists. * * @param clazz The class on which to invoke the method. * @param methodName The name of the method. * @param defaultValue This value is returned, if the method does not exist. * @return The value returned by the getter method or the default value. */ public static boolean invokeStaticGetter(Class clazz, String methodName, boolean defaultValue) { try { Method method = clazz.getMethod(methodName, new Class[0]); Object result = method.invoke(null, new Object[0]); return ((Boolean) result).booleanValue(); } catch (NoSuchMethodException e) { return defaultValue; } catch (IllegalAccessException e) { return defaultValue; } catch (InvocationTargetException e) { return defaultValue; } } /** * Invokes the specified setter method if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. */ public static Object invoke(Object obj, String methodName, boolean newValue) throws NoSuchMethodException { try { Method method = obj.getClass().getMethod(methodName, new Class[] { Boolean.TYPE} ); return method.invoke(obj, new Object[] { new Boolean(newValue)}); } catch (IllegalAccessException e) { throw new NoSuchMethodException(methodName+" is not accessible"); } catch (InvocationTargetException e) { // The method is not supposed to throw exceptions throw new InternalError(e.getMessage()); } } /** * Invokes the specified method if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. */ public static Object invoke(Object obj, String methodName, int newValue) throws NoSuchMethodException { try { Method method = obj.getClass().getMethod(methodName, new Class[] { Integer.TYPE} ); return method.invoke(obj, new Object[] { new Integer(newValue)}); } catch (IllegalAccessException e) { throw new NoSuchMethodException(methodName+" is not accessible"); } catch (InvocationTargetException e) { // The method is not supposed to throw exceptions throw new InternalError(e.getMessage()); } } /** * Invokes the specified setter method if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. */ public static Object invoke(Object obj, String methodName, float newValue) throws NoSuchMethodException { try { Method method = obj.getClass().getMethod(methodName, new Class[] { Float.TYPE} ); return method.invoke(obj, new Object[] { new Float(newValue)}); } catch (IllegalAccessException e) { throw new NoSuchMethodException(methodName+" is not accessible"); } catch (InvocationTargetException e) { // The method is not supposed to throw exceptions throw new InternalError(e.getMessage()); } } /** * Invokes the specified setter method if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. */ public static Object invoke(Object obj, String methodName, Class clazz, Object newValue) throws NoSuchMethodException { try { Method method = obj.getClass().getMethod(methodName, new Class[] { clazz } ); return method.invoke(obj, new Object[] { newValue}); } catch (IllegalAccessException e) { throw new NoSuchMethodException(methodName+" is not accessible"); } catch (InvocationTargetException e) { // The method is not supposed to throw exceptions throw new InternalError(e.getMessage()); } } /** * Invokes the specified setter method if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. */ public static void invokeIfExists(Object obj, String methodName) { try { invoke(obj, methodName); } catch (NoSuchMethodException e) { // ignore } } /** * Invokes the specified setter method if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. */ public static void invokeIfExists(Object obj, String methodName, int newValue) { try { invoke(obj, methodName, newValue); } catch (NoSuchMethodException e) { // ignore } } /** * Invokes the specified setter method if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. */ public static void invokeIfExists(Object obj, String methodName, float newValue) { try { invoke(obj, methodName, newValue); } catch (NoSuchMethodException e) { // ignore } } /** * Invokes the specified method if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. */ public static void invokeIfExists(Object obj, String methodName, boolean newValue) { try { invoke(obj, methodName, newValue); } catch (NoSuchMethodException e) { // ignore } } /** * Invokes the specified setter method if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. */ public static void invokeIfExists(Object obj, String methodName, Class parameterClass, Object newValue) { try { invoke(obj, methodName, parameterClass, newValue); } catch (NoSuchMethodException e) { // ignore } } /** * Invokes the specified setter method if it exists. * * @param obj The object on which to invoke the method. * @param methodName The name of the method. */ public static void invokeIfExistsWithEnum(Object obj, String methodName, String enumClassName, String enumValueName) { try { Class enumClass = Class.forName(enumClassName); Object enumValue = invokeStatic("java.lang.Enum", "valueOf", new Class[] {Class.class, String.class}, new Object[] {enumClass, enumValueName} ); invoke(obj, methodName, enumClass, enumValue); } catch (ClassNotFoundException e) { // ignore e.printStackTrace(); } catch (NoSuchMethodException e) { // ignore e.printStackTrace(); } } /** * Invokes the specified constructor if it exists. * * @param clazz The Class on which to invoke the constructor. * @param types The parameter types of the constructor. * @param values The parameter values of the constructor. */ public static Object newInstance(Class clazz, Class[] types, Object[] values) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { return clazz.getConstructor(types).newInstance(values); }; }substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/util/Worker.java0000644000175000017500000000524210564356432026101 0ustar drazzibdrazzib/* * @(#)Worker.java 2.1 2005-10-16 * * Copyright (c) 1998-2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ //package ch.randelshofer.util; package contrib.ch.randelshofer.quaqua.util; import java.awt.ActiveEvent; import javax.swing.SwingUtilities; /** * This is an abstract class that you subclass to * perform GUI-related work in a dedicated event dispatcher. *

* This class is similar to SwingWorker but less complex. * Like a SwingWorker it can run using an an internal * worker thread but it can also be like a Runnable object. * * @author Werner Randelshofer * @version 2.1 2005-10-16 Method start() added. *
2.0 2005-09-27 Revised. *
1.1.1 2001-08-24 Call finished() within finally block. *
1.1 2001-08-24 Reworked for JDK 1.3. *
1.0 1998-10-07 Created. */ public abstract class Worker implements Runnable { private Object value; // see getValue(), setValue() /** * Calls #construct on the current thread and invokes * #finished on the AWT event dispatcher thread. */ public final void run() { final Runnable doFinished = new Runnable() { public void run() { finished(getValue()); } }; try { setValue(construct()); } catch (Throwable e) { e.printStackTrace(); } finally { SwingUtilities.invokeLater(doFinished); } } /** * Compute the value to be returned by the get method. */ public abstract Object construct(); /** * Called on the event dispatching thread (not on the worker thread) * after the construct method has returned. * * @param value The return value of the construct method. */ public abstract void finished(Object value); /** * Get the value produced by the worker thread, or null if it * hasn't been constructed yet. */ protected synchronized Object getValue() { return value; } /** * Set the value produced by worker thread */ private synchronized void setValue(Object x) { value = x; } /** * Starts the Worker on an internal worker thread. */ public void start() { new Thread(this).start(); } }substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/0000755000175000017500000000000011256731144025502 5ustar drazzibdrazzibsubstance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/HSBColorSliderModel.java0000644000175000017500000000351710564356430032114 0ustar drazzibdrazzib/* * @(#)HSBColorSliderModel.java 1.0 May 22, 2005 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import javax.swing.*; /** * ColorSliderModel for the HSB color model (hue, saturation, brightness). * * @author Werner Randelshofer * @version 1.0 May 22, 2005 Created. */ public class HSBColorSliderModel extends ColorSliderModel { /** * Creates a new instance. */ public HSBColorSliderModel() { super(new DefaultBoundedRangeModel[] { new DefaultBoundedRangeModel(0, 0, 0, 359), new DefaultBoundedRangeModel(0, 0, 0, 100), new DefaultBoundedRangeModel(0, 0, 0, 100) }); } public int getRGB() { return Color.HSBtoRGB( components[0].getValue() / 360f, components[1].getValue() / 100f, components[2].getValue() / 100f ); } public void setRGB(int rgb) { float[] hsb = Color.RGBtoHSB((rgb & 0xff0000) >>> 16, (rgb & 0xff00) >>> 8, rgb & 0xff, new float[3]); components[0].setValue((int) (hsb[0] * 360f)); components[1].setValue((int) (hsb[1] * 100f)); components[2].setValue((int) (hsb[2] * 100f)); } public int toRGB(int[] values) { return Color.HSBtoRGB( values[0] / 360f, values[1] / 100f, values[2] / 100f ); } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/CMYKChooser.form0000644000175000017500000003472110564356426030473 0ustar drazzibdrazzib

substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/QuaquaColorPreviewPanel.form0000644000175000017500000000064410322471734033150 0ustar drazzibdrazzib
substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ColorPalettesChooser.form0000644000175000017500000000746310564356426032513 0ustar drazzibdrazzib
substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ColorWheel.java0000644000175000017500000001206210564356430030413 0ustar drazzibdrazzib/* * @(#)ColorWheel.java 1.0 August 27, 2005 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; /** * The ColorWheel displays a hue/saturation wheel of the HSB color model. * The user can click at the wheel to pick a color on the ColorWheel. * The ColorWheel should be used together with a HSB brightness color slider. * * @author Werner Randelshofer * @version 1.0 August 27, 2005 Created. */ public class ColorWheel extends JPanel { private Image colorWheelImage; private ColorWheelImageProducer colorWheelProducer; private HSBColorSliderModel model; private class MouseHandler implements MouseListener, MouseMotionListener { public void mouseClicked(MouseEvent e) { } public void mouseDragged(MouseEvent e) { update(e); } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mouseMoved(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { update(e); } private void update(MouseEvent e) { int x = e.getX() - getWidth() / 2; int y = e.getY() - getHeight() / 2; float r = (float) Math.sqrt(x*x + y*y); float theta = (float) Math.atan2(y, -x); model.setValue(0, 180 + (int) (theta / Math.PI * 180d)); model.setValue(1, (int) (Math.min(1f, (float) r / colorWheelProducer.getRadius()) * 100f)); // FIXME - We should only repaint the damaged area repaint(); } } private MouseHandler mouseHandler; private class ModelHandler implements ChangeListener { public void stateChanged(ChangeEvent e) { repaint(); } }; private ModelHandler modelHandler; /** * Creates a new instance. */ public ColorWheel() { model = new HSBColorSliderModel(); initComponents(); colorWheelProducer = new ColorWheelImageProducer(0, 0); mouseHandler = new MouseHandler(); modelHandler = new ModelHandler(); addMouseListener(mouseHandler); addMouseMotionListener(mouseHandler); setOpaque(false); } public void setModel(HSBColorSliderModel m) { if (model != null) { model.removeChangeListener(modelHandler); } model = m; if (model != null) { model.addChangeListener(modelHandler); repaint(); } } public Dimension getPreferredSize() { return new Dimension(100,100); } public HSBColorSliderModel getModel() { return model; } public void paintComponent(Graphics g) { int w = getWidth(); int h = getHeight(); if (colorWheelImage == null || colorWheelImage.getWidth(this) != w || colorWheelImage.getHeight(this) != h) { if (colorWheelImage != null) { colorWheelImage.flush(); } colorWheelProducer = new ColorWheelImageProducer(w, h); colorWheelImage = createImage(colorWheelProducer); } colorWheelProducer.setBrightness(model.getValue(2) / 100f); colorWheelProducer.regenerateColorWheel(); g.drawImage(colorWheelImage, 0, 0, this); int x = w / 2 + (int) (colorWheelProducer.getRadius() * model.getValue(1) / 100d * Math.cos(model.getValue(0) * Math.PI / 180d)); int y = h / 2 - (int) (colorWheelProducer.getRadius() * model.getValue(1) / 100d * Math.sin(model.getValue(0) * Math.PI / 180d)); g.setColor(Color.white); g.fillRect(x - 1, y - 1, 2, 2); g.setColor(Color.black); g.drawRect(x - 2, y - 2, 3, 3); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents setLayout(new java.awt.BorderLayout()); }//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/Crayons.form0000644000175000017500000000161010564356430030005 0ustar drazzibdrazzib
substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/package.html0000644000175000017500000000124610322471742027764 0ustar drazzibdrazzib Contains classes used by the QuaquaColorChooserUI. substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ColorPalettesChooser.java0000644000175000017500000002440710564356430032461 0ustar drazzibdrazzib/* * @(#)ColorPalettesChooser.java 1.1 2006-04-23 * * Copyright (c) 2005-2006 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import java.text.*; import javax.swing.*; import javax.swing.colorchooser.*; import javax.swing.border.*; import javax.swing.event.*; import javax.swing.plaf.*; import contrib.ch.randelshofer.quaqua.*; import contrib.ch.randelshofer.quaqua.util.*; import java.util.*; /** * ColorPalettesChooser. * * @author Werner Randelshofer * @version 1.1 2006-04-23 Get UIManager directly from UIManager. *
1.0.1 2005-11-07 Load "UIManager" resource bundle from UIManager. *
1.0 September 18, 2005 Created. */ public class ColorPalettesChooser extends AbstractColorChooserPanel implements UIResource { /** * We store here the name of the last selected color sliders panel. * When the ColorSlidersChooser is recreated multiple times in the same * panel, the application 'remembers' which panel the user had opened * before. */ private static int lastSelectedPalette = 0; /** * Creates a new instance. */ public ColorPalettesChooser() { initComponents(); // Font font = UIManager.getFont("ColorChooser.font"); paletteLabel.setFont(font); paletteCombo.setFont(font); paletteScrollPane.setFont(font); paletteList.setFont(font); // paletteList.setCellRenderer(new PaletteEntryCellRenderer()); // DefaultComboBoxModel cbm = new DefaultComboBoxModel(loadPalettes()); paletteCombo.setModel(cbm); //updatePaletteList(); paletteList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { /** * Called whenever the value of the selection changes. * @param e the event that characterizes the change. */ public void valueChanged(ListSelectionEvent e) { PaletteEntry entry = (PaletteEntry) paletteList.getSelectedValue(); if (entry != null) { PaletteListModel lm = (PaletteListModel) paletteList.getModel(); lm.setClosestIndex(-1); setColorToModel(entry.getColor()); } } }); paletteCombo.setSelectedIndex(lastSelectedPalette); loadPalettes(); updatePaletteList(); } /** * @return Vector. */ protected Vector loadPalettes() { Vector palettes = new Vector(); Color[] colors; PaletteEntry[] entries; colors = DefaultPalettes.APPLE_COLORS; entries = new PaletteEntry[colors.length]; for (int i=0; i < colors.length; i++) { entries[i] = new PaletteEntry( UIManager.getString("ColorChooser.apple."+Integer.toHexString(0xff000000|colors[i].getRGB()).substring(2)), colors[i] ); } palettes.add(new PaletteListModel( UIManager.getString("ColorChooser.appleColors"), MessageFormat.format(UIManager.getString("ColorChooser.profileContainsNColors"), new Object[] {UIManager.getString("ColorChooser.appleColors"), new Integer(entries.length)}), entries) ); colors = DefaultPalettes.CRAYONS; entries = new PaletteEntry[colors.length]; for (int i=0; i < colors.length; i++) { entries[i % 8 + colors.length - (i / 8) * 8 - 8] = new PaletteEntry( UIManager.getString("ColorChooser.crayon."+Integer.toHexString(0xff000000|colors[i].getRGB()).substring(2)), colors[i] ); } palettes.add(new PaletteListModel( UIManager.getString("ColorChooser.crayons"), MessageFormat.format(UIManager.getString("ColorChooser.profileContainsNColors"), new Object[] {UIManager.getString("ColorChooser.crayons"), new Integer(entries.length)}), entries) ); colors = DefaultPalettes.WEB_SAFE_COLORS; entries = new PaletteEntry[colors.length]; for (int i=0; i < colors.length; i++) { entries[i] = new PaletteEntry( Integer.toHexString(0xff000000|colors[i].getRGB()).substring(2).toUpperCase(), colors[i] ); } palettes.add(new PaletteListModel( UIManager.getString("ColorChooser.webSafeColors"), MessageFormat.format(UIManager.getString("ColorChooser.profileContainsNColors"), new Object[] {UIManager.getString("ColorChooser.webSafeColors"), new Integer(entries.length)}), entries) ); return palettes; } private void updatePaletteList() { PaletteListModel palette = (PaletteListModel) paletteCombo.getSelectedItem(); paletteList.setModel(palette); paletteCombo.setToolTipText(palette.getInfo()); updateChooser(); } protected void buildChooser() { } public String getDisplayName() { return UIManager.getString("ColorChooser.colorPalettes"); } public javax.swing.Icon getLargeDisplayIcon() { return UIManager.getIcon("ColorChooser.colorPalettesIcon"); } public Icon getSmallDisplayIcon() { return getLargeDisplayIcon(); } public void updateChooser() { Color color; try { color = getColorFromModel(); } catch (NullPointerException e) { return; } int rgb = color.getRGB() & 0xffffff; // Return quickly if color is the same as selected entry PaletteEntry entry = (PaletteEntry) paletteList.getSelectedValue(); if (entry != null && (entry.getColor().getRGB() & 0xffffff) == rgb) { return; } // Search for entry and select it PaletteListModel lm = (PaletteListModel) paletteList.getModel(); int i, n; for (i=0, n = lm.getSize(); i < n; i++) { entry = (PaletteEntry) lm.getElementAt(i); if ((entry.getColor().getRGB() & 0xffffff) == rgb) { break; } } if (i < n) { // Matching color found? Select it and scroll it to visible. lm.setClosestIndex(-1); paletteList.setSelectedIndex(i); paletteList.scrollRectToVisible(paletteList.getCellBounds(i,i)); } else { // No matching color found? Clear selection, paletteList.clearSelection(); int closest = lm.computeClosestIndex(color); lm.setClosestIndex(closest); if (closest != -1) { paletteList.scrollRectToVisible(paletteList.getCellBounds(closest,closest)); } } } public void setColorToModel(Color color) { getColorSelectionModel().setSelectedColor(color); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // //GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; paletteLabel = new javax.swing.JLabel(); paletteCombo = new javax.swing.JComboBox(); paletteScrollPane = new javax.swing.JScrollPane(); paletteList = new javax.swing.JList(); setLayout(new java.awt.GridBagLayout()); paletteLabel.setLabelFor(paletteCombo); paletteLabel.setText(UIManager.getString("ColorChooser.list")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 0; add(paletteLabel, gridBagConstraints); paletteCombo.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { paletteChanged(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; add(paletteCombo, gridBagConstraints); paletteScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); paletteScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); paletteList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); paletteScrollPane.setViewportView(paletteList); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; add(paletteScrollPane, gridBagConstraints); }// //GEN-END:initComponents private void paletteChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_paletteChanged updatePaletteList(); lastSelectedPalette = paletteCombo.getSelectedIndex(); }//GEN-LAST:event_paletteChanged // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox paletteCombo; private javax.swing.JLabel paletteLabel; private javax.swing.JList paletteList; private javax.swing.JScrollPane paletteScrollPane; // End of variables declaration//GEN-END:variables } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/SwatchPanel.java0000644000175000017500000001351410564356432030566 0ustar drazzibdrazzib/* * @(#)SwatchPanel.java 1.0 30 March 2005 * * Copyright (c) 2004 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.text.*; import javax.swing.event.*; import javax.swing.border.*; import javax.swing.colorchooser.*; import javax.swing.plaf.*; import contrib.ch.randelshofer.quaqua.*; /** * SwatchPanel. * * Code derived from javax.swing.colorchooser.DefaultSwatchChooserPanel. * * @author Werner Randelshofer * @version 1.0 30 March 2005 Created. */ public class SwatchPanel extends javax.swing.JPanel { protected Color[] colors; protected Dimension swatchSize = new Dimension(); protected Dimension defaultSwatchSize; protected Dimension numSwatches; protected Dimension gap; private final static Color gridColor = new Color(0xaaaaaa); /** Creates new form. */ public SwatchPanel() { initComponents(); initValues(); initColors(); setToolTipText(""); // register for events setOpaque(false); //setBackground(Color.white); setRequestFocusEnabled(false); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents setLayout(new java.awt.BorderLayout()); }//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables public boolean isFocusTraversable() { return false; } protected void initValues() { defaultSwatchSize = UIManager.getDimension("ColorChooser.swatchesSwatchSize"); swatchSize.width = defaultSwatchSize.width; swatchSize.height = defaultSwatchSize.height; gap = new Dimension(1, 1); } public void setBounds(int x, int y, int width, int height) { super.setBounds(x, y, width, height); if (width > getPreferredSize().width) { swatchSize.width = (width - numSwatches.width * gap.width) / numSwatches.width; } else { swatchSize.width = defaultSwatchSize.width; } if (height > getPreferredSize().height) { swatchSize.height = (height - numSwatches.height * gap.height) / numSwatches.height; } else { swatchSize.height = defaultSwatchSize.height; } } public void setColors(Color[] colors) { this.colors = colors; } public void setNumSwatches(int rows, int columns) { numSwatches = new Dimension(rows, columns); } public void paintComponent(Graphics g) { Dimension preferredSize = getSwatchesSize(); int xoffset = (getWidth() - preferredSize.width) / 2; int yoffset = 0;// (getHeight() - preferredSize.height) / 2; for (int row = 0; row < numSwatches.height; row++) { for (int column = 0; column < numSwatches.width; column++) { Color cellColor = getColorForCell(column, row); g.setColor(cellColor); //int x = (numSwatches.width - column - 1) * (swatchSize.width + gap.width); int x = xoffset + column * (swatchSize.width + gap.width) + 1; int y = yoffset + row * (swatchSize.height + gap.height) + 1; g.fillRect( x, y, swatchSize.width, swatchSize.height); g.setColor(cellColor.darker()); g.fillRect(x - 1, y - 1, swatchSize.width+1, 1); g.fillRect(x - 1, y, 1, swatchSize.height); } } } public Dimension getSwatchesSize() { int x = numSwatches.width * (swatchSize.width + gap.width); int y = numSwatches.height * (swatchSize.height + gap.height); return new Dimension( x, y ); } public Dimension getPreferredSize() { int x = numSwatches.width * (defaultSwatchSize.width + gap.width); int y = numSwatches.height * (defaultSwatchSize.height + gap.height); return new Dimension( x, y ); } protected void initColors() { } public String getToolTipText(MouseEvent e) { Color color = getColorForLocation(e.getX(), e.getY()); return (color == null) ? null : color.getRed()+", "+ color.getGreen() + ", " + color.getBlue(); } public Color getColorForLocation( int x, int y ) { Dimension preferredSize = getSwatchesSize(); x -= (getWidth() - preferredSize.width) / 2; //y -= (getHeight() - preferredSize.height) / 2; int column; if ((!this.getComponentOrientation().isLeftToRight())) { column = numSwatches.width - x / (swatchSize.width + gap.width) - 1; } else { column = x / (swatchSize.width + gap.width); } int row = y / (swatchSize.height + gap.height); return getColorForCell(column, row); } private Color getColorForCell( int column, int row) { int index = (row * numSwatches.width) + column; return (index < colors.length) ? colors[index] : null; } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/CrayonsChooser.form0000644000175000017500000000032510322471726031330 0ustar drazzibdrazzib
substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/Quaqua15ColorPicker.java0000644000175000017500000002413611205527566032120 0ustar drazzibdrazzib/* * @(#)Quaqua15ColorPicker.java 1.2 2006-04-23 * * Copyright (c) 2005-2006 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; import java.security.AccessControlException; import javax.swing.*; import javax.swing.colorchooser.AbstractColorChooserPanel; import javax.swing.plaf.IconUIResource; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceImageCreator; import org.jvnet.substance.utils.icon.TransitionAwareIcon; /** * Quaqua15ColorPicker. * * * * @author Werner Randelshofer * @version 1.2 2006-04-23 Retrieve labels from UIManager.
* 1.1.1 2006-03-15 Forgot to create robot instance.
* 1.1 2006-03-06 Abort picker when the user presses the Escape-Key.
* 1.0 December 18, 2005 Created. */ public class Quaqua15ColorPicker extends AbstractColorChooserPanel { /** * This frame is constantly moved to the current location of the mouse. This * ensures that we can trap mouse clicks while the picker cursor is showing. * Also, by tying the picker cursor to this frame, we ensure that the picker * cursor (the magnifying glass) is shown. */ private Dialog pickerFrame; private Timer pickerTimer; /** * Holds the image of the picker cursor. */ private BufferedImage cursorImage; /** * Graphics object used for drawing on the cursorImage. */ private Graphics2D cursorGraphics; /** * The picker cursor. */ private Cursor pickerCursor; /** * The hot spot of the cursor. */ private Point hotSpot; /** * Offset from the hot spot of the pickerCursor to the pixel that we want to * pick. We can't pick the color at the hotSpot of the cursor, because this * point is obscured by the pickerFrame. */ private Point pickOffset; /** * The magnifying glass image. */ private BufferedImage magnifierImage; /** * The robot is used for creating screen captures. */ private Robot robot; private Color previousColor = Color.white; private Point previousLoc = new Point(); private Point pickLoc = new Point(); private Point captureOffset = new Point(); private Rectangle captureRect; private final static Color transparentColor = new Color(0, true); private Rectangle zoomRect; private Rectangle glassRect; /** * Creates a new instance. */ public Quaqua15ColorPicker() { // Try immediately to create a screen capture in order to fail quickly, // when // we can't provide a color picker functionality. try { robot = new Robot(); robot.createScreenCapture(new Rectangle(0, 0, 1, 1)); } catch (AWTException e) { throw new AccessControlException("Unable to capture screen"); } } /** * Gets the picker frame. If the frame does not yet exist, it is created * along with all the other objects that are needed to make the picker work. */ private Dialog getPickerFrame() { if (pickerFrame == null) { Window owner = SwingUtilities.getWindowAncestor(this); if (owner instanceof Dialog) { pickerFrame = new Dialog((Dialog) owner); } else if (owner instanceof Frame) { pickerFrame = new Dialog((Frame) owner); } else { pickerFrame = new Dialog(new JFrame()); } pickerFrame.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { pickFinish(); } @Override public void mouseExited(MouseEvent evt) { updatePicker(); } }); pickerFrame.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent evt) { updatePicker(); } }); pickerFrame.setSize(3, 3); pickerFrame.setUndecorated(true); pickerFrame.setAlwaysOnTop(true); pickerFrame.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_ESCAPE: pickCancel(); break; case KeyEvent.VK_ENTER: pickFinish(); break; } } }); magnifierImage = (BufferedImage) UIManager .get("ColorChooser.colorPickerMagnifier"); glassRect = (Rectangle) UIManager .get("ColorChooser.colorPickerGlassRect"); zoomRect = (Rectangle) UIManager .get("ColorChooser.colorPickerZoomRect"); hotSpot = (Point) UIManager.get("ColorChooser.colorPickerHotSpot");// new // Point(29, // 29); captureRect = new Rectangle((Rectangle) UIManager .get("ColorChooser.colorPickerCaptureRect")); pickOffset = (Point) UIManager .get("ColorChooser.colorPickerPickOffset"); captureOffset = new Point(captureRect.x, captureRect.y); cursorImage = getGraphicsConfiguration().createCompatibleImage( magnifierImage.getWidth(), magnifierImage.getHeight(), Transparency.TRANSLUCENT); cursorGraphics = cursorImage.createGraphics(); cursorGraphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); pickerTimer = new Timer(5, new ActionListener() { public void actionPerformed(ActionEvent evt) { updatePicker(); } }); } return pickerFrame; } /** * Updates the color picker. */ protected void updatePicker() { if (pickerFrame != null && pickerFrame.isShowing()) { PointerInfo info = MouseInfo.getPointerInfo(); Point mouseLoc = info.getLocation(); pickerFrame.setLocation(mouseLoc.x - pickerFrame.getWidth() / 2, mouseLoc.y - pickerFrame.getHeight() / 2); pickLoc.x = mouseLoc.x + pickOffset.x; pickLoc.y = mouseLoc.y + pickOffset.y; if (pickLoc.x >= 0 && pickLoc.y >= 0) { Color c = robot.getPixelColor(pickLoc.x, pickLoc.y); if (!c.equals(previousColor) || !mouseLoc.equals(previousLoc)) { previousColor = c; previousLoc = mouseLoc; captureRect.setLocation(mouseLoc.x + captureOffset.x, mouseLoc.y + captureOffset.y); if (captureRect.x >= 0 && captureRect.y >= 0) { BufferedImage capture = robot .createScreenCapture(captureRect); // Clear the cursor graphics cursorGraphics.setComposite(AlphaComposite.Src); cursorGraphics.setColor(transparentColor); cursorGraphics.fillRect(0, 0, cursorImage.getWidth(), cursorImage.getHeight()); // Fill the area for the zoomed screen capture with a // non-transparent color (any non-transparent color does // the job). cursorGraphics.setColor(Color.red); cursorGraphics.fillOval(glassRect.x, glassRect.y, glassRect.width, glassRect.height); // Paint the screen capture with a zoom factor of 5 cursorGraphics.setComposite(AlphaComposite.SrcIn); cursorGraphics.drawImage(capture, zoomRect.x, zoomRect.y, zoomRect.width, zoomRect.height, this); // Draw the magnifying glass image cursorGraphics.setComposite(AlphaComposite.SrcOver); cursorGraphics.drawImage(magnifierImage, 0, 0, this); // We need to create a new subImage. This forces that // the color picker uses the new imagery. BufferedImage subImage = cursorImage .getSubimage(0, 0, cursorImage.getWidth(), cursorImage.getHeight()); pickerFrame.setCursor(getToolkit().createCustomCursor( cursorImage, hotSpot, "ColorPicker")); } } } } } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ private void initComponents() {// GEN-BEGIN:initComponents pickerButton = new javax.swing.JButton(); setLayout(new java.awt.BorderLayout()); // pickerButton.setBorderPainted(false); pickerButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); pickerButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { pickBegin(evt); } }); add(pickerButton, java.awt.BorderLayout.CENTER); }// GEN-END:initComponents private void pickBegin(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_pickBegin getPickerFrame(); pickerTimer.start(); getPickerFrame().setVisible(true); }// GEN-LAST:event_pickBegin protected void pickFinish() { pickerTimer.stop(); pickerFrame.setVisible(false); PointerInfo info = MouseInfo.getPointerInfo(); Point loc = info.getLocation(); Color c = robot.getPixelColor(loc.x + pickOffset.x, loc.y + pickOffset.y); getColorSelectionModel().setSelectedColor(c); } protected void pickCancel() { pickerTimer.stop(); pickerFrame.setVisible(false); } @Override protected void buildChooser() { initComponents(); pickerButton.setIcon(new TransitionAwareIcon(pickerButton, new TransitionAwareIcon.Delegate() { @Override public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { return new IconUIResource(SubstanceImageCreator .getSearchIcon(15, scheme, pickerButton .getComponentOrientation() .isLeftToRight())); } }, "ColorChooser.colorPickerIcon")); } @Override public String getDisplayName() { return UIManager.getString("ColorChooser.colorPicker"); } @Override public Icon getLargeDisplayIcon() { return UIManager.getIcon("ColorChooser.colorPickerIcon"); } @Override public Icon getSmallDisplayIcon() { return getLargeDisplayIcon(); } @Override public void updateChooser() { } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton pickerButton; // End of variables declaration//GEN-END:variables } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ColorPicker.java0000644000175000017500000002360611205551534030565 0ustar drazzibdrazzib/* * @(#)ColorPicker.java 1.1 2006-03-05 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; import java.security.AccessControlException; import javax.swing.*; import javax.swing.colorchooser.AbstractColorChooserPanel; import javax.swing.plaf.IconUIResource; import org.jvnet.substance.api.SubstanceColorScheme; import org.jvnet.substance.utils.SubstanceImageCreator; import org.jvnet.substance.utils.icon.TransitionAwareIcon; /** * ColorPicker. * * @author Werner Randelshofer * @version 1.1 2006-03-06 Abort picker when the user presses the Escape-Key.
* 1.0 December 18, 2005 Created. */ public class ColorPicker extends AbstractColorChooserPanel { /** * This frame is constantly moved to the current location of the mouse. This * ensures that we can trap mouse clicks while the picker cursor is showing. * Also, by tying the picker cursor to this frame, we ensure that the picker * cursor (the magnifying glass) is shown. */ private Dialog pickerFrame; private Timer pickerTimer; /** * Holds the image of the picker cursor. */ private BufferedImage cursorImage; /** * Graphics object used for drawing on the cursorImage. */ private Graphics2D cursorGraphics; /** * The picker cursor. */ private Cursor pickerCursor; /** * The hot spot of the cursor. */ private Point hotSpot; /** * Offset from the hot spot of the pickerCursor to the pixel that we want to * pick. We can't pick the color at the hotSpot of the cursor, because this * point is obscured by the pickerFrame. */ private Point pickOffset; /** * The magnifying glass image. */ private BufferedImage magnifierImage; /** * The robot is used for creating screen captures. */ private Robot robot; private Color previousColor = Color.white; private Point previousLoc = new Point(); private Point pickLoc = new Point(); private Point captureOffset = new Point(); private Rectangle captureRect; private final static Color transparentColor = new Color(0, true); private Rectangle zoomRect; private Rectangle glassRect; /** * Creates a new instance. */ public ColorPicker() { // Try immediately to create a screen capture in order to fail quickly, // when // we can't provide a color picker functionality. try { robot = new Robot(); robot.createScreenCapture(new Rectangle(0, 0, 1, 1)); } catch (AWTException e) { throw new AccessControlException("Unable to capture screen"); } } /** * Gets the picker frame. If the frame does not yet exist, it is created * along with all the other objects that are needed to make the picker work. */ private Dialog getPickerFrame() { if (pickerFrame == null) { Window owner = SwingUtilities.getWindowAncestor(this); if (owner instanceof Dialog) { pickerFrame = new Dialog((Dialog) owner); } else if (owner instanceof Frame) { pickerFrame = new Dialog((Frame) owner); } else { pickerFrame = new Dialog(new JFrame()); } pickerFrame.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { pickFinish(); } @Override public void mouseExited(MouseEvent evt) { updatePicker(); } }); pickerFrame.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent evt) { updatePicker(); } }); pickerFrame.setSize(3, 3); pickerFrame.setUndecorated(true); pickerFrame.setAlwaysOnTop(true); pickerFrame.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_ESCAPE: pickCancel(); break; case KeyEvent.VK_ENTER: pickFinish(); break; } } }); magnifierImage = (BufferedImage) UIManager .get("ColorChooser.colorPickerMagnifier"); glassRect = (Rectangle) UIManager .get("ColorChooser.colorPickerGlassRect"); zoomRect = (Rectangle) UIManager .get("ColorChooser.colorPickerZoomRect"); hotSpot = (Point) UIManager.get("ColorChooser.colorPickerHotSpot");// new // Point(29, // 29); captureRect = new Rectangle((Rectangle) UIManager .get("ColorChooser.colorPickerCaptureRect")); pickOffset = (Point) UIManager .get("ColorChooser.colorPickerPickOffset"); captureOffset = new Point(captureRect.x, captureRect.y); cursorImage = getGraphicsConfiguration().createCompatibleImage( magnifierImage.getWidth(), magnifierImage.getHeight(), Transparency.TRANSLUCENT); cursorGraphics = cursorImage.createGraphics(); cursorGraphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); pickerTimer = new Timer(5, new ActionListener() { public void actionPerformed(ActionEvent evt) { updatePicker(); } }); } return pickerFrame; } /** * Updates the color picker. */ protected void updatePicker() { if (pickerFrame != null && pickerFrame.isShowing()) { PointerInfo info = MouseInfo.getPointerInfo(); Point mouseLoc = info.getLocation(); pickerFrame.setLocation(mouseLoc.x - pickerFrame.getWidth() / 2, mouseLoc.y - pickerFrame.getHeight() / 2); pickLoc.x = mouseLoc.x + pickOffset.x; pickLoc.y = mouseLoc.y + pickOffset.y; if (pickLoc.x >= 0 && pickLoc.y >= 0) { Color c = robot.getPixelColor(pickLoc.x, pickLoc.y); if (!c.equals(previousColor) || !mouseLoc.equals(previousLoc)) { previousColor = c; previousLoc = mouseLoc; captureRect.setLocation(mouseLoc.x + captureOffset.x, mouseLoc.y + captureOffset.y); if (captureRect.x >= 0 && captureRect.y >= 0) { BufferedImage capture = robot .createScreenCapture(captureRect); // Clear the cursor graphics cursorGraphics.setComposite(AlphaComposite.Src); cursorGraphics.setColor(transparentColor); cursorGraphics.fillRect(0, 0, cursorImage.getWidth(), cursorImage.getHeight()); // Fill the area for the zoomed screen capture with a // non-transparent color (any non-transparent color does // the job). cursorGraphics.setColor(Color.red); cursorGraphics.fillOval(glassRect.x, glassRect.y, glassRect.width, glassRect.height); // Paint the screen capture with a zoom factor of 5 cursorGraphics.setComposite(AlphaComposite.SrcIn); cursorGraphics.drawImage(capture, zoomRect.x, zoomRect.y, zoomRect.width, zoomRect.height, this); // Draw the magnifying glass image cursorGraphics.setComposite(AlphaComposite.SrcOver); cursorGraphics.drawImage(magnifierImage, 0, 0, this); // We need to create a new subImage. This forces that // the color picker uses the new imagery. BufferedImage subImage = cursorImage .getSubimage(0, 0, cursorImage.getWidth(), cursorImage.getHeight()); pickerFrame.setCursor(getToolkit().createCustomCursor( cursorImage, hotSpot, "ColorPicker")); } } } } } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ private void initComponents() {// GEN-BEGIN:initComponents pickerButton = new javax.swing.JButton(); setLayout(new java.awt.BorderLayout()); pickerButton.setBorderPainted(false); pickerButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); pickerButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { pickBegin(evt); } }); add(pickerButton, java.awt.BorderLayout.CENTER); }// GEN-END:initComponents private void pickBegin(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_pickBegin getPickerFrame(); pickerTimer.start(); getPickerFrame().setVisible(true); }// GEN-LAST:event_pickBegin protected void pickFinish() { pickerTimer.stop(); pickerFrame.setVisible(false); PointerInfo info = MouseInfo.getPointerInfo(); Point loc = info.getLocation(); Color c = robot.getPixelColor(loc.x + pickOffset.x, loc.y + pickOffset.y); getColorSelectionModel().setSelectedColor(c); } protected void pickCancel() { pickerTimer.stop(); pickerFrame.setVisible(false); } @Override protected void buildChooser() { initComponents(); pickerButton.setIcon(new TransitionAwareIcon(pickerButton, new TransitionAwareIcon.Delegate() { @Override public Icon getColorSchemeIcon(SubstanceColorScheme scheme) { return new IconUIResource(SubstanceImageCreator .getSearchIcon(15, scheme, pickerButton .getComponentOrientation() .isLeftToRight())); } }, "ColorChooser.colorPickerIcon")); } @Override public String getDisplayName() { return "Color Picker"; } @Override public Icon getLargeDisplayIcon() { return UIManager.getIcon("ColorChooser.colorPickerIcon"); } @Override public Icon getSmallDisplayIcon() { return getLargeDisplayIcon(); } @Override public void updateChooser() { } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton pickerButton; // End of variables declaration//GEN-END:variables } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/CrayonsChooser.java0000644000175000017500000000533210564356430031313 0ustar drazzibdrazzib/* * @(#)CrayonsChooser.java 1.1 2006-04-23 * * Copyright (c) 2005-2006 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; //import java.awt.event.*; import java.beans.*; import javax.swing.*; import javax.swing.colorchooser.*; import javax.swing.event.*; import javax.swing.plaf.*; import contrib.ch.randelshofer.quaqua.util.*; /** * A color chooser which provides a choice of Crayons. * * @author Werner Randelshofer * @version 1.2 2006-04-23 Retrieve labels from UIManager. *
1.0.2 2005-11-07 Get "labels" resource bundle from UIManager. *
1.0.1 2005-09-11 Get icon from UIManager. *
1.0 August 28, 2005 Created. */ public class CrayonsChooser extends AbstractColorChooserPanel implements UIResource { private Crayons crayons; /** * Creates a new instance. */ public CrayonsChooser() { initComponents(); crayons = new Crayons(); add(crayons); crayons.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("Color")) { setColorToModel(crayons.getColor()); } } }); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents }//GEN-END:initComponents protected void buildChooser() { } public String getDisplayName() { return UIManager.getString("ColorChooser.crayons"); } public javax.swing.Icon getLargeDisplayIcon() { return UIManager.getIcon("ColorChooser.crayonsIcon"); } public Icon getSmallDisplayIcon() { return getLargeDisplayIcon(); } public void updateChooser() { crayons.setColor(getColorFromModel()); } public void setColorToModel(Color color) { getColorSelectionModel().setSelectedColor(color); } // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ColorTrackImageProducer.java0000644000175000017500000001074310564356430033066 0ustar drazzibdrazzib/* * @(#)ColorTrackImageProducer.java 1.1 2005-08-28 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import java.awt.image.*; import javax.swing.*; /** * ColorTrackImageProducer creates the image for the track of a * color slider. * * @see ColorSliderUI * * @author Werner Randelshofer * @version 1.1 2005-08-28 Support for vertical color track implemented. * Passing now a null pixel array to super constructor to avoid unnecessary * memory allocation. Method markAsDirty() added. *
1.0.1 2005-04-18 Fixed a minor shift in the color range. *
1.0 29 March 2005 Created. */ public class ColorTrackImageProducer extends MemoryImageSource { private int[] pixels; private int w, h; private float[] baseComponents; private int component; private int trackBuffer; private ColorSliderModel colorizer = new RGBColorSliderModel(); private boolean isDirty = true; private int componentIndex = 0; private boolean isHorizontal; /** Creates a new instance. */ public ColorTrackImageProducer(int w, int h, int trackBuffer, boolean isHorizontal) { super(w, h, null, 0, w); pixels = new int[w*h]; this.w = w; this.h = h; // trackBuffer must be even this.trackBuffer = (trackBuffer % 2 == 1) ? trackBuffer - 1 : trackBuffer; this.componentIndex = componentIndex; this.isHorizontal = isHorizontal; newPixels(pixels, ColorModel.getRGBdefault(), 0, w); setAnimated(true); } public int getWidth() { return w; } public int getHeight() { return h; } public void markAsDirty() { isDirty = true; } public boolean needsGeneration() { return isDirty; } public void regenerateColorTrack() { if (isDirty) { generateColorTrack(); } } public void generateColorTrack() { if (isHorizontal) { generateHorizontalColorTrack(); } else { generateVerticalColorTrack(); } newPixels(); isDirty = false; } private void generateHorizontalColorTrack() { int offset = trackBuffer / 2; for (int x = 0, n = w - trackBuffer - 1; x <= n; x++) { pixels[x + offset] = colorizer.getInterpolatedRGB(componentIndex, x / (float) n); } for (int x=0; x < offset; x++) { pixels[x] = pixels[offset]; pixels[w - x - 1] = pixels[w - offset - 1]; } for (int y=w, n = w*h; y < n; y+=w) { System.arraycopy(pixels, 0, pixels, y, w); } } private void generateVerticalColorTrack() { int offset = trackBuffer / 2; for (int y = 0, n = h - trackBuffer - 1; y <= n; y++) { pixels[(y + offset) * w] = colorizer.getInterpolatedRGB(componentIndex, 1 - y / (float) n); } for (int y=0; y < offset; y++) { pixels[y * w] = pixels[offset * w]; pixels[(h - y - 1) * w] = pixels[(h - offset - 1) * w]; } for (int x=1; x < w; x++) { for (int y=0, n = w*h; y < n; y+=w) { pixels[x + y] = pixels[x - 1 + y]; } } } public void setBaseComponents(BoundedRangeModel[] components) { isDirty = true; //isDirty = isDirty || colorizer.needsRegeneration(this.baseRGB, baseRGB); //this.baseRGB = baseRGB; for (int i=0; i < components.length; i++) { baseComponents[i] = components[i].getValue() / (float) components[i].getMaximum(); } } public void setColorSliderModel(ColorSliderModel colorizer) { this.colorizer = colorizer; isDirty = true; } public void setColorComponentIndex(int index) { this.componentIndex = index; isDirty = true; } public void componentChanged(int index) { isDirty |= this.componentIndex != index; } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/PaletteListModel.java0000644000175000017500000000742110564356432031570 0ustar drazzibdrazzib/* * @(#)PaletteListModel.java 1.0 19 septembre 2005 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import javax.swing.*; import java.util.*; import java.io.*; /** * PaletteListModel manages a list of PaletteEntry. * * @author Werner Randelshofer * @version 1.0 19 septembre 2005 Created. */ public class PaletteListModel extends AbstractListModel { /** * Name of the palette. */ private String name; /** * Informatation about the palette, such as the copyright. */ private String info; private PaletteEntry[] entries; /** * Index of the color which is closest to the current color in * the color chooser. */ private int closestIndex; /** * Creates a new instance. */ public PaletteListModel(String name, String info, PaletteEntry[] entries) { this.name = name; this.info = info; this.entries = entries; } public void setName(String newValue) { name = newValue; } public String getName() { return name; } public void setInfo(String newValue) { info = newValue; } public String getInfo() { return info; } public Object getElementAt(int index) { return entries[index]; } public int getSize() { return entries.length; } /** * Used for displaying the name of the palette in the combo box * of the ColorPalettesChooser. */ public String toString() { return getName(); } /** * Computes the index of the color which comes closest to the specified * color. * This may return -1, if there is no sufficiently close color in the * color list. */ public int computeClosestIndex(Color referenceColor) { int refRGB = referenceColor.getRGB(); int closest = -1; // Setting this to a lower value than Integer.MAX_VALUE makes this // method search for closer matches. //int closestDistance = Integer.MAX_VALUE; int closestDistance = 1024*3; for (int i=0, n = getSize(); i < n; i++) { PaletteEntry entry = (PaletteEntry) getElementAt(i); int entryRGB = entry.getColor().getRGB(); int rDiff = ((entryRGB & 0xff0000) - (refRGB & 0xff0000)) >> 16; int gDiff = ((entryRGB & 0xff00) - (refRGB & 0xff00)) >> 8; int bDiff = (entryRGB & 0xff) - (refRGB & 0xff); int distance = rDiff * rDiff + gDiff * gDiff + bDiff * bDiff; if (distance < closestDistance) { closest = i; closestDistance = distance; } } return closest; } /** * Sets the index of the color which is closest to the current color in * the color chooser. * * @param newValue closest index or -1, if no color is close. */ public void setClosestIndex(int newValue) { closestIndex = newValue; } /** * Returns the index of the color which is closest to the current color in * the color chooser, or -1 of no such color exists. */ public int getClosestIndex() { return closestIndex; } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/RGBChooser.java0000644000175000017500000002624110564356432030313 0ustar drazzibdrazzib/* * @(#)RGBChooser.java 1.3 2006-04-23 * * Copyright (c) 2005-2006 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import javax.swing.*; import javax.swing.text.*; import javax.swing.event.*; import javax.swing.border.*; import javax.swing.colorchooser.*; import javax.swing.plaf.*; import contrib.ch.randelshofer.quaqua.*; import contrib.ch.randelshofer.quaqua.util.*; /** * RGBChooser. * * @author Werner Randelshofer * @version 1.3 2006-04-23 Retrieve labels directly from UIManager. *
1.2 2005-11-22 Moved handler for text fields into separate class. *
1.1.1 2005-11-07 Get "Labels" resource bundle from UIManager. *
1.1 2005-09-05 Get font, spacing and icon from UIManager. *
1.0 29 March 2005 Created. */ public class RGBChooser extends AbstractColorChooserPanel implements UIResource { private ColorSliderModel ccModel = new RGBColorSliderModel(); /** Creates new form. */ public RGBChooser() { initComponents(); // Font font = UIManager.getFont("ColorChooser.font"); redLabel.setFont(font); redSlider.setFont(font); redField.setFont(font); greenLabel.setFont(font); greenSlider.setFont(font); greenField.setFont(font); blueLabel.setFont(font); blueSlider.setFont(font); blueField.setFont(font); // int textSliderGap = UIManager.getInt("ColorChooser.textSliderGap"); if (textSliderGap != 0) { Insets fieldInsets = new Insets(0,textSliderGap,0,0); GridBagLayout layout = (GridBagLayout) getLayout(); GridBagConstraints gbc; gbc = layout.getConstraints(redField); gbc.insets = fieldInsets; layout.setConstraints(redField, gbc); gbc = layout.getConstraints(greenField); gbc.insets = fieldInsets; layout.setConstraints(greenField, gbc); gbc = layout.getConstraints(blueField); gbc.insets = fieldInsets; layout.setConstraints(blueField, gbc); } ccModel.configureColorSlider(0, redSlider); ccModel.configureColorSlider(1, greenSlider); ccModel.configureColorSlider(2, blueSlider); redField.setText(Integer.toString(redSlider.getValue())); greenField.setText(Integer.toString(greenSlider.getValue())); blueField.setText(Integer.toString(blueSlider.getValue())); new ColorSliderTextFieldHandler(redField, ccModel, 0); new ColorSliderTextFieldHandler(greenField, ccModel, 1); new ColorSliderTextFieldHandler(blueField, ccModel, 2); ccModel.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { setColorToModel(ccModel.getColor()); } }); redField.setMinimumSize(redField.getPreferredSize()); greenField.setMinimumSize(greenField.getPreferredSize()); blueField.setMinimumSize(blueField.getPreferredSize()); VisualMargin bm = new VisualMargin(false,false,true,false); redLabel.setBorder(bm); greenLabel.setBorder(bm); blueLabel.setBorder(bm); } protected void buildChooser() { } public String getDisplayName() { return UIManager.getString("ColorChooser.rgbSliders"); } public Icon getLargeDisplayIcon() { return UIManager.getIcon("ColorChooser.colorSlidersIcon"); } public Icon getSmallDisplayIcon() { return getLargeDisplayIcon(); } public void updateChooser() { ccModel.setColor(getColorFromModel()); } public void setColorToModel(Color color) { getColorSelectionModel().setSelectedColor(color); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // //GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; redLabel = new javax.swing.JLabel(); redSlider = new javax.swing.JSlider(); redField = new javax.swing.JTextField(); greenLabel = new javax.swing.JLabel(); greenSlider = new javax.swing.JSlider(); greenField = new javax.swing.JTextField(); blueLabel = new javax.swing.JLabel(); blueSlider = new javax.swing.JSlider(); blueField = new javax.swing.JTextField(); springPanel = new javax.swing.JPanel(); setLayout(new java.awt.GridBagLayout()); redLabel.setText(UIManager.getString("ColorChooser.rgbRedText")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.insets = new java.awt.Insets(1, 0, 0, 0); add(redLabel, gridBagConstraints); redSlider.setMajorTickSpacing(255); redSlider.setMaximum(255); redSlider.setMinorTickSpacing(128); redSlider.setPaintTicks(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; gridBagConstraints.weightx = 1.0; add(redSlider, gridBagConstraints); redField.setColumns(3); redField.setHorizontalAlignment(javax.swing.JTextField.TRAILING); redField.setText("0"); redField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { redFieldFocusLost(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; add(redField, gridBagConstraints); greenLabel.setText(UIManager.getString("ColorChooser.rgbGreenText")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.insets = new java.awt.Insets(1, 0, 0, 0); add(greenLabel, gridBagConstraints); greenSlider.setMajorTickSpacing(255); greenSlider.setMaximum(255); greenSlider.setMinorTickSpacing(128); greenSlider.setPaintTicks(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; gridBagConstraints.weightx = 1.0; add(greenSlider, gridBagConstraints); greenField.setColumns(3); greenField.setHorizontalAlignment(javax.swing.JTextField.TRAILING); greenField.setText("0"); greenField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { greenFieldFocusLost(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; add(greenField, gridBagConstraints); blueLabel.setText(UIManager.getString("ColorChooser.rgbBlueText")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.insets = new java.awt.Insets(1, 0, 0, 0); add(blueLabel, gridBagConstraints); blueSlider.setMajorTickSpacing(255); blueSlider.setMaximum(255); blueSlider.setMinorTickSpacing(128); blueSlider.setPaintTicks(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; gridBagConstraints.weightx = 1.0; add(blueSlider, gridBagConstraints); blueField.setColumns(3); blueField.setHorizontalAlignment(javax.swing.JTextField.TRAILING); blueField.setText("0"); blueField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { blueFieldFocusLost(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; add(blueField, gridBagConstraints); springPanel.setLayout(new java.awt.BorderLayout()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 100; gridBagConstraints.weighty = 1.0; add(springPanel, gridBagConstraints); }// //GEN-END:initComponents private void blueFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_blueFieldFocusLost blueField.setText(Integer.toString(ccModel.getValue(2))); }//GEN-LAST:event_blueFieldFocusLost private void greenFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_greenFieldFocusLost greenField.setText(Integer.toString(ccModel.getValue(1))); }//GEN-LAST:event_greenFieldFocusLost private void redFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_redFieldFocusLost redField.setText(Integer.toString(ccModel.getValue(0))); }//GEN-LAST:event_redFieldFocusLost // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField blueField; private javax.swing.JLabel blueLabel; private javax.swing.JSlider blueSlider; private javax.swing.JTextField greenField; private javax.swing.JLabel greenLabel; private javax.swing.JSlider greenSlider; private javax.swing.JTextField redField; private javax.swing.JLabel redLabel; private javax.swing.JSlider redSlider; private javax.swing.JPanel springPanel; // End of variables declaration//GEN-END:variables } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/GrayChooser.java0000644000175000017500000003202010564356430030571 0ustar drazzibdrazzib/* * @(#)GrayChooser.java 1.4 2006-04-23 * * Copyright (c) 2005-2006 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entehue into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import javax.swing.*; import javax.swing.text.*; import javax.swing.event.*; import javax.swing.border.*; import javax.swing.colorchooser.*; import javax.swing.plaf.*; import contrib.ch.randelshofer.quaqua.*; import contrib.ch.randelshofer.quaqua.util.*; /** * A color chooser with a brightness slider. * * @author Werner Randelshofer * @version 1.4 2006-04-23 Retrieve labels from UIManager. *
1.3 2005-11-22 Moved handler for text fields into separate class. *
1.2.1 2005-11-07 Get "Labels" ResourceBundle from UIManager. *
1.2 2005-09-05 Get font, spacing and icon from UIManager. *
1.1.1 2005-04-23 Localized form. Added color swatches for 0%, 25%, 50%, * 75% and 100% brightness. *
1.0 29 March 2005 Created. */ public class GrayChooser extends AbstractColorChooserPanel implements UIResource { private ColorSliderModel ccModel = new GrayColorSliderModel(); /** Creates new form. */ public GrayChooser() { initComponents(); Font font = UIManager.getFont("ColorChooser.font"); brightnessLabel.setFont(font); brightnessSlider.setFont(font); brightnessField.setFont(font); brightnessFieldLabel.setFont(font); zeroPercentButton.setFont(font); twentyFivePercentButton.setFont(font); fiftyPercentButton.setFont(font); seventyFivePercentButton.setFont(font); // int textSliderGap = UIManager.getInt("ColorChooser.textSliderGap"); if (textSliderGap != 0) { Border fieldBorder = new EmptyBorder(0,textSliderGap,0,0); brightnessFieldPanel.setBorder(fieldBorder); } ccModel.configureColorSlider(0, brightnessSlider); brightnessField.setText(Integer.toString(brightnessSlider.getValue())); Insets borderMargin = (Insets) UIManager.getInsets("Component.visualMargin").clone(); borderMargin.left = 3 - borderMargin.left; brightnessFieldLabel.putClientProperty("Quaqua.Component.visualMargin",borderMargin); new ColorSliderTextFieldHandler(brightnessField, ccModel, 0); ccModel.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { if (updateRecursion == 0) { setColorToModel(ccModel.getColor()); } } }); brightnessField.setMinimumSize(brightnessField.getPreferredSize()); VisualMargin bm = new VisualMargin(false,false,true,false); brightnessLabel.setBorder(bm); zeroPercentButton.putClientProperty("Quaqua.Button.style","colorWell"); twentyFivePercentButton.putClientProperty("Quaqua.Button.style","colorWell"); fiftyPercentButton.putClientProperty("Quaqua.Button.style","colorWell"); seventyFivePercentButton.putClientProperty("Quaqua.Button.style","colorWell"); hundredPercentButton.putClientProperty("Quaqua.Button.style","colorWell"); Border b = new CompoundBorder(new VisualMargin(), new SmallColorWellBorder()); zeroPercentButton.setBorder(b); twentyFivePercentButton.setBorder(b); fiftyPercentButton.setBorder(b); seventyFivePercentButton.setBorder(b); hundredPercentButton.setBorder(b); Insets bmInsets = UIManager.getInsets("Component.visualMargin"); Dimension d = new Dimension(12+bmInsets.left+bmInsets.right,12+bmInsets.top+bmInsets.bottom); zeroPercentButton.setPreferredSize(d); twentyFivePercentButton.setPreferredSize(d); fiftyPercentButton.setPreferredSize(d); seventyFivePercentButton.setPreferredSize(d); hundredPercentButton.setPreferredSize(d); } protected void buildChooser() { } public String getDisplayName() { return UIManager.getString("ColorChooser.grayScaleSlider"); } public Icon getLargeDisplayIcon() { return UIManager.getIcon("ColorChooser.colorSlidersIcon"); } public Icon getSmallDisplayIcon() { return getLargeDisplayIcon(); } /** * We have to prevent us from constantly updating the color model, because * the gray chooser is not able to preserve all color components. */ private int updateRecursion; public void updateChooser() { updateRecursion++; Color cfm = getColorFromModel(); ccModel.setColor(cfm); updateRecursion--; } public void setColorToModel(Color color) { getColorSelectionModel().setSelectedColor(color); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // //GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; brightnessLabel = new javax.swing.JLabel(); brightnessSlider = new javax.swing.JSlider(); brightnessFieldPanel = new javax.swing.JPanel(); brightnessField = new javax.swing.JTextField(); brightnessFieldLabel = new javax.swing.JLabel(); springPanel = new javax.swing.JPanel(); percentPanel = new javax.swing.JPanel(); zeroPercentButton = new javax.swing.JButton(); twentyFivePercentButton = new javax.swing.JButton(); fiftyPercentButton = new javax.swing.JButton(); seventyFivePercentButton = new javax.swing.JButton(); hundredPercentButton = new javax.swing.JButton(); setLayout(new java.awt.GridBagLayout()); brightnessLabel.setText(UIManager.getString("ColorChooser.hsbBrightnessText")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.insets = new java.awt.Insets(1, 0, 0, 0); add(brightnessLabel, gridBagConstraints); brightnessSlider.setMajorTickSpacing(100); brightnessSlider.setMinorTickSpacing(50); brightnessSlider.setPaintTicks(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridwidth = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; add(brightnessSlider, gridBagConstraints); brightnessFieldPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0)); brightnessField.setColumns(3); brightnessField.setHorizontalAlignment(javax.swing.JTextField.TRAILING); brightnessField.setText("0"); brightnessField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { brightnessFieldFocusLost(evt); } }); brightnessFieldPanel.add(brightnessField); brightnessFieldLabel.setText("%"); brightnessFieldPanel.add(brightnessFieldLabel); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 5; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; add(brightnessFieldPanel, gridBagConstraints); springPanel.setLayout(new java.awt.BorderLayout()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 100; gridBagConstraints.weighty = 1.0; add(springPanel, gridBagConstraints); percentPanel.setLayout(new java.awt.GridBagLayout()); zeroPercentButton.setBackground(new java.awt.Color(0, 0, 0)); zeroPercentButton.setToolTipText("0 %"); zeroPercentButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { percentActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; percentPanel.add(zeroPercentButton, gridBagConstraints); twentyFivePercentButton.setBackground(new java.awt.Color(64, 64, 64)); twentyFivePercentButton.setToolTipText("25 %"); twentyFivePercentButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { percentActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 2; gridBagConstraints.weightx = 1.0; percentPanel.add(twentyFivePercentButton, gridBagConstraints); fiftyPercentButton.setBackground(new java.awt.Color(128, 128, 128)); fiftyPercentButton.setToolTipText("50 %"); fiftyPercentButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { percentActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 2; percentPanel.add(fiftyPercentButton, gridBagConstraints); seventyFivePercentButton.setBackground(new java.awt.Color(192, 192, 192)); seventyFivePercentButton.setToolTipText("75 %"); seventyFivePercentButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { percentActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 2; gridBagConstraints.weightx = 1.0; percentPanel.add(seventyFivePercentButton, gridBagConstraints); hundredPercentButton.setBackground(new java.awt.Color(255, 255, 255)); hundredPercentButton.setToolTipText("100 %"); hundredPercentButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { percentActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; percentPanel.add(hundredPercentButton, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; add(percentPanel, gridBagConstraints); }// //GEN-END:initComponents private void percentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_percentActionPerformed setColorToModel(((JButton) evt.getSource()).getBackground()); }//GEN-LAST:event_percentActionPerformed private void brightnessFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_brightnessFieldFocusLost brightnessField.setText(Integer.toString(ccModel.getBoundedRangeModel(0).getValue())); }//GEN-LAST:event_brightnessFieldFocusLost // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField brightnessField; private javax.swing.JLabel brightnessFieldLabel; private javax.swing.JPanel brightnessFieldPanel; private javax.swing.JLabel brightnessLabel; private javax.swing.JSlider brightnessSlider; private javax.swing.JButton fiftyPercentButton; private javax.swing.JButton hundredPercentButton; private javax.swing.JPanel percentPanel; private javax.swing.JButton seventyFivePercentButton; private javax.swing.JPanel springPanel; private javax.swing.JButton twentyFivePercentButton; private javax.swing.JButton zeroPercentButton; // End of variables declaration//GEN-END:variables } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ColorSlidersChooser.form0000644000175000017500000000343710564356430032327 0ustar drazzibdrazzib
substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/CMYKChooser.java0000644000175000017500000004206510564356426030451 0ustar drazzibdrazzib/* * @(#)CMYKChooser.java 1.4 2006-04-23 * * Copyright (c) 2004-2006 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entecyan into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import java.io.*; import javax.swing.*; import javax.swing.text.*; import javax.swing.event.*; import javax.swing.border.*; import javax.swing.colorchooser.*; import javax.swing.plaf.*; import contrib.ch.randelshofer.quaqua.*; import contrib.ch.randelshofer.quaqua.util.*; /** * A color chooser with CMYK color sliders. * * @author Werner Randelshofer * @version 1.4 2006-04-23 Get labels directly from UIManager. *
1.3 2005-11-22 Moved handler for text fields into separate class. *
1.2.2 2005-11-22 If the user enters a non-numeric value, set the * corresponding bounded range model to 0. *
1.2.1 2005-11-07 Get "Labels" ResourceBundle from UIManager. *
1.2 2005-09-05 Get font, spacing and icon from UIManager. *
1.1.1 2005-05-23 Localized form. *
1.0 29 March 2005 Created. */ public class CMYKChooser extends AbstractColorChooserPanel implements UIResource { private ColorSliderModel ccModel; private int updateRecursion = 0; /** Creates new form. */ public CMYKChooser() { initComponents(); // Font font = UIManager.getFont("ColorChooser.font"); cyanLabel.setFont(font); cyanSlider.setFont(font); cyanField.setFont(font); cyanFieldLabel.setFont(font); magentaLabel.setFont(font); magentaSlider.setFont(font); magentaField.setFont(font); magentaFieldLabel.setFont(font); yellowLabel.setFont(font); yellowSlider.setFont(font); yellowField.setFont(font); yellowFieldLabel.setFont(font); blackLabel.setFont(font); blackSlider.setFont(font); blackField.setFont(font); blackFieldLabel.setFont(font); // int textSliderGap = UIManager.getInt("ColorChooser.textSliderGap"); if (textSliderGap != 0) { Border fieldBorder = new EmptyBorder(0,textSliderGap,0,0); cyanFieldPanel.setBorder(fieldBorder); magentaFieldPanel.setBorder(fieldBorder); yellowFieldPanel.setBorder(fieldBorder); blackFieldPanel.setBorder(fieldBorder); } ccModel = new NominalCMYKColorSliderModel(); /* Unfortunately the following does not work due to Java bug #4760025 as * described at http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4760025 InputStream in = null; try { in = new FileInputStream("/System/Library/ColorSync/Profiles/Generic CMYK Profile.icc"); ccModel = new ICC_CMYKColorSliderModel(in); } catch (IOException e) { e.printStackTrace(); ccModel = new NominalCMYKColorSliderModel(); } finally { try { if (in != null) in.close(); } catch (IOException e) { // suppress } }*/ ccModel.configureColorSlider(0, cyanSlider); ccModel.configureColorSlider(1, magentaSlider); ccModel.configureColorSlider(2, yellowSlider); ccModel.configureColorSlider(3, blackSlider); cyanField.setText(Integer.toString(cyanSlider.getValue())); magentaField.setText(Integer.toString(magentaSlider.getValue())); yellowField.setText(Integer.toString(yellowSlider.getValue())); blackField.setText(Integer.toString(blackSlider.getValue())); Insets borderMargin = (Insets) UIManager.getInsets("Component.visualMargin").clone(); borderMargin.left = 3 - borderMargin.left; cyanFieldLabel.putClientProperty("Quaqua.Component.visualMargin",borderMargin); magentaFieldLabel.putClientProperty("Quaqua.Component.visualMargin",borderMargin); yellowFieldLabel.putClientProperty("Quaqua.Component.visualMargin",borderMargin); blackFieldLabel.putClientProperty("Quaqua.Component.visualMargin",borderMargin); new ColorSliderTextFieldHandler(cyanField, ccModel, 0); new ColorSliderTextFieldHandler(magentaField, ccModel, 1); new ColorSliderTextFieldHandler(yellowField, ccModel, 2); new ColorSliderTextFieldHandler(blackField, ccModel, 3); ccModel.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { setColorToModel(ccModel.getColor()); } }); cyanField.setMinimumSize(cyanField.getPreferredSize()); magentaField.setMinimumSize(magentaField.getPreferredSize()); yellowField.setMinimumSize(yellowField.getPreferredSize()); blackField.setMinimumSize(blackField.getPreferredSize()); VisualMargin bm = new VisualMargin(false,false,true,false); cyanLabel.setBorder(bm); magentaLabel.setBorder(bm); yellowLabel.setBorder(bm); blackLabel.setBorder(bm); } protected void buildChooser() { } public String getDisplayName() { return UIManager.getString("ColorChooser.cmykSliders"); } public Icon getLargeDisplayIcon() { return UIManager.getIcon("ColorChooser.colorSlidersIcon"); } public Icon getSmallDisplayIcon() { return getLargeDisplayIcon(); } public void updateChooser() { if (updateRecursion == 0) { updateRecursion++; ccModel.setColor(getColorFromModel()); updateRecursion--; } } public void setColorToModel(Color color) { if (updateRecursion == 0) { updateRecursion++; getColorSelectionModel().setSelectedColor(color); updateRecursion--; } } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // //GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; cyanLabel = new javax.swing.JLabel(); cyanSlider = new javax.swing.JSlider(); cyanFieldPanel = new javax.swing.JPanel(); cyanField = new javax.swing.JTextField(); cyanFieldLabel = new javax.swing.JLabel(); magentaLabel = new javax.swing.JLabel(); magentaSlider = new javax.swing.JSlider(); magentaFieldPanel = new javax.swing.JPanel(); magentaField = new javax.swing.JTextField(); magentaFieldLabel = new javax.swing.JLabel(); yellowLabel = new javax.swing.JLabel(); yellowSlider = new javax.swing.JSlider(); yellowFieldPanel = new javax.swing.JPanel(); yellowField = new javax.swing.JTextField(); yellowFieldLabel = new javax.swing.JLabel(); blackLabel = new javax.swing.JLabel(); blackSlider = new javax.swing.JSlider(); blackFieldPanel = new javax.swing.JPanel(); blackField = new javax.swing.JTextField(); blackFieldLabel = new javax.swing.JLabel(); springPanel = new javax.swing.JPanel(); setLayout(new java.awt.GridBagLayout()); cyanLabel.setText(UIManager.getString("ColorChooser.cmykCyanText")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.insets = new java.awt.Insets(1, 0, 0, 0); add(cyanLabel, gridBagConstraints); cyanSlider.setMajorTickSpacing(100); cyanSlider.setMinorTickSpacing(50); cyanSlider.setPaintTicks(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; add(cyanSlider, gridBagConstraints); cyanFieldPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0)); cyanField.setColumns(3); cyanField.setHorizontalAlignment(javax.swing.JTextField.TRAILING); cyanField.setText("0"); cyanField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { cyanFieldFocusLost(evt); } }); cyanFieldPanel.add(cyanField); cyanFieldLabel.setText("%"); cyanFieldPanel.add(cyanFieldLabel); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; add(cyanFieldPanel, gridBagConstraints); magentaLabel.setText(UIManager.getString("ColorChooser.cmykMagentaText")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.insets = new java.awt.Insets(1, 0, 0, 0); add(magentaLabel, gridBagConstraints); magentaSlider.setMajorTickSpacing(100); magentaSlider.setMinorTickSpacing(50); magentaSlider.setPaintTicks(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; add(magentaSlider, gridBagConstraints); magentaFieldPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0)); magentaField.setColumns(3); magentaField.setHorizontalAlignment(javax.swing.JTextField.TRAILING); magentaField.setText("0"); magentaField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { magentaFieldFocusLost(evt); } }); magentaFieldPanel.add(magentaField); magentaFieldLabel.setText("%"); magentaFieldPanel.add(magentaFieldLabel); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; add(magentaFieldPanel, gridBagConstraints); yellowLabel.setText(UIManager.getString("ColorChooser.cmykYellowText")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.insets = new java.awt.Insets(1, 0, 0, 0); add(yellowLabel, gridBagConstraints); yellowSlider.setMajorTickSpacing(100); yellowSlider.setMinorTickSpacing(50); yellowSlider.setPaintTicks(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; add(yellowSlider, gridBagConstraints); yellowFieldPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0)); yellowField.setColumns(3); yellowField.setHorizontalAlignment(javax.swing.JTextField.TRAILING); yellowField.setText("0"); yellowField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { yellowFieldFocusLost(evt); } }); yellowFieldPanel.add(yellowField); yellowFieldLabel.setText("%"); yellowFieldPanel.add(yellowFieldLabel); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 4; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; add(yellowFieldPanel, gridBagConstraints); blackLabel.setText(UIManager.getString("ColorChooser.cmykBlackText")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.insets = new java.awt.Insets(1, 0, 0, 0); add(blackLabel, gridBagConstraints); blackSlider.setMajorTickSpacing(100); blackSlider.setMinorTickSpacing(50); blackSlider.setPaintTicks(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; add(blackSlider, gridBagConstraints); blackFieldPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0)); blackField.setColumns(3); blackField.setHorizontalAlignment(javax.swing.JTextField.TRAILING); blackField.setText("0"); blackField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { blackFieldFocusLost(evt); } }); blackFieldPanel.add(blackField); blackFieldLabel.setText("%"); blackFieldPanel.add(blackFieldLabel); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 6; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; add(blackFieldPanel, gridBagConstraints); springPanel.setLayout(new java.awt.BorderLayout()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 100; gridBagConstraints.weighty = 1.0; add(springPanel, gridBagConstraints); }// //GEN-END:initComponents private void blackFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_blackFieldFocusLost blackField.setText(Integer.toString(ccModel.getBoundedRangeModel(3).getValue())); }//GEN-LAST:event_blackFieldFocusLost private void yellowFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_yellowFieldFocusLost yellowField.setText(Integer.toString(ccModel.getBoundedRangeModel(2).getValue())); }//GEN-LAST:event_yellowFieldFocusLost private void magentaFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_magentaFieldFocusLost magentaField.setText(Integer.toString(ccModel.getBoundedRangeModel(1).getValue())); }//GEN-LAST:event_magentaFieldFocusLost private void cyanFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cyanFieldFocusLost cyanField.setText(Integer.toString(ccModel.getBoundedRangeModel(0).getValue())); }//GEN-LAST:event_cyanFieldFocusLost // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField blackField; private javax.swing.JLabel blackFieldLabel; private javax.swing.JPanel blackFieldPanel; private javax.swing.JLabel blackLabel; private javax.swing.JSlider blackSlider; private javax.swing.JTextField cyanField; private javax.swing.JLabel cyanFieldLabel; private javax.swing.JPanel cyanFieldPanel; private javax.swing.JLabel cyanLabel; private javax.swing.JSlider cyanSlider; private javax.swing.JTextField magentaField; private javax.swing.JLabel magentaFieldLabel; private javax.swing.JPanel magentaFieldPanel; private javax.swing.JLabel magentaLabel; private javax.swing.JSlider magentaSlider; private javax.swing.JPanel springPanel; private javax.swing.JTextField yellowField; private javax.swing.JLabel yellowFieldLabel; private javax.swing.JPanel yellowFieldPanel; private javax.swing.JLabel yellowLabel; private javax.swing.JSlider yellowSlider; // End of variables declaration//GEN-END:variables } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ColorWheelImageProducer.java0000644000175000017500000000735310564356430033071 0ustar drazzibdrazzib/* * @(#)ColorWheelImageProducer.java 1.0 August 27, 2005 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import java.awt.image.*; import java.awt.color.*; /** * Produces the image of a ColorWheel. * * @see ColorWheel * * @author Werner Randelshofer * @version 1.0 August 27, 2005 Created. */ public class ColorWheelImageProducer extends MemoryImageSource { private int[] pixels; private int w, h; private float brightness = 1f; private boolean isDirty = true; /** Lookup table for hues. */ private float[] hues; /** Lookup table for saturations. */ private float[] saturations; /** Lookup table for alphas. * The alpha value is used for antialiasing the * color wheel. */ private int[] alphas; /** Creates a new instance. */ public ColorWheelImageProducer(int w, int h) { super(w, h, null, 0, w); pixels = new int[w*h]; this.w = w; this.h = h; generateLookupTables(); newPixels(pixels, ColorModel.getRGBdefault(), 0, w); setAnimated(true); generateColorWheel(); } public int getRadius() { return Math.min(w, h) / 2 - 2; } private void generateLookupTables() { saturations = new float[w*h]; hues = new float[w*h]; alphas = new int[w*h]; float radius = getRadius(); // blend is used to create a linear alpha gradient of two extra pixels float blend = (radius + 2f) / radius - 1f; // Center of the color wheel circle int cx = w / 2; int cy = h / 2; for (int x=0; x < w; x++) { int kx = x - cx; // Kartesian coordinates of x int squarekx = kx * kx; // Square of kartesian x for (int y=0; y < h; y++) { int ky = cy - y; // Kartesian coordinates of y int index = x + y * w; saturations[index] = (float) Math.sqrt(squarekx + ky*ky) / radius; if (saturations[index] <= 1f) { alphas[index] = 0xff000000; } else { alphas[index] = (int) ((blend - Math.min(blend,saturations[index] - 1f)) * 255 / blend) << 24; saturations[index] = 1f; } if (alphas[index] != 0) { hues[index] = (float) (Math.atan2(ky, kx) / Math.PI / 2d); } } } } public void setBrightness(float newValue) { isDirty = isDirty || brightness != newValue; brightness = newValue; } public boolean needsGeneration() { return isDirty; } public void regenerateColorWheel() { if (isDirty) { generateColorWheel(); } } public void generateColorWheel() { float radius = (float) Math.min(w, h); for (int index=0; index < pixels.length; index++) { if (alphas[index] != 0) { pixels[index] = alphas[index] | 0xffffff & Color.HSBtoRGB(hues[index], saturations[index], brightness); } } newPixels(); isDirty = false; } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ColorChooserMainPanel.form0000644000175000017500000000745510564356426032577 0ustar drazzibdrazzib
substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/RGBColorSliderModel.java0000644000175000017500000000327710564356432032117 0ustar drazzibdrazzib/* * @(#)RGBColorSliderModel.java 1.0 May 22, 2005 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import javax.swing.*; /** * A ColorSliderModel for RGB color components (red, green, blue). * * @author Werner Randelshofer * @version 1.0 May 22, 2005 Created. */ public class RGBColorSliderModel extends ColorSliderModel { /** * Creates a new instance. */ public RGBColorSliderModel() { super(new DefaultBoundedRangeModel[] { new DefaultBoundedRangeModel(255, 0, 0, 255), new DefaultBoundedRangeModel(255, 0, 0, 255), new DefaultBoundedRangeModel(255, 0, 0, 255) }); } public int getRGB() { return getRGB(components[0].getValue(), components[1].getValue(), components[2].getValue()); } protected int getRGB(int r, int g, int b) { return 0xff000000 | r << 16 | g << 8 | b; } public void setRGB(int rgb) { components[0].setValue((rgb & 0xff0000) >> 16); components[1].setValue((rgb & 0x00ff00) >> 8); components[2].setValue( rgb & 0x0000ff); } public int toRGB(int[] values) { return 0xff000000 | values[0] << 16 | values[1] << 8 | values[2]; } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/Quaqua15ColorPicker.form0000644000175000017500000000341510564356666032147 0ustar drazzibdrazzib
substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/HTMLChooser.form0000644000175000017500000003155410564356430030470 0ustar drazzibdrazzib
substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/SmallColorWellBorder.java0000644000175000017500000000275610564356432032414 0ustar drazzibdrazzib/* * @(#)QuaquaSmallColorWellBorder.java 1.0 2005-04-18 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import javax.swing.*; import javax.swing.border.*; /** * SmallColorWellBorder. * * @author werni */ public class SmallColorWellBorder implements Border { private static Color inner = Color.white; private static Color outer = new Color(0x949494); /** Creates a new instance of QuaquaSquareButtonBorder */ public SmallColorWellBorder() { } public Insets getBorderInsets(Component c) { return new Insets(1, 1, 1, 1); } public boolean isBorderOpaque() { return true; } public void paintBorder(Component c, Graphics gr, int x, int y, int width, int height) { gr.setColor(c.getBackground()); gr.fillRect(x + 2, y + 2, width - 4, height - 4); gr.setColor(inner); gr.drawRect(x + 1, y + 1, width - 3, height - 3); gr.setColor(outer); gr.drawRect(x, y, width - 1, height - 1); } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ColorWheel.form0000644000175000017500000000032710322471722030430 0ustar drazzibdrazzib
substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/GrayColorSliderModel.java0000644000175000017500000000301510564356430032373 0ustar drazzibdrazzib/* * @(#)GrayColorSliderModel.java 1.0 May 22, 2005 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import javax.swing.*; /** * A ColorSliderModel for a gray color model (brightness). * * @author Werner Randelshofer * @version 1.0 May 22, 2005 Created. */ public class GrayColorSliderModel extends ColorSliderModel { /** * Creates a new instance. */ public GrayColorSliderModel() { super(new DefaultBoundedRangeModel[] { new DefaultBoundedRangeModel(0, 0, 0, 100) }); } public int getRGB() { int br = (int) (components[0].getValue() * 2.55f); return 0xff000000 | (br << 16) | (br << 8) | (br); } public void setRGB(int rgb) { components[0].setValue((int) ( (((rgb & 0xff0000) >> 16) + ((rgb & 0x00ff00) >> 8) + (rgb & 0x0000ff)) / 3f / 2.55f ) ); } public int toRGB(int[] values) { int br = (int) (values[0] * 2.55f); return 0xff000000 | (br << 16) | (br << 8) | (br); } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ColorWheelChooser.java0000644000175000017500000000667310564356430031751 0ustar drazzibdrazzib/* * @(#)ColorWheelChooser.java 1.1 2006-04-23 * * Copyright (c) 2005-2006 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import javax.swing.*; import javax.swing.colorchooser.*; import javax.swing.event.*; import javax.swing.plaf.*; import contrib.ch.randelshofer.quaqua.util.*; /** * A HSB color chooser, which displays a hue/saturation color wheel, and a * brightness slider. * * @author Werner Randelshofer * @version 1.1 2006-04-23 Retrieve labels from UIManager. *
1.0.2 2005-11-07 Get "labels" resource bundle from UIManager. *
1.0.1 2005-09-11 Get icon from UIManager. *
1.0 August 27, 2005 Created. */ public class ColorWheelChooser extends AbstractColorChooserPanel implements UIResource { private ColorWheel colorWheel; private HSBColorSliderModel ccModel = new HSBColorSliderModel(); /** * Creates a new instance. */ public ColorWheelChooser() { initComponents(); int textSliderGap = UIManager.getInt("ColorChooser.textSliderGap"); if (textSliderGap != 0) { BorderLayout layout = (BorderLayout) getLayout(); layout.setHgap(textSliderGap); } colorWheel = new ColorWheel(); add(colorWheel); ccModel.configureColorSlider(2, brightnessSlider); colorWheel.setModel(ccModel); ccModel.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { setColorToModel(ccModel.getColor()); } }); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents brightnessSlider = new javax.swing.JSlider(); setLayout(new java.awt.BorderLayout()); brightnessSlider.setMajorTickSpacing(50); brightnessSlider.setOrientation(javax.swing.JSlider.VERTICAL); brightnessSlider.setPaintTicks(true); add(brightnessSlider, java.awt.BorderLayout.EAST); }//GEN-END:initComponents protected void buildChooser() { } public String getDisplayName() { return UIManager.getString("ColorChooser.colorWheel"); } public javax.swing.Icon getLargeDisplayIcon() { return UIManager.getIcon("ColorChooser.colorWheelIcon"); } public Icon getSmallDisplayIcon() { return getLargeDisplayIcon(); } public void updateChooser() { ccModel.setColor(getColorFromModel()); } public void setColorToModel(Color color) { getColorSelectionModel().setSelectedColor(color); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JSlider brightnessSlider; // End of variables declaration//GEN-END:variables } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/PaletteEntryCellRenderer.java0000644000175000017500000001012210564356432033254 0ustar drazzibdrazzib/* * @(#)PaletteEntryCellRenderer.java 1.0 19 septembre 2005 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import javax.swing.*; import javax.swing.border.*; /** * PaletteEntryCellRenderer. * * @author Werner Randelshofer * @version 1.0 19 septembre 2005 Created. */ public class PaletteEntryCellRenderer extends DefaultListCellRenderer { /** The following colors are used to draw the marker that marks the * closest color in the palette. * The "closest color" is used, when the palette does not contain an * exact match to the currently selected color in the color chooser. * The marker is used to help the user finding the closest color in the * palette. */ private Color closestMarker1 = new Color(0xe6e6e6); private Color closestMarker2 = new Color(0xededed); private Color closestMarker3 = new Color(0xf0f0f0); static class ColorIcon implements Icon { private Color color = Color.black; public void setColor(Color c) { this.color = c; } public Color getColor() { return color; } public int getIconHeight() { return 15; } public int getIconWidth() { return 25; } public void paintIcon(Component c, Graphics g, int x, int y) { g.setColor(getColor()); g.fillRect(x + 1, y + 1, getIconWidth() - 2, getIconHeight() - 2); g.setColor(getColor().darker()); g.drawRect(x, y, getIconWidth() - 1, getIconHeight() - 1); } } private ColorIcon icon; private boolean isClosestColor; /** * Creates a new instance. */ public PaletteEntryCellRenderer() { icon = new ColorIcon(); setIcon(icon); setOpaque(false); } public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { setComponentOrientation(list.getComponentOrientation()); if (isSelected) { setBackground(UIManager.getColor("ColorChooser.listSelectionBackground")); setForeground(UIManager.getColor("ColorChooser.listSelectionForeground")); isClosestColor = false; } else { setBackground(list.getBackground()); setForeground(list.getForeground()); PaletteListModel model = (PaletteListModel) list.getModel(); isClosestColor = model.getClosestIndex() == index; } setEnabled(list.isEnabled()); setFont(list.getFont()); //setBorder((cellHasFocus) ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder); PaletteEntry entry = (PaletteEntry) value; icon.setColor(entry.getColor()); setText(entry.getName()); return this; } public void paintComponent(Graphics g) { int width = getWidth(); int height = getHeight(); g.setColor(getBackground()); g.fillRect(0,0,width,height); if (isClosestColor) { g.setColor(closestMarker1); g.fillRect(0,0,width,2); g.fillRect(0,height - 2,width,2); g.setColor(closestMarker2); g.fillRect(0,2,width,1); g.fillRect(0,height - 3,width,1); g.setColor(closestMarker3); g.fillRect(0,3,width,1); g.fillRect(0,height - 4,width,1); } super.paintComponent(g); } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ColorSliderModel.java0000644000175000017500000001512610564356430031556 0ustar drazzibdrazzib/* * @(#)ColorSliderModel.java 1.0 May 22, 2005 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import java.awt.color.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.plaf.*; import java.io.*; import java.util.*; /** * Abstract super class for ColorModels which can be used in conjunction with * ColorSliderUI user interface delegates. *

* Colors are represented as arrays of color components represented as * BoundedRangeModel's. Each BoundedRangeModel can be visualized using a JSlider * having a ColorSliderUI. * * @author Werner Randelshofer * @version 1.0 May 22, 2005 Created. */ public abstract class ColorSliderModel { /** * JSlider's associated to this ColorSliderModel. */ private LinkedList sliders = new LinkedList(); /** * ChangeListener's listening to changes in this ColorSliderModel. */ private LinkedList listeners = new LinkedList(); /** * Components of the color model. */ protected DefaultBoundedRangeModel[] components; /** * Speed optimization. This way, we do not need to create a new array * for each invocation of method getInterpolatedRGB(). * Note: This variable must not use in reentrant methods. */ protected int[] values; /** * Creates a new ColorSliderModel with an array of BoundedRangeModel's * for the color components. */ protected ColorSliderModel(DefaultBoundedRangeModel[] components) { this.components = components; values = new int[components.length]; for (int i=0; i < components.length; i++) { final int componentIndex = i; components[i].addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { fireColorChanged(componentIndex); fireStateChanged(); } }); } } /** * Configures a JSlider for this ColorSliderModel. * If the JSlider is already configured for another ColorSliderModel, * it is unconfigured first. */ public void configureColorSlider(int component, JSlider slider) { if (slider.getClientProperty("ColorSliderModel") != null) { ((ColorSliderModel) slider.getClientProperty("ColorSliderModel")) .unconfigureColorSlider(slider); } if ( ! (slider.getUI() instanceof ColorSliderUI)) { slider.setUI(new ColorSliderUI(slider)); } slider.setModel(getBoundedRangeModel(component)); slider.putClientProperty("ColorSliderModel", this); slider.putClientProperty("ColorComponentIndex", new Integer(component)); addColorSlider(slider); } /** * Unconfigures a JSlider from this ColorSliderModel. */ public void unconfigureColorSlider(JSlider slider) { if (slider.getClientProperty("ColorSliderModel") == this) { // XXX - This creates a NullPointerException ?? //slider.setUI((SliderUI) UIManager.getUI(slider)); slider.setModel(new DefaultBoundedRangeModel()); slider.putClientProperty("ColorSliderModel", null); slider.putClientProperty("ColorComponentIndex", null); removeColorSlider(slider); } } /** * Returns the number of components of this color component model. */ public int getComponentCount() { return components.length; } /** * Returns the bounded range model of the specified color component. */ public DefaultBoundedRangeModel getBoundedRangeModel(int component) { return components[component]; } /** * Returns the value of the specified color component. */ public int getValue(int component) { return components[component].getValue(); } /** * Sets the value of the specified color component. */ public void setValue(int component, int value) { components[component].setValue(value); } /** * Returns an interpolated RGB value by using the values of the color * components of this ColorSliderModel except for the component specified * as an argument. For this component the ratio between zero * and the maximum of its BoundedRangeModel is used. */ public int getInterpolatedRGB(int component, float ratio) { for (int i=0, n = getComponentCount(); i < n; i++) { values[i] = components[i].getValue(); } values[component] = (int) (ratio * components[component].getMaximum()); return toRGB(values); } protected void addColorSlider(JSlider slider) { sliders.add(slider); } protected void removeColorSlider(JSlider slider) { sliders.remove(slider); } public void addChangeListener(ChangeListener l) { listeners.add(l); } public void removeChangeListener(ChangeListener l) { listeners.remove(l); } protected void fireColorChanged(int componentIndex) { Integer index = new Integer(componentIndex); Color value = getColor(); for (Iterator i = sliders.iterator(); i.hasNext(); ) { JSlider slider = (JSlider) i.next(); slider.putClientProperty("ColorComponentChange", index); slider.putClientProperty("ColorComponentValue", value); } } public void fireStateChanged() { ChangeEvent event = new ChangeEvent(this); for (Iterator i=listeners.iterator(); i.hasNext(); ) { ChangeListener l = (ChangeListener) i.next(); l.stateChanged(event); } } public Color getColor() { return new Color(getRGB()); } public void setColor(Color color) { int rgb = color.getRGB(); if (rgb != getRGB()) { setRGB(rgb); } } public abstract void setRGB(int rgb); public abstract int getRGB(); public abstract int toRGB(int[] values); } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ColorSlidersChooser.java0000644000175000017500000001316610564356430032305 0ustar drazzibdrazzib/* * @(#)ColorSlidersChooser.java 1.4 2006-04-23 * * Copyright (c) 2005-2006 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.colorchooser.*; import javax.swing.plaf.*; import contrib.ch.randelshofer.quaqua.*; import contrib.ch.randelshofer.quaqua.util.*; import java.util.*; /** * The ColorSlidersChooser contains four individual color slider pages: gray * slider, RGB sliders, CMYK sliders, and HTML sliders. * * @author Werner Randelshofer * @version 1.4 2006-04-23 Retrieve labels from UIManager. *
1.3.1 2005-11-07 Get "UIManager" ResourceBundle from UIManager. *
1.3 2005-09-05 Get Font and icon from UIManager. *
1.2 2005-08-27 Keep track of last slider panel, and open this * panel, when the ColorSlidersChooser is recreated. *
1.1.1 2005-04-23 Localized form. *
1.0 30 March 2005 Created. */ public class ColorSlidersChooser extends AbstractColorChooserPanel implements UIResource { /** * We store here the name of the last selected color sliders panel. * When the ColorSlidersChooser is recreated multiple times in the same * panel, the application 'remembers' which panel the user had opened * before. */ private static int lastSelectedPanelIndex = 1; /** Creates new form. */ public ColorSlidersChooser() { initComponents(); slidersComboBox.setFont(UIManager.getFont("ColorChooser.font")); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents slidersComboBox = new javax.swing.JComboBox(); slidersHolder = new javax.swing.JPanel(); setLayout(new java.awt.BorderLayout()); add(slidersComboBox, java.awt.BorderLayout.NORTH); slidersHolder.setLayout(new java.awt.CardLayout()); add(slidersHolder, java.awt.BorderLayout.CENTER); }//GEN-END:initComponents protected void buildChooser() { slidersHolder.add(new GrayChooser(),UIManager.getString("ColorChooser.grayScaleSlider")); slidersHolder.add(new RGBChooser(),UIManager.getString("ColorChooser.rgbSliders")); slidersHolder.add(new CMYKChooser(),UIManager.getString("ColorChooser.cmykSliders")); slidersHolder.add(new HSBChooser(),UIManager.getString("ColorChooser.hsbSliders")); slidersHolder.add(new HTMLChooser(),UIManager.getString("ColorChooser.htmlSliders")); DefaultComboBoxModel cbm = new DefaultComboBoxModel(); cbm.addElement(UIManager.getString("ColorChooser.grayScaleSlider")); cbm.addElement(UIManager.getString("ColorChooser.rgbSliders")); cbm.addElement(UIManager.getString("ColorChooser.cmykSliders")); cbm.addElement(UIManager.getString("ColorChooser.hsbSliders")); cbm.addElement(UIManager.getString("ColorChooser.htmlSliders")); slidersComboBox.setModel(cbm); slidersComboBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent evt) { if (evt.getStateChange() == ItemEvent.SELECTED) { ((CardLayout) slidersHolder.getLayout()).show(slidersHolder, (String) evt.getItem()); lastSelectedPanelIndex = slidersComboBox.getSelectedIndex(); } } }); slidersComboBox.setSelectedIndex(lastSelectedPanelIndex); } public void installChooserPanel(JColorChooser enclosingChooser) { super.installChooserPanel(enclosingChooser); Component[] components = slidersHolder.getComponents(); for (int i=0; i < components.length; i++) { AbstractColorChooserPanel ccp = (AbstractColorChooserPanel) components[i]; ccp.installChooserPanel(enclosingChooser); } } /** * Invoked when the panel is removed from the chooser. * If override this, be sure to call super. */ public void uninstallChooserPanel(JColorChooser enclosingChooser) { Component[] components = slidersHolder.getComponents(); for (int i=0; i < components.length; i++) { AbstractColorChooserPanel ccp = (AbstractColorChooserPanel) components[i]; ccp.uninstallChooserPanel(enclosingChooser); } super.uninstallChooserPanel(enclosingChooser); } public String getDisplayName() { return UIManager.getString("ColorChooser.colorSliders"); } public Icon getLargeDisplayIcon() { return UIManager.getIcon("ColorChooser.colorSlidersIcon"); } public Icon getSmallDisplayIcon() { return getLargeDisplayIcon(); } public void updateChooser() { } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JComboBox slidersComboBox; private javax.swing.JPanel slidersHolder; // End of variables declaration//GEN-END:variables } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/GrayChooser.form0000644000175000017500000002606610564356430030630 0ustar drazzibdrazzib

substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/SwatchesChooser.form0000644000175000017500000000264210564356432031503 0ustar drazzibdrazzib
substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/HTMLColorSliderModel.java0000644000175000017500000000660610564356432032250 0ustar drazzibdrazzib/* * @(#)HTMLColorSliderModel.java 1.0.1 2005-08-28 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import javax.swing.*; /** * ColorSliderModel for the HTML color model (red, green, blue, restricted * to values considered as web-save). * * @author Werner Randelshofer * @version 1.0.1 2005-08-28 Method toWebSave generates now ARGB value instead * of just an RGB value. Method isWebSave ignores the alpha channel of a color. *
1.0 May 22, 2005 Created. */ public class HTMLColorSliderModel extends RGBColorSliderModel { private boolean isWebSaveOnly = true; /** * Creates a new instance. */ public HTMLColorSliderModel() { } public int getRGB() { return getRGB(components[0].getValue(), components[1].getValue(), components[2].getValue()); } public int getInterpolatedRGB(int component, float value) { if (isWebSaveOnly) { for (int i=0, n = getComponentCount(); i < n; i++) { values[i] = Math.round(components[i].getValue() / 51f) * 51; } values[component] = Math.round((value * components[component].getMaximum()) / 51f) * 51; return toRGB(values); } else { return super.getInterpolatedRGB(component, value); } } protected int getRGB(int r, int g, int b) { if (isWebSaveOnly) { return 0xff000000 | (Math.round(r / 51f) * 51) << 16 | (Math.round(g / 51f) * 51) << 8 | Math.round(b / 51f) * 51; } else { return super.getRGB(r, g, b); } } public void setRGB(int rgb) { if (isWebSaveOnly) { components[0].setValue((Math.round((rgb & 0xff0000) / 51f) * 51) >> 16); components[1].setValue((Math.round((rgb & 0x00ff00) / 51f) * 51) >> 8); components[2].setValue(Math.round((rgb & 0x0000ff) / 51f) * 51); } else { super.setRGB(rgb); } } public int toRGB(int[] values) { if (isWebSaveOnly) { return 0xff000000 | (Math.round(values[0] / 51f) * 51) << 16 | (Math.round(values[1] / 51f) * 51) << 8 | (Math.round(values[2] / 51f) * 51); } else { return super.toRGB(values); } } public void setWebSaveOnly(boolean b) { isWebSaveOnly = b; if (b) { setRGB(getRGB()); } fireColorChanged(-1); } public boolean isWebSaveOnly() { return isWebSaveOnly; } public static boolean isWebSave(int rgb) { return (rgb & 0xffffff) == (toWebSave(rgb) & 0xffffff); } public static int toWebSave(int rgb) { return (rgb & 0xff000000) | ((Math.round(((rgb & 0xff0000) >> 16) / 51f) * 51) << 16) | ((Math.round(((rgb & 0x00ff00) >> 8) / 51f) * 51) << 8) | (Math.round((rgb & 0x0000ff) / 51f) * 51); } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ColorSliderTextFieldHandler.java0000644000175000017500000000456010564356430033704 0ustar drazzibdrazzib/* * @(#)ColorSliderTextFieldHandler.java 1.0 November 22, 2005 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; /** * This handler adjusts the value of a component in the color slider model, * when the user enters text into the text field. * * @author Werner Randelshofer * @version 1.0 November 22, 2005 Created. */ public class ColorSliderTextFieldHandler implements DocumentListener, ChangeListener { private JTextField textField; private ColorSliderModel ccModel; private int component; public ColorSliderTextFieldHandler(JTextField textField, ColorSliderModel ccModel, int component) { this.textField = textField; this.ccModel = ccModel; this.component = component; textField.getDocument().addDocumentListener(this); ccModel.getBoundedRangeModel(component).addChangeListener(this); } public void changedUpdate(DocumentEvent evt) { docChanged(); } public void removeUpdate(DocumentEvent evt) { docChanged(); } public void insertUpdate(DocumentEvent evt) { docChanged(); } private void docChanged() { if (textField.hasFocus()) { BoundedRangeModel brm = ccModel.getBoundedRangeModel(component); try { int value = Integer.decode(textField.getText()).intValue(); if (brm.getMinimum() <= value && value <= brm.getMaximum()) { brm.setValue(value); } } catch (NumberFormatException e) { // Don't change value if it isn't numeric. } } } public void stateChanged(ChangeEvent e) { if (! textField.hasFocus()) { textField.setText(Integer.toString(ccModel.getBoundedRangeModel(component).getValue())); } } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ColorWheelChooser.form0000644000175000017500000000305010564356430031755 0ustar drazzibdrazzib
substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/PaletteEntry.java0000644000175000017500000000214310564356432030771 0ustar drazzibdrazzibpackage contrib.ch.randelshofer.quaqua.colorchooser; /* * @(#)PaletteEntry.java 1.0 19 septembre 2005 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ import java.awt.*; /** * PaletteEntry. * * @author Werner Randelshofer * @version 1.0 19 septembre 2005 Created. */ public class PaletteEntry { private String name; private Color color; /** * Creates a new instance. */ public PaletteEntry(String name, Color color) { this.name = name; this.color = color; } public String getName() { return name; } public String toString() { return name; } public Color getColor() { return color; } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/HTMLSliderTextFieldHandler.java0000644000175000017500000000503410564356432033371 0ustar drazzibdrazzib/* * @(#)HTMLSliderTextFieldHandler.java 1.0 November 22, 2005 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; /** * This handler adjusts the value of a component in the HTML color slider model, * when the user enters text into the text field. * * @author Werner Randelshofer * @version 1.0 November 22, 2005 Created. */ public class HTMLSliderTextFieldHandler implements DocumentListener, ChangeListener { private JTextField textField; private HTMLColorSliderModel ccModel; private int component; public HTMLSliderTextFieldHandler(JTextField textField, HTMLColorSliderModel ccModel, int component) { this.textField = textField; this.ccModel = ccModel; this.component = component; textField.getDocument().addDocumentListener(this); ccModel.getBoundedRangeModel(component).addChangeListener(this); } public void changedUpdate(DocumentEvent evt) { docChanged(); } public void removeUpdate(DocumentEvent evt) { docChanged(); } public void insertUpdate(DocumentEvent evt) { docChanged(); } private void docChanged() { if (textField.hasFocus()) { BoundedRangeModel brm = ccModel.getBoundedRangeModel(component); try { int value = Integer.decode("#"+textField.getText()).intValue(); if (brm.getMinimum() <= value && value <= brm.getMaximum()) { brm.setValue(value); } } catch (NumberFormatException e) { } } } public void stateChanged(ChangeEvent e) { if (! textField.hasFocus()) { int value = ccModel.getBoundedRangeModel(2).getValue(); if (ccModel.isWebSaveOnly()) { value = Math.round(value / 51f) * 51; } String hex = Integer.toHexString(value).toUpperCase(); textField.setText((hex.length() == 1) ? "0"+hex : hex); } } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/RGBChooser.form0000644000175000017500000002313510564356432030334 0ustar drazzibdrazzib
substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ColorSliderUI.java0000644000175000017500000004507610564356430031042 0ustar drazzibdrazzib/* * @(#)ColorSliderUI.java 1.0.3 2005-09-11 * * Copyright (c) 2004 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import java.awt.event.*; import java.beans.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.plaf.*; import javax.swing.plaf.basic.*; import contrib.ch.randelshofer.quaqua.*; /** * A UI delegate for color sliders. The track of the slider visualizes how * changing the value of the slider affects the color. * * * @author Werner Randelshofer * @version 1.0.3 2005-09-11 Tweaked layout and drawing code. *
1.0.2 2005-08-28 Color track must always be regenerated if the * snapToTicks property changes. *
1.0.1 2005-04-18 Fixed an undesired shift of the track on the x-axis. *
1.0 29 March 2005 Created. */ public class ColorSliderUI extends BasicSliderUI { private final static Color foreground = new Color(0x949494); private final static Color trackBackground = new Color(0xffffff); private ColorTrackImageProducer colorTrackImageProducer; private Image colorTrackImage; private static final Dimension PREFERRED_HORIZONTAL_SIZE = new Dimension(36, 16); private static final Dimension PREFERRED_VERTICAL_SIZE = new Dimension(26, 100); private static final Dimension MINIMUM_HORIZONTAL_SIZE = new Dimension(36, 16); private static final Dimension MINIMUM_VERTICAL_SIZE = new Dimension(26, 36); /** Creates a new instance. */ public ColorSliderUI(JSlider b) { super(b); } public static ComponentUI createUI(JComponent b) { return new ColorSliderUI((JSlider)b); } protected void installDefaults( JSlider slider ) { super.installDefaults(slider); focusInsets = new Insets(0,0,0,0); slider.setOpaque(false); if (slider.getOrientation() == JSlider.HORIZONTAL) { slider.setBorder(new VisualMargin(0,1,-1,1)); } else { slider.setBorder(new VisualMargin(0,0,0,1)); } //slider.setRequestFocusEnabled(QuaquaManager.getBoolean("Slider.requestFocusEnabled")); slider.setRequestFocusEnabled(true); } protected Dimension getThumbSize() { Icon thumb = getThumbIcon(); return new Dimension(thumb.getIconWidth(), thumb.getIconHeight()); } public Dimension getPreferredHorizontalSize() { return PREFERRED_HORIZONTAL_SIZE; } public Dimension getPreferredVerticalSize() { return PREFERRED_VERTICAL_SIZE; } public Dimension getMinimumHorizontalSize() { return MINIMUM_HORIZONTAL_SIZE; } public Dimension getMinimumVerticalSize() { return MINIMUM_VERTICAL_SIZE; } protected void calculateThumbLocation() { super.calculateThumbLocation(); if ( slider.getOrientation() == JSlider.HORIZONTAL ) { thumbRect.y -= 1; } else { thumbRect.x -= 1; } } /* public void paint( Graphics g, JComponent c ) { g.setColor(Color.green); g.fillRect(0,0,c.getWidth(), c.getHeight()); super.paint(g,c); } */ protected Icon getThumbIcon() { if (slider.getOrientation() == JSlider.HORIZONTAL) { return UIManager.getIcon("Slider.upThumbSmall"); } else { return UIManager.getIcon("Slider.leftThumbSmall"); } } public void paintThumb(Graphics g) { Rectangle knobBounds = thumbRect; int w = knobBounds.width; int h = knobBounds.height; getThumbIcon().paintIcon(slider, g, knobBounds.x, knobBounds.y); /* g.setColor(Color.green); ((Graphics2D) g).draw(knobBounds); */ } public void paintTrack(Graphics g) { int cx, cy, cw, ch; int pad; Rectangle trackBounds = trackRect; if ( slider.getOrientation() == JSlider.HORIZONTAL ) { pad = trackBuffer;// - thumbRect.width / 2 + 2; cx = trackBounds.x - pad + 1; cy = trackBounds.y; //cy = (trackBounds.height / 2) - 4; cw = trackBounds.width + pad * 2 - 2; ch = trackBounds.height; } else { pad = trackBuffer; //cx = (trackBounds.width / 2) - 4; //cx = (trackBounds.width / 2); //cx = thumbRect.x + 2; cx = trackBounds.x; //cy = pad; cy = contentRect.y + 2; cw = trackBounds.width - 1; //ch = trackBounds.height; ch = trackBounds.height + pad * 2 - 5; } g.setColor(trackBackground); g.fillRect(cx,cy,cw,ch); g.setColor(foreground); g.drawRect(cx,cy,cw - 1,ch - 1); paintColorTrack(g, cx + 2, cy + 2, cw - 4, ch - 4, trackBuffer); } public void paintTicks(Graphics g) { Rectangle tickBounds = tickRect; int i; int maj, min, max; int w = tickBounds.width; int h = tickBounds.height; int centerEffect, tickHeight; /* g.setColor(slider.getBackground()); g.fillRect(tickBounds.x, tickBounds.y, tickBounds.width, tickBounds.height); */ g.setColor(foreground); maj = slider.getMajorTickSpacing(); min = slider.getMinorTickSpacing(); if ( slider.getOrientation() == JSlider.HORIZONTAL ) { g.translate( 0, tickBounds.y); int value = slider.getMinimum(); int xPos = 0; if ( slider.getMinorTickSpacing() > 0 ) { while ( value <= slider.getMaximum() ) { xPos = xPositionForValue( value ); paintMinorTickForHorizSlider( g, tickBounds, xPos ); value += slider.getMinorTickSpacing(); } } if ( slider.getMajorTickSpacing() > 0 ) { value = slider.getMinimum(); while ( value <= slider.getMaximum() ) { xPos = xPositionForValue( value ); paintMajorTickForHorizSlider( g, tickBounds, xPos ); value += slider.getMajorTickSpacing(); } } g.translate( 0, -tickBounds.y); } else { g.translate(tickBounds.x, 0); int value = slider.getMinimum(); int yPos = 0; if ( slider.getMinorTickSpacing() > 0 ) { int offset = 0; if(!QuaquaUtilities.isLeftToRight(slider)) { offset = tickBounds.width - tickBounds.width / 2; g.translate(offset, 0); } while ( value <= slider.getMaximum() ) { yPos = yPositionForValue( value ); paintMinorTickForVertSlider( g, tickBounds, yPos ); value += slider.getMinorTickSpacing(); } if(!QuaquaUtilities.isLeftToRight(slider)) { g.translate(-offset, 0); } } if ( slider.getMajorTickSpacing() > 0 ) { value = slider.getMinimum(); if(!QuaquaUtilities.isLeftToRight(slider)) { g.translate(2, 0); } while ( value <= slider.getMaximum() ) { yPos = yPositionForValue( value ); paintMajorTickForVertSlider( g, tickBounds, yPos ); value += slider.getMajorTickSpacing(); } if(!QuaquaUtilities.isLeftToRight(slider)) { g.translate(-2, 0); } } g.translate(-tickBounds.x, 0); } /* g.setColor(Color.red); ((Graphics2D) g).draw(tickBounds); */ } protected void paintMajorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x) { g.drawLine(x, 0, x, tickBounds.height - 1); } protected void paintMinorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) { //g.drawLine( x, 0, x, tickBounds.height / 2 - 1 ); g.drawLine(x, 0, x, tickBounds.height - 1); } protected void paintMinorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) { g.drawLine( tickBounds.width / 2, y, tickBounds.width / 2 - 1, y); } protected void paintMajorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) { g.drawLine(0, y, tickBounds.width - 1, y); } public void paintFocus(Graphics g) { } public void paintColorTrack(Graphics g, int x, int y, int width, int height, int buffer) { //g.setColor(Color.black); //g.fillRect(x, y, width, height); if (colorTrackImageProducer == null || colorTrackImageProducer.getWidth() != width || colorTrackImageProducer.getHeight() != height) { if (colorTrackImage != null) { colorTrackImage.flush(); } colorTrackImageProducer = new ColorTrackImageProducer(width, height, buffer + 2, slider.getOrientation() == JSlider.HORIZONTAL); if (slider.getClientProperty("ColorSliderModel") != null) { colorTrackImageProducer.setColorSliderModel((ColorSliderModel) slider.getClientProperty("ColorSliderModel")); } if (slider.getClientProperty("ColorComponentIndex") != null) { colorTrackImageProducer.setColorComponentIndex(((Integer) slider.getClientProperty("ColorComponentIndex")).intValue()); } colorTrackImageProducer.generateColorTrack(); colorTrackImage = slider.createImage(colorTrackImageProducer); } else { colorTrackImageProducer.regenerateColorTrack(); } g.drawImage(colorTrackImage, x, y, slider); } protected void calculateTrackRect() { int centerSpacing = 0; // used to center sliders added using BorderLayout.CENTER (bug 4275631) if ( slider.getOrientation() == JSlider.HORIZONTAL ) { centerSpacing = thumbRect.height; if ( slider.getPaintTicks() ) centerSpacing += getTickLength(); if ( slider.getPaintLabels() ) centerSpacing += getHeightOfTallestLabel(); trackRect.x = contentRect.x + trackBuffer + 1; //trackRect.y = contentRect.y + (contentRect.height - centerSpacing - 1)/2; trackRect.height = 13; trackRect.y = contentRect.y + contentRect.height - trackRect.height; trackRect.width = contentRect.width - (trackBuffer * 2) - 1; } else { /* centerSpacing = thumbRect.width; if (! QuaquaUtilities.isLeftToRight(slider)) { if ( slider.getPaintTicks() ) centerSpacing += getTickLength(); if ( slider.getPaintLabels() ) centerSpacing += getWidthOfWidestLabel(); } else { if ( slider.getPaintTicks() ) centerSpacing -= getTickLength(); if ( slider.getPaintLabels() ) centerSpacing -= getWidthOfWidestLabel(); } trackRect.x = contentRect.x + (contentRect.width - centerSpacing - 1)/2 + 2; */ trackRect.width = 14; trackRect.x = contentRect.x + contentRect.width - trackRect.width; trackRect.y = contentRect.y + trackBuffer; trackRect.height = contentRect.height - (trackBuffer * 2) + 1; } } protected void calculateTickRect() { if ( slider.getOrientation() == JSlider.HORIZONTAL ) { tickRect.x = trackRect.x; //tickRect.y = trackRect.y + trackRect.height; tickRect.y = trackRect.y - getTickLength(); tickRect.width = trackRect.width; tickRect.height = getTickLength(); if ( !slider.getPaintTicks() ) { --tickRect.y; tickRect.height = 0; } } else { /* if(! QuaquaUtilities.isLeftToRight(slider)) { tickRect.x = trackRect.x + trackRect.width; tickRect.width = getTickLength(); } else { tickRect.width = getTickLength(); tickRect.x = trackRect.x - tickRect.width; }*/ tickRect.width = getTickLength(); tickRect.x = contentRect.x;//trackRect.x - tickRect.width - 1; tickRect.y = trackRect.y; tickRect.height = trackRect.height; if ( !slider.getPaintTicks() ) { --tickRect.x; tickRect.width = 0; } } } /** * Gets the height of the tick area for horizontal sliders and the width of the * tick area for vertical sliders. BasicSliderUI uses the returned value to * determine the tick area rectangle. If you want to give your ticks some room, * make this larger than you need and paint your ticks away from the sides in paintTicks(). */ protected int getTickLength() { return 4; } protected PropertyChangeListener createPropertyChangeListener( JSlider slider ) { return new CSUIPropertyChangeHandler(); } public class CSUIPropertyChangeHandler extends BasicSliderUI.PropertyChangeHandler { public void propertyChange( PropertyChangeEvent e ) { String propertyName = e.getPropertyName(); if (propertyName.equals( "Frame.active" )) { //calculateGeometry(); slider.repaint(); } else if (propertyName.equals( "ColorSliderModel" )) { if (colorTrackImageProducer != null) { colorTrackImageProducer.setColorSliderModel(((ColorSliderModel) e.getNewValue())); if (colorTrackImageProducer.needsGeneration()) { slider.repaint(); } } } else if (propertyName.equals( "snapToTicks" )) { if (colorTrackImageProducer != null) { colorTrackImageProducer.markAsDirty(); slider.repaint(); } } else if (propertyName.equals( "ColorComponentIndex" )) { if (colorTrackImageProducer != null && e.getNewValue() != null) { colorTrackImageProducer.setColorComponentIndex(((Integer) e.getNewValue()).intValue()); if (colorTrackImageProducer.needsGeneration()) { slider.repaint(); } } } else if (propertyName.equals( "ColorComponentChange" )) { Integer value = (Integer) e.getNewValue(); if (value != null && colorTrackImageProducer != null) { colorTrackImageProducer.componentChanged(value.intValue()); if (colorTrackImageProducer.needsGeneration()) { slider.repaint(); } } } else if (propertyName.equals( "ColorComponentValue" )) { Integer value = (Integer) slider.getClientProperty("ColorComponentChange"); if (value != null && colorTrackImageProducer != null) { colorTrackImageProducer.componentChanged(value.intValue()); if (colorTrackImageProducer.needsGeneration()) { slider.repaint(); } } } else if (propertyName.equals( "Orientation" )) { if (slider.getOrientation() == JSlider.HORIZONTAL) { slider.setBorder(new VisualMargin(0,1,-1,1)); } else { slider.setBorder(new VisualMargin(0,0,0,1)); } } super.propertyChange(e); } } protected TrackListener createTrackListener( JSlider slider ) { return new QuaquaTrackListener(); } /** * Track mouse movements. * * This inner class is marked "public" due to a compiler bug. * This class should be treated as a "protected" inner class. * Instantiate it only within subclasses of . */ public class QuaquaTrackListener extends BasicSliderUI.TrackListener { /** * If the mouse is pressed above the "thumb" component * then reduce the scrollbars value by one page ("page up"), * otherwise increase it by one page. If there is no * thumb then page up if the mouse is in the upper half * of the track. */ public void mousePressed(MouseEvent e) { if ( !slider.isEnabled() ) return; currentMouseX = e.getX(); currentMouseY = e.getY(); if (slider.isRequestFocusEnabled()) { slider.requestFocus(); } // Clicked inside the Thumb area? if (thumbRect.contains(currentMouseX, currentMouseY) ) { super.mousePressed(e); } else { Dimension sbSize = slider.getSize(); int direction = POSITIVE_SCROLL; switch ( slider.getOrientation() ) { case JSlider.VERTICAL: slider.setValue(valueForYPosition(currentMouseY)); break; case JSlider.HORIZONTAL: slider.setValue(valueForXPosition(currentMouseX)); break; } // FIXME: // We should set isDragging to false here. Unfortunately, // we can not access this variable in class BasicSliderUI. } } } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/HSBChooser.java0000644000175000017500000003232410564356430030312 0ustar drazzibdrazzib/* * @(#)HSBChooser.java 1.3 2006-04-23 * * Copyright (c) 2005-2006 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entehue into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import javax.swing.*; import javax.swing.text.*; import javax.swing.event.*; import javax.swing.border.*; import javax.swing.colorchooser.*; import javax.swing.plaf.*; import contrib.ch.randelshofer.quaqua.*; import contrib.ch.randelshofer.quaqua.util.*; /** * A ColorChooser with HSB sliders. * * @author Werner Randelshofer * @version 1.3 2006-04-23 Retrieve labels from UIManager. *
1.2 2005-11-22 Moved handler for text fields into separate class. *
1.2.1 2005-11-07 Get "Labels" resource bundle from UIManager. *
1.2 2005-09-05 Get font, spacing and icon from UIManager. *
1.1.1 2005-04-23 Localized form. *
1.0 29 March 2005 Created. */ public class HSBChooser extends AbstractColorChooserPanel implements UIResource { private ColorSliderModel ccModel = new HSBColorSliderModel(); /** Creates new form. */ public HSBChooser() { initComponents(); // Font font = UIManager.getFont("ColorChooser.font"); hueLabel.setFont(font); hueSlider.setFont(font); hueField.setFont(font); hueFieldLabel.setFont(font); saturationLabel.setFont(font); saturationSlider.setFont(font); saturationField.setFont(font); saturationFieldLabel.setFont(font); brightnessLabel.setFont(font); brightnessSlider.setFont(font); brightnessField.setFont(font); brightnessFieldLabel.setFont(font); // int textSliderGap = UIManager.getInt("ColorChooser.textSliderGap"); if (textSliderGap != 0) { Border fieldBorder = new EmptyBorder(0,textSliderGap,0,0); hueFieldPanel.setBorder(fieldBorder); saturationFieldPanel.setBorder(fieldBorder); brightnessFieldPanel.setBorder(fieldBorder); } ccModel.configureColorSlider(0, hueSlider); ccModel.configureColorSlider(1, saturationSlider); ccModel.configureColorSlider(2, brightnessSlider); hueField.setText(Integer.toString(hueSlider.getValue())); saturationField.setText(Integer.toString(saturationSlider.getValue())); brightnessField.setText(Integer.toString(brightnessSlider.getValue())); Insets borderMargin = (Insets) UIManager.getInsets("Component.visualMargin").clone(); borderMargin.left = 3 - borderMargin.left; hueFieldLabel.putClientProperty("Quaqua.Component.visualMargin",borderMargin); saturationFieldLabel.putClientProperty("Quaqua.Component.visualMargin",borderMargin); brightnessFieldLabel.putClientProperty("Quaqua.Component.visualMargin",borderMargin); new ColorSliderTextFieldHandler(hueField, ccModel, 0); new ColorSliderTextFieldHandler(saturationField, ccModel, 1); new ColorSliderTextFieldHandler(brightnessField, ccModel, 2); ccModel.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { setColorToModel(ccModel.getColor()); } }); hueField.setMinimumSize(hueField.getPreferredSize()); saturationField.setMinimumSize(saturationField.getPreferredSize()); brightnessField.setMinimumSize(brightnessField.getPreferredSize()); VisualMargin bm = new VisualMargin(false,false,true,false); hueLabel.setBorder(bm); saturationLabel.setBorder(bm); brightnessLabel.setBorder(bm); } protected void buildChooser() { } public String getDisplayName() { return UIManager.getString("ColorChooser.hsbSliders"); } public Icon getLargeDisplayIcon() { return UIManager.getIcon("ColorChooser.colorSlidersIcon"); } public Icon getSmallDisplayIcon() { return getLargeDisplayIcon(); } public void updateChooser() { ccModel.setColor(getColorFromModel()); } public void setColorToModel(Color color) { getColorSelectionModel().setSelectedColor(color); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // //GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; hueLabel = new javax.swing.JLabel(); hueSlider = new javax.swing.JSlider(); hueFieldPanel = new javax.swing.JPanel(); hueField = new javax.swing.JTextField(); hueFieldLabel = new javax.swing.JLabel(); saturationLabel = new javax.swing.JLabel(); saturationSlider = new javax.swing.JSlider(); saturationFieldPanel = new javax.swing.JPanel(); saturationField = new javax.swing.JTextField(); saturationFieldLabel = new javax.swing.JLabel(); brightnessLabel = new javax.swing.JLabel(); brightnessSlider = new javax.swing.JSlider(); brightnessFieldPanel = new javax.swing.JPanel(); brightnessField = new javax.swing.JTextField(); brightnessFieldLabel = new javax.swing.JLabel(); springPanel = new javax.swing.JPanel(); setLayout(new java.awt.GridBagLayout()); hueLabel.setText(UIManager.getString("ColorChooser.hsbHueText")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.insets = new java.awt.Insets(1, 0, 0, 0); add(hueLabel, gridBagConstraints); hueSlider.setMajorTickSpacing(359); hueSlider.setMaximum(359); hueSlider.setMinorTickSpacing(180); hueSlider.setPaintTicks(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; add(hueSlider, gridBagConstraints); hueFieldPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0)); hueField.setColumns(3); hueField.setHorizontalAlignment(javax.swing.JTextField.TRAILING); hueField.setText("0"); hueField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { hueFieldFocusLost(evt); } }); hueFieldPanel.add(hueField); hueFieldLabel.setText("\u00b0"); hueFieldPanel.add(hueFieldLabel); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; add(hueFieldPanel, gridBagConstraints); saturationLabel.setText(UIManager.getString("ColorChooser.hsbSaturationText")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.insets = new java.awt.Insets(1, 0, 0, 0); add(saturationLabel, gridBagConstraints); saturationSlider.setMajorTickSpacing(100); saturationSlider.setMinorTickSpacing(50); saturationSlider.setPaintTicks(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; add(saturationSlider, gridBagConstraints); saturationFieldPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0)); saturationField.setColumns(3); saturationField.setHorizontalAlignment(javax.swing.JTextField.TRAILING); saturationField.setText("0"); saturationField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { saturationFieldFocusLost(evt); } }); saturationFieldPanel.add(saturationField); saturationFieldLabel.setText("%"); saturationFieldPanel.add(saturationFieldLabel); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; add(saturationFieldPanel, gridBagConstraints); brightnessLabel.setText(UIManager.getString("ColorChooser.hsbBrightnessText")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.insets = new java.awt.Insets(1, 0, 0, 0); add(brightnessLabel, gridBagConstraints); brightnessSlider.setMajorTickSpacing(100); brightnessSlider.setMinorTickSpacing(50); brightnessSlider.setPaintTicks(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; add(brightnessSlider, gridBagConstraints); brightnessFieldPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 0)); brightnessField.setColumns(3); brightnessField.setHorizontalAlignment(javax.swing.JTextField.TRAILING); brightnessField.setText("0"); brightnessField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { brightnessFieldFocusLost(evt); } }); brightnessFieldPanel.add(brightnessField); brightnessFieldLabel.setText("%"); brightnessFieldPanel.add(brightnessFieldLabel); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 4; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; add(brightnessFieldPanel, gridBagConstraints); springPanel.setLayout(new java.awt.BorderLayout()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 100; gridBagConstraints.weighty = 1.0; add(springPanel, gridBagConstraints); }// //GEN-END:initComponents private void brightnessFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_brightnessFieldFocusLost brightnessField.setText(Integer.toString(ccModel.getBoundedRangeModel(2).getValue())); }//GEN-LAST:event_brightnessFieldFocusLost private void saturationFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_saturationFieldFocusLost saturationField.setText(Integer.toString(ccModel.getBoundedRangeModel(1).getValue())); }//GEN-LAST:event_saturationFieldFocusLost private void hueFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_hueFieldFocusLost hueField.setText(Integer.toString(ccModel.getBoundedRangeModel(0).getValue())); }//GEN-LAST:event_hueFieldFocusLost // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField brightnessField; private javax.swing.JLabel brightnessFieldLabel; private javax.swing.JPanel brightnessFieldPanel; private javax.swing.JLabel brightnessLabel; private javax.swing.JSlider brightnessSlider; private javax.swing.JTextField hueField; private javax.swing.JLabel hueFieldLabel; private javax.swing.JPanel hueFieldPanel; private javax.swing.JLabel hueLabel; private javax.swing.JSlider hueSlider; private javax.swing.JTextField saturationField; private javax.swing.JLabel saturationFieldLabel; private javax.swing.JPanel saturationFieldPanel; private javax.swing.JLabel saturationLabel; private javax.swing.JSlider saturationSlider; private javax.swing.JPanel springPanel; // End of variables declaration//GEN-END:variables } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/Crayons.java0000644000175000017500000001455610564356430030000 0ustar drazzibdrazzib/* * @(#)Crayons.java 1.2 2006-04-23 * * Copyright (c) 2005-2006 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.awt.geom.*; import javax.swing.*; import javax.swing.event.*; import contrib.ch.randelshofer.quaqua.*; import contrib.ch.randelshofer.quaqua.util.*; /** * A panel which displays a selection of color crayons. The user can click at * a crayon to pick a color. * * @author Werner Randelshofer * @version 1.2 2006-04-23 Retrieve labels directly from UIManager. *
1.1.1 2005-11-07 Get "labels" resource bundle from UIManager. *
1.1 2005-08-30 Rearranged code to ease the creation of derived look * and feels. *
1.0 August 28, 2005 Created. */ public class Crayons extends javax.swing.JPanel { /** * Shared crayons image. */ private Image crayonsImage; /** * Coordinates of crayon shaped polygon. */ private final static int[] crayonXPoints = { 10, 12, 20, 22, 22, 0, 0, 2 }; // xpoints private final static int[] crayonYPoints = { 0, 0, 21, 21, 104, 104, 21, 21 }; // ypoints /** * Current color. */ private Color color = Color.white; /** * Selected crayon. */ private Crayon selectedCrayon = null; /** * Crayon. */ private class Crayon { Polygon shape; Color color; String name; public Crayon(Color color, String name, Polygon shape) { this.color = color; this.name = name; this.shape = shape; } } private class MouseHandler extends MouseAdapter { public void mousePressed(MouseEvent evt) { int x = evt.getX(); int y = evt.getY(); if (x > 0 && x < crayonsImage.getWidth(Crayons.this) && y > 0 && y < crayonsImage.getHeight(Crayons.this) ) { for (int i=crayons.length - 1; i >= 0; i--) { if (crayons[i].shape.contains(x, y)) { setColor(crayons[i].color); break; } } } } } private MouseHandler mouseHandler; /** * Crayons. */ private Crayon[] crayons; /** * Creates a new instance. */ public Crayons() { initComponents(); setForeground(new Color(0x808080)); setPreferredSize(new Dimension(195, 208)); setFont(UIManager.getFont("ColorChooser.crayonsFont")); crayonsImage = createCrayonsImage(); crayons = createCrayons(); mouseHandler = new MouseHandler(); addMouseListener(mouseHandler); } protected Image createCrayonsImage() { return (Image) UIManager.get("ColorChooser.crayonsImage"); } /** * Creates the crayons. * @return Array of crayons in z-order from bottom to top. */ protected Crayon[] createCrayons() { Color[] colors = DefaultPalettes.CRAYONS; crayons = new Crayon[colors.length]; for (int i=0; i < colors.length; i++) { crayons[i] = new Crayon( colors[i], UIManager.getString("ColorChooser.crayon."+Integer.toHexString(0xff000000|colors[i].getRGB()).substring(2)), new Polygon((int[]) crayonXPoints.clone(), (int[]) crayonYPoints.clone(), crayonXPoints.length)); crayons[i].shape.translate( (i % 8) * 22 + 4 +((i / 8) % 2) * 11, (i / 8) * 20 + 23 ); } return crayons; } /** * Sets the current color. * This results in a selection of a crayon, if a crayon with the same * RGB values exists. */ public void setColor(Color newValue) { Color oldValue = color; color = newValue; Crayon newSelectedCrayon = null; int newRGB = newValue.getRGB() & 0xffffff; for (int i=0; i < crayons.length; i++) { if ((crayons[i].color.getRGB() & 0xffffff) == newRGB) { newSelectedCrayon = crayons[i]; } } if (newSelectedCrayon != selectedCrayon) { selectedCrayon = newSelectedCrayon; repaint(); } firePropertyChange("Color", oldValue, newValue); } /** * Returns the current color. */ public Color getColor() { return color; } public void paintComponent(Graphics gr) { Graphics2D g = (Graphics2D) gr; Object oldHints = QuaquaUtilities.beginGraphics((Graphics2D) g); g.drawImage(crayonsImage, 0, 0, this); if (selectedCrayon != null) { /* g.setColor(new Color(0x60ffffff & selectedCrayon.color.getRGB(),true)); g.fill(selectedCrayon.shape); */ g.setColor(getForeground()); FontMetrics fm = g.getFontMetrics(); int nameWidth = fm.stringWidth(selectedCrayon.name); g.drawString( selectedCrayon.name, (crayonsImage.getWidth(this) - nameWidth) / 2, fm.getAscent() + 1 ); } QuaquaUtilities.endGraphics((Graphics2D) g, oldHints); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents setLayout(new java.awt.BorderLayout()); }//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/HSBChooser.form0000644000175000017500000002652610564356430030343 0ustar drazzibdrazzib
substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ICC_CMYKColorSliderModel.java0000644000175000017500000000624610564356432032725 0ustar drazzibdrazzibpackage contrib.ch.randelshofer.quaqua.colorchooser; /* * @(#)ICC_CMYKColorSliderModel.java 1.0 2005-05-22 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ import java.awt.*; import java.awt.color.*; import java.io.*; import javax.swing.*; /** * A ColorSliderModel for CMYK color models (cyan, magenta, yellow, black) in * a color space defined by a ICC color profile (International Color Consortium). *

* XXX - This does not work. I think this is because of * Java bug #4760025 at * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4760025 * but maybe I am doing something in the wrong way. * * * @author Werner Randelshofer * @version 1.0 May 22, 2005 Created. */ public class ICC_CMYKColorSliderModel extends ColorSliderModel { private ICC_ColorSpace colorSpace; float[] cmyk = new float[4]; float[] rgb = new float[3]; /** * Creates a new instance. */ public ICC_CMYKColorSliderModel(InputStream iccProfile) throws IOException { super(new DefaultBoundedRangeModel[] { new DefaultBoundedRangeModel(0, 0, 0, 100), new DefaultBoundedRangeModel(0, 0, 0, 100), new DefaultBoundedRangeModel(0, 0, 0, 100), new DefaultBoundedRangeModel(0, 0, 0, 100) }); this.colorSpace = new ICC_ColorSpace(ICC_Profile.getInstance(iccProfile)); } public int getRGB() { cmyk[0] = components[0].getValue() / 100f; cmyk[1] = components[1].getValue() / 100f; cmyk[2] = components[2].getValue() / 100f; cmyk[3] = components[3].getValue() / 100f; rgb = colorSpace.toRGB(cmyk); return 0xff000000 | ((int) (rgb[0] * 255f) << 16) | ((int) (rgb[1] * 255f) << 8) | (int) (rgb[2] * 255f); } public void setRGB(int newRGB) { rgb[0] = ((newRGB & 0xff0000) >>> 16) / 255f; rgb[1] = ((newRGB & 0x00ff00) >>> 8) / 255f; rgb[2] = (newRGB & 0x0000ff) / 255f; cmyk = colorSpace.fromRGB(rgb); System.out.print("rgb in:"+new Color(newRGB)); components[0].setValue((int) (cmyk[0] * 100f)); components[1].setValue((int) (cmyk[1] * 100f)); components[2].setValue((int) (cmyk[2] * 100f)); components[3].setValue((int) (cmyk[3] * 100f)); rgb = colorSpace.toRGB(cmyk); System.out.println(" out:"+new Color((int) (rgb[0]*255f), (int)(rgb[1]*255f), (int)(rgb[2]*255f))); } public int toRGB(int[] values) { cmyk[0] = values[0] / 100f; cmyk[1] = values[1] / 100f; cmyk[2] = values[2] / 100f; cmyk[3] = values[3] / 100f; rgb = colorSpace.toRGB(cmyk); return 0xff000000 | ((int) (rgb[0] * 255f) << 16) | ((int) (rgb[1] * 255f) << 8) | (int) (rgb[2] * 255f); } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/QuaquaColorPreviewPanel.java0000644000175000017500000000523310564356432033132 0ustar drazzibdrazzib/* * @(#)QuaquaColorPreviewPanel.java 1.2 2005-12-18 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.plaf.*; import contrib.ch.randelshofer.quaqua.*; /** * QuaquaColorPreviewPanel. * * @author Werner Randelshofer * @version 1.2 2005-12-18 Tweaked insets. *
1.1 2005-09-20 Added tooltip. This is not what the native * NSColorPicker does, but it is very useful. *
1.0 30 March 2005 Created. */ public class QuaquaColorPreviewPanel extends JPanel implements UIResource { private final static Color previewBorderColor = new Color(0x949494); private final static Color previewBackgroundColor = new Color(0xffffff); /** Creates new form. */ public QuaquaColorPreviewPanel() { initComponents(); setBorder(new VisualMargin(3,0,3,0)); setToolTipText("on"); // set dummy text, to switch tooltip on } public void paintComponent(Graphics g) { Insets insets = getInsets(); int x = insets.left; int y = insets.top; int w = getWidth() - insets.left - insets.right; int h = getHeight() - insets.top - insets.bottom; g.setColor(previewBackgroundColor); g.fillRect(x+1,y+1,w-2,h-2); g.setColor(previewBorderColor); g.drawRect(x,y,w-1,h-1); g.setColor(getForeground()); g.fillRect(x+2,y+2,w-4,h-4); } public String getToolTipText(MouseEvent evt) { Color color = getForeground(); return (color == null) ? null : color.getRed()+", "+ color.getGreen() + ", " + color.getBlue(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents setLayout(new java.awt.BorderLayout()); setPreferredSize(new java.awt.Dimension(26, 26)); }//GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/SwatchPanel.form0000644000175000017500000000032710322471740030576 0ustar drazzibdrazzib

substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/HTMLChooser.java0000644000175000017500000004433110564356430030443 0ustar drazzibdrazzib/* * @(#)HTMLChooser.java 1.5 2006-04-23 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import javax.swing.*; import javax.swing.text.*; import javax.swing.event.*; import javax.swing.border.*; import javax.swing.colorchooser.*; import javax.swing.plaf.*; import contrib.ch.randelshofer.quaqua.*; import contrib.ch.randelshofer.quaqua.util.*; import java.util.*; /** * HTMLChooser. * * @author Werner Randelshofer * @version 1.5 2006-04-23 Retrieve labels from UIManager. *
1.4 2005-11-22 Moved handler for text fields into separate class. *
1.3.1 2005-11-07 Get "Labels" resource bundle from UIManager. *
1.3 2005-09-05 Get font,spacing and icon from UIManager. *
1.2 2005-08-28 Remember last selection state of "webSaveCheckBox". *
1.1.1 2005-06-19 Sliders were not updated when a color was entered * into the HTML field. *
1.1 2005-04-18 Localized form. *
1.0 29 March 2005 Created. */ public class HTMLChooser extends AbstractColorChooserPanel implements UIResource { private HTMLColorSliderModel ccModel = new HTMLColorSliderModel(); private ChangeListener htmlListener; /** * This is used to remember the last selection state of the "webSaveCheckBox". */ private static boolean lastWebSaveSelectionState = false; /** * We have to prevent us from constantly updating the color model, because * the gray chooser is not able to preserve all color components. */ private int updateRecursion; /** * W3C HTML 4.1 well known color names. */ private final static Object[][] colorNames = { {"Black", new Color(0x000000)}, {"Green", new Color(0x008000)}, {"Silver", new Color(0xC0C0C0)}, {"Lime", new Color(0x00FF00)}, {"Gray", new Color(0x808080)}, {"Olive", new Color(0x808000)}, {"White", new Color(0xFFFFFF)}, {"Yellow", new Color(0xFFFF00)}, {"Maroon", new Color(0x800000)}, {"Navy", new Color(0x000080)}, {"Red", new Color(0xFF0000)}, {"Blue", new Color(0x0000FF)}, {"Purple", new Color(0x800080)}, {"Teal", new Color(0x008080)}, {"Fuchsia", new Color(0xFF00FF)}, {"Aqua", new Color(0x00FF)} }; private final static HashMap nameToColorMap = new HashMap(); static { for (int i=0; i < colorNames.length; i++) { nameToColorMap.put(((String) colorNames[i][0]).toLowerCase(), colorNames[i][1]); } } /** Creates new form. */ public HTMLChooser() { initComponents(); // Font font = UIManager.getFont("ColorChooser.font"); redLabel.setFont(font); redSlider.setFont(font); redField.setFont(font); greenLabel.setFont(font); greenField.setFont(font); greenSlider.setFont(font); blueLabel.setFont(font); blueSlider.setFont(font); blueField.setFont(font); htmlLabel.setFont(font); htmlField.setFont(font); webSaveCheckBox.setFont(font); // int textSliderGap = UIManager.getInt("ColorChooser.textSliderGap"); if (textSliderGap != 0) { Insets fieldInsets = new Insets(0,textSliderGap,0,0); GridBagLayout layout = (GridBagLayout) getLayout(); GridBagConstraints gbc; gbc = layout.getConstraints(redField); gbc.insets = fieldInsets; layout.setConstraints(redField, gbc); gbc = layout.getConstraints(greenField); gbc.insets = fieldInsets; layout.setConstraints(greenField, gbc); gbc = layout.getConstraints(blueField); gbc.insets = fieldInsets; layout.setConstraints(blueField, gbc); } webSaveCheckBox.setSelected(lastWebSaveSelectionState); redSlider.setSnapToTicks(lastWebSaveSelectionState); greenSlider.setSnapToTicks(lastWebSaveSelectionState); blueSlider.setSnapToTicks(lastWebSaveSelectionState); htmlListener = new ChangeListener() { public void stateChanged(ChangeEvent evt) { Color c = ccModel.getColor(); setColorToModel(c); if (! c.equals(nameToColorMap.get(htmlField.getText().toLowerCase()))) { if (! htmlField.hasFocus()) { String hex = Integer.toHexString(0xffffff & c.getRGB()); StringBuffer buf = new StringBuffer(7); buf.append('#'); for (int i=hex.length(); i < 6; i++) { buf.append('0'); } buf.append(hex.toUpperCase()); if (! htmlField.getText().equals(buf.toString())) { htmlField.setText(buf.toString()); } } } } }; updateRecursion++; ccModel = new HTMLColorSliderModel(); ccModel.setWebSaveOnly(lastWebSaveSelectionState); ccModel.configureColorSlider(0, redSlider); ccModel.configureColorSlider(1, greenSlider); ccModel.configureColorSlider(2, blueSlider); new ColorSliderTextFieldHandler(redField, ccModel, 0); new ColorSliderTextFieldHandler(greenField, ccModel, 1); new ColorSliderTextFieldHandler(blueField, ccModel, 2); ccModel.addChangeListener(htmlListener); redFieldFocusLost(null); greenFieldFocusLost(null); blueFieldFocusLost(null); htmlFieldFocusLost(null); updateRecursion--; redField.setMinimumSize(redField.getPreferredSize()); greenField.setMinimumSize(greenField.getPreferredSize()); blueField.setMinimumSize(blueField.getPreferredSize()); htmlPanel.setMinimumSize(htmlPanel.getPreferredSize()); VisualMargin bm = new VisualMargin(false,false,true,false); redLabel.setBorder(bm); greenLabel.setBorder(bm); blueLabel.setBorder(bm); } protected void buildChooser() { } public String getDisplayName() { return UIManager.getString("ColorChooser.htmlSliders"); } public Icon getLargeDisplayIcon() { return UIManager.getIcon("ColorChooser.colorSlidersIcon"); } public Icon getSmallDisplayIcon() { return getLargeDisplayIcon(); } public void updateChooser() { if (updateRecursion == 0) { updateRecursion++; if (ccModel.isWebSaveOnly()) { Color c = getColorFromModel(); if (! HTMLColorSliderModel.isWebSave(c.getRGB())) { webSaveCheckBox.setSelected(false); } } ccModel.setColor(getColorFromModel()); updateRecursion--; } } public void setColorToModel(Color color) { if (updateRecursion == 0) { updateRecursion++; getColorSelectionModel().setSelectedColor(color); updateRecursion--; } } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // //GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; redLabel = new javax.swing.JLabel(); redSlider = new javax.swing.JSlider(); redField = new javax.swing.JTextField(); greenLabel = new javax.swing.JLabel(); greenField = new javax.swing.JTextField(); greenSlider = new javax.swing.JSlider(); blueLabel = new javax.swing.JLabel(); blueSlider = new javax.swing.JSlider(); blueField = new javax.swing.JTextField(); htmlPanel = new javax.swing.JPanel(); htmlLabel = new javax.swing.JLabel(); htmlField = new javax.swing.JTextField(); webSaveCheckBox = new javax.swing.JCheckBox(); springPanel = new javax.swing.JPanel(); setLayout(new java.awt.GridBagLayout()); redLabel.setText(UIManager.getString("ColorChooser.rgbRedText")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.insets = new java.awt.Insets(1, 0, 0, 0); add(redLabel, gridBagConstraints); redSlider.setMajorTickSpacing(255); redSlider.setMaximum(255); redSlider.setMinorTickSpacing(51); redSlider.setPaintTicks(true); redSlider.setSnapToTicks(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; add(redSlider, gridBagConstraints); redField.setColumns(3); redField.setHorizontalAlignment(javax.swing.JTextField.TRAILING); redField.setText("0"); redField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { redFieldFocusLost(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; add(redField, gridBagConstraints); greenLabel.setText(UIManager.getString("ColorChooser.rgbGreenText")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.insets = new java.awt.Insets(1, 0, 0, 0); add(greenLabel, gridBagConstraints); greenField.setColumns(3); greenField.setHorizontalAlignment(javax.swing.JTextField.TRAILING); greenField.setText("0"); greenField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { greenFieldFocusLost(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; add(greenField, gridBagConstraints); greenSlider.setMajorTickSpacing(255); greenSlider.setMaximum(255); greenSlider.setMinorTickSpacing(51); greenSlider.setPaintTicks(true); greenSlider.setSnapToTicks(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; add(greenSlider, gridBagConstraints); blueLabel.setText(UIManager.getString("ColorChooser.rgbBlueText")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; gridBagConstraints.insets = new java.awt.Insets(1, 0, 0, 0); add(blueLabel, gridBagConstraints); blueSlider.setMajorTickSpacing(255); blueSlider.setMaximum(255); blueSlider.setMinorTickSpacing(51); blueSlider.setPaintTicks(true); blueSlider.setSnapToTicks(true); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; add(blueSlider, gridBagConstraints); blueField.setColumns(3); blueField.setHorizontalAlignment(javax.swing.JTextField.TRAILING); blueField.setText("0"); blueField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { blueFieldFocusLost(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; add(blueField, gridBagConstraints); htmlPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 0, 5)); htmlLabel.setText(UIManager.getString("ColorChooser.htmlText")); htmlLabel.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 4)); htmlPanel.add(htmlLabel); htmlField.setColumns(7); htmlField.setText("#000000"); htmlField.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { htmlFieldFocusLost(evt); } }); htmlPanel.add(htmlField); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0); add(htmlPanel, gridBagConstraints); webSaveCheckBox.setText(UIManager.getString("ColorChooser.htmlChooseOnlyWebSaveColorsText")); webSaveCheckBox.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { webSaveChanged(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; add(webSaveCheckBox, gridBagConstraints); springPanel.setLayout(new java.awt.BorderLayout()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 100; gridBagConstraints.weighty = 1.0; add(springPanel, gridBagConstraints); }// //GEN-END:initComponents private void blueFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_blueFieldFocusLost String hex = Integer.toHexString(ccModel.getBoundedRangeModel(2).getValue()).toUpperCase(); blueField.setText((hex.length() == 1) ? "0"+hex : hex); }//GEN-LAST:event_blueFieldFocusLost private void greenFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_greenFieldFocusLost String hex = Integer.toHexString(ccModel.getBoundedRangeModel(1).getValue()).toUpperCase(); greenField.setText((hex.length() == 1) ? "0"+hex : hex); }//GEN-LAST:event_greenFieldFocusLost private void redFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_redFieldFocusLost String hex = Integer.toHexString(ccModel.getBoundedRangeModel(0).getValue()).toUpperCase(); redField.setText((hex.length() == 1) ? "0"+hex : hex); }//GEN-LAST:event_redFieldFocusLost private void htmlFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_htmlFieldFocusLost Color mc = ccModel.getColor(); Color fc = (Color) nameToColorMap.get(htmlField.getText().toLowerCase()); if (fc == null || ! fc.equals(mc)) { String hex = Integer.toHexString(0xffffff & mc.getRGB()); StringBuffer buf = new StringBuffer(7); buf.append('#'); for (int i=hex.length(); i < 6; i++) { buf.append('0'); } buf.append(hex.toUpperCase()); htmlField.setText(buf.toString()); } }//GEN-LAST:event_htmlFieldFocusLost private void webSaveChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_webSaveChanged // TODO add your handling code here: boolean b = webSaveCheckBox.isSelected(); redSlider.setSnapToTicks(b); greenSlider.setSnapToTicks(b); blueSlider.setSnapToTicks(b); lastWebSaveSelectionState = b; /* redSlider.repaint(); greenSlider.repaint(); blueSlider.repaint(); */ ccModel.setWebSaveOnly(b); }//GEN-LAST:event_webSaveChanged // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField blueField; private javax.swing.JLabel blueLabel; private javax.swing.JSlider blueSlider; private javax.swing.JTextField greenField; private javax.swing.JLabel greenLabel; private javax.swing.JSlider greenSlider; private javax.swing.JTextField htmlField; private javax.swing.JLabel htmlLabel; private javax.swing.JPanel htmlPanel; private javax.swing.JTextField redField; private javax.swing.JLabel redLabel; private javax.swing.JSlider redSlider; private javax.swing.JPanel springPanel; private javax.swing.JCheckBox webSaveCheckBox; // End of variables declaration//GEN-END:variables } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/ColorChooserMainPanel.java0000644000175000017500000001255510674304666032553 0ustar drazzibdrazzib/* * @(#)ColorChooserMainPanel.java 1.4 2005-12-18 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import javax.swing.*; import javax.swing.colorchooser.AbstractColorChooserPanel; import contrib.ch.randelshofer.quaqua.util.Methods; /** * The main panel of the color chooser UI. * * @author Werner Randelshofer * @version 1.4 2005-12-18 ColorPicker added.
* 1.3 2005-09-05 Get font from UIManager.
* 1.2 2005-08-27 Remember chooser panel.
* 1.1 2005-04-23 Removed main method.
* 1.0 30 March 2005 Created. */ public class ColorChooserMainPanel extends javax.swing.JPanel { /** * We store here the name of the last selected chooser. When the * ColorChooserMainPanel is recreated multiple times in the same applicatin, * the application 'remembers' which panel the user had opened before. */ private static String lastSelectedChooserName = null; /** Creates new form. */ public ColorChooserMainPanel() { initComponents(); toolBar .putClientProperty("Quaqua.ToolBar.isDividerDrawn", Boolean.TRUE); } public void setPreviewPanel(JComponent c) { previewPanelHolder.removeAll(); if (c != null) { previewPanelHolder.add(c); } } public void addColorChooserPanel(final AbstractColorChooserPanel ccp) { final String displayName = ccp.getDisplayName(); if (displayName.equals("Color Picker")) { northPanel.add(ccp, BorderLayout.WEST); } else { Icon displayIcon = ccp.getLargeDisplayIcon(); JToggleButton tb = new JToggleButton(null, displayIcon); tb.setToolTipText(displayName); Methods.invokeIfExists(tb, "setFocusable", false); tb.setHorizontalTextPosition(SwingConstants.CENTER); tb.setVerticalTextPosition(SwingConstants.BOTTOM); tb.setFont(UIManager.getFont("ColorChooser.font")); tb.putClientProperty("Quaqua.Button.style", "toolBarTab"); JPanel centerView = new JPanel(new BorderLayout()); centerView.add(ccp); chooserPanelHolder.add(centerView, displayName); toolBarButtonGroup.add(tb); toolBar.add(tb); if (toolBar.getComponentCount() == 1 || lastSelectedChooserName != null && lastSelectedChooserName.equals(displayName)) { tb.setSelected(true); CardLayout cl = (CardLayout) chooserPanelHolder.getLayout(); cl.show(chooserPanelHolder, displayName); } tb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent evt) { if (evt.getStateChange() == ItemEvent.SELECTED) { CardLayout cl = (CardLayout) chooserPanelHolder .getLayout(); cl.show(chooserPanelHolder, displayName); lastSelectedChooserName = displayName; } } }); } } public void removeAllColorChooserPanels() { Component[] tb = toolBar.getComponents(); for (int i = 0; i < tb.length; i++) { if (tb[i] instanceof AbstractButton) { toolBarButtonGroup.remove((AbstractButton) tb[i]); } } toolBar.removeAll(); chooserPanelHolder.removeAll(); northPanel.removeAll(); northPanel.add(previewPanelHolder); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ private void initComponents() {// GEN-BEGIN:initComponents toolBarButtonGroup = new javax.swing.ButtonGroup(); toolBar = new javax.swing.JToolBar(); mainPanel = new javax.swing.JPanel(); northPanel = new javax.swing.JPanel(); previewPanelHolder = new javax.swing.JPanel(); chooserPanelHolder = new javax.swing.JPanel(); setLayout(new java.awt.BorderLayout()); toolBar.setFloatable(false); add(toolBar, java.awt.BorderLayout.NORTH); mainPanel.setLayout(new java.awt.BorderLayout()); mainPanel.setBorder(new javax.swing.border.EmptyBorder( new java.awt.Insets(5, 4, 7, 4))); northPanel.setLayout(new java.awt.BorderLayout()); previewPanelHolder.setLayout(new java.awt.BorderLayout()); northPanel.add(previewPanelHolder, java.awt.BorderLayout.CENTER); mainPanel.add(northPanel, java.awt.BorderLayout.NORTH); chooserPanelHolder.setLayout(new java.awt.CardLayout()); chooserPanelHolder.setBorder(new javax.swing.border.EmptyBorder( new java.awt.Insets(5, 0, 0, 0))); mainPanel.add(chooserPanelHolder, java.awt.BorderLayout.CENTER); add(mainPanel, java.awt.BorderLayout.CENTER); }// GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel chooserPanelHolder; private javax.swing.JPanel mainPanel; private javax.swing.JPanel northPanel; private javax.swing.JPanel previewPanelHolder; private javax.swing.JToolBar toolBar; private javax.swing.ButtonGroup toolBarButtonGroup; // End of variables declaration//GEN-END:variables } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/SwatchesChooser.java0000644000175000017500000002561110564356432031462 0ustar drazzibdrazzib/* * @(#)SwatchesChooser.java 1.1 2006-04-23 * * Copyright (c) 2005-2006 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.text.*; import javax.swing.event.*; import javax.swing.border.*; import javax.swing.colorchooser.*; import javax.swing.plaf.*; import contrib.ch.randelshofer.quaqua.*; import contrib.ch.randelshofer.quaqua.util.*; /** * SwatchesChooser. * * @author Werner Randelshofer * @version 1.3 2006-04-23 Retrieve labels directly from UIManager. *
1.0.2 2005-11-07 Get "Labels" ResourceBundle fro UIManager. *
1.0.1 2005-09-11 Get icon from UIManager. *
1.0 30 March 2005 Created. */ public class SwatchesChooser extends AbstractColorChooserPanel implements UIResource { private SwatchPanel swatchPanel; /** Creates new form. */ public SwatchesChooser() { initComponents(); swatchPanel = new SwatchPanel(); initColors(); scrollPane.setViewportView(swatchPanel); } protected void initColors() { int[] rawValues = initRawValues(); int numColors = rawValues.length / 3; Color[] colors = new Color[numColors]; for (int i = 0; i < numColors ; i++) { int x = i % 31; int y = i / 31; colors[x * 9 + y % 9] = new Color( rawValues[(i*3)], rawValues[(i*3)+1], rawValues[(i*3)+2] ); } swatchPanel.setColors(colors); swatchPanel.setNumSwatches(9, 31); swatchPanel.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { Color c = swatchPanel.getColorForLocation(e.getX(), e.getY()); if (c != null) { setColorToModel(c); } } }); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents scrollPane = new javax.swing.JScrollPane(); setLayout(new java.awt.BorderLayout()); add(scrollPane, java.awt.BorderLayout.CENTER); }//GEN-END:initComponents protected void buildChooser() { } public String getDisplayName() { return UIManager.getString("ColorChooser.colorSwatches"); } public Icon getLargeDisplayIcon() { return UIManager.getIcon("ColorChooser.colorSwatchesIcon"); } public Icon getSmallDisplayIcon() { return getLargeDisplayIcon(); } public void setColorToModel(Color color) { getColorSelectionModel().setSelectedColor(color); } public void updateChooser() { } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane scrollPane; // End of variables declaration//GEN-END:variables private int[] initRawValues() { int[] rawValues = { 255, 255, 255, // first row. 204, 255, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 255, 204, 255, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 255, 204, 204, 204, 204, // second row. 153, 255, 255, 153, 204, 255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 204, 153, 255, 255, 153, 255, 255, 153, 204, 255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 204, 153, 255, 255, 153, 204, 255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 153, 153, 255, 204, 204, 204, 204, // third row 102, 255, 255, 102, 204, 255, 102, 153, 255, 102, 102, 255, 102, 102, 255, 102, 102, 255, 102, 102, 255, 102, 102, 255, 153, 102, 255, 204, 102, 255, 255, 102, 255, 255, 102, 204, 255, 102, 153, 255, 102, 102, 255, 102, 102, 255, 102, 102, 255, 102, 102, 255, 102, 102, 255, 153, 102, 255, 204, 102, 255, 255, 102, 204, 255, 102, 153, 255, 102, 102, 255, 102, 102, 255, 102, 102, 255, 102, 102, 255, 102, 102, 255, 102, 102, 255, 153, 102, 255, 204, 153, 153, 153, // fourth row 51, 255, 255, 51, 204, 255, 51, 153, 255, 51, 102, 255, 51, 51, 255, 51, 51, 255, 51, 51, 255, 102, 51, 255, 153, 51, 255, 204, 51, 255, 255, 51, 255, 255, 51, 204, 255, 51, 153, 255, 51, 102, 255, 51, 51, 255, 51, 51, 255, 51, 51, 255, 102, 51, 255, 153, 51, 255, 204, 51, 255, 255, 51, 204, 255, 51, 153, 244, 51, 102, 255, 51, 51, 255, 51, 51, 255, 51, 51, 255, 51, 51, 255, 102, 51, 255, 153, 51, 255, 204, 153, 153, 153, // Fifth row 0, 255, 255, 0, 204, 255, 0, 153, 255, 0, 102, 255, 0, 51, 255, 0, 0, 255, 51, 0, 255, 102, 0, 255, 153, 0, 255, 204, 0, 255, 255, 0, 255, 255, 0, 204, 255, 0, 153, 255, 0, 102, 255, 0, 51, 255, 0 , 0, 255, 51, 0, 255, 102, 0, 255, 153, 0, 255, 204, 0, 255, 255, 0, 204, 255, 0, 153, 255, 0, 102, 255, 0, 51, 255, 0, 0, 255, 0, 0, 255, 51, 0, 255, 102, 0, 255, 153, 0, 255, 204, 102, 102, 102, // sixth row 0, 204, 204, 0, 204, 204, 0, 153, 204, 0, 102, 204, 0, 51, 204, 0, 0, 204, 51, 0, 204, 102, 0, 204, 153, 0, 204, 204, 0, 204, 204, 0, 204, 204, 0, 204, 204, 0, 153, 204, 0, 102, 204, 0, 51, 204, 0, 0, 204, 51, 0, 204, 102, 0, 204, 153, 0, 204, 204, 0, 204, 204, 0, 204, 204, 0, 153, 204, 0, 102, 204, 0, 51, 204, 0, 0, 204, 0, 0, 204, 51, 0, 204, 102, 0, 204, 153, 0, 204, 204, 102, 102, 102, // seventh row 0, 153, 153, 0, 153, 153, 0, 153, 153, 0, 102, 153, 0, 51, 153, 0, 0, 153, 51, 0, 153, 102, 0, 153, 153, 0, 153, 153, 0, 153, 153, 0, 153, 153, 0, 153, 153, 0, 153, 153, 0, 102, 153, 0, 51, 153, 0, 0, 153, 51, 0, 153, 102, 0, 153, 153, 0, 153, 153, 0, 153, 153, 0, 153, 153, 0, 153, 153, 0, 102, 153, 0, 51, 153, 0, 0, 153, 0, 0, 153, 51, 0, 153, 102, 0, 153, 153, 0, 153, 153, 51, 51, 51, // eigth row 0, 102, 102, 0, 102, 102, 0, 102, 102, 0, 102, 102, 0, 51, 102, 0, 0, 102, 51, 0, 102, 102, 0, 102, 102, 0, 102, 102, 0, 102, 102, 0, 102, 102, 0, 102, 102, 0, 102, 102, 0, 102, 102, 0, 51, 102, 0, 0, 102, 51, 0, 102, 102, 0, 102, 102, 0, 102, 102, 0, 102, 102, 0, 102, 102, 0, 102, 102, 0, 102, 102, 0, 51, 102, 0, 0, 102, 0, 0, 102, 51, 0, 102, 102, 0, 102, 102, 0, 102, 102, 0, 0, 0, // ninth row 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 0, 51, 0, 0, 51, 51, 0, 51, 51, 0, 51, 51, 0, 51, 51, 51, 51, 51 }; return rawValues; } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/NominalCMYKColorSliderModel.java0000644000175000017500000000706210564356432033562 0ustar drazzibdrazzibpackage contrib.ch.randelshofer.quaqua.colorchooser; /* * @(#)ICC_CMYKColorSliderModel.java 1.0 May 22, 2005 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ import java.awt.*; import java.awt.color.*; import java.io.*; import javax.swing.*; /** * A ColorSliderModel for CMYK color models (cyan, magenta, yellow, black) with * nominally converted color components from/to an RGB color model. *

* This model may not be very useful. It assumes that the color components * perfectly absorb the desired wavelenghts. * * @author Werner Randelshofer * @version 1.0 May 22, 2005 Created. */ public class NominalCMYKColorSliderModel extends ColorSliderModel { /** * Creates a new instance. */ public NominalCMYKColorSliderModel() { super(new DefaultBoundedRangeModel[] { new DefaultBoundedRangeModel(0, 0, 0, 100), new DefaultBoundedRangeModel(0, 0, 0, 100), new DefaultBoundedRangeModel(0, 0, 0, 100), new DefaultBoundedRangeModel(0, 0, 0, 100) }); } public int getRGB() { float cyan, magenta, yellow, black; cyan = components[0].getValue() / 100f; magenta = components[1].getValue() / 100f; yellow = components[2].getValue() / 100f; black = components[3].getValue() / 100f; float red, green, blue; red = 1f - cyan * (1f - black) - black; green = 1f - magenta * (1f - black) - black; blue = 1f - yellow * (1f - black) - black; return 0xff000000 | ((int) (red * 255) << 16) | ((int) (green * 255) << 8) | (int) (blue * 255); } public void setRGB(int rgb) { float cyan, magenta, yellow, black; cyan = 1f - ((rgb & 0xff0000) >>> 16) / 255f; magenta = 1f - ((rgb & 0x00ff00) >>> 8) / 255f; yellow = 1f - (rgb & 0x0000ff) / 255f; if (Math.min(Math.min(cyan, magenta), yellow) >= 1f) { cyan = magenta = yellow = 0f; black = 1f; } else { black = Math.min(Math.min(cyan, magenta), yellow); if (black > 0f) { cyan = (cyan - black) / (1 - black); magenta = (magenta - black) / (1 - black); yellow = (yellow - black) / (1 - black); } } components[0].setValue((int) (cyan * 100f)); components[1].setValue((int) (magenta * 100f)); components[2].setValue((int) (yellow * 100f)); components[3].setValue((int) (black * 100f)); } public int toRGB(int[] values) { float cyan, magenta, yellow, black; cyan = values[0] / 100f; magenta = values[1] / 100f; yellow = values[2] / 100f; black = values[3] / 100f; float red, green, blue; red = 1f - cyan * (1f - black) - black; green = 1f - magenta * (1f - black) - black; blue = 1f - yellow * (1f - black) - black; return 0xff000000 | ((int) (red * 255) << 16) | ((int) (green * 255) << 8) | (int) (blue * 255); } } substance-5.3.orig/src/contrib/ch/randelshofer/quaqua/colorchooser/DefaultPalettes.java0000644000175000017500000003314310564356430031441 0ustar drazzibdrazzib/* * @(#)ColorPalettes.java 1.0 September 18, 2005 * * Copyright (c) 2005 Werner Randelshofer * Staldenmattweg 2, Immensee, CH-6405, Switzerland. * All rights reserved. * * This software is the confidential and proprietary information of * Werner Randelshofer. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Werner Randelshofer. */ package contrib.ch.randelshofer.quaqua.colorchooser; import java.awt.*; /** * This class provides some well known color palettes as array constants. * * @author Werner Randelshofer * @version 1.0 September 18, 2005 Created. */ public class DefaultPalettes { /** * Apple Crayon Colors. * Copyright Apple Computer Inc., All rights reserved. * * The colors are listed here in a logical sequence. * Do not change this sequence! Other classes depend on it. */ public final static Color[] CRAYONS = { new Color(0x800000), //Cayenne new Color(0x808000), //Asparagus new Color(0x008000), //Clover new Color(0x008080), //Teal new Color(0x000080), //Midnight new Color(0x800080), //Plum new Color(0x7f7f7f), //Tin new Color(0x808080), //Nickel new Color(0x804000), //Mocha new Color(0x408000), //Fern new Color(0x008040), //Moss new Color(0x004080), //Ocean new Color(0x400080), //Eggplant new Color(0x800040), //Maroon new Color(0x666666), //Steel new Color(0x999999), //Aluminium new Color(0xff0000), //Maraschino new Color(0xffff00), //Lemon new Color(0x00ff00), //Spring new Color(0x00ffff), //Turquoise new Color(0x0000ff), //Blueberry new Color(0xff00ff), //Magenta new Color(0x4c4c4c), //Iron new Color(0xb3b3b3), //Magnesium new Color(0xff8000), //Tangerine new Color(0x80ff00), //Lime new Color(0x00ff80), //Sea Foam new Color(0x0080ff), //Aqua new Color(0x8000ff), //Grape new Color(0xff0080), //Strawberry new Color(0x333333), //Tungsten new Color(0xcccccc), //Silver new Color(0xff6666), //Salmon new Color(0xffff66), //Banana new Color(0x66ff66), //Flora new Color(0x66ffff), //Ice new Color(0x6666ff), //Orchid new Color(0xff66ff), //Bubblegum new Color(0x191919), //Lead new Color(0xe6e6e6), //Mercury new Color(0xffcc66), //Cantaloupe new Color(0xccff66), //Honeydew new Color(0x66ffcc), //Spindrift new Color(0x66ccff), //Sky new Color(0xcc66ff), //Lavender new Color(0xff6fcf), //Carnation new Color(0x000000), //Licorice new Color(0xffffff), //Snow }; /** * Apple Colors. * Copyright Apple Computer Inc., All rights reserved. * * The colors are listed here in a logical sequence. * Do not change this sequence! Other classes depend on it. */ public final static Color[] APPLE_COLORS = { new Color(0x000000), //Black new Color(0x0000ff), //Blue new Color(0x996633), //Brown new Color(0x00ffff), //Cyan new Color(0x00ff00), //Green new Color(0xff00ff), //Magenta new Color(0xff8000), //Orange new Color(0x800080), //Purple new Color(0xff0000), //Red new Color(0xffff00), //Yellow new Color(0xffffff), //White }; /** * Windows Basic Colors. * Copyright Microsoft Inc., All rights reserved. * * The colors are listed here in a logical sequence. * (This is the sequence used by native the Microsoft Windows color dialog.) * Do not alter this sequence! Other classes depend on it. */ public final static Color[] WINDOWS_BASIC_COLORS = { new Color(0xff8080), //salmon new Color(0xffff80), //pale yellow new Color(0x80ff80), //pale green new Color(0x00ff80), //spring green new Color(0x80ffff), //pale turquoise new Color(0x0080ff), //deep sky blue new Color(0xff80c0), //pale rose new Color(0xff80ff), //pink new Color(0xff0000), //red new Color(0xffff00), //yellow new Color(0x80ff00), //apple green new Color(0x00ff40), //light green new Color(0x00ffff), //aqua new Color(0x0080c0), //turquoise new Color(0x8080c0), //pale slate blue new Color(0xff00ff), //magenta new Color(0x804040), //chocolate new Color(0xff8040), //pumpkin new Color(0x00ff00), //lime new Color(0x008080), //teal new Color(0x004080), //dark turquoise new Color(0x8080ff), //medium slate blue new Color(0x800040), //maroon new Color(0xff0080), //rose new Color(0x800000), //dark red new Color(0xff8000), //dark orange new Color(0x008000), //green new Color(0x008040), //sea green new Color(0x0000ff), //blue new Color(0x0000a0), //medium blue new Color(0x800080), //purple new Color(0x8000ff), //blueviolet new Color(0x400000), //dark brown new Color(0x804000), //saddle brown new Color(0x004000), //dark forest green new Color(0x004040), //dark teal new Color(0x000080), //navy new Color(0x000040), //midnight blue new Color(0x400040), //dark purple new Color(0x400080), //dark blueviolet new Color(0x000000), //black new Color(0x808000), //olive new Color(0x808040), //dark olive new Color(0x808080), //grey new Color(0x408080), //light teal new Color(0xc0c0c0), //light grey new Color(0x400040), //dark purple new Color(0xffffff), //white }; /** * Web safe colors. * Copyright Apple Computer Inc., All rights reserved. * * The colors are listed here in a logical sequence. * (This is the sequence used by native NSColorPicker color dialog.) * Do not alter this sequence! Other classes depend on it. */ public final static Color[] WEB_SAFE_COLORS = { new Color(0xffffff), new Color(0xcccccc), new Color(0x999999), new Color(0x666666), new Color(0x333333), new Color(0x000000), new Color(0xffcccc), new Color(0xcc9999), new Color(0x996666), new Color(0x663333), new Color(0x330000), new Color(0xff9999), new Color(0xcc6666), new Color(0xcc3333), new Color(0x993333), new Color(0x660000), new Color(0xff6666), new Color(0xff3333), new Color(0xff0000), new Color(0xcc0000), new Color(0x990000), new Color(0xff9966), new Color(0xff6633), new Color(0xff3300), new Color(0xcc3300), new Color(0x993300), new Color(0xffcc99), new Color(0xcc9966), new Color(0xcc6633), new Color(0x996633), new Color(0x663300), new Color(0xff9933), new Color(0xff6600), new Color(0xff9900), new Color(0xcc6600), new Color(0xcc9933), new Color(0xffcc66), new Color(0xffcc33), new Color(0xffcc00), new Color(0xcc9900), new Color(0x996600), new Color(0xffffcc), new Color(0xcccc99), new Color(0x999966), new Color(0x666633), new Color(0x333300), new Color(0xffff99), new Color(0xcccc66), new Color(0xcccc33), new Color(0x999933), new Color(0x666600), new Color(0xffff66), new Color(0xffff33), new Color(0xffff00), new Color(0xcccc00), new Color(0x999900), new Color(0xccff66), new Color(0xccff33), new Color(0xccff00), new Color(0x99cc00), new Color(0x669900), new Color(0xccff99), new Color(0x99cc66), new Color(0x99cc33), new Color(0x669933), new Color(0x336600), new Color(0x99ff33), new Color(0x99ff00), new Color(0x66ff00), new Color(0x66cc00), new Color(0x66cc33), new Color(0x99ff66), new Color(0x66ff33), new Color(0x33ff00), new Color(0x33cc00), new Color(0x339900), new Color(0xccffcc), new Color(0x99cc99), new Color(0x669966), new Color(0x336633), new Color(0x003300), new Color(0x99ff99), new Color(0x66cc66), new Color(0x33cc33), new Color(0x339933), new Color(0x006600), new Color(0x66ff66), new Color(0x33ff33), new Color(0x00ff00), new Color(0x00cc00), new Color(0x009900), new Color(0x66ff99), new Color(0x33ff66), new Color(0x00ff33), new Color(0x00cc33), new Color(0x009933), new Color(0x99ffcc), new Color(0x66cc99), new Color(0x33cc66), new Color(0x339966), new Color(0x006633), new Color(0x33ff99), new Color(0x00ff66), new Color(0x00ff99), new Color(0x00cc66), new Color(0x33cc99), new Color(0x66ffcc), new Color(0x33ffcc), new Color(0x00ffcc), new Color(0x00cc99), new Color(0x009966), new Color(0xccffff), new Color(0x99cccc), new Color(0x669999), new Color(0x336666), new Color(0x003333), new Color(0x99ffff), new Color(0x66cccc), new Color(0x33cccc), new Color(0x339999), new Color(0x006666), new Color(0x66ffff), new Color(0x33ffff), new Color(0x00ffff), new Color(0x00cccc), new Color(0x009999), new Color(0x66ccff), new Color(0x33ccff), new Color(0x00ccff), new Color(0x0099cc), new Color(0x006699), new Color(0x99ccff), new Color(0x6699cc), new Color(0x3399cc), new Color(0x336699), new Color(0x003366), new Color(0x3399ff), new Color(0x0099ff), new Color(0x0066ff), new Color(0x0066cc), new Color(0x3366cc), new Color(0x6699ff), new Color(0x3366ff), new Color(0x0033ff), new Color(0x0033cc), new Color(0x003399), new Color(0xccccff), new Color(0x9999cc), new Color(0x666699), new Color(0x333366), new Color(0x003333), new Color(0x9999ff), new Color(0x6666cc), new Color(0x3333cc), new Color(0x333399), new Color(0x000066), new Color(0x6666ff), new Color(0x3333ff), new Color(0x0000ff), new Color(0x0000cc), new Color(0x000099), new Color(0x9966ff), new Color(0x6633ff), new Color(0x3300ff), new Color(0x3300cc), new Color(0x330099), new Color(0xcc99ff), new Color(0x9966cc), new Color(0x6633cc), new Color(0x663399), new Color(0x330066), new Color(0x9933ff), new Color(0x6600ff), new Color(0x9900ff), new Color(0x6600cc), new Color(0x9933cc), new Color(0xcc66ff), new Color(0xcc33ff), new Color(0xcc00ff), new Color(0x9900cc), new Color(0x660099), new Color(0xffccff), new Color(0xcc99cc), new Color(0x996699), new Color(0x663366), new Color(0x330033), new Color(0xff99ff), new Color(0xcc66cc), new Color(0xcc33cc), new Color(0x993399), new Color(0x660066), new Color(0xff66ff), new Color(0xff33ff), new Color(0xff00ff), new Color(0xcc00cc), new Color(0x990099), new Color(0xff66cc), new Color(0xff33cc), new Color(0xff00cc), new Color(0xcc0099), new Color(0x990066), new Color(0xff99cc), new Color(0xcc6699), new Color(0xcc3399), new Color(0x993366), new Color(0x660033), new Color(0xff3399), new Color(0xff0099), new Color(0xff0066), new Color(0xcc0066), new Color(0xcc3366), new Color(0xff6699), new Color(0xff3366), new Color(0xff0033), new Color(0xcc0033), new Color(0x990033), }; /** * Microsoft Office Colors. * Copyright Microsoft Inc., All rights reserved. * * The colors are listed here in a logical sequence. * (This is the sequence used by native the Microsoft Office color dialog.) * Do not alter this sequence! Other classes depend on it. */ public final static Color[] MS_OFFICE_COLORS = { new Color(0x000000), //Black }; /** * Prevent instance creation. */ private DefaultPalettes() { } /* public static void main(String[] args) { for (int i=0; i < WINDOWS_BASIC_COLORS.length; i+=2) { System.out.println("new Color(0x" +Integer.toHexString(((Color)WINDOWS_BASIC_COLORS[i+1]).getRGB()).substring(2) +"), //"+WINDOWS_BASIC_COLORS[i]); } }*/ } substance-5.3.orig/src/contrib/com/0000755000175000017500000000000010570313710017205 5ustar drazzibdrazzibsubstance-5.3.orig/src/contrib/com/jgoodies/0000755000175000017500000000000010570313710021010 5ustar drazzibdrazzibsubstance-5.3.orig/src/contrib/com/jgoodies/looks/0000755000175000017500000000000011256731144022146 5ustar drazzibdrazzibsubstance-5.3.orig/src/contrib/com/jgoodies/looks/FontSizeHints.java0000644000175000017500000001502310631727710025561 0ustar drazzibdrazzib/* * Copyright (c) 2001-2005 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package contrib.com.jgoodies.looks; import org.jvnet.lafwidget.utils.LookUtils; /** * Describes font size hints used by the JGoodies Windows look&feel; * future implementations of the Plastic l&f may use the same hints.

* * These hints are only applied if the dialog font is Tahoma, * which is the default font on the majority of Windows desktops. * The hints apply a size delta to increase or decrease the given * system font size.

* * NOTE: This is work in progress and will probably change in the * next release, to better reflect the font choice in the J2SE 1.4.". * * @author Karsten Lentzsch * @version $Revision: 1.2 $ * * @see Options#setGlobalFontSizeHints(FontSizeHints) * @see FontUtils */ public final class FontSizeHints { public static final FontSizeHints LARGE = new FontSizeHints(12, 12, 14, 14); public static final FontSizeHints SYSTEM = new FontSizeHints(11, 11, 14, 14); public static final FontSizeHints MIXED2 = new FontSizeHints(11, 11, 14, 13); public static final FontSizeHints MIXED = new FontSizeHints(11, 11, 14, 12); public static final FontSizeHints SMALL = new FontSizeHints(11, 11, 12, 12); public static final FontSizeHints FIXED = new FontSizeHints(12, 12, 12, 12); public static final FontSizeHints DEFAULT = SYSTEM; private final int loResMenuFontSize; private final int loResControlFontSize; private final int hiResMenuFontSize; private final int hiResControlFontSize; /** * Constructs FontSizeHints for the specified menu and * control fonts, both for low and high resolution environments. * * @param loResMenuFontSize the size of the menu font in low resolution * @param loResControlFontSize the size of the control font in low resolution * @param hiResMenuFontSize the size of the menu font in low resolution * @param hiResControlFontSize the size of the control font in low resolution */ public FontSizeHints(int loResMenuFontSize, int loResControlFontSize, int hiResMenuFontSize, int hiResControlFontSize) { this.loResMenuFontSize = loResMenuFontSize; this.loResControlFontSize = loResControlFontSize; this.hiResMenuFontSize = hiResMenuFontSize; this.hiResControlFontSize = hiResControlFontSize; } /** * Returns the low resolution menu font size. * * @return the size of the menu font in low resolution mode */ public int loResMenuFontSize() { return loResMenuFontSize; } /** * Returns the low resolution control font size. * * @return the size of the control font in low resolution mode */ public int loResControlFontSize() { return loResControlFontSize; } /** * Returns the high resolution menu font size. * * @return the size of the menu font in high resolution mode */ public int hiResMenuFontSize() { return hiResMenuFontSize; } /** * Returns the high resolution control font size. * * @return the size of the control font in high resolution mode */ public int hiResControlFontSize() { return hiResControlFontSize; } /** * Returns the menu font size. * * @return the size of the menu font in the current resolution */ public int menuFontSize() { return LookUtils.IS_LOW_RESOLUTION ? loResMenuFontSize : hiResMenuFontSize(); } /** * Returns the control font size. * * @return the size of the control font in the current resolution */ public int controlFontSize() { return LookUtils.IS_LOW_RESOLUTION ? loResControlFontSize : hiResControlFontSize(); } /** * Returns the delta between the system menu font size and * our menu font size hint. * * @return the delta between the system menu font size and * our menu font size hint */ public float menuFontSizeDelta() { return menuFontSize() - SYSTEM.menuFontSize(); } /** * Returns the delta between system control font size and * our control font size hint. * * @return the delta between the system control font size and * our control font size hint */ public float controlFontSizeDelta() { return controlFontSize() - SYSTEM.controlFontSize(); } /** * Looksup and returns the FontSizeHints for the specified name. * * @param name the name of the FontSizeHints object * @return the associated FontSizeHints object */ public static FontSizeHints valueOf(String name) { if (name.equalsIgnoreCase("LARGE")) return LARGE; else if (name.equalsIgnoreCase("SYSTEM")) return SYSTEM; else if (name.equalsIgnoreCase("MIXED")) return MIXED; else if (name.equalsIgnoreCase("SMALL")) return SMALL; else if (name.equalsIgnoreCase("FIXED")) return FIXED; else throw new IllegalArgumentException("Unknown font size hints name: " + name); } }substance-5.3.orig/src/contrib/com/jgoodies/looks/common/0000755000175000017500000000000011256731144023436 5ustar drazzibdrazzibsubstance-5.3.orig/src/contrib/com/jgoodies/looks/common/ShadowPopup.java0000644000175000017500000003172210630665044026557 0ustar drazzibdrazzib/* * Copyright (c) 2005 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package contrib.com.jgoodies.looks.common; import java.awt.*; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; import javax.swing.*; import javax.swing.border.Border; import org.jvnet.lafwidget.animation.FadeKind; /** * Does all the magic for getting popups with drop shadows. It adds the drop * shadow border to the Popup, in #show it snapshots the screen * background as needed, and in #hide it cleans up all changes * made before. * * @author Andrej Golovnin * @version $Revision: 1.10 $ * * @see com.jgoodies.looks.common.ShadowPopupBorder * @see com.jgoodies.looks.common.ShadowPopupFactory */ public final class ShadowPopup extends Popup { /** * Max number of items to store in the cache. */ private static final int MAX_CACHE_SIZE = 5; /** * The cache to use for ShadowPopups. */ private static List cache; /** * The singleton instance used to draw all borders. */ private static final Border SHADOW_BORDER = ShadowPopupBorder.getInstance(); /** * The size of the drop shadow. */ private static final int SHADOW_SIZE = 5; /** * Indicates whether we can make snapshots from screen or not. */ private static boolean canSnapshot = true; /** * The component mouse coordinates are relative to, may be null. */ private Component owner; /** * The contents of the popup. */ private Component contents; /** * The desired x and y location of the popup. */ private int x, y; /** * The real popup. The #show() and #hide() methods will delegate all calls * to these popup. */ private Popup popup; /** * The border of the contents' parent replaced by SHADOW_BORDER. */ private Border oldBorder; /** * The old value of the opaque property of the contents' parent. */ private boolean oldOpaque; /** * The heavy weight container of the popup contents, may be null. */ private Container heavyWeightContainer; protected static final FadeKind MENU_APPEAR = new FadeKind( "substancelaf.internal.menuAppear"); /** * Returns a previously used ShadowPopup, or a new one if * none of the popups have been recycled. */ static Popup getInstance(Component owner, Component contents, int x, int y, Popup delegate) { ShadowPopup result; synchronized (ShadowPopup.class) { if (cache == null) { cache = new ArrayList(MAX_CACHE_SIZE); } if (cache.size() > 0) { result = (ShadowPopup) cache.remove(0); } else { result = new ShadowPopup(); } } result.reset(owner, contents, x, y, delegate); return result; } /** * Recycles the ShadowPopup. */ private static void recycle(ShadowPopup popup) { synchronized (ShadowPopup.class) { if (cache.size() < MAX_CACHE_SIZE) { cache.add(popup); } } } public static boolean canSnapshot() { return canSnapshot; } /** * Hides and disposes of the Popup. Once a * Popup has been disposed you should no longer invoke * methods on it. A disposed Popup may be * reclaimed and later used based on the PopupFactory. As * such, if you invoke methods on a disposed Popup, * indeterminate behavior will result. *

* * In addition to the superclass behavior, we reset the stored horizontal * and vertical drop shadows - if any. */ public void hide() { if (contents == null) return; final JComponent parent = (JComponent) contents.getParent(); // final int width = contents.getWidth(); // final int height = contents.getHeight(); // FadeTracker.getInstance().trackFadeOut(MENU_APPEAR, parent, false, // new FadeTracker.FadeTrackerCallback() { // public void fadePerformed(FadeKind fadeKind, // final float fadeCycle10) { // Component c = contents; // System.out.println(fadeCycle10); // while (c != null) { // System.out.println(c.getClass().getName()); // if (c instanceof JPopupMenu) // break; // c = c.getParent(); // } // if (c != null) { // c.setSize((int) (width * fadeCycle10 / 10.0), // (int) (height * fadeCycle10 / 10.0)); // c.repaint(); // } // } // // public void fadeEnded(FadeKind fadeKind) { popup.hide(); if (parent.getBorder() == SHADOW_BORDER) { parent.setBorder(oldBorder); parent.setOpaque(oldOpaque); oldBorder = null; if (heavyWeightContainer != null) { parent .putClientProperty( ShadowPopupFactory.PROP_HORIZONTAL_BACKGROUND, null); parent .putClientProperty( ShadowPopupFactory.PROP_VERTICAL_BACKGROUND, null); heavyWeightContainer = null; } } owner = null; contents = null; popup = null; recycle(ShadowPopup.this); // } // }); } /** * Makes the Popup visible. If the popup has a heavy-weight * container, we try to snapshot the background. If the Popup * is currently visible, it remains visible. */ public void show() { if (heavyWeightContainer != null) { snapshot(); } popup.show(); } /** * Reinitializes this ShadowPopup using the given parameters. * * @param owner * component mouse coordinates are relative to, may be null * @param contents * the contents of the popup * @param x * the desired x location of the popup * @param y * the desired y location of the popup * @param popup * the popup to wrap */ private void reset(Component owner, Component contents, int x, int y, Popup popup) { this.owner = owner; this.contents = contents; this.popup = popup; this.x = x; this.y = y; if (owner instanceof JComboBox) { return; } for (Container p = contents.getParent(); p != null; p = p.getParent()) { if ((p instanceof JWindow) || (p instanceof Panel)) { // Workaround for the gray rect problem. p.setBackground(contents.getBackground()); heavyWeightContainer = p; break; } } JComponent parent = (JComponent) contents.getParent(); oldOpaque = parent.isOpaque(); oldBorder = parent.getBorder(); parent.setOpaque(false); parent.setBorder(SHADOW_BORDER); // Pack it because we have changed the border. if (heavyWeightContainer != null) { heavyWeightContainer.setSize(heavyWeightContainer .getPreferredSize()); } else { parent.setSize(parent.getPreferredSize()); } } /** * The 'scratch pad' objects used to calculate dirty regions of the screen * snapshots. * * @see #snapshot() */ private static final Point point = new Point(); private static final Rectangle rect = new Rectangle(); /** * Snapshots the background. The snapshots are stored as client properties * of the contents' parent. The next time the border is drawn, this * background will be used. *

* * Uses a robot on the default screen device to capture the screen region * under the drop shadow. Does not use the window's device, * because that may be an outdated device (due to popup reuse) and the * robot's origin seems to be adjusted with the default screen device. * * @see #show() * @see com.jgoodies.looks.common.ShadowPopupBorder */ private void snapshot() { try { Robot robot = new Robot(); // uses the default screen device Dimension size = heavyWeightContainer.getPreferredSize(); int width = size.width; int height = size.height; rect.setBounds(x, y + height - SHADOW_SIZE, width, SHADOW_SIZE); BufferedImage hShadowBg = robot.createScreenCapture(rect); rect.setBounds(x + width - SHADOW_SIZE, y, SHADOW_SIZE, height - SHADOW_SIZE); BufferedImage vShadowBg = robot.createScreenCapture(rect); JComponent parent = (JComponent) contents.getParent(); parent.putClientProperty( ShadowPopupFactory.PROP_HORIZONTAL_BACKGROUND, hShadowBg); parent.putClientProperty( ShadowPopupFactory.PROP_VERTICAL_BACKGROUND, vShadowBg); Container layeredPane = getLayeredPane(); if (layeredPane == null) { // This could happen if owner is null. return; } int layeredPaneWidth = layeredPane.getWidth(); int layeredPaneHeight = layeredPane.getHeight(); point.x = x; point.y = y; SwingUtilities.convertPointFromScreen(point, layeredPane); // If needed paint dirty region of the horizontal snapshot. rect.x = point.x; rect.y = point.y + height - SHADOW_SIZE; rect.width = width; rect.height = SHADOW_SIZE; if ((rect.x + rect.width) > layeredPaneWidth) { rect.width = layeredPaneWidth - rect.x; } if ((rect.y + rect.height) > layeredPaneHeight) { rect.height = layeredPaneHeight - rect.y; } if (!rect.isEmpty()) { Graphics g = hShadowBg.createGraphics(); g.translate(-rect.x, -rect.y); g.setClip(rect); if (layeredPane instanceof JComponent) { JComponent c = (JComponent) layeredPane; boolean doubleBuffered = c.isDoubleBuffered(); c.setDoubleBuffered(false); c.paintAll(g); c.setDoubleBuffered(doubleBuffered); } else { layeredPane.paintAll(g); } g.dispose(); } // If needed paint dirty region of the vertical snapshot. rect.x = point.x + width - SHADOW_SIZE; rect.y = point.y; rect.width = SHADOW_SIZE; rect.height = height - SHADOW_SIZE; if ((rect.x + rect.width) > layeredPaneWidth) { rect.width = layeredPaneWidth - rect.x; } if ((rect.y + rect.height) > layeredPaneHeight) { rect.height = layeredPaneHeight - rect.y; } if (!rect.isEmpty()) { Graphics g = vShadowBg.createGraphics(); g.translate(-rect.x, -rect.y); g.setClip(rect); if (layeredPane instanceof JComponent) { JComponent c = (JComponent) layeredPane; boolean doubleBuffered = c.isDoubleBuffered(); c.setDoubleBuffered(false); c.paintAll(g); c.setDoubleBuffered(doubleBuffered); } else { layeredPane.paintAll(g); } g.dispose(); } } catch (AWTException e) { canSnapshot = false; } catch (SecurityException e) { canSnapshot = false; } } /** * @return the top level layered pane which contains the owner. */ private Container getLayeredPane() { // The code below is copied from PopupFactory#LightWeightPopup#show() Container parent = null; if (owner != null) { parent = owner instanceof Container ? (Container) owner : owner .getParent(); } // Try to find a JLayeredPane and Window to add for (Container p = parent; p != null; p = p.getParent()) { if (p instanceof JRootPane) { if (p.getParent() instanceof JInternalFrame) { continue; } parent = ((JRootPane) p).getLayeredPane(); // Continue, so that if there is a higher JRootPane, we'll // pick it up. } else if (p instanceof Window) { if (parent == null) { parent = p; } break; } else if (p instanceof JApplet) { // Painting code stops at Applets, we don't want // to add to a Component above an Applet otherwise // you'll never see it painted. break; } } return parent; } }substance-5.3.orig/src/contrib/com/jgoodies/looks/common/ShadowPopupFactory.java0000644000175000017500000001673110631727710030112 0ustar drazzibdrazzib/* * Copyright (c) 2005 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package contrib.com.jgoodies.looks.common; import static contrib.com.jgoodies.looks.common.ShadowPopupFactory.install; import java.awt.Component; import javax.swing.*; import org.jvnet.lafwidget.utils.LookUtils; import contrib.com.jgoodies.looks.Options; /** * The JGoodies Looks implementation of PopupFactory. * Adds a drop shadow border to all popups except ComboBox popups. * It is installed by the JGoodies Plastic L&F, as well as by * the JGoodies Windows L&F during the Look&Feel initialization, * see {@link com.jgoodies.looks.plastic.PlasticLookAndFeel#initialize} and * {@link com.jgoodies.looks.windows.WindowsLookAndFeel#initialize}.

* * This factory shall not be used on platforms that provide native drop shadows, * such as the Mac OS X. Therefore the invocation of the {@link #install()} * method will have no effect on such platforms.

* * Note: To be used in a sandbox environment, this PopupFactory * requires two AWT permissions: createRobot and * readDisplayPixels. The reason for it is, that in the case of * the heavy weight popups this PopupFactory uses a Robot to snapshot * the screen background to simulate the drop shadow effect. * * @author Andrej Golovnin * @author Karsten Lentzsch * @version $Revision: 1.9 $ * * @see java.awt.AWTPermission * @see java.awt.Robot * @see javax.swing.Popup * @see LookAndFeel#initialize * @see LookAndFeel#uninitialize */ public final class ShadowPopupFactory extends PopupFactory { /** * In the case of heavy weight popups, snapshots of the screen background * will be stored as client properties of the popup contents' parent. * These snapshots will be used by the popup border to simulate the drop * shadow effect. The two following constants define the names of * these client properties. * * @see com.jgoodies.looks.common.ShadowPopupBorder */ static final String PROP_HORIZONTAL_BACKGROUND = "jgoodies.hShadowBg"; static final String PROP_VERTICAL_BACKGROUND = "jgoodies.vShadowBg"; /** * The PopupFactory used before this PopupFactory has been installed * in #install. Used to restored the original state * in #uninstall. */ private final PopupFactory storedFactory; // Instance Creation ****************************************************** private ShadowPopupFactory(PopupFactory storedFactory) { this.storedFactory = storedFactory; } // API ******************************************************************** /** * Installs the ShadowPopupFactory as the shared popup factory * on non-Mac platforms. Also stores the previously set factory, * so that it can be restored in #uninstall.

* * In some Mac Java environments the popup factory throws * a NullPointerException when we call #getPopup.

* * TODO: The Mac case shows that we may have problems replacing * non PopupFactory instances. Therefore we should consider * replacing only instances of PopupFactory. * * @see #uninstall() */ public static void install() { if (LookUtils.IS_OS_MAC) { return; } PopupFactory factory = PopupFactory.getSharedInstance(); if (factory instanceof ShadowPopupFactory) return; PopupFactory.setSharedInstance(new ShadowPopupFactory(factory)); } /** * Uninstalls the ShadowPopupFactory and restores the original * popup factory as the new shared popup factory. * * @see #install() */ public static void uninstall() { PopupFactory factory = PopupFactory.getSharedInstance(); if (!(factory instanceof ShadowPopupFactory)) return; PopupFactory stored = ((ShadowPopupFactory) factory).storedFactory; PopupFactory.setSharedInstance(stored); } /** * Creates a Popup for the Component owner * containing the Component contents. In addition to * the superclass behavior, we try to return a Popup that has a drop shadow, * if popup drop shadows are active - as returned by * Options#isPopupDropShadowActive.

* * owner is used to determine which Window the new * Popup will parent the Component the * Popup creates to. A null owner implies there * is no valid parent. x and * y specify the preferred initial location to place * the Popup at. Based on screen size, or other paramaters, * the Popup may not display at x and * y.

* * We invoke the super #getPopup, not the one in the * stored factory, because the popup type is set in this instance, * not in the stored one. * * @param owner Component mouse coordinates are relative to, may be null * @param contents Contents of the Popup * @param x Initial x screen coordinate * @param y Initial y screen coordinate * @return Popup containing Contents * @throws IllegalArgumentException if contents is null * * @see Options#isPopupDropShadowActive() */ public Popup getPopup(Component owner, Component contents, int x, int y) throws IllegalArgumentException { Popup popup = super.getPopup(owner, contents, x, y); return Options.isPopupDropShadowActive() ? ShadowPopup.getInstance(owner, contents, x, y, popup) : popup; } } substance-5.3.orig/src/contrib/com/jgoodies/looks/common/shadow.png0000644000175000017500000000047310322471752025434 0ustar drazzibdrazzibPNG  IHDR w&+tEXtCreation TimeMi 11 Feb 2004 10:17:51 +0100ltIME ;!͌ pHYs  ~gAMA aIDATx} 0E6覫B6#w@pμzӄ7'/HV)h Xr-Yr&#c8 6P H-e_cOxQ|8,:ʩsn(1˿IENDB`substance-5.3.orig/src/contrib/com/jgoodies/looks/common/ShadowPopupBorder.java0000644000175000017500000001141510355431636027714 0ustar drazzibdrazzib/* * Copyright (c) 2001-2005 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package contrib.com.jgoodies.looks.common; import java.awt.*; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.border.AbstractBorder; /** * A border with a drop shadow intended to be used as the outer border * of popups. Can paint the screen background if used with heavy-weight * popup windows. * * @author Stefan Matthias Aust * @author Karsten Lentzsch * @author Andrej Golovnin * @version $Revision: 1.7 $ * * @see ShadowPopup * @see ShadowPopupFactory */ final class ShadowPopupBorder extends AbstractBorder { /** * The drop shadow needs 5 pixels at the bottom and the right hand side. */ private static final int SHADOW_SIZE = 5; /** * The singleton instance used to draw all borders. */ private static ShadowPopupBorder instance = new ShadowPopupBorder(); /** * The drop shadow is created from a PNG image with 8 bit alpha channel. */ private static Image shadow = new ImageIcon(ShadowPopupBorder.class.getResource("shadow.png")).getImage(); // Instance Creation ***************************************************** /** * Returns the singleton instance used to draw all borders. */ public static ShadowPopupBorder getInstance() { return instance; } /** * Paints the border for the specified component with the specified * position and size. */ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { // fake drop shadow effect in case of heavy weight popups JComponent popup = (JComponent) c; Image hShadowBg = (Image) popup.getClientProperty(ShadowPopupFactory.PROP_HORIZONTAL_BACKGROUND); if (hShadowBg != null) { g.drawImage(hShadowBg, x, y + height - 5, c); } Image vShadowBg = (Image) popup.getClientProperty(ShadowPopupFactory.PROP_VERTICAL_BACKGROUND); if (vShadowBg != null) { g.drawImage(vShadowBg, x + width - 5, y, c); } // draw drop shadow g.drawImage(shadow, x + 5, y + height - 5, x + 10, y + height, 0, 6, 5, 11, null, c); g.drawImage(shadow, x + 10, y + height - 5, x + width - 5, y + height, 5, 6, 6, 11, null, c); g.drawImage(shadow, x + width - 5, y + 5, x + width, y + 10, 6, 0, 11, 5, null, c); g.drawImage(shadow, x + width - 5, y + 10, x + width, y + height - 5, 6, 5, 11, 6, null, c); g.drawImage(shadow, x + width - 5, y + height - 5, x + width, y + height, 6, 6, 11, 11, null, c); } /** * Returns the insets of the border. */ public Insets getBorderInsets(Component c) { return new Insets(0, 0, SHADOW_SIZE, SHADOW_SIZE); } /** * Reinitializes the insets parameter with this Border's current Insets. * @param c the component for which this border insets value applies * @param insets the object to be reinitialized * @return the insets object */ public Insets getBorderInsets(Component c, Insets insets) { insets.left = insets.top = 0; insets.right = insets.bottom = SHADOW_SIZE; return insets; } } substance-5.3.orig/src/contrib/com/jgoodies/looks/Options.java0000644000175000017500000004566510631727710024464 0ustar drazzibdrazzib/* * Copyright (c) 2001-2005 JGoodies Karsten Lentzsch. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * o Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * o Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * o Neither the name of JGoodies Karsten Lentzsch nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package contrib.com.jgoodies.looks; import java.awt.Dimension; import java.util.HashMap; import java.util.Map; import javax.swing.UIManager; import org.jvnet.lafwidget.utils.LookUtils; import contrib.com.jgoodies.looks.common.ShadowPopup; /** * Provides access to several optional properties for the * JGoodies L&Fs, either by a key to the UIDefaults table * or via a method or both. * * @author Karsten Lentzsch * @version $Revision: 1.3 $ */ public final class Options { // Look & Feel Names **************************************************** public static final String PLASTIC_NAME = "com.jgoodies.looks.plastic.PlasticLookAndFeel"; public static final String PLASTIC3D_NAME = "com.jgoodies.looks.plastic.Plastic3DLookAndFeel"; public static final String PLASTICXP_NAME = "com.jgoodies.looks.plastic.PlasticXPLookAndFeel"; public static final String JGOODIES_WINDOWS_NAME = "com.jgoodies.looks.windows.WindowsLookAndFeel"; /** * This outdated constant will be removed in the Looks version 1.4. * * @deprecated Replaced by {@link #JGOODIES_WINDOWS_NAME}. */ public static final String EXT_WINDOWS_NAME = JGOODIES_WINDOWS_NAME; public static final String DEFAULT_LOOK_NAME = PLASTIC3D_NAME; /** * Holds a Map that enables the look&feel replacement * mechanism to replace one look by another. * Maps the original class names to their replacement class names. */ private static final Map LAF_REPLACEMENTS; static { LAF_REPLACEMENTS = new HashMap(); initializeDefaultReplacements(); } // Keys for Overriding Font Settings ************************************ public static final String MENU_FONT_KEY = "jgoodies.menuFont"; public static final String CONTROL_FONT_KEY = "jgoodies.controlFont"; public static final String FONT_SIZE_HINTS_KEY = "jgoodies.fontSizeHints"; public static final String USE_SYSTEM_FONTS_KEY = "swing.useSystemFontSettings"; public static final String USE_SYSTEM_FONTS_APP_KEY = "Application.useSystemFontSettings"; // Optional Global User Properties ************************************** public static final String DEFAULT_ICON_SIZE_KEY = "jgoodies.defaultIconSize"; public static final String USE_NARROW_BUTTONS_KEY = "jgoodies.useNarrowButtons"; public static final String TAB_ICONS_ENABLED_KEY = "jgoodies.tabIconsEnabled"; public static final String POPUP_DROP_SHADOW_ENABLED_KEY = "jgoodies.popupDropShadowEnabled"; // Optional Client Properties ******************************************* /** * Hint that the button margin should be narrow. */ public static final String IS_NARROW_KEY = "jgoodies.isNarrow"; /** * Hint that the scroll pane border should be etched. */ public static final String IS_ETCHED_KEY = "jgoodies.isEtched"; /** * Hint for the style: Single or Both, see HeaderStyle. */ public static final String HEADER_STYLE_KEY = "jgoodies.headerStyle"; /** * Hint that the menu items in the menu have no icons. */ public static final String NO_ICONS_KEY = "jgoodies.noIcons"; /** * A client property key for JTrees. * Used with the angled and none style values. */ public static final String TREE_LINE_STYLE_KEY = "JTree.lineStyle"; /** * A client property value for JTrees * that indicates that lines shall be drawn. */ public static final String TREE_LINE_STYLE_ANGLED_VALUE = "Angled"; /** * A client property value for JTrees * that indicates that lines shall be hidden. */ public static final String TREE_LINE_STYLE_NONE_VALUE = "None"; /** * A client property key for JTabbedPanes that indicates * that no content border shall be painted. * Supported by the Plastic look&feel family. * This effect will be achieved also if the EMBEDDED property is true. */ public static final String NO_CONTENT_BORDER_KEY = "jgoodies.noContentBorder"; /** * A client property key for JTabbedPanes that indicates * that tabs are painted with a special embedded appearance. * Supported by the Plastic look&feel family. * This effect will be achieved also if the EMBEDDED property is true. */ public static final String EMBEDDED_TABS_KEY = "jgoodies.embeddedTabs"; // System Settings ******************************************************** /** * Holds the Boolean system property value for the tab icon enablement, * or null, if it has not been set. If this property has been * set, we log a message about the choosen value. * * @see #isTabIconsEnabled() */ private static final Boolean TAB_ICONS_ENABLED_SYSTEM_VALUE = LookUtils.getBooleanSystemProperty( TAB_ICONS_ENABLED_KEY, "Icons in tabbed panes"); /** * Holds the Boolean system property value for the popup drop shadow * enablement, or null, if it has not been set. If this property has been * set, we log a message about the choosen value.

* * This property just set the feature's enablement, not its actual * activation. For example, drop shadows are always inactive on * the Mac OS X, because this platform already provides shadows. * The activation is requested in #isPopupDropShadowActive. * * @see #isPopupDropShadowEnabled() * @see #isPopupDropShadowActive() */ private static final Boolean POPUP_DROP_SHADOW_ENABLED_SYSTEM_VALUE = LookUtils.getBooleanSystemProperty( POPUP_DROP_SHADOW_ENABLED_KEY, "Popup drop shadows"); // Private **************************************************************** private static final Dimension DEFAULT_ICON_SIZE = new Dimension(20, 20); private Options() { // Override default constructor; prevents instantiation. } // Accessing Options ****************************************************** /** * Returns whether a hint is set in the UIManager that indicates, * that a look&feel may use the native system fonts. * * @return true if the UIManager indicates that system fonts shall be used * @see #setUseSystemFonts(boolean) */ public static boolean getUseSystemFonts() { return UIManager.get(USE_SYSTEM_FONTS_APP_KEY).equals(Boolean.TRUE); } /** * Sets a value in the UIManager to indicate, * that a look&feel may use the native system fonts. * * @param useSystemFonts true to enable system fonts in the UIManager * @see #getUseSystemFonts() */ public static void setUseSystemFonts(boolean useSystemFonts) { UIManager.put(USE_SYSTEM_FONTS_APP_KEY, Boolean.valueOf(useSystemFonts)); } /** * Returns the default icon size that is used in menus, menu items and * toolbars. Menu items that have no icon set are aligned using the default * icon dimensions. * * @return the dimension of the default icon * @see #setDefaultIconSize(Dimension) */ public static Dimension getDefaultIconSize() { Dimension size = UIManager.getDimension(DEFAULT_ICON_SIZE_KEY); return size == null ? DEFAULT_ICON_SIZE : size; } /** * Sets the default icon size. * * @param defaultIconSize the default icon size to set * @see #getDefaultIconSize() */ public static void setDefaultIconSize(Dimension defaultIconSize) { UIManager.put(DEFAULT_ICON_SIZE_KEY, defaultIconSize); } /** * Returns the global FontSizeHints * that can be overriden by a look-specific setting. * * @return the gobally used FontSizeHints object * @see #setGlobalFontSizeHints(FontSizeHints) */ public static FontSizeHints getGlobalFontSizeHints() { Object value = UIManager.get(FONT_SIZE_HINTS_KEY); if (value != null) return (FontSizeHints) value; String name = LookUtils.getSystemProperty(FONT_SIZE_HINTS_KEY, ""); try { return FontSizeHints.valueOf(name); } catch (IllegalArgumentException e) { return FontSizeHints.DEFAULT; } } /** * Sets the global FontSizeHints. * * @param hints the FontSizeHints object to be used globally * @see #getGlobalFontSizeHints() */ public static void setGlobalFontSizeHints(FontSizeHints hints) { UIManager.put(FONT_SIZE_HINTS_KEY, hints); } /** * Checks and answers if we shall use narrow button margins of 4 pixels. * Sun's L&F implementations use a much wider button margin of 14 pixels, * which leads to good button minimum width in the typical case.

* * Using narrow button margins can potentially cause compatibility issues, * so this feature must be switched on programmatically.

* * If you use narrow margin, you should take care of minimum button width, * either by the layout management or appropriate ButtonUI minimum widths. * * @return true if all buttons shall use narrow margins * @see #setUseNarrowButtons(boolean) */ public static boolean getUseNarrowButtons() { return UIManager.getBoolean(USE_NARROW_BUTTONS_KEY); } /** * Sets if we use narrow or standard button margins. * * @param b true to use narrow button margins globally * @see #getUseNarrowButtons() */ public static void setUseNarrowButtons(boolean b) { UIManager.put(USE_NARROW_BUTTONS_KEY, Boolean.valueOf(b)); } /** * Checks and answers if we shall use icons in JTabbedPanes. * By default, tab icons are enabled. If the user has set a system property, * we log a message about the choosen style. * * @return true if icons in tabbed panes are enabled, false if disabled * @see #setTabIconsEnabled(boolean) */ public static boolean isTabIconsEnabled() { return TAB_ICONS_ENABLED_SYSTEM_VALUE == null ? !Boolean.FALSE.equals(UIManager.get(TAB_ICONS_ENABLED_KEY)) : TAB_ICONS_ENABLED_SYSTEM_VALUE.booleanValue(); } /** * Enables or disables the use of icons in JTabbedPanes. * * @param b true to enable icons in tabbed panes, false to disable them * @see #isTabIconsEnabled() */ public static void setTabIconsEnabled(boolean b) { UIManager.put(TAB_ICONS_ENABLED_KEY, Boolean.valueOf(b)); } /** * Checks and answers whether popup drop shadows are active. * This feature shall be inactive with toolkits that use * native drop shadows, such as Aqua on the Mac OS X. * It is also inactive if the ShadowPopup cannot snapshot * the desktop background (due to security and AWT exceptions). * Otherwise the feature's enablement state is returned.

* * Currently only the Mac OS X is detected as platform where * the toolkit uses native drop shadows. * * @return true if drop shadows are active, false if inactive * * @see #isPopupDropShadowEnabled() * @see #setPopupDropShadowEnabled(boolean) */ public static boolean isPopupDropShadowActive() { return !LookUtils.getToolkitUsesNativeDropShadows() && ShadowPopup.canSnapshot() && isPopupDropShadowEnabled(); } /** * Checks and answers whether the optional drop shadows for * PopupMenus are enabled or disabled. * * @return true if drop shadows are enabled, false if disabled * * @see #isPopupDropShadowActive() * @see #setPopupDropShadowEnabled(boolean) */ public static boolean isPopupDropShadowEnabled() { if (POPUP_DROP_SHADOW_ENABLED_SYSTEM_VALUE != null) return POPUP_DROP_SHADOW_ENABLED_SYSTEM_VALUE.booleanValue(); Object value = UIManager.get(POPUP_DROP_SHADOW_ENABLED_KEY); return value == null ? isPopupDropShadowEnabledDefault() : Boolean.TRUE.equals(value); } /** * Enables or disables drop shadows in PopupMenus. * Note that drop shadows are always inactive on platforms * that provide native drop shadows such as the Mac OS X.

* * It is recommended to enable this feature only on platforms that * accelerate translucency and snapshots with the hardware. * * @param b true to enable drop shadows, false to disable them * * @see #isPopupDropShadowActive() * @see #isPopupDropShadowEnabled() */ public static void setPopupDropShadowEnabled(boolean b) { UIManager.put(POPUP_DROP_SHADOW_ENABLED_KEY, Boolean.valueOf(b)); } /** * Checks and answers whether popup drop shadows are enabled * or disabled by default. True for modern Windows platforms: * Windows 98/ME/2000/XP.

* * TODO: Consider enabling popup drop shadows on Linux by default.

* * TODO: Consider moving the default to the individual L&F's * component defaults initialization. For example Plastic and Plastic3D * may disable this feature by default, while PlasticXP enables it * by default. * * @return false */ private static boolean isPopupDropShadowEnabledDefault() { return LookUtils.IS_OS_WINDOWS_MODERN; } // Look And Feel Replacements ******************************************* /** * Puts a replacement name for a given LookAndFeel * class name in the list of all look and feel replacements. * * @param original the name of the look-and-feel to replace * @param replacement the name of the replacement look-and-feel * @see #removeLookAndFeelReplacement(String) * @see #getReplacementClassNameFor(String) */ public static void putLookAndFeelReplacement( String original, String replacement) { LAF_REPLACEMENTS.put(original, replacement); } /** * Removes a replacement name for a given LookAndFeel * class name from the list of all look and feel replacements. * * @param original the name of the look-and-feel that has been replaced * @see #putLookAndFeelReplacement(String, String) * @see #getReplacementClassNameFor(String) */ public static void removeLookAndFeelReplacement(String original) { LAF_REPLACEMENTS.remove(original); } /** * Initializes some default class name replacements, that replace * Sun's Java look and feel, and Sun's Windows look and feel by * the appropriate JGoodies replacements. * * @see #putLookAndFeelReplacement(String, String) * @see #removeLookAndFeelReplacement(String) * @see #getReplacementClassNameFor(String) */ public static void initializeDefaultReplacements() { putLookAndFeelReplacement( "javax.swing.plaf.metal.MetalLookAndFeel", PLASTIC3D_NAME); putLookAndFeelReplacement( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel", JGOODIES_WINDOWS_NAME); } /** * Returns the class name that can be used to replace the specified * LookAndFeel class name. * * @param className the name of the look-and-feel class * @return the name of the suggested replacement class * @see #putLookAndFeelReplacement(String, String) * @see #removeLookAndFeelReplacement(String) * @see #initializeDefaultReplacements() */ public static String getReplacementClassNameFor(String className) { String replacement = (String) LAF_REPLACEMENTS.get(className); return replacement == null ? className : replacement; } /** * Returns the class name for a cross-platform LookAndFeel. * * @return the name of a cross platform look-and-feel class * @see #getSystemLookAndFeelClassName() */ public static String getCrossPlatformLookAndFeelClassName() { return PLASTIC3D_NAME; } /** * Returns the class name for a system specific LookAndFeel. * * @return the name of the system look-and-feel class * @see #getCrossPlatformLookAndFeelClassName() */ public static String getSystemLookAndFeelClassName() { String osName = System.getProperty("os.name"); if (osName.startsWith("Windows")) return Options.JGOODIES_WINDOWS_NAME; else if (osName.startsWith("Mac")) return UIManager.getSystemLookAndFeelClassName(); else return getCrossPlatformLookAndFeelClassName(); } }