Package jsynoptic.plugins.merge

Source Code of jsynoptic.plugins.merge.JSMergeCollectionPlugin$TestMergedCollection2

/* ========================
* JSynoptic : a free Synoptic editor
* ========================
*
* Project Info:  http://jsynoptic.sourceforge.net/index.html
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* (C) Copyright 2001-2004, by :
*     Corporate:
*         EADS Astrium SAS
*         EADS CRC
*     Individual:
*        Ronan Ogor
*
* $Id: JSMergeCollectionPlugin.java,v 1.3 2008/10/06 11:08:01 ogor Exp $
*
* Changes
* -------
* 25 jan. 2005 : Initial public rel  ease (CC);
*
*/

package jsynoptic.plugins.merge;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Logger;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import jsynoptic.base.Plugin;
import jsynoptic.plugins.merge.ui.MCWizardManager;
import jsynoptic.ui.JSynoptic;
import simtools.data.DataInfo;
import simtools.data.DataSourcePool;
import simtools.data.DynamicDataSourceCollection;
import simtools.data.UnsupportedOperation;
import simtools.data.ValueProvider;
import simtools.data.async.AsynchronousMergeDSCollection;
import simtools.data.buffer.DelayedBuffer;
import simtools.data.merge.SynchronousMergeDSCollection;
import simtools.ui.MenuResourceBundle;
import simtools.ui.ResourceFinder;
import simtools.ui.WizardDisplayer;

/**
* @author ogor
*/
public class JSMergeCollectionPlugin extends Plugin implements ActionListener{
 
  /**
   * A looger to dump error or warning messages in a soket, an output stream, a file...
   */
  static Logger _logger = simtools.util.LogConfigurator.getLogger(JSMergeCollectionPlugin.class.getName());

  protected JMenuItem mergeItem;
  public static MenuResourceBundle resources =  ResourceFinder.getMenu(JSMergeCollectionPlugin.class);
 
  public static int numberOfMergeCollection=0;
 
 
  public JSMergeCollectionPlugin() {
    DataSourcePool.global.addProvider(new JSMergeDSCollectionProvider());
  }
   
  public void actionPerformed(ActionEvent e){
    if (e.getSource()== mergeItem){
      MCWizardManager wizardManager = new MCWizardManager();
      new WizardDisplayer(JSynoptic.gui.getOwner(), resources.getString("createMergeCollectionWizard"), wizardManager).show();
    }
  }
 
  /**
   *
   * @return the default name used for a next merged collection
   */
  public static String getADefaultName(){
    return resources.getString("mergeCollection") (numberOfMergeCollection+1);
  }

 

  /** Adds a menu entry in the tools menu */
 
  public void setMenu(JMenuBar mb) {
    Component c[] = mb.getComponents();
    JMenu jm =null;
    boolean found=false;
   
    for (int i=0; i<c.length; ++i) {
      jm = (JMenu)c[i];
      if (jm.getText().equals(resources.getString("data"))) {
        found=true;
        break;
      }
    }
    if (!found){
      jm = new JMenu(resources.getString("data"));
      mb.add(jm);
    }
    mergeItem= new JMenuItem(resources.getString("merge"));
    mergeItem.setIcon(resources.getIcon("mergeDataImage"));
   
    mergeItem.addActionListener(this);
    jm.add(mergeItem);
  }
 
  public Object[][] getDataSourceIcons() {

    Object[][] ret = new Object[4][2];
    ret[0][0] = SynchronousMergeDSCollection.class;
    ret[0][1] = resources.getIcon("synchronousMergeCollection");
   
    ret[1][0] = SynchronousMergeDSCollection.DirectSynchronousMergedDataSource.class;
    ret[1][1] = resources.getIcon("synchronousMergeDataSource");

    ret[2][0] = AsynchronousMergeDSCollection.class;
    ret[2][1] = resources.getIcon("asynchronousMergeCollection");
 
    ret[3][0] = AsynchronousMergeDSCollection.AsynchronousMergeDataSource.class;
    ret[3][1] = resources.getIcon("asynchronousMergeDataSource");
    return ret;
  }
 
  public String about() {
    return resources.getString("about");
  }

 
  public class TestMergedCollection1 extends DynamicDataSourceCollection{

    public TestMergedCollection1(){
      for(int i=0;i<2;i++){
        createDataSource(new DataInfo("source " + i), ValueProvider.DoubleProvider);
       
        // Wrap a buffer around it so we see past values too
        try {
          bufferize(i, new DelayedBuffer(ValueProvider.DoubleProvider, 100));
        } catch (UnsupportedOperation e) {
          e.printStackTrace();
        }
      }
     
      // 10 echantillons -
      for(int j=0;j<10;j++){
          setDoubleValue(0, 120 + j); // time
          setDoubleValue(1, j); // value
        registerNewValues();
      }
    }
   
    public DataInfo getInformation(){
      return new DataInfo("test merged 1");
    }
  }
 
 
  public class TestMergedCollection2 extends DynamicDataSourceCollection{

    public TestMergedCollection2(){
      for(int i=0;i<2;i++){
        createDataSource(new DataInfo("source " + i), ValueProvider.DoubleProvider);
       
        // Wrap a buffer around it so we see past values too
        try {
          bufferize(i, new DelayedBuffer(ValueProvider.DoubleProvider, 100));
        } catch (UnsupportedOperation e) {
          e.printStackTrace();
        }
      }
     
      // 10 echantillons
      for(int j=0;j<10;j++){
       
          setDoubleValue(0, 120 + j); // time
          setDoubleValue(1, j); // value
         
        registerNewValues();
       
      }
    }
   
    public DataInfo getInformation(){
      return new DataInfo("test merged 2");
    }
  }
}

TOP

Related Classes of jsynoptic.plugins.merge.JSMergeCollectionPlugin$TestMergedCollection2

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.