001package org.vishia.gral.test;
002
003import org.vishia.gral.base.GralGraphicTimeOrder;
004import org.vishia.gral.base.GralMng;
005import org.vishia.gral.base.GralWindow;
006import org.vishia.gral.widget.GralPlotArea;
007import org.vishia.msgDispatch.LogMessage;
008import org.vishia.msgDispatch.LogMessageStream;
009
010/**A window which contains a {@link GralPlotArea} for simple plot in a window for example able to use in JZcmd.
011 * @author Hartmut Schorrig
012 *
013 */
014public class GralPlotWindow
015{
016
017    /**Version, history and license.
018   * <ul>
019   * <li>2015-09-26 Hartmut creation.   
020   * </ul>
021   * <br><br>
022   * <b>Copyright/Copyleft</b>:
023   * For this source the LGPL Lesser General Public License,
024   * published by the Free Software Foundation is valid.
025   * It means:
026   * <ol>
027   * <li> You can use this source without any restriction for any desired purpose.
028   * <li> You can redistribute copies of this source to everybody.
029   * <li> Every user of this source, also the user of redistribute copies
030   *    with or without payment, must accept this license for further using.
031   * <li> But the LPGL is not appropriate for a whole software product,
032   *    if this source is only a part of them. It means, the user
033   *    must publish this part of source,
034   *    but don't need to publish the whole source of the own product.
035   * <li> You can study and modify (improve) this source
036   *    for own using or for redistribution, but you have to license the
037   *    modified sources likewise under this LGPL Lesser General Public License.
038   *    You mustn't delete this Copyright/Copyleft inscription in this source file.
039   * </ol>
040   * If you are intent to use this sources without publishing its usage, you can get
041   * a second license subscribing a special contract with the author. 
042   * 
043   * @author Hartmut Schorrig = hartmut@vishia.org
044   * 
045   */
046  public static final String sVersion = "2015-09-26";
047
048  final GralMng gralMng = GralMng.get();
049  
050  final GralWindow window;
051  
052  final GralPlotArea canvas;
053  
054  
055  public static GralPlotWindow create(String sTitle){
056    GralPlotWindow obj = new GralPlotWindow(sTitle);
057    obj.gralMng.gralDevice.addDispatchOrder(obj.initGraphic);
058    obj.initGraphic.awaitExecution(1, 0);
059    return obj;  
060  }
061
062  
063  GralPlotWindow(String sTitle)
064  { window = new GralWindow("10+120, 10+200", "window", sTitle, GralWindow.windResizeable);
065    canvas = new GralPlotArea("@0..0,0..0=canvas");
066    LogMessage log = new LogMessageStream(System.out);
067    window.create("SWT", 'B', log, initGraphic);
068    
069  }
070  
071  public void waitForClose(){
072    while(gralMng.gralDevice.isRunning()){
073      try{ Thread.sleep(100);} 
074      catch (InterruptedException e)
075      { //dialogZbnfConfigurator.terminate();
076      }
077    }
078
079  }
080  
081  
082  /**To use all methods of GralCanvasArea.
083   */
084  public GralPlotArea canvas(){ return canvas; }
085    
086    
087    
088  GralGraphicTimeOrder initGraphic = new GralGraphicTimeOrder("GralArea9Window.initGraphic"){
089    @Override public void executeOrder()
090    {
091      //canvas.createImplWidget_Gthread();      
092      //gralMng.addTextField();
093    } };
094
095  
096}