Package simtools.data

Examples of simtools.data.DataSourceCollection


    dscId = dscId.substring(marker.length());

    // Try to get data source from pool
    // If conflicts with other data source collections, consider the fisrt DataSourceCollectionAnimator
    DataSourceCollection existingDsc=null;
    if (pool != null){
      try {
        existingDsc = pool.getCollectionForDataSourceId(id);
      } catch (DuplicateIdException e) {
        //  Eliminates the collections that are not TimeStamped
        for (Iterator it = e.conflicts.iterator(); it.hasNext();) {
          DataSourceCollection d = (DataSourceCollection) it.next();
          if (!(d instanceof DataSourceCollectionAnimator)){
            it.remove();
            continue;
          }
        }
        if (e.conflicts.size() == 0)
          existingDsc = null;

        else if (e.conflicts.size() > 0)
          existingDsc = (DataSourceCollectionAnimator) e.conflicts.get(0);
      }
    }

    if ( (existingDsc!=null) &&  (existingDsc instanceof DataSourceCollectionAnimator)){
      if (chooseUseCollection(existingDsc, dscId, id)==YES_OPTION)
        return existingDsc.get(id);
    }


    // Otherwise create a new collection
    long period = ((Long)(((Object[])optionalInformation)[1])).longValue();
    boolean autostop = ((Boolean)(((Object[])optionalInformation)[2])).booleanValue();
    Object realOption = ((Object[])optionalInformation)[3];

    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);
          return emptyDs;
    }
   
    if (ds instanceof BufferedDataSource) ds = ((BufferedDataSource)ds).dataSource;
    if (!(ds instanceof CollectiveDataSource)) return null;
    DataSourceCollection dsc = ((CollectiveDataSource)ds).getCollection();
    int i = ((CollectiveDataSource)ds).getPosition();

    DataSourceCollectionAnimator dsca = new DataSourceCollectionAnimator(dsc);
    dsca.setPeriod(period);
    dsca.setAutoStop(autostop);
View Full Code Here


                  else{
                      add(ds, dataInfo.timeReference, dataInfo.isRelative, dataInfo.offset, dataInfo.initialDate);
                  }

              } else// merge all collection
                  DataSourceCollection dsc = SynchronousMergeDataSourceInformation.creationCollectionFromDataSource(ds);
                  if (dsc != null){
                      if (dsc instanceof TimeStampedDataSourceCollection){
                          add((TimeStampedDataSourceCollection)dsc, dataInfo.offset, dataInfo.initialDate);
                      }else{
                          add(dsc, dataInfo.timeReference,dataInfo.isRelative,  dataInfo.offset, dataInfo.initialDate);  
View Full Code Here

  public DataSource provide(String id, String dscId, Object optionalInformation, DataSourcePool pool){
    if ((id==null) || (dscId==null) || !(dscId.startsWith(JSAsynchronousMergeDSCollection.ID_MARKER) || dscId.startsWith(JSSynchronousMergeDSCollection.ID_MARKER)))
      return null;

    DataSource foundDS = null;
    DataSourceCollection adsc = null;
   
    MergeDataException.mergeDataErrors.clear();   // clear merge errors list
    try {
     
      if (dscId.startsWith(JSAsynchronousMergeDSCollection.ID_MARKER))
        adsc = new JSAsynchronousMergeDSCollection((AsynchronousMergeDSCollectionInformation)optionalInformation);
      else
        adsc = new JSSynchronousMergeDSCollection((SynchronousMergeDSCollectionInformation)optionalInformation);

      if ((adsc==null) || !(adsc instanceof DataSourceCollection)){
        return null;
      }
      for (int i = 0; i < adsc.size(); ++i) {
        if (id.equals( adsc.getInformation(i).id)) {
          foundDS = (DataSource) adsc.get(i);
          break;
        }
      }
    } catch (Exception e) {} 
View Full Code Here

                      add((TimeStampedDataSource)ds,  dataInfo.offset, dataInfo.initialDate);
                  else{
                      add(ds, dataInfo.timeReference, dataInfo.isRelative, dataInfo.offset, dataInfo.initialDate);
                  }
              }else// merge all collection
                  DataSourceCollection dsc = AsynchronousMergeDataSourceInformation.creationCollectionFromDataSource(ds);
                  if (dsc instanceof TimeStampedDataSourceCollection){
                      add((TimeStampedDataSourceCollection)dsc, dataInfo.offset, dataInfo.initialDate);
                  }else{

                      add(dsc, dataInfo.timeReference,  dataInfo.isRelative, dataInfo.offset,  dataInfo.initialDate)
View Full Code Here

    protected boolean processAsciiFile(File f, int action) {
        if (action != OPEN) {
            return false; // but should not happen
        }
        try {
            DataSourceCollection dsc;
            if ((optionPanel != null) && optionPanel.isSubSampled()) {
                dsc = new AsciiFileDataSourceCollection(f, (int) optionPanel.getSubSampleValue(), optionPanel
                        .getChartsetName(), f.getName().endsWith(".csv"));
            } else if (optionPanel != null) {
                dsc = new AsciiFileDataSourceCollection(f, optionPanel.getChartsetName(), f.getName().endsWith(".csv"));
            } else {
                dsc = new AsciiFileDataSourceCollection(f, f.getName().endsWith(".csv"));
            }
            if ((optionPanel != null) && optionPanel.isDynamic()) {
                DataSourceCollectionAnimator dsca = new DataSourceCollectionAnimator(dsc);
                dsca.bufferize(new DelayedBuffer(optionPanel.getBufferSize()));
                dsca.setPeriod(optionPanel.getDynamicRefreshValue());
                DataSourcePool.global.addDataSourceCollection(dsca);
            } else {
                dsc.bufferize(new ResizeableBuffer(resources.getIntValue("maxBufferSize")));
                DataSourcePool.global.addDataSourceCollection(dsc);
            }
        } catch (Exception e) {
            if (JSynoptic.gui == null) {
                _logger.severe(messageWriter.print1args("cannotLoadFile", f.getName()));
View Full Code Here

            notifyChange();
            return true;
        }
       
        if (action.equals(resources.getString("SetOneCellPerSource"))) {
            DataSourceCollection dsc = (DataSourceCollection) o;
            int cellSize = _h / cells.size();
            for (Iterator it = cells.iterator(); it.hasNext();) {
                TextShape ts = (TextShape) it.next();
                ts.setDelegateEndNotificationListener(ts); // remove ourselves
                // as listener
            }
            Vector newCells = new Vector();
            for (int i = 0; i < dsc.size(); ++i) {
                TextShape ts = new TextShape("", _w, cellSize);
                ts.setDelegateEndNotificationListener(this);
                ts.setSource((DataSource) dsc.get(i));
                newCells.add(ts);
            }
            cells = newCells;
            Rectangle bounds = getBounds();
            _h = cellSize * cells.size();
            _y = _h;
            positionCells();
            bounds.add(getBounds()); // enclose largest array to update()
            notifyChange(bounds);
            return true;
        }
       
        if (action.equals(resources.getString("CreateNewCellsForEachSource"))) {
            DataSourceCollection dsc = (DataSourceCollection) o;
            int cellSize = _h / cells.size();
            for (int i = 0; i < dsc.size(); ++i) {
                TextShape ts = new TextShape("", _w, cellSize);
                ts.setDelegateEndNotificationListener(this);
                ts.setSource((DataSource) dsc.get(i));
                cells.add(ts);
            }
            _h = cellSize * cells.size();
            _y = _h;
            positionCells();
View Full Code Here

   *  => same behaviour when loading an ascii file and an archive
   */
  public DataSource provide(String id, String dscId, Object optionalInformation, DataSourcePool pool) {
    DataSource ret = super.provide(id, dscId, optionalInformation, pool);
    if (pool!=null) {
      DataSourceCollection dsc = null;
      int index = -1;
      Set set = pool.dataSourceCollections();
      for (Iterator it = set.iterator(); it.hasNext(); ) {
        DataSourceCollection col = (DataSourceCollection)it.next();
        int idx = col.indexOf(ret);
        if (idx!=-1) {
          index = idx;
          dsc = col;
          break;
        }
View Full Code Here

                // data transformation
                boolean canTransformData = false;
                Set dataSourceCollections = DataSourcePool.global.dataSourceCollections();
                for(Iterator it=dataSourceCollections.iterator(); it.hasNext();){
                    DataSourceCollection dsc = (DataSourceCollection)it.next();
                    for (int j = 0; j < Run.plugins.size(); ++j) {
                        Plugin p = (Plugin) Run.plugins.get(j);
                        canTransformData |= p.processDataSourceCollection(dsc, actionType);
                    }
                }
View Full Code Here

            return res;
        }

        if (o instanceof DataSourceCollection) {
            DataSourceCollection dsc = (DataSourceCollection)o;
            if (action.equals(resources.getStringValue("setXY1Yn"))) {
                if (dsc.size()<1) return false;
                new LongAction(0, new Object[] {dsc,action}) {
                    protected void doAction() {
                        DataSourceCollection dsc = (DataSourceCollection)((Object[])param)[0];
                        setPrimaryX((DataSource)dsc.get(0), false);
                        boolean hasValues = axesLimitsArray[PY].validity;
                        axesLimitsArray[PY].validity = true; // compute only once all curve are inserted
                        for (int i=1; i<dsc.size()-1; i++)
                            addPrimaryY((DataSource)dsc.get(i), false);
                        axesLimitsArray[PY].validity = hasValues;
                        if (dsc.size()>1) addPrimaryY((DataSource)dsc.get(dsc.size()-1), false);
                        Rectangle bounds = getBounds();
                        setTitle(DataInfo.getLabel(dsc));
                        repaintDiagram(bounds);
                    }
                }.start();
                return false;
            }

            if (action.equals(resources.getStringValue("addY1Yn"))) {
                if (dsc.size()<1) return false;
                new LongAction(0, new Object[] {dsc,action}) {
                    protected void doAction() {
                        DataSourceCollection dsc = (DataSourceCollection)((Object[])param)[0];
                        boolean hasValues = axesLimitsArray[PY].validity;
                        axesLimitsArray[PY].validity = true; // compute only once all curve are inserted
                        for (int i=0; i<dsc.size()-1; i++)
                            addPrimaryY((DataSource)dsc.get(i), false);
                        axesLimitsArray[PY].validity = hasValues;
                        if (dsc.size()>0) addPrimaryY((DataSource)dsc.get(dsc.size()-1), false);
                        Rectangle bounds = getBounds();
                        repaintDiagram(bounds);
                    }
                }.start();
                return false;
            }

            if (action.equals(resources.getStringValue("addSecY1Yn"))) {
                if (dsc.size()<1) return false;
                new LongAction(0, new Object[] {dsc,action}) {
                    protected void doAction() {
                        DataSourceCollection dsc = (DataSourceCollection)((Object[])param)[0];
                        boolean hasValues = axesLimitsArray[SY].validity;
                        boolean hasLabel = (axesLimitsArray[SY].label!=null);
                        axesLimitsArray[SY].validity = true; // compute only once all curve are inserted
                        for (int i=0; i<dsc.size()-1; i++)
                            addSecondaryY((DataSource)dsc.get(i), false);
                        axesLimitsArray[SY].validity = hasValues;
                        if (dsc.size()>0) addSecondaryY((DataSource)dsc.get(dsc.size()-1), false);
                        Rectangle bounds = getBounds();
                        if ((!hasLabel) && (dsc.size()>1)) {axesLimitsArray[SY].label = null; setLegendVisible(true);}
                        repaintDiagram(bounds);
                    }
                }.start();
                return false;
            }

            if (action.equals(resources.getStringValue("setSecXY1Yn"))) {
                if (dsc.size()<1) return false;
                new LongAction(0, new Object[] {dsc,action}) {
                    protected void doAction() {
                        DataSourceCollection dsc = (DataSourceCollection)((Object[])param)[0];
                        setSecondaryX((DataSource)dsc.get(0), false);
                        boolean hasValues = axesLimitsArray[SY].validity;
                        boolean hasLabel = (axesLimitsArray[SY].label!=null);
                        axesLimitsArray[SY].validity = true; // compute only once all curve are inserted
                        for (int i=1; i<dsc.size()-1; i++)
                            addSecondaryY((DataSource)dsc.get(i), false);
                        axesLimitsArray[SY].validity = hasValues;
                        if (dsc.size()>1) addSecondaryY((DataSource)dsc.get(dsc.size()-1), false);
                        Rectangle bounds = getBounds();
                        if ((!hasLabel) && (dsc.size()>2)) {axesLimitsArray[SY].label = null; setLegendVisible(true);}
                        repaintDiagram(bounds);
                    }
                }.start();
                return false;
            }

            if (action.equals(resources.getStringValue("addSecY1YnForSecX"))) {
                if (dsc.size()<1) return false;
                new LongAction(0, new Object[] {dsc,action}) {
                    protected void doAction() {
                        DataSourceCollection dsc = (DataSourceCollection)((Object[])param)[0];
                        boolean hasValues = axesLimitsArray[SY].validity;
                        boolean hasLabel = (axesLimitsArray[SY].label!=null);
                        axesLimitsArray[SY].validity = true; // compute only once all curve are inserted
                        for (int i=0; i<dsc.size()-1; i++)
                            addSecondaryYForSecondaryX((DataSource)dsc.get(i), false);
                        axesLimitsArray[SY].validity = hasValues;
                        if (dsc.size()>0) addSecondaryYForSecondaryX((DataSource)dsc.get(dsc.size()-1), false);
                        Rectangle bounds = getBounds();
                        if ((!hasLabel) && (dsc.size()>1)) {axesLimitsArray[SY].label = null; setLegendVisible(true);}
                        repaintDiagram(bounds);
                    }
                }.start();
                return false;
            }
View Full Code Here

   */
  public DataSource provide(String id, String dscId, Object optionalInformation, DataSourcePool pool){
    if ((id == null) || (dscId == null) || (!dscId.startsWith(marker)))
      return null;
   
    DataSourceCollection existingDsc = null;
    if (pool != null){
      try {
        existingDsc = pool.getCollectionForDataSourceId(id);
      } catch (DuplicateIdException e) {
        if (e.conflicts.size() == 0)
          existingDsc = null;
        else if (e.conflicts.size() > 0)
          existingDsc = (DataSourceCollection) e.conflicts.get(0);
      }
    }
    if (existingDsc instanceof DataSourceCollection){
      if (chooseUseCollection(existingDsc, dscId, id)==YES_OPTION)
        return existingDsc.get(id);
    }

    // Check if an empty data source shall be returned
    if (EmptyDataSourcePool.global.containsEmptyCollection(dscId)){
      DataSource emptyDs;
      if ((emptyDs = (DataSource)EmptyDataSourcePool.global.getEmptyDataSource(id))==null){
        emptyDs = createEmptyDatasource(id, dscId, optionalInformation);
        EmptyDataSourcePool.global.addEmptyDaSource(id, (EmptyDataSource)emptyDs);
      }
      if (emptyDs!=null)
        return emptyDs; 
    }
    DataSource foundDS = null;
    DataSourceCollection adsc = null;
    String fileName = dscId.substring(marker.length());
    do {
      File f = chooseFile(fileName, id);
      if ( (f != null) && (f.exists()) ){
        try {
          adsc = createCollection(f,optionalInformation);
          if ((adsc==null) || !(adsc instanceof DataSourceCollection)){
            return null;
          }
          for (int i = 0; i < adsc.size(); ++i) {
            if (id.equals( adsc.getInformation(i).id)) {
              foundDS = (DataSource) adsc.get(i);
              break;
            }
          }
        } catch (Exception e) {} 
      }
View Full Code Here

TOP

Related Classes of simtools.data.DataSourceCollection

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.