import jcontrol.lang.Math;
import jcontrol.lang.ThreadExt;
import jcontrol.ui.vole.Frame;
import jcontrol.ui.vole.Label;
import jcontrol.ui.vole.graph.Histogram;

/**
 * <p>This example demonstrates how to use the
 * component Histogram within the GUI framework
 * JControl/Vole.</p>
 *
 * <p>(C) DOMOLOGIC Home Automation GmbH 2003-2005</p>
 */
public class VoleHistogramExample extends Frame {

  /**
   * Create a Histogram and fill it with some random values.
   */
  public VoleHistogramExample() {

    // create the Histogram
    Histogram his = new Histogram(0, 10, 128, 40, 0, 20, 30);
    his.setCaption("0", "20", Histogram.ALIGN_LEFT);
    add(his);
    
    // add a Label
    add(new Label("Histogram", 0, 52, 128, 10, Label.ALIGN_CENTER));
    
    // show the frame
    show();
    
    // generate random values and pass them to the Diagram
    for (;;) {
      his.setValue(Math.rnd(20));
      // sleep 
      try {
        ThreadExt.sleep(500);
      } catch (InterruptedException e) {}
    }    
  }

  /**
   * Create an instance of the VoleHistogramExample
   */
  public static void main(String[] args) {
    new VoleHistogramExample();
  }
}
