Package simtools.data

Examples of simtools.data.DataSource


        // disable invalid operations
        if(dsc instanceof MergeDSCollection){
            throw new MergeDataException(DataInfo.getId(dsc) + " is already a merge of collection");
       

        DataSource addedDs=null;

        // 1 - Update merged time
        if (timeDs.sortedOrder() != 1) {
            throw new MergeDataException("Cannot add " + DataInfo.getId(dsc) + " because its time reference is not sorted");
        }
View Full Code Here


    public void add(DataSource ds, DataSource timeDs, boolean isRelative, double offset,  double initialDate) throws MergeDataException{
        if ( (ds==null) || (timeDs==null)) {
            throw new MergeDataException("Null argument when merging data");
        }

        DataSource addedDs=null;
        String id = DataInfo.getId(ds);

        if (get(id)!=null){    // if data source name already exists then add collection name as a suffix
            String name ="";
            if (ds instanceof CollectiveDataSource){
View Full Code Here

            }
           

            // 2. Allocate all other elements buffer
            for(int i=1;i<size();i++){
                DataSource ds = (DataSource)get(i);
               
                if (ds instanceof DirectSynchronousMergedDataSource){
                    try {
                        ((DirectSynchronousMergedDataSource)ds).updateDirectBuffer();
                  
View Full Code Here

            Hashtable newRepositories = new Hashtable();
            ArrayList dataList = new ArrayList(repertory.getChildren());
            for (Iterator iter = repertory.getChildren().iterator(); iter.hasNext(); ) {
                o = iter.next();
                if (o instanceof DataSource){
                    DataSource d = (DataSource)o;
                    String dsName = ((d.getInformation().id));
                    String repName = dsName.substring(dsName.indexOf(".")+1);

                    for(int i =0;i<proof-1;i++){
                        repName = repName.substring(repName.indexOf(".")+1);
                    }
View Full Code Here

                    if (o==null) return;
                    if (!(o instanceof SourceTemplate)) return;
                    SourceTemplate t = (SourceTemplate)o;
                   
                    // Ask the plugin to create the source
                    DataSource ds = t.plugin.createSource(t.template, name);
                    if (ds==null) return;
                   
                    // Add the source to the panel
                    DataSourcePool.global.addDataSource(ds);
                    ExpressionPanel.this.sourceTree.setSelectedValue(ds);
                    return;
                }
               
                String exp = tfExpression.getText();
                if ((name == null) || name.equals("")) {
                    JOptionPane.showMessageDialog(JSynoptic.gui.getOwner(),resources.getString("PleaseEnterNewSourceName"),resources.getString("Error"),JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if ((exp == null) || exp.equals("")) {
                    JOptionPane.showMessageDialog(JSynoptic.gui.getOwner(),resources.getString("PleaseEnterAMathematicalExpression"),resources.getString("Error"),JOptionPane.ERROR_MESSAGE);
                    return;
                }
                ExpressionNode node = null;
                try {
                    ExpressionParser ep = new ExpressionParser(exp);
                    // Add the data sources as variables
                    // start by looping through collections
                    Set collections = DataSourcePool.global.dataSourceCollections();
                    for (Iterator it = collections.iterator(); it.hasNext(); ) {
                        Collection c = (Collection)it.next();
                        for (Iterator it2 = c.iterator(); it2.hasNext();) addVariable(ep, it2.next());
                    }
                    // also add sources
                    Set sources = DataSourcePool.global.dataSources();
                    for (Iterator it = sources.iterator(); it.hasNext();) addVariable(ep, it.next());
                    // Add known plugins => may bring in more mathematical functions
                    for (Iterator it = Run.plugins.iterator(); it.hasNext();) ep.addClass(it.next().getClass());
                    node = ep.parse();
                } catch (ParseException pe) {
                    // Also catches duplicate variable names
                    JOptionPane.showMessageDialog(JSynoptic.gui.getOwner(),pe.getLocalizedMessage(),resources.getString("InvalidExpression"),JOptionPane.ERROR_MESSAGE);
                    return;
                } catch (Error err) {
                    JOptionPane.showMessageDialog(JSynoptic.gui.getOwner(),err.getLocalizedMessage(),resources.getString("InvalidExpression"),JOptionPane.ERROR_MESSAGE);
                    return;
                }
                // Now we have a correct node, ready to evaluate()
                // Create a data source
                boolean newSource = true;
                // Check if the source exists, and in this case change the expression on the fly
                for (Iterator it = DataSourcePool.global.dataSources().iterator(); it.hasNext(); ) {
                    Object o = it.next();
                    if (!(o instanceof ExpressionDataSource)) continue;
                    ExpressionDataSource ds = (ExpressionDataSource)o;
                    if (name.equals(DataInfo.getLabel(ds)) || name.equals(DataInfo.getAlias(ds))) {
                        ds.changeExpression(exp, node);
                        newSource = false;
                        ExpressionPanel.this.sourceTree.setSelectedValue(ds);
                        TreeNode tn = (TreeNode)(ExpressionPanel.this.sourceTree.getSelectionPath().getLastPathComponent());
                        ((DefaultTreeModel)(ExpressionPanel.this.sourceTree.getModel())).nodeChanged(tn);
                        break;
View Full Code Here

        if (pool == null) {
            poolToSearch = DataSourcePool.global;
        }
        // Do not add the result in the datapool yet, but rather add this object
        // on success
        DataSource ds = poolToSearch.provide(id, dscId, realOption, false);
        if (ds == null) {
            return null;
        }
        if (ds instanceof EmptyDataSource) {
            DefaultEmptyDataSource emptyDs = new DefaultEmptyDataSource(id, simtools.data.DataSourceAnimator.MARKER
View Full Code Here

            res = (ColorMapper)dynamicColorPanel.getPropertyValue(DynamicColorPanel.DYNAMIC_COLOR_MAPPER);
            return res;
        }

        protected DataSource getDynamicColorDataSource(){
            DataSource res = null;
                res = (DataSource)dynamicColorPanel.getPropertyValue(DynamicColorPanel.DYNAMIC_COLOR_SOURCE);
            return res;
        }
View Full Code Here

        PiePlot plot = (PiePlot)chart.getPlot();
        SourcePieDataset dst = (SourcePieDataset)plot.getDataset();
        dst.setDataSourceCollection((DataSourceCollection)o);
        chart.setTitle(dst.getName());
        for (int i=0; i<mappers.size(); ++i) {
          DataSource ds = (DataSource)mapperSources.get(i);
          if (ds!=null) ds.removeListener(this);
          ColorMapper cm = (ColorMapper)mappers.get(i);
          if (cm!=null) cm.removeListener(this);
        }
        for (int i=0; i<((DataSourceCollection)o).size(); ++i) {
          mappers.add(null); mapperSources.add(null); // no mapper by default
View Full Code Here

  private void readObject(java.io.ObjectInputStream in) throws java.lang.ClassNotFoundException, java.io.IOException {
    in.defaultReadObject();
    mapperSources = new Vector();
    int n =in.readInt();
    for (int i=0; i<n; ++i) {
        DataSource ds = DataSourcePool.global.readDataSource(in);
      mapperSources.add(ds);
      if (ds!=null) {
          ds.addListener(this);
          ds.addEndNotificationListener(this);
      }
    }
  }
View Full Code Here

    DataSourcePool poolToSearch = pool;
    if (pool==null) poolToSearch=DataSourcePool.global;

    // Do not add the result in the datapool yet, but rather add this object on success
    DataSource ds = poolToSearch.provide(id,dscId,realOption,false);
    if (ds==null) return null;

    if (ds instanceof EmptyDataSource){
      DefaultEmptyDataSource emptyDs = new DefaultEmptyDataSource(id, marker + dscId, optionalInformation);
      EmptyDataSourcePool.global.addEmptyDaSource(id, emptyDs);
View Full Code Here

TOP

Related Classes of simtools.data.DataSource

Copyright © 2018 www.massapicom. 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.