/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.autoplot.html; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import org.das2.datum.Datum; import org.das2.datum.Units; import org.das2.util.monitor.ProgressMonitor; import org.das2.qds.QDataSet; import org.das2.qds.SemanticOps; import org.autoplot.datasource.AbstractDataSourceFormat; /** * * @author jbf */ public class HtmlTableFormat extends AbstractDataSourceFormat { @Override public void formatData(String uri, QDataSet data, ProgressMonitor mon) throws Exception { if ( data.rank()==2 ) { formatDataRank2( uri, data, mon ); } else if ( data.rank()==1 ) { formatDataRank1( uri, data, mon ); } } public void formatDataRank2(String uri, QDataSet data, ProgressMonitor mon) throws Exception { setUri(uri); maybeMkdirs(); File f= new File( getResourceURI() ); try (BufferedWriter w = new BufferedWriter( new FileWriter(f) )) { QDataSet bds= (QDataSet) data.property(QDataSet.BUNDLE_1); w.write("
"); u= SemanticOps.getUnits(dep0); String h= (String)dep0.property(QDataSet.LABEL); if ( h!=null ) { w.append(h); } if ( u!=Units.dimensionless ){ w.append("("); w.append(u.toString()); w.append(")"); } w.append(" | \n"); w.append(""); u= SemanticOps.getUnits(data); h= (String)data.property(QDataSet.LABEL); if ( h!=null ) { w.append(h); } if ( u!=Units.dimensionless ){ w.append("("); w.append(u.toString()); w.append(")"); } w.append(" | "); w.append("\n"); for ( int i=0; i"); u= SemanticOps.getUnits(dep0); if ( u==null ) u= Units.dimensionless; d= u.createDatum(dep0.value(i)); b.append( d.getFormatter().format(d,u) ); b.append(" | "); b.append(""); u= SemanticOps.getUnits(data); d= u.createDatum(data.value(i)); b.append( d.getFormatter().format(d,u) ); b.append(" | "); b.append("\n"); w.write( b.toString() ); } w.write("
---|