/*
 *
 * Copyright (C)  30-août-2003 Jean-Yves Beaujean 
 * 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.
 * 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.

 * 
 */

package jxtray.ui;

import java.awt.Color;
import java.awt.Insets;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GradientPaint;
import java.awt.Rectangle;

import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;


public class JxtProgressBarUI extends javax.swing.plaf.basic.BasicProgressBarUI
{
  private static final Color START = new Color(54,80,125);
  private static final Color END = new Color(145, 160, 183);

  public static ComponentUI createUI(JComponent c)
  {
    return new JxtProgressBarUI();
  }

  public void paint(Graphics g, JComponent c)
  {
    Insets b = progressBar.getInsets();
    int barRectX = b.left;
    int barRectY = b.top;
    int barRectWidth = progressBar.getWidth() - (b.right + barRectX);
    int barRectHeight = progressBar.getHeight() - (b.bottom + barRectY);
    int amountFull = getAmountFull(b, barRectWidth, barRectHeight);

    if (amountFull > 0)
    {
      GradientPaint painter = new GradientPaint(barRectX, barRectY,
                                                START,
                                                barRectX + barRectWidth, barRectY + barRectHeight,
                                                END);
      Graphics2D g2 = (Graphics2D) g;
      g2.setPaint(painter);
      g2.fill(new Rectangle(barRectX, barRectY, amountFull, barRectHeight));
    }

    if (progressBar.isStringPainted())
      paintString(g, barRectX, barRectY, barRectWidth, barRectHeight, amountFull, b);
  }
}

// End of JextProgressBarUI.java
