// Copyright 2004, FreeHEP.
package hep.graphics.heprep1.adapter;

import java.util.*;

import hep.graphics.heprep.HepRepInstance;
import hep.graphics.heprep.HepRepInstanceTree;
import hep.graphics.heprep.HepRepPoint;
import hep.graphics.heprep.HepRepSelectFilter;
import hep.graphics.heprep.HepRepType;
import hep.graphics.heprep.HepRepTypeTree;

/**
 *
 * @author Mark Donszelmann
 * @version $Id: HepRepInstanceFromInstanceAdapter.java,v 1.3 2004/07/27 21:40:27 duns Exp $
 */
public class HepRepInstanceFromInstanceAdapter extends AbstractHepRepInstanceAdapter {

    private hep.graphics.heprep1.HepRepInstance instance1;
    private List instances;
    private List points;

    public HepRepInstanceFromInstanceAdapter(hep.graphics.heprep1.HepRepInstance instance1,
                                             HepRepInstance parent,
                                             HepRepType type) {
        super(instance1, parent, type);
        this.instance1 = instance1;

        HepRepAdapterFactory factory = HepRepAdapterFactory.getFactory();        
        instances = new ArrayList();
        // types
        for (Enumeration e=instance1.getTypes(); e.hasMoreElements(); ) {
            hep.graphics.heprep1.HepRepType type1 = (hep.graphics.heprep1.HepRepType)e.nextElement();
            type.addType(factory.createHepRepType(type1, type, this));
        }
        // primitives
        for (Enumeration e=instance1.getPrimitives(); e.hasMoreElements(); ) {
            hep.graphics.heprep1.HepRepPrimitive primitive1 = (hep.graphics.heprep1.HepRepPrimitive)e.nextElement();
            instances.add(factory.createHepRepInstance(null, primitive1, this, type));
        }
        // points
        points = new ArrayList();
        for (Enumeration e=instance1.getPoints(); e.hasMoreElements(); ) {
            points.add(factory.createHepRepPoint((hep.graphics.heprep1.HepRepPoint)e.nextElement(), this));
        }
    }
    
    public List/*<HepRepInstance>*/ getInstances() {
        return instances;
    }
        
    public List/*<HepRepPoint>*/ getPoints() {
        return points;
    }    
}
