This method is just a help method so you can specify a component instead of a rectangle
- Code: Select all
public static void fillGradient(Graphics2D graphics, Component component, Color startColor, Color endColor, boolean isVertical) {
Rectangle rectangle = new Rectangle(0, 0, component.getWidth(), component.getHeight());
JideSwingUtilities.fillGradient(graphics, rectangle, startColor, endColor, isVertical);
}
This method paints two gradients, with 3 specified colors so you can achieve a bar or pipe look.
- Code: Select all
public static void fillGradient(Graphics2D graphics, Rectangle rectangle, Color startColor, Color middleColor, Color endColor, boolean isVertical) {
Rectangle top = new Rectangle();
if (isVertical) {
top.setRect(0, 0, rectangle.getWidth(), rectangle.getHeight() / 2);
} else {
top.setRect(0, 0, rectangle.getWidth() / 2.0, rectangle.getHeight());
}
Rectangle bottom = new Rectangle();
if (isVertical) {
bottom.setRect(0, (rectangle.getHeight() / 2), rectangle.getWidth(), (rectangle.getHeight() / 2));
} else {
bottom.setRect((rectangle.getWidth() / 2), 0, (rectangle.getWidth() / 2), rectangle.getHeight());
}
JideSwingUtilities.fillGradient(graphics, top, startColor, middleColor, isVertical);
JideSwingUtilities.fillGradient(graphics, bottom, middleColor, endColor, isVertical);
}
This method is just a help method so you can specify a component instead of a rectangle
- Code: Select all
public static void fillGradient(Graphics2D graphics, Component component, Color startColor, Color middleColor, Color endColor, boolean isVertical) {
Rectangle rectangle = new Rectangle(0, 0, component.getWidth(), component.getHeight());
fillGradient(graphics, rectangle, startColor, middleColor, endColor, isVertical);
}