/* * AppendTableDataSet.java * * Created on September 27, 2005, 2:12 PM * * */ package org.das2.dataset; import java.util.ArrayList; import java.util.List; /** * * @author Jeremy */ public class AppendTableDataSet implements TableDataSet { TableDataSet[] tableDataSets; int[] firstIndexs; int[] firstTables; public AppendTableDataSet( TableDataSet tds1, TableDataSet tds2 ) { List tableDataSetsList= new ArrayList(); List firstIndexsList= new ArrayList(); List firstTablesList= new ArrayList(); if ( tds1 instanceof AppendTableDataSet && tds2 instanceof AppendTableDataSet ) { throw new IllegalStateException("not implemented"); } else if ( tds1 instanceof AppendTableDataSet ) { AppendTableDataSet atds1= (AppendTableDataSet)tds1; tableDataSetsList.addAll( box( atds1.tableDataSets ) ); firstIndexsList.addAll( box( atds1.firstIndexs ) ); firstTablesList.addAll( box( atds1.firstTables ) ); tableDataSetsList.add( tds2 ); firstIndexsList.add( Integer.valueOf( atds1.firstIndexs[atds1.tableDataSets.length]+tds2.getXLength() ) ); firstTablesList.add( Integer.valueOf( atds1.firstTables[atds1.tableDataSets.length]+tds2.getXLength() ) ); tableDataSets= (TableDataSet[])tableDataSetsList.toArray( new TableDataSet[ tableDataSetsList.size() ] ); firstIndexs= unbox( firstIndexsList ); firstTables= unbox( firstTablesList ); } else if ( tds2 instanceof AppendTableDataSet ) { throw new IllegalStateException("not implemented"); } else { tableDataSets= new TableDataSet[2]; tableDataSets[0]= tds1; tableDataSets[1]= tds2; firstIndexs= new int[3]; firstIndexs[0]= 0; firstIndexs[1]= tds1.getXLength(); firstIndexs[2]= firstIndexs[1] + tds2.getXLength(); firstTables= new int[3]; firstTables[0]= 0; firstTables[1]= tds1.tableCount(); firstTables[2]= firstTables[1] + tds2.tableCount(); } } private int[] unbox( List intList ) { int[] result= new int[intList.size()]; for ( int i=0; i=i ) return itds; } return firstIndexs.length-1; } private int tdsTable( int itable ) { for ( int itds=0; itds=itable ) return itds; } return firstIndexs.length-1; } public org.das2.datum.Datum getDatum(int i, int j) { int itds= tdsIndex(i); return tableDataSets[itds].getDatum( i-firstIndexs[itds], j ); } public double getDouble(int i, int j, org.das2.datum.Units units) { int itds= tdsIndex(i); return tableDataSets[itds].getDouble( i-firstIndexs[itds], j, units ); } public double[] getDoubleScan(int i, org.das2.datum.Units units) { int itds= tdsIndex(i); return tableDataSets[itds].getDoubleScan( i-firstIndexs[itds], units ); } public int getInt(int i, int j, org.das2.datum.Units units) { int itds= tdsIndex(i); return tableDataSets[itds].getInt( i-firstIndexs[itds], j, units ); } public DataSet getPlanarView(String planeID) { TableDataSet[] tdsPlane= new TableDataSet[tableDataSets.length]; for ( int i=0; i