// $Id: ProgressPanel.java,v 1.1 2006/10/21 17:52:23 Sasha Buzko Exp $ // // Copyright (c) 2000-2002 San Diego Supercomputer Center (SDSC), // a facility operated jointly by the University of California, // San Diego (UCSD) and General Atomics, San Diego, California, USA. // // Users and possessors of this source code are hereby granted a // nonexclusive, royalty-free copyright and design patent license to // use this code in individual software. License is not granted for // commercial resale, in whole or in part, without prior written // permission from SDSC. This source is provided "AS IS" without express // or implied warranty of any kind. // // For further information, please see: http://mbt.sdsc.edu // // History: // $Log: ProgressPanel.java,v $ // Revision 1.1 2006/10/21 17:52:23 Sasha Buzko // Refactored the project to move all new code to edu.sdsc.sirius package. // // Revision 1.1 2006/05/20 17:02:08 Sasha Buzko // Updated version // // Revision 1.1 2006/04/30 20:13:59 Sasha Buzko // New version of the app // // Revision 1.1 2006/04/15 19:42:29 Sasha Buzko // Initial commit // // Revision 1.2 2006/04/05 23:59:30 Administrator // *** empty log message *** // // Revision 1.1 2005/11/13 04:35:08 Administrator // *** empty log message *** // // Revision 1.1 2003/04/03 23:07:00 moreland // Added an "as-needed" ProgressPanel to the StatusPanel. // // Revision 1.0 2003/01/22 01:16:31 moreland // First verision. // package edu.sdsc.sirius.viewers; // Core import java.awt.*; import javax.swing.*; /** * Provides a GUI component to display a simple progress meter. *
* @author John L. Moreland */ public class ProgressPanel extends JLabel { private float percent = 0.0f; public void setPercent( float percent ) { this.percent = percent; repaint(); } protected void paintComponent( Graphics graphics ) { // First, paint the background. super.paintComponent( graphics ); // Second, paint our background. if ( graphics != null ) { int height = getHeight( ); int width = getWidth( ); int prog = (int) ((float) width * percent); graphics.setColor( Color.blue ); graphics.fillRect( 0, 0, prog, height ); graphics.setColor( Color.lightGray ); graphics.fillRect( prog, 0, width-prog, height ); graphics.setColor( Color.white ); int perc = (int) (100.0f * percent); String msg = " (" + perc + "%) " + getText(); graphics.drawString( msg, 0, height-5 ); } } }