view src/MPipeline2/src/mpipeline/main/ProgressPanel.java @ 52:daf4eab1a51e database-connection-manager tip

Fix. Default password should be [] not an empty string
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:29:47 +0100
parents f0afece42f48
children
line wrap: on
line source

/*
 * Copyright (c) 2009 Max-Planck-Gesellschaft, Martin Hewitson <martin.hewitson at aei.mpg.de>
 *
 * 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 3 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, see <http://www.gnu.org/licenses/>.
 *
 */

package mpipeline.main;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JPanel;

/**
 *
 * @author hewitson
 */
public class ProgressPanel extends JPanel {

  private int maxSteps = 1;
  private int currentStep = 0;

  /**
   *
   */
  public ProgressPanel() {

    setBackground(Color.lightGray);
  }

  /**
   *
   * @return
   */
  public int getCurrentStep() {
    return currentStep;
  }

  /**
   *
   * @param currentStep
   */
  public void setCurrentStep(int currentStep) {
    this.currentStep = currentStep;
  }

  /**
   *
   * @return
   */
  public int getMaxSteps() {
    return maxSteps;
  }

  /**
   *
   * @param maxSteps
   */
  public void setMaxSteps(int maxSteps) {
    this.maxSteps = maxSteps;
  }

  @Override
  public void paintComponent(Graphics g) {

    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g;

    float prog = (1.0f * currentStep) / (1.0f * maxSteps);
    g2d.setColor(Color.RED);
    g2d.fillRect(0, 0, (int) Math.round(prog * getWidth()), getHeight());
  }
}