Gradient fill in JideSwingUtilities

This forum is used by users to request and discuss new product features. Please do not use this forum for technical support including bug reports.

Moderator: JIDE Support

Forum rules
Product suggestions only. Please do not use this forum for technical support including bug reports.

Gradient fill in JideSwingUtilities

Postby Skjalg » Fri Jan 15, 2010 3:15 am

I suggest adding these three methods to JideSwingUtilities, for easier use:

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);
    }
Skjalg
 
Posts: 51
Joined: Tue May 12, 2009 6:45 am

Re: Gradient fill in JideSwingUtilities

Postby JIDE Support » Fri Jan 15, 2010 9:18 am

Thanks for those nice codes. However, we have to try our best to reduce the exposed APIs we provided to our customers as much as possible while adding new features continuously. That's why we will leave those methods for our customers to accomplish. We will refer them to this thread if any other customers are interested in similar features.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to Product Suggestions

Who is online

Users browsing this forum: No registered users and 12 guests

cron