1
package com.incors.plaf.kunststoff;
4
* This code was developed by INCORS GmbH (www.incors.com).
5
* It is published under the terms of the GNU Lesser General Public License.
9
import com.incors.plaf.*;
12
* Collection of methods often used in the Kunststoff Look&Feel
14
public class KunststoffUtilities {
17
* Convenience method to create a translucent <code>Color</color>.
19
public static Color getTranslucentColor(Color color, int alpha) {
22
} else if (alpha == 255) {
25
return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);
30
* Convenience method to create a translucent <code>ColorUIResource</code>.
32
public static Color getTranslucentColorUIResource(Color color, int alpha) {
35
} else if (alpha == 255) {
38
return new ColorUIResource2(color.getRed(), color.getGreen(), color.getBlue(), alpha);
43
* Convenience method to draw a gradient on the specified rectangle
45
public static void drawGradient(Graphics g, Color color1, Color color2, Rectangle rect, boolean isVertical) {
46
Graphics2D g2D = (Graphics2D) g;
47
Paint gradient = new FastGradientPaint(color1, color2, isVertical);
48
g2D.setPaint(gradient);
53
* Convenience method to draw a gradient. The first rectangle defines the drawing region,
54
* the second rectangle defines the size of the gradient.
56
public static void drawGradient(Graphics g, Color color1, Color color2, Rectangle rect, Rectangle rect2, boolean isVertical) {
57
// We are currently not using the FastGradientPaint to render this gradient, because we have to decide how
58
// we can use FastGradientPaint if rect and rect2 are different.
60
Graphics2D g2D = (Graphics2D) g;
61
GradientPaint gradient = new GradientPaint(0f, (float) rect.getY(), color1, 0f, (float) (rect.getHeight() + rect.getY()), color2);
62
g2D.setPaint(gradient);
65
Graphics2D g2D = (Graphics2D) g;
66
GradientPaint gradient = new GradientPaint((float) rect.getX(), 0f, color1, (float) (rect.getWidth() + rect.getX()), 0f, color2);
67
g2D.setPaint(gradient);
73
* Returns true if the display uses 24- or 32-bit color depth (= true color)
75
public static boolean isToolkitTrueColor(Component c) {
76
int pixelsize = c.getToolkit().getColorModel().getPixelSize();
77
return pixelsize >= 24;