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

/**
 * <p>This example demonstrates how to use the
 * component Diagram within the GUI framework
 * JControl/Vole.</p>
 *
 * <p>(C) DOMOLOGIC Home Automation GmbH 2003-2005</p>
 */
public class VoleDiagramExample extends Frame {
  
  /**
   * Create a Diagram and fill it with some random values.
   */
  public VoleDiagramExample() {
    
    // create the Diagram
    Diagram dia = new Diagram(0, 10, 128, 40, 0, 20, 30);
    dia.setCaption("0", "20", Diagram.ALIGN_LEFT);
    add(dia);
    
    // add a Label
    add(new Label("Diagram", 0, 52, 128, 10, Label.ALIGN_CENTER));
    
    // show the frame
    show();
    
    // generate random values and pass them to the Diagram
    for (;;) {
      dia.setValue(Math.rnd(20));
      // sleep 
      try {
        ThreadExt.sleep(500);
      } catch (InterruptedException e) {}
    }    
  }

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