import java.awt.*; //import gjt.Stopwatch; //import gjt.StopwatchClient; public class BarChart extends Panel{ MovingBar theChart; Label Percentage; ThreeDBorder border; Panel p; Color default_fill=Color.red; public Color second_fill=Color.blue; double default_scale=1, default_offset=0; double m_Scale,m_Offset; String default_title="Bar Chart"; public BarChart(){ this(Color.red,"Bar Chart",1.0,0.0); } public BarChart(Color fill){ this(fill, "Bar Chart", 1.0, 0.0); } public BarChart(Color fill, String title){ this(fill, title, 1.0, 0.0); } public BarChart(Color fill, String title, double Scale){ this(fill, title, Scale, 0.0); } public BarChart(Color fillColor, String title, double Scale, double Offset){ m_Scale=Scale; m_Offset=Offset; theChart=new MovingBar(fillColor); p=new Panel(); p.setLayout(new BorderLayout()); p.add("Center",theChart); p.add("North",new Label(title,Label.CENTER)); p.add("East",Percentage=new Label("100",Label.CENTER)); border=new ThreeDBorder(p); setLayout(new BorderLayout()); add("Center",border); //theChart.start(); setFillValue(0.0); setBackground(new Color(204,204,204)); } public void setFillValue(double P){ int Pi= (int)((P+m_Offset)*100.0/m_Scale); theChart.setFillPercent(Pi); int i=(int)(P*10); Percentage.setText(""+Math.round((double)i/10.0)); } public void setSecondFillValue(double P){ int Pi= (int)((P+m_Offset)*100.0/m_Scale); theChart.addedFill=Pi; } public Dimension minimumSize() { return preferredSize(); } public Dimension preferredSize() { //int w = border.getThickness() ; return new Dimension(160, 75); } public void stop(){ theChart.stop(); } public void start(){ theChart.start(); } // public void paint(Graphics g){ // theChart.paint(g); // border.inset(); // border.paint(g); // fill(); // g.drawImage(m_image,m_dimImage.x,m_dimImage.y,null); // } }