package hep.aida.ref.histogram;

import hep.aida.IAxis;
import hep.aida.ICloud1D;
import hep.aida.ICloud2D;
import hep.aida.ICloud3D;
import hep.aida.IDataPoint;
import hep.aida.IDataPointSet;
import hep.aida.IDataPointSetFactory;
import hep.aida.IHistogram1D;
import hep.aida.IHistogram2D;
import hep.aida.IHistogram3D;
import hep.aida.IProfile1D;
import hep.aida.IProfile2D;
import hep.aida.ITree;
import hep.aida.ref.AidaUtils;
import hep.aida.ref.tree.Tree;

/**
 * Basic user-level interface for creating a factory
 * of IDataPointSet.
 *
 * @author The AIDA team @ SLAC.
 *
 */
public class DataPointSetFactory implements IDataPointSetFactory {

    private Tree tree;
    
    private String nameInPath( String path ) {
        return AidaUtils.parseName(path);
    }
    
    private String parentPath( String path ) {
        return AidaUtils.parseDirName(path);
    }

  /**
   * Create an IDataPointSetFactory.
   * @param t The ITree which created IDataPointSet will be associated to.
   * @throws     IllegalArgumentException if tree is null.
   */
    public DataPointSetFactory(ITree t) {
	this.tree = null;
	if (t instanceof hep.aida.ref.tree.Tree) this.tree = (hep.aida.ref.tree.Tree) t;
    }

    public DataPointSetFactory() { this.tree = null; }

    public IDataPointSet create(String path, String title, int dimOfPoints) {
        return create(path, title, dimOfPoints, null);
    }
    public IDataPointSet create(String path, String title, int dimOfPoints, String options) {
	DataPointSet set =  new DataPointSet(nameInPath(path), title, dimOfPoints, options);
	if (tree != null) tree.addFromFactory( parentPath(path),set);
	return set;
    }

    public IDataPointSet create(String pathAndTitle, int dimOfPoints, String options) {
	return  create(pathAndTitle, nameInPath(pathAndTitle), dimOfPoints, options);
    }

    public IDataPointSet create(String pathAndTitle, int dimOfPoints) {
	return  create(pathAndTitle, nameInPath(pathAndTitle), dimOfPoints);
    }

    public IDataPointSet createCopy(String path, IDataPointSet dataPointSet) {
	int dimension = dataPointSet.dimension();
	int size = dataPointSet.size();
	DataPointSet set = new DataPointSet(nameInPath(path), dataPointSet.title(), dimension, size);
	for (int i=0; i 

Ads help maintain this website.