<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package usda.weru.util;

// import the necessary java classes, including the Table package
import java.awt.*;
import java.util.*;
import javax.swing.*;

import java.text.NumberFormat;

//import java.awt.event.ActionListener;
import java.awt.event.*;
import com.klg.jclass.util.swing.JCExitFrame;
import com.klg.jclass.table.*;
//import com.klg.jclass.table.data.JCVectorDataSource;
import com.klg.jclass.table.data.JCEditableVectorDataSource;
import com.klg.jclass.field.cell.JCTextFieldCellEditor;
import de.schlichtherle.truezip.file.TFile;
import de.schlichtherle.truezip.file.TFileReader;
import java.beans.*;

import java.io.BufferedReader;
import java.io.IOException;
import usda.weru.util.wepsFileChooser2.WepsFileChooser2;
import usda.weru.util.wepsFileChooser2.WepsFileTypes2;
import usda.weru.weps.*;

/**
 * Simple LiveTable example.  Creates a simple table using a JCVectorDataSource.
 */
public class SimpleTable extends JPanel implements ActionListener, JCPrintListener, PropertyChangeListener {

    private static final long serialVersionUID = 1L;

    /**
     * initialize the Table object
     */
    protected ToolTipsTable jctable;
    private JCEditableVectorDataSource dataSource;
    private int hdrRows;
    private int bodRows;
    private int hdrCols = 4;

    /**
     *
     */
    protected Vector&lt;String&gt; repVec = new Vector&lt;&gt;();

    /**
     *
     */
    public Vector&lt;String&gt; repTitleVec = new Vector&lt;&gt;();
    private String repColFmt = "";
    private String repRowFmt = "";

    /**
     *
     */
    protected String[][] tableData = null;
    //private final Vector spanVec = new Vector();
    private final Vector&lt;String&gt; cfgVec = new Vector&lt;&gt;();
//private Vector inpVec;
    private String runDir = "";
    private double regionAngle = 0.0;
    private int cntcol;
    private String[] headerNames;
    private boolean vecFlag = true;

    /**
     *
     */
    protected Hashtable&lt;String, String&gt; ht = null;
// Build the table, point to the data source and define the table
// properties.
//public Table(record inprec, int gridType, boolean fixedFlag)

    /**
     *
     * @param args
     */
    static public void main(String args[]) {

        de.schlichtherle.truezip.file.TFile sf = null;
        String runDir = "";
        //String units = Util.SIUnits;
        WepsFileChooser2 wfc;
        RunFileData rfd = new RunFileData();
        if (args.length == 0 || !args[0].endsWith(RunFileData.RunSuffix)) {

            if (args.length == 0) {
                //System.out.println("PS_m: arg.length == 0");
                wfc = new WepsFileChooser2(WepsFileTypes2.Run, ".",
                        WepsFileChooser2.Action.Select);
                wfc.setCurrentDirectory(new de.schlichtherle.truezip.file.TFile("."));
            } else {
                //System.out.println("PS_m: " + args[0]);
                wfc = new WepsFileChooser2(WepsFileTypes2.Run, args[0],
                        WepsFileChooser2.Action.Select);
                wfc.setCurrentDirectory(new de.schlichtherle.truezip.file.TFile(args[0]));
            }
            if (wfc.showDialog(null) == WepsFileChooser2.APPROVE_OPTION) {
                sf = new TFile(wfc.getSelectedFile());
                try {
                    runDir = sf.getCanonicalPath();
                } catch (java.io.IOException e) {
                    System.err.println(
                            "Error getting canoncial path of runDir");
                }
                rfd.readRunFile(runDir);
                rfd.showRunFileData("this is a test");
            } else {
                System.err.println("No project directory selected");
                return;
            }
        } else {
            runDir = args[0];
            if ((new TFile(runDir)).exists()) {
                rfd.readRunFile(runDir);
            } else {
                System.err.println("CS_m : current run does not exist " + runDir);
                return;
            }
        }

        JCExitFrame f = new JCExitFrame("Test Report");
        SimpleTable tab = null;
        if (args.length == 2) {
            tab = new SimpleTable(runDir, "cfg", args[1], rfd);
        } else {
            tab = new SimpleTable(runDir, "cfg", rfd);
        }

        f.getContentPane().add(tab);
        f.setSize(600, 400);
        f.setVisible(true);

    }

    /*********************************************************************** wjr */
    public SimpleTable() {
        super();
    }

    /*********************************************************************** wjr
     * @param runDir
     * @param rfd
     * @param configDir */
    public SimpleTable(String runDir, String configDir, RunFileData rfd) {
        this(runDir, configDir, Util.SIUnits, rfd);
    }

    /*********************************************************************** wjr
     * @param runDir
     * @param rfd
     * @param configDir
     * @param units */
    public SimpleTable(String runDir, String configDir, String units, RunFileData rfd) {
        this(runDir, configDir, units, rfd, false);
    }

    /**
     *
     * @param runDir
     * @param configDir
     * @param units
     * @param rfd
     * @param print
     */
    public SimpleTable(String runDir, String configDir, String units, RunFileData rfd, boolean print) {
        rfd.addPropertyChangeListener(this);
        rfd.fireAll(this);

        //System.out.println("T_T: enter " + units);
        this.runDir = runDir;

        if (print) {
            ht = readConfig(configDir, "gui_print_data.cfg");
        } else {
            ht = readConfig(configDir);
        }
        String[][] headerRows = parseHeaders(ht, units);
        readReports(configDir, repVec, ht);
        setFrozenColumns(ht);

        hdrRows = headerRows.length;
        String[][] bodyRows = readData(runDir, ht, units);
        bodRows = bodyRows.length;
        
        tableData = new String[hdrRows + bodRows][];
        int jdx;
        for (jdx = 0; jdx &lt; hdrRows; jdx++) {
            tableData[jdx] = headerRows[jdx];
        }
        for (; jdx &lt; hdrRows + bodRows; jdx++) {
            tableData[jdx] = bodyRows[jdx - hdrRows];        // check data integrity
        }
        for (jdx = 0; jdx &lt; hdrRows + bodRows; jdx++) {
            if (tableData[0].length != tableData[jdx].length) {
                System.err.println("T: # of columns in row " + jdx + " "
                        + tableData[jdx].length + " is in error");
                System.err.println("T: # of columns in row should be "
                        + tableData[0].length);
            }
        }

        // find dimensions for data table
        int cntrow = hdrRows + bodRows;
        cntcol = tableData[cntrow - 1].length;

        int[] columnWidths = getColumnWidths(cntcol, ht);

        setLayout(new java.awt.GridLayout());
        // Create table object
        jctable = new ToolTipsTable("RepDetailPanel", new TFile("cfg", "reportstooltips.cfg"));
        ToolTipManager.sharedInstance().registerComponent(jctable);

        // Create a vector data source to contain our data
        dataSource = new JCEditableVectorDataSource();

        jctable.setColumnLabelDisplay(false);
        jctable.setRowLabelDisplay(false);
        jctable.setDataSource(dataSource);

        dataSource.setNumRows(cntrow);
        dataSource.setNumColumns(cntcol);

        convertDates(tableData, hdrRows);
        setLimits(tableData, hdrRows, cntcol);

        formatCells(jctable, hdrRows, cntrow, cntcol);
        jctable.setPixelHeight(JCTableEnum.ALLCELLS, JCTableEnum.VARIABLE);	// test
        setColumnStyles(ht, jctable, hdrRows, cntrow, cntcol);

        dataSource.setCells(tableData);

        String[] labels = tableData[hdrRows];
        for (String label : labels) {
            //System.out.print(" " + labels[idx]);
        }
        //System.out.println();
        jctable.setLabels(labels);

        jctable.setDoubleBuffered(true);

        /*		jctable.setFont(JCTableEnum.ALL, JCTableEnum.ALL, new Font("Times Roman", 0, 9));
         jctable.setFont(new Font("Times Roman", 0, 20));*/
////System.out.print("sCW: start");
        setColumnWidths(columnWidths);
////System.out.print("sCW: end");
        hideRows(tableData, "YTP", hdrRows);				// test value
////System.out.println("T_T: ");
        makeSpan(tableData, hdrRows, jctable);
        updateSpans(hdrRows);
        loadImages();
        //	addToolTips();

        colorRows(ht, hdrRows, hdrCols, cntcol);

        this.add(jctable);

        rfd.fireAll(this);
    }

    /*********************************************************************** wjr */
    /**
     * test routine to see if loading data is fast (it is)
     */
    void loadData(int hdrRows) {
////System.out.println("lD: start");
        for (int rdx = hdrRows; rdx &lt; tableData.length; rdx++) {
            for (int cdx = 0; cdx &lt; tableData[rdx].length; cdx++) {
                dataSource.setTableDataItem(tableData[rdx][cdx], rdx, cdx);
                if (tableData[rdx][cdx].equals("0.0000")) {
                    dataSource.setTableDataItem("none", rdx, cdx);
                }
            }
        }
////System.out.println("lD: end");
    }

    /**
     *
     * @param b
     */
    public void commitEdit(boolean b) {
        jctable.commitEdit(b);
    }

    /*********************************************************************** wjr */
    /**
     * test routine to see if loading data is fast (it is)
     */
    void updateSpans(int hdrRows) {

////System.out.println("T_uS: hdrRows=" + hdrRows);
        String lastHeader = "";
        for (int rdx = 0; rdx &lt; hdrRows; rdx++) {
////System.out.println("T_uS: hdrCols=" + tableData[rdx].length);
            for (int cdx = 0; cdx &lt; tableData[rdx].length; cdx++) {
                if (tableData[rdx][cdx].equals("~*R")) {
                    dataSource.setTableDataItem(lastHeader, rdx, cdx);
////System.out.println("T_uS: " + lastHeader);
                } else {
                    lastHeader = tableData[rdx][cdx];
                }
            }
        }
//		//System.out.println("lD: end");
    }

    /*********************************************************************** wjr */
    void formatCells(JCTable jctable, int hdrRows, int cntrow, int cntcol) {
////System.out.println("fC: start");
        jctable.setHorizSBPosition(JCTableEnum.ATTACH_SIDE);
        jctable.setVertSBPosition(JCTableEnum.ATTACH_SIDE);
        JCCellStyle cs = new JCCellStyle();
        cs.setBackground(new Color(255, 255, 210));
        cs.setForeground(Color.black);
        cs.setHorizontalAlignment(JCTableEnum.RIGHT);
        cs.setClipHints(JCTableEnum.SHOW_NONE);
        cs.setCellBorderSides(JCTableEnum.BORDERSIDE_ALL);
        cs.setCellBorderSides(JCTableEnum.BORDERSIDE_NONE);
        cs.setEditable(false);
        cs.setTraversable(true);
        jctable.setCellStyle(JCTableEnum.ALLCELLS, JCTableEnum.ALLCELLS, cs);

        CellStyleModel labelStyle = jctable.getDefaultLabelStyle();
        labelStyle.setBackground(new Color(255, 255, 160));
        labelStyle.setForeground(Color.blue);
//		labelStyle.setForeground(Color.black);
        labelStyle.setHorizontalAlignment(JCTableEnum.CENTER);
        labelStyle.setClipHints(JCTableEnum.SHOW_NONE);
        labelStyle.setCellBorderSides(JCTableEnum.BORDERSIDE_ALL);
        labelStyle.setEditable(false);
        labelStyle.setTraversable(false);
//		jctable.setCellStyle(new JCCellRange(0,0,0,0), labelStyle);
        jctable.setCellStyle(new JCCellRange(0, 0, hdrRows, cntcol), labelStyle);
        jctable.setFrozenRows(hdrRows);
        jctable.setFrozenColumns(hdrCols);

        jctable.setHorizSBTrack(JCTableEnum.TRACK_COLUMN_NUMBER);

        CellStyleModel labelStyle2 = (CellStyleModel) labelStyle.clone();
        labelStyle2.setHorizontalAlignment(JCTableEnum.LEFT);
        jctable.setCellStyle(new JCCellRange(0, 1, cntrow, 3), labelStyle2);

        /*	jctable.setResizeInteractive(true); // default value
         jctable.setResizeEven(false); // default value			Manmohan Changed it.
         jctable.setDoubleBuffered(true);
         jctable.setAutoScroll(JCTableEnum.AUTO_SCROLL_BOTH);*/
////System.out.print("fC: 1\n");
/*
         JCCellStyle csl = new JCCellStyle();
         csl.setBackground(new Color(255,255,210));
         csl.setForeground(Color.black);
         csl.setHorizontalAlignment(JCTableEnum.LEFT);
         csl.setClipHints(JCTableEnum.SHOW_NONE);
         csl.setCellBorderSides(JCTableEnum.BORDERSIDE_ALL);
         csl.setEditable(false);
         csl.setTraversable(true);
    
         jctable.setColumnLabelDisplay(false);
         jctable.setRowLabelDisplay(false);
         jctable.setCellStyle(new JCCellRange(hdrRows,0,cntrow-hdrRows,1), csl);
         jctable.setFrozenRows(hdrRows);
         jctable.setFrozenColumns(3);
         jctable.setPixelWidth(JCTableEnum.ALLCELLS, JCTableEnum.VARIABLE);
         jctable.setPixelWidth(JCTableEnum.LABEL, 30);
         jctable.setSelectionPolicy(JCTableEnum.SELECT_RANGE);
         jctable.setAutoScroll(JCTableEnum.AUTO_SCROLL_BOTH);
         jctable.setHorizSBDisplay(JCTableEnum.SCROLLBAR_ALWAYS);
         */
//		setColumnWidths(tableData, hdrRows);
//		jctable.setPixelHeight(hdrRows, 0);
////System.out.println("fC: end");
    }

    /*********************************************************************** wjr */
    private void setColumnStyles(Map&lt;String, String&gt; map, JCTable jctable, int hdrRows,
            int cntrow, int cntcol) {
        for (Map.Entry&lt;String, String&gt; entry : ht.entrySet()) {
            String key = entry.getKey();

            if (!key.startsWith("style")) {
                continue;
            }
            String line = entry.getValue();

            StringTokenizer st = new StringTokenizer(line, ";");
            if (st.countTokens() != 4) {
                System.err.println("T_sS: wrong number of tokens " + line);
                continue;
            }
            String colStr = st.nextToken();
            String clrStr = st.nextToken();
            String jusStr = st.nextToken().trim();
            String fntStr = st.nextToken();
//			//System.out.println("T_sS:" +
//							   " colStr " + colStr +
//							   " clrStr " + clrStr +
//							   " jusStr " + jusStr +
//							   " fntStr " + fntStr);

            int colNum = 0;
            try {
                colNum = Integer.parseInt(colStr.trim());
            } catch (NumberFormatException e) {
                System.err.println("T_sS: bad column number " + e);
                continue;
            }

            CellStyleModel csm = jctable.getCellStyle(hdrRows, colNum);
            csm = (CellStyleModel) csm.clone();

            // parse color string
            st = new StringTokenizer(clrStr, "(,)");
            if (st.countTokens() != 3) {
                System.err.println("T_sS: bad color spec " + clrStr);
                continue;
            }
            int[] rgb = new int[3];
            try {
                for (int idx = 0; idx &lt; 3; idx++) {
                    rgb[idx] = Integer.parseInt(st.nextToken().trim());
                }
            } catch (NumberFormatException e) {
                System.err.println("T_sS: bad color attribute " + e);
                continue;
            }
            csm.setForeground(new Color(rgb[0], rgb[1], rgb[2]));

            // determine alignment
            int jusNum = 0;
            if (jusStr.equals("RIGHT")) {
                jusNum = JCTableEnum.RIGHT;
            } else if (jusStr.equals("LEFT")) {
                jusNum = JCTableEnum.LEFT;
            } else if (jusStr.equals("CENTER")) {
                jusNum = JCTableEnum.CENTER;
            } else {
                System.err.println("T_sS: bad alignment " + jusStr);
            }
            csm.setHorizontalAlignment(jusNum);

            // determine font
            int fontStyle = 0;
            int fontSize;
            String fontName;
            st = new StringTokenizer(fntStr, "(,)");
            if (st.countTokens() != 3) {
                System.err.println("T_sS: bad font spec " + fntStr);
                continue;
            }
            fontName = st.nextToken().trim();
            String fontStyleStr = st.nextToken().trim();
            if (fontStyleStr.equals("PLAIN")) {
                fontStyle = Font.PLAIN;
            } else if (fontStyleStr.equals("BOLD")) {
                fontStyle = Font.BOLD;
            } else if (fontStyleStr.equals("ITALIC")) {
                fontStyle = Font.ITALIC;
            } else if (fontStyleStr.equals("BOLD+ITALIC")) {
                fontStyle = Font.BOLD + Font.ITALIC;
            } else {
                System.err.println("T_sS: bad font style " + fontStyle);
                continue;
            }
            try {
                fontSize = Integer.parseInt(st.nextToken().trim());
            } catch (NumberFormatException e) {
                System.err.println("T_sS: bad font size " + e);
                continue;
            }
            csm.setFont(new Font(fontName, fontStyle, fontSize));

////System.out.println("T_sS: " + hdrRows + " " + colNum + " " + (cntrow-1));
            jctable.setCellStyle(new JCCellRange(hdrRows, colNum, cntrow - 1, colNum), csm);

        }

        for (Map.Entry&lt;String, String&gt; entry : ht.entrySet()) {
            String key = entry.getKey();
            if (!key.startsWith("hstyle")) {
                continue;
            }
            String line = entry.getValue();
            StringTokenizer st = new StringTokenizer(line, ";");
            if (st.countTokens() != 4) {
                System.err.println("T_sS: wrong number of tokens " + line);
                continue;
            }
            String colStr = st.nextToken();
            String clrStr = st.nextToken();
            String jusStr = st.nextToken().trim();
            String fntStr = st.nextToken();
            int colNum = 0;
            try {
                colNum = Integer.parseInt(colStr.trim());
            } catch (NumberFormatException e) {
                System.err.println("T_sS: bad column number " + e);
                continue;
            }

            CellStyleModel csm = jctable.getCellStyle(0, colNum);
            csm = (CellStyleModel) csm.clone();

            // parse color string
            st = new StringTokenizer(clrStr, "(,)");
            if (st.countTokens() != 3) {
                System.err.println("T_sS: bad color spec " + clrStr);
                continue;
            }
            int[] rgb = new int[3];
            try {
                for (int idx = 0; idx &lt; 3; idx++) {
                    rgb[idx] = Integer.parseInt(st.nextToken().trim());
                }
            } catch (NumberFormatException e) {
                System.err.println("T_sS: bad color attribute " + e);
                continue;
            }
            csm.setForeground(new Color(rgb[0], rgb[1], rgb[2]));

            // determine alignment
            int jusNum = 0;
            if (jusStr.equals("RIGHT")) {
                jusNum = JCTableEnum.RIGHT;
            } else if (jusStr.equals("LEFT")) {
                jusNum = JCTableEnum.LEFT;
            } else if (jusStr.equals("CENTER")) {
                jusNum = JCTableEnum.CENTER;
            } else {
                System.err.println("T_sS: bad alignment " + jusStr);
            }
            csm.setHorizontalAlignment(jusNum);

            // determine font
            int fontStyle = 0;
            int fontSize;
            String fontName;
            st = new StringTokenizer(fntStr, "(,)");
            if (st.countTokens() != 3) {
                System.err.println("T_sS: bad font spec " + fntStr);
                continue;
            }
            fontName = st.nextToken().trim();
            String fontStyleStr = st.nextToken().trim();
            if (fontStyleStr.equals("PLAIN")) {
                fontStyle = Font.PLAIN;
            } else if (fontStyleStr.equals("BOLD")) {
                fontStyle = Font.BOLD;
            } else if (fontStyleStr.equals("ITALIC")) {
                fontStyle = Font.ITALIC;
            } else if (fontStyleStr.equals("BOLD+ITALIC")) {
                fontStyle = Font.BOLD + Font.ITALIC;
            } else {
                System.err.println("T_sS: bad font style " + fontStyle);
                continue;
            }
            try {
                fontSize = Integer.parseInt(st.nextToken().trim());
            } catch (NumberFormatException e) {
                System.err.println("T_sS: bad font size " + e);
                continue;
            }
            csm.setFont(new Font(fontName, fontStyle, fontSize));

            if (colNum == -1) {
                jctable.setCellStyle(new JCCellRange(0, 4, hdrRows, cntcol), csm);
            } else {
                jctable.setCellStyle(new JCCellRange(0, 0, hdrRows, 3), csm);
            }
        }

        for (Map.Entry&lt;String, String&gt; entry : ht.entrySet()) {
            String key = entry.getKey();
            if (!key.startsWith("tstyle")) {
                continue;
            }
            String line = entry.getValue();
            StringTokenizer st = new StringTokenizer(line, ";");
            if (st.countTokens() != 3) {
                System.err.println("T_sS: wrong number of tokens " + line);
                continue;
            }
            String clrStr = st.nextToken();
            String jusStr = st.nextToken().trim();
            String fntStr = st.nextToken();

            CellStyleModel csm = jctable.getCellStyle(hdrRows, 3);
            csm = (CellStyleModel) csm.clone();

            // parse color string
            st = new StringTokenizer(clrStr, "(,)");
            if (st.countTokens() != 3) {
                System.err.println("T_sS: bad color spec " + clrStr);
                continue;
            }
            int[] rgb = new int[3];
            try {
                for (int idx = 0; idx &lt; 3; idx++) {
                    rgb[idx] = Integer.parseInt(st.nextToken().trim());
                }
            } catch (NumberFormatException e) {
                System.err.println("T_sS: bad color attribute " + e);
                continue;
            }
            csm.setForeground(new Color(rgb[0], rgb[1], rgb[2]));

            // determine alignment
            int jusNum = 0;
            if (jusStr.equals("RIGHT")) {
                jusNum = JCTableEnum.RIGHT;
            } else if (jusStr.equals("LEFT")) {
                jusNum = JCTableEnum.LEFT;
            } else if (jusStr.equals("CENTER")) {
                jusNum = JCTableEnum.CENTER;
            } else {
                System.err.println("T_sS: bad alignment " + jusStr);
            }
            csm.setHorizontalAlignment(jusNum);

            // determine font
            int fontStyle = 0;
            int fontSize;
            String fontName;
            st = new StringTokenizer(fntStr, "(,)");
            if (st.countTokens() != 3) {
                System.err.println("T_sS: bad font spec " + fntStr);
                continue;
            }
            fontName = st.nextToken().trim();
            String fontStyleStr = st.nextToken().trim();
            if (fontStyleStr.equals("PLAIN")) {
                fontStyle = Font.PLAIN;
            } else if (fontStyleStr.equals("BOLD")) {
                fontStyle = Font.BOLD;
            } else if (fontStyleStr.equals("ITALIC")) {
                fontStyle = Font.ITALIC;
            } else if (fontStyleStr.equals("BOLD+ITALIC")) {
                fontStyle = Font.BOLD + Font.ITALIC;
            } else {
                System.err.println("T_sS: bad font style " + fontStyle);
                continue;
            }
            try {
                fontSize = Integer.parseInt(st.nextToken().trim());
            } catch (NumberFormatException e) {
                System.err.println("T_sS: bad font size " + e);
                continue;
            }
            csm.setFont(new Font(fontName, fontStyle, fontSize));

            jctable.setCellStyle(new JCCellRange(hdrRows, 4, cntrow, cntcol), csm);
        }
    }

    /*********************************************************************** wjr */
    private void setColumnWidths(int[] columnWidths) {
        for (int cdx = 0; cdx &lt; columnWidths.length; cdx++) {
            jctable.setPixelWidth(cdx, columnWidths[cdx]);
//			jctable.setPixelWidth(cdx, 80); // temp wjrs
        }
    }

    /*********************************************************************** fix */
    private void hideRows(String[][] tableData, String filterStr, int hdrRows) {

        for (int rdx = hdrRows; rdx &lt; tableData.length; rdx++) {
////System.out.println("sRH: " + filterStr + " |" + tableData[rdx][0] + "|");
            if (filterStr.indexOf(tableData[rdx][0]) &gt;= 0) {
                jctable.setRowHidden(rdx, false);
            } else {
                jctable.setRowHidden(rdx, true);
            }
        }
//		jctable.setRowHidden(7, true);
    }

    /*********************************************************************** wjr */
    private Hashtable&lt;String, String&gt; readConfig(String configDir) {
        return readConfig(configDir, "gui_data.cfg");
    }

    /*********************************************************************** wjr
     * @param configDir
     * @param fileName
     * @return  */
    protected Hashtable&lt;String, String&gt; readConfig(String configDir, String fileName) {
        Hashtable&lt;String, String&gt; ht = new Hashtable&lt;&gt;();
        try {
            TFile f = new TFile(configDir, fileName);
            BufferedReader in = new BufferedReader(new TFileReader(f));
            String temp;
            while ((temp = in.readLine()) != null) {
                //If a blank line is encountered, ignore - neha
                if (temp.equals("") == true) {
                    continue;
                }
                if (temp.charAt(0) == '#') {
                    continue;
                }
                StringTokenizer st = new StringTokenizer(temp, "=");
                if (st.countTokens() &lt; 2) {
                    continue;
                }
                String id = st.nextToken().trim();
                if (ht.containsKey(id)) {
                    System.err.println("T_rC: duplicate label in report spec " + id);
                }
                String data = st.nextToken().trim();
////System.out.println("T_rC: " + id + " -&gt; " + data);
                ht.put(id, data);
            }
            in.close();
        } catch (IOException e) {
            System.err.println("RMSP-lF: " + e);
        }

        return ht;
    }

    /*********************************************************************** wjr
     * @param configDir
     * @param ht
     * @param repVec */
    protected void readReports(String configDir, Vector&lt;String&gt; repVec, Map&lt;String, String&gt; ht) {
//		//System.out.println("T_rR:");
        if (configDir != null) {
            // get reports from reports file
            try {
                BufferedReader in = new BufferedReader(new TFileReader(
                        new TFile(configDir, "reports.cfg")));
                String temp;
                while ((temp = in.readLine()) != null) {
                    if (temp.charAt(0) == '#') {
                        continue;
                    }
                    StringTokenizer st = new StringTokenizer(temp, "=");
                    String id = st.nextToken();
                    if (id.startsWith("report")) {
                        vecFlag = true;
                        String line = st.nextToken();
                        repVec.add(line);
                        ////System.out.println("T_rR: " + line);
                        String ntoken = new StringTokenizer(line, "|").nextToken();
                        //If there occur duplicate report headings in report.cfg, then only the first one is
                        // considered and the second on eis ignored.
                        if (repTitleVec.size() &gt; 0) {
                            for (int i = 0; i &lt; repTitleVec.size(); i++) {
                                String vecElement = repTitleVec.elementAt(i);
                                //    //System.out.println("vecElement:"+vecElement+" ntoken:"+ntoken);
                                if (vecElement.equals(ntoken)) {
                                    vecFlag = false;
                                    System.err.println("There is a duplicate occurence of the "
                                            + vecElement + " Heading");

                                }
                            }//end of for loop
                            if (vecFlag) {
                                repTitleVec.add(ntoken);
                            }
                        } else {
                            repTitleVec.add(new StringTokenizer(line, "|").nextToken());
                        }
                        //	repvec.add(st.nextToken());

                    } else {
                        System.err.println("Illegal line in reports.cfg:" + temp);
                    }
                }
                in.close();
            } catch (IOException e) {
                System.err.println("RMSP-lF: " + e);
            }
        }
        for (String id : ht.keySet()) {
////System.out.println("T_rR: " + id);
            if (id.startsWith("report")) {
                String line = ht.get(id);
                vecFlag = true;
                repVec.add(line);
                ////System.out.println("T_rR: " + line);
                String ntoken = new StringTokenizer(line, "|").nextToken();
                //If there occur duplicate report headings in report.cfg, then only the first one is
                // considered and the second on eis ignored.
                if (repTitleVec.size() &gt; 0) {
                    for (int i = 0; i &lt; repTitleVec.size(); i++) {
                        String vecElement = repTitleVec.elementAt(i);
                        //    //System.out.println("vecElement:"+vecElement+" ntoken:"+ntoken);
                        if (vecElement.equals(ntoken)) {
                            vecFlag = false;
                            System.err.println("There is a duplicate occurence of the " + vecElement + " Heading");

                        }
                    }//end of for loop
                    if (vecFlag == true) {
                        repTitleVec.add(ntoken);
                    }
                } else {
                    repTitleVec.add(new StringTokenizer(line, "|").nextToken());
                }
            }
        }
    }

    /*********************************************************************** wjr
     * @param ht
     * @param units
     * @return  */
    protected String[][] parseHeaders(Map&lt;String, String&gt; ht, String units) {

        Vector&lt;String&gt; inpVec = new Vector&lt;&gt;();
        String inpstr = "";

////System.out.println("T_pH: units " + units);
        Set&lt;String&gt; ks = ht.keySet();
        for (String key : ks) {
            if (key.startsWith("title")) {
                String line = ht.get(key);
                inpVec.add(line);
            }
        }

        // get US titles and put them at end of vector if US units
        // specified. being at end, they naturally replace SI units if
        // needed and are not included if not needed.
        if (units.equals(Util.USUnits)) {
            for (String key : ks) {
                if (key.startsWith("etitle")) {
                    String line = ht.get(key);
                    inpVec.add(line);
                }
            }
        }

        // arbitrary large number of header lines allows for
        // non-contiguous, non-inital 0 header ids
        String[][] tmpArr = new String[100][];
        int arrCnt = 0;
        for (int rdx = 0; rdx &lt; inpVec.size(); rdx++) {
            inpstr = inpVec.elementAt(rdx);
            StringTokenizer st = new StringTokenizer(inpstr, ";");
            try {
                String linNum = st.nextToken().trim();
                int ldx = Integer.parseInt(linNum);
                st = new StringTokenizer(inpstr.substring(linNum.length() + 1), "|");
                String[] coldata = new String[st.countTokens()];
                if (tmpArr[ldx] == null) {
                    arrCnt++;
                }
                tmpArr[ldx] = coldata;
                for (int cdx = 0; st.hasMoreTokens(); cdx++) {
                    coldata[cdx] = st.nextToken().trim();
                    coldata[cdx] = coldata[cdx].replace('`', '\n');  //allows multi line headers
                }
            } catch (NumberFormatException e) {
                System.err.println("T_pH: invalid header line number " + e + " " + inpstr);
            } catch (ArrayIndexOutOfBoundsException f) {
                System.err.println("T_pH: out of range header line number " + f + " " + inpstr);
            }
        }

        String[][] rtnArr = new String[arrCnt][];
        int jdx = 0;
        for (String[] tmpArr1 : tmpArr) {
            if (tmpArr1 != null) {
////System.out.println("T_pH: " + tmpArr[idx][0]);
                rtnArr[jdx++] = tmpArr1;
            }
        }
        return rtnArr;

    }

    /*********************************************************************** wjr */
    private void setFrozenColumns(Map&lt;String, String&gt; ht) {
        if (!ht.containsKey("frozenColumns")) {
            return;
        }
        String inpStr = ht.get("frozenColumns");
        StringTokenizer st = new StringTokenizer(inpStr, "=");
        if (st.countTokens() != 1) {
            System.err.println("T_sFC: invalid row header count " + inpStr);
        }
        try {
            hdrCols = Integer.parseInt(st.nextToken().trim());
        } catch (NumberFormatException e) {
            System.err.println("T_sFC: invalid row header count " + inpStr);
        }
    }

    /*********************************************************************** wjr */
    private String[][] readData(String runDir, Map&lt;String, String&gt; ht, String units) {
        boolean USFlg = units.equals(Util.USUnits);

        String inpStr = ht.get(((USFlg) ? "e" : "") + "resolution");
        StringTokenizer st = new StringTokenizer(inpStr, ",");
        int[] resArr = new int[st.countTokens()];
        for (int idx = 0; idx &lt; resArr.length; idx++) {
            try {
                resArr[idx] = Integer.parseInt(st.nextToken().trim());
            } catch (NumberFormatException e) {
                resArr[idx] = -1;
            }
        }

        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setGroupingUsed(false);

        double[] conArr = null;
        inpStr = ht.get(((USFlg) ? "e" : "") + "conversion");
        st = new StringTokenizer(inpStr, ",");
        conArr = new double[st.countTokens()];
        for (int idx = 0; idx &lt; conArr.length; idx++) {
            try {
                conArr[idx] = Double.parseDouble(st.nextToken().trim());
            } catch (NumberFormatException e) {
                conArr[idx] = -1;
            }
        }

        inpStr = ht.get(((USFlg) ? "e" : "") + "upperlimit");
        st = new StringTokenizer(inpStr, ",");
        double[] uplArr = new double[st.countTokens()];
        for (int idx = 0; idx &lt; uplArr.length; idx++) {
            try {
                uplArr[idx] = Double.parseDouble(st.nextToken().trim());
            } catch (NumberFormatException e) {
                uplArr[idx] = -1;
            }
        }

        inpStr = ht.get(((USFlg) ? "e" : "") + "uppervalue");
        st = new StringTokenizer(inpStr, ",");
        String[] upvArr = new String[st.countTokens()];
        for (int idx = 0; idx &lt; upvArr.length; idx++) {
            upvArr[idx] = st.nextToken().trim();
        }

        inpStr = ht.get(((USFlg) ? "e" : "") + "lowerlimit");
        st = new StringTokenizer(inpStr, ",");
        double[] lolArr = new double[st.countTokens()];
        for (int idx = 0; idx &lt; lolArr.length; idx++) {
            try {
                lolArr[idx] = Double.parseDouble(st.nextToken().trim());
            } catch (NumberFormatException e) {
                lolArr[idx] = -1;
            }
        }

        inpStr = ht.get(((USFlg) ? "e" : "") + "lowervalue");
        st = new StringTokenizer(inpStr, ",");
        String[] lovArr = new String[st.countTokens()];
        for (int idx = 0; idx &lt; lovArr.length; idx++) {
            lovArr[idx] = st.nextToken().trim();
        }

        Vector&lt;String&gt; inpVec = new Vector&lt;&gt;();
        try {
            BufferedReader in = new BufferedReader(new TFileReader(
                    new TFile(runDir, RunFileData.WepsOutput)));
            String temp;
            while ((temp = in.readLine()) != null) {
                inpVec.add(temp);
            }
            in.close();
        } catch (IOException e) {
            System.err.println("RMSP-lF: " + e);
        }

        String[][] rtnval = new String[inpVec.size()][];

        for (int rdx = 0; rdx &lt; inpVec.size(); rdx++) {
            String inpstr = inpVec.get(rdx);
            st = new StringTokenizer(inpstr, "|");

            String[] coldata = new String[st.countTokens()];
            rtnval[rdx] = coldata;
            for (int cdx = 0; st.hasMoreTokens(); cdx++) {
                String str = st.nextToken().trim();
                str = str.replaceAll("~", "\n");					// added to make multi operations into multi lines
                if (resArr[cdx] &gt;= 0) {
                    try {
                        double val = Double.parseDouble(str);
                        if (conArr != null) {
                            if (val != 0.0) {
                                val *= conArr[cdx];
                            }
                        }
                        if (lovArr[cdx].length() &gt; 0 &amp;&amp; (lolArr[cdx] &gt; Math.abs(val) &amp;&amp; val != 0.0)) {
                            str = lovArr[cdx];
                        } else if (upvArr[cdx].length() &gt; 0 &amp;&amp; uplArr[cdx] &lt; Math.abs(val)) {
                            str = upvArr[cdx];
                        } else {
                            nf.setMaximumFractionDigits(resArr[cdx]);
                            nf.setMinimumFractionDigits(resArr[cdx]);
                            str = nf.format(val);
                        }
                    } catch (NumberFormatException e) {
                    }
                }
                coldata[cdx] = str;
////System.out.println("T_rD: " + coldata[cdx]);
            }
        }
        headerNames = rtnval[0];
        return rtnval;
    }

    /*********************************************************************** wjr */
    void convertDates(String[][] tableData, int hdrRows) {
        String[] monthNames = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
            "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
        };

        for (int rdx = hdrRows; rdx &lt; tableData.length; rdx++) {
            StringTokenizer st = new StringTokenizer(tableData[rdx][1], "/");
            if (st.countTokens() != 3) {
                continue;
            }
            String outStr = st.nextToken().trim();
            outStr += " ";
            int mdx = 0;
            try {
                mdx = Integer.parseInt(st.nextToken().trim());
            } catch (java.lang.NumberFormatException e) {
                System.err.println("cD: Invalid month field " + e);
                continue;
            }
            mdx--;
            if (mdx &lt; 0 || mdx &gt; 11) {
                System.err.println("cD: Invalid month number " + mdx + 1);
            }
            outStr += monthNames[mdx];
            outStr += " ";
            outStr += st.nextToken().trim();
            tableData[rdx][1] = outStr;
        }
    }

    /*********************************************************************** wjr */
    private void setLimits(String[][] tableData, int hdrRows, int cntCols) {
        String[] lowerValue = new String[cntCols];
        String[] upperValue = new String[cntCols];
        double[] lowerTest = new double[cntCols];
        double[] upperTest = new double[cntCols];
        double[] conversion = new double[cntCols];
        int[] resolution = new int[cntCols];
        boolean[] upperCheck = new boolean[cntCols];
        boolean[] lowerCheck = new boolean[cntCols];

        for (String tmp : cfgVec) {
            StringTokenizer st = new StringTokenizer(tmp, "=");
            if (st.countTokens() != 2) {
                System.err.println("Invalid limit specification " + tmp);
                continue;
            }
            String key = st.nextToken();
            String values = st.nextToken();
            st = new StringTokenizer(values, ",");
            if (st.countTokens() != cntCols) {
                System.err.println("Wrong number of limits specified in " + key
                        + " is " + st.countTokens() + " should be " + cntCols);
                continue;
            }

            if (key.toLowerCase().equals("lowerlimit")) {
                for (int idx = 0; idx &lt; cntCols; idx++) {
                    try {
                        lowerCheck[idx] = false;
                        lowerTest[idx] = Double.parseDouble(st.nextToken().trim());
                        lowerCheck[idx] = true;
                    } catch (java.lang.NumberFormatException e) {
                        System.err.println("sL: " + key + " " + idx + " " + e);
                    }
                }
            } else if (key.toLowerCase().equals("upperlimit")) {
                for (int idx = 0; idx &lt; cntCols; idx++) {
                    try {
                        upperCheck[idx] = false;
                        upperTest[idx] = Double.parseDouble(st.nextToken().trim());
                        upperCheck[idx] = true;
                    } catch (java.lang.NumberFormatException e) {
                        System.err.println("sL: " + key + " " + idx + " " + e);
                    }
                }
            } else if (key.toLowerCase().equals("lowervalue")) {
                for (int idx = 0; idx &lt; cntCols; idx++) {
                    lowerValue[idx] = st.nextToken().trim();
                }
            } else if (key.toLowerCase().equals("uppervalue")) {
                for (int idx = 0; idx &lt; cntCols; idx++) {
                    upperValue[idx] = st.nextToken().trim();
                }
            } else if (key.toLowerCase().equals("resolution")) {
                for (int idx = 0; idx &lt; cntCols; idx++) {
                    try {
                        resolution[idx] = Integer.parseInt(st.nextToken().trim());
                    } catch (java.lang.NumberFormatException e) {
                        System.err.println("sL: " + key + " " + idx + " " + e);
                    }
                }
            } else if (key.toLowerCase().equals("conversion")) {
                for (int idx = 0; idx &lt; cntCols; idx++) {
                    try {
                        conversion[idx] = Double.parseDouble(st.nextToken().trim());
                    } catch (java.lang.NumberFormatException e) {
                        System.err.println("sL: " + key + " " + idx + " " + e);
                    }
                }
            }
        }

        for (int cdx = 0; cdx &lt; cntCols; cdx++) {
            for (int rdx = hdrRows; rdx &lt; tableData.length; rdx++) {
                if (upperCheck[cdx]) {
                    try {
                        double testVal = Double.parseDouble(tableData[rdx][cdx].trim());
                        if (testVal &gt; upperTest[cdx]) {
                            tableData[rdx][cdx] = upperValue[cdx];
                        }
                    } catch (java.lang.NumberFormatException e) {
                        System.err.println("sL: bad value in grid "
                                + tableData[rdx][cdx] + " " + e);
                    }
                }
                if (lowerCheck[cdx]) {
                    try {
                        double testVal = Double.parseDouble(tableData[rdx][cdx].trim());
                        if (testVal != 0.0 &amp;&amp; testVal &lt; Math.abs(lowerTest[cdx])) {
                            tableData[rdx][cdx] = lowerValue[cdx];
                        }
                    } catch (java.lang.NumberFormatException e) {
                        if (!tableData[rdx][cdx].equals("N/A")) {
                            System.err.println("sL: bad value in grid "
                                    + tableData[rdx][cdx] + " " + e);
                        }
                    }
                }
            }
        }
    }

    /*********************************************************************** wjr */
    private void colorRows(Map&lt;String, String&gt; ht, int hdrRows, int cntrow, int cntcol) {
        Hashtable&lt;String, Color&gt; cht = new Hashtable&lt;&gt;();

        for (Map.Entry&lt;String, String&gt; entry : ht.entrySet()) {
            String key = entry.getKey();
            if (!key.startsWith("rowColor")) {
                continue;
            }
            String line = entry.getValue();

            StringTokenizer st = new StringTokenizer(line, ";");
            if (st.countTokens() != 2) {
                System.err.println("T_cR: bad row color " + line);
                continue;
            }

            String cod = st.nextToken().trim();
            String clrStr = st.nextToken().trim();

            // parse color string
            st = new StringTokenizer(clrStr, "(,)");
            if (st.countTokens() != 3) {
                System.err.println("T_cR: bad color spec " + clrStr);
                continue;
            }
            int[] rgb = new int[3];
            try {
                for (int idx = 0; idx &lt; 3; idx++) {
                    rgb[idx] = Integer.parseInt(st.nextToken().trim());
                }
            } catch (NumberFormatException e) {
                System.err.println("T_cR: bad color attribute " + e);
                continue;
            }
            Color clr = new Color(rgb[0], rgb[1], rgb[2]);
            cht.put(cod.trim(), clr);
        }

        for (int rdx = hdrRows; rdx &lt; tableData.length; rdx++) {
            if (!cht.containsKey(tableData[rdx][0].trim())) {
                continue;
            }
            CellStyleModel csm = jctable.getCellStyle(rdx, hdrCols);
            csm = (CellStyleModel) csm.clone();
            csm.setBackground(cht.get(tableData[rdx][0].trim()));
            jctable.setCellStyle(new JCCellRange(rdx, hdrCols, rdx, cntcol), csm);

        }
    }
    /*********************************************************************** wjr */
    static int cnt = 0;

    static class ImageComponent extends Component {

        private static final long serialVersionUID = 1L;

        Image aImage;
        double angle;

        ImageComponent(Image i, Component com, double angle) {
            aImage = i;
            this.angle = angle;
        }

        public Image getImage() {
            return aImage;
        }

        public void setImage(Image aImage) {
            this.aImage = aImage;
            repaint();
        }

        @Override
        public void paint(Graphics g) {
            int ih = aImage.getHeight(this);
            int iw = aImage.getWidth(this);
            int gw = getSize().width;
            int gh = getSize().height;
            Graphics2D g2d = (Graphics2D) g;
            g2d.translate(gw / 2, gh / 2);
            g2d.rotate(angle * Math.PI / 180.0);
            g2d.drawImage(aImage, -iw / 2, -ih / 2, iw, ih, this);
            g2d.rotate(-angle * Math.PI / 180.0);
            g2d.translate(-gw / 2, -gh / 2);
        }
    }

    /*********************************************************************** wjr */
    private void loadImages() {
        for (int rdx = 0; rdx &lt; hdrRows; rdx++) {
            for (int cdx = 0; cdx &lt; tableData[rdx].length; cdx++) {
                String val = tableData[rdx][cdx].trim();
                if (val.indexOf("{") != 0) {
                    continue;
                }
                StringTokenizer st = new StringTokenizer(val, "{}");
                Image i = Toolkit.getDefaultToolkit().getImage(st.nextToken().trim());
                ImageComponent ic = new ImageComponent(i, jctable.getComponent(rdx, cdx), regionAngle);
                jctable.setComponent(rdx, cdx, ic);
            }
        }

    }
    /*********************************************************************** wjr */
    private String reportName = "";

    /**
     *
     * @param reportName
     */
    public void setReport(String reportName) {
////System.out.println("T_sR: reportName " + reportName);
        String line = "";
        int idx = 0;
        StringTokenizer st = null;
        for (idx = 0; idx &lt; this.repVec.size(); idx++) {
            line = this.repVec.elementAt(idx);
            st = new StringTokenizer(line, "|");
////System.out.println("T-sR: " + line);
            if (reportName.equals(st.nextToken())) {
                break;
            }
        }
        if (idx == this.repVec.size()) {
            System.err.println("T_sR: can't find report name in list "
                    + "&gt;" + reportName + "&lt;");
            return;
        }

//		JCTableDataEvent event = new JCTableDataEvent(this,1,0,0,0, JCTableDataEvent.CHANGE_VALUE);
//		jctable.fireTableDataEvent(event);
//		dataSource.setTableDataItem(new String(reportName), 0, 1);
        this.reportName = reportName;

////System.out.println("T-sR: " + reportName);
        tableData[1][1] = reportName;
        repColFmt = st.nextToken();
        hideColumns(repColFmt);

        repRowFmt = st.nextToken();
        hideRows(tableData, repRowFmt, hdrRows);

    }

    /*********************************************************************** wjr
     * @param tag */
    public void displayColumns(String tag) {
        //System.out.println("T_dC: " + tag);
        for (int idx = 0; idx &lt; repVec.size(); idx++) {
//			//System.out.println("T_dC: " + (String) repVec.elementAt(idx));
            StringTokenizer st = new StringTokenizer(repVec.elementAt(idx), "|");
            String id = st.nextToken();
            if (id.equals(tag)) {
                String fmtStr = st.nextToken();
////System.out.println("T_dC: " + tag + " " + fmtStr);
                hideColumns(fmtStr);
                break;
            }
        }
    }

    /*********************************************************************** wjr */
    private void hideColumns(String repColFmt) {
        int cdx;
        int numCol = 0;

////System.out.println("T_hC: " + repColFmt);
        boolean[] hidCol;
        for (String[] tableData1 : tableData) {
            if (tableData1.length &gt; numCol) {
                numCol = tableData1.length;
            }
        }
        hidCol = new boolean[numCol];
        if (repColFmt.trim().equals("*")) {
            for (cdx = 0; cdx &lt; hidCol.length; cdx++) {
                hidCol[cdx] = false;
            }
        } else {
            for (cdx = 0; cdx &lt; hidCol.length; cdx++) {
                hidCol[cdx] = true;
            }
            for (StringTokenizer st = new StringTokenizer(repColFmt, ";");
                    st.hasMoreTokens();) {
                cdx = Integer.parseInt(st.nextToken());
                hidCol[cdx] = false;
            }
        }

        for (cdx = 0; cdx &lt; hidCol.length; cdx++) {
            jctable.setColumnHidden(cdx, hidCol[cdx]);
        }
    }

    /*********************************************************************** wjr */
    /*
     private	void	addToolTips(int hdrRows, int bodRows, int bodCols)
     {
     ////System.out.println("aTT : " + hdrRows + " " + bodRows + " " + bodCols);
     errorRange[] eR = inputRecord.getToolTipText(inputType);
     for (int rdx = hdrRows; rdx &lt; (hdrRows + bodRows); rdx++) {
     for (int cdx = 0; cdx &lt; bodCols; cdx++) {
     CellStyleModel csm = jctable.getUniqueCellStyle(rdx, cdx);
     //			 JCCellEditor jcce = csm.getCellEditor();
     //			 JCTextFieldCellEditor jcce = csm.getCellEditor();
     //			 JComponent jcce = csm.getCellEditor();
     //			 jcce.setToolTipText("fred is here");
     //			(csm.getCellEditor()).setToolTipText("fred is here");
     ////System.out.println("aTT: " + csm.getCellEditor());
     JCTextFieldCellEditor tfce = new JCTextFieldCellEditor();
     //			tfce.setToolTipText("fred is here " + rdx + cdx);
     ////System.out.println("aTT: " + cdx + " " + eR[cdx].getToolTipText());
     tfce.setToolTipText(eR[cdx].getToolTipText());
     csm.setCellEditor(tfce);
     jctable.setCellStyle(hdrRows, bodCols-1, csm);
     }
     }
     }
     */
    /*********************************************************************** wjr */
    /**
     * Makes the spans for the headings.  That is, it combines rows and/or
     * columns for bigger headers.  "~*R" denotes cells that should be
     * spanned.
     * @param tableData
     * @param table
     * @param hdrRows
     */
    protected void makeSpan(String[][] tableData, int hdrRows, JCTable table) {
        int curRow;
        int nxtRow;
        int curCol;
        int nxtCol;
        String lastHdr;

////System.out.println("T_mS: hdrRows == " + hdrRows);
        // create spanned fields along rows
        for (curRow = 0; curRow &lt; hdrRows; curRow++) {
            lastHdr = "";
            for (curCol = 0; curCol &lt; tableData[curRow].length; curCol++) {
                if (tableData[curRow][curCol].equals("~*R")) {
//				tableData[curRow][curCol] = new String("");
                    tableData[curRow][curCol] = lastHdr;
                    continue;
                }
                lastHdr = tableData[curRow][curCol];
                for (nxtCol = curCol + 1; nxtCol &lt; tableData[curRow].length; nxtCol++) {
                    if (!tableData[curRow][nxtCol].equals("~*R")) {
                        break;
//				lastHdr = tableData[curRow][nxtCol];
////System.out.println("T_mS: header copy -&gt; " + lastHdr);
                    }
                }
                if ((nxtCol == curCol + 1)) {
                    continue; // no "~*R" found
////System.out.println("T_mS: " + curRow + " " + curCol + " " + (nxtCol - 1));
                }
                JCCellRange spanrange = new JCCellRange(curRow, curCol, curRow, nxtCol - 1);
                try {
                    jctable.addSpannedRange(spanrange);
                } catch (java.lang.IllegalArgumentException e) {
                    System.err.println("T_mS: overlapping spanning ranges " + spanrange);
                    @SuppressWarnings("unchecked") // this is Quest's fault
                    Vector&lt;Object&gt; sR = (Vector&lt;Object&gt;) jctable.getSpanHandler().getSpannedRanges();
                    for (Object o : sR) {
                        System.err.println("T_mS: " + o);
                    }
                }
            }
        }

        // create spanned fields along columns
        for (curCol = 0; curCol &lt; tableData[0].length; curCol++) {
            for (curRow = 0; curRow &lt; hdrRows; curRow++) {

                try {
                    if (tableData[curRow][curCol].equals("~*D")) {
                        tableData[curRow][curCol] = "";
                        continue;
                    }
                } catch (ArrayIndexOutOfBoundsException e) {
                    break;
                }
                for (nxtRow = curRow + 1; nxtRow &lt; hdrRows; nxtRow++) {
                    try {
                        if (!tableData[nxtRow][curCol].equals("~*D")) {
                            break;
                        }
                    } catch (ArrayIndexOutOfBoundsException e) {
                        break;
                    }
                }

                if ((nxtRow == curRow + 1)) {
                    continue; // no "~*D" found
////System.out.println("T_mS: " + curRow + " " + curCol + " " + (nxtCol - 1));
                }
                JCCellRange spanrange = new JCCellRange(curRow, curCol, nxtRow - 1, curCol);
                try {
                    jctable.addSpannedRange(spanrange);
                } catch (java.lang.IllegalArgumentException e) {
                    System.err.println("T_mS: overlapping spanning ranges " + spanrange);
                    @SuppressWarnings("unchecked") // this is Quest's fault
                    Vector&lt;Object&gt; sR = (Vector&lt;Object&gt;) jctable.getSpanHandler().getSpannedRanges();
                    for (Object o : sR) {
                        System.err.println("T_mS: " + o);
                    }
                }
            }
        }
    }

    /*********************************************************************** wjr */
    private void updateHeaders(String[][] tableData, int hdrRows) {
        int crx;
        int nrx;
        int ccx;
        int ncx;

        // put multi-line header fields into multiple cells
        for (crx = 0; crx &lt; hdrRows; crx++) {
            for (ccx = 0; ccx &lt; tableData[crx].length; ccx++) {
                if (tableData[crx][ccx].indexOf("`") == -1) {
                    continue;
//			tableData[crx][ccx].replace('`', '\n');
//			//System.out.println("mS: " + tableData[crx][ccx]);
                }
                StringTokenizer st = new StringTokenizer(tableData[crx][ccx], "`");
                for (nrx = crx; st.hasMoreTokens(); nrx++) {
                    tableData[nrx][ccx] = st.nextToken();
//				//System.out.println("mS: " + nrx + " " + ccx + " " + tableData[nrx][ccx]);
                }
            }
        }
    }

    /*********************************************************************** wjr */
    /*private void createSpans() {
    // should use iterator but that does not seem to work
    //	for (int vdx = 0; vdx &lt; spanVec.size(); vdx++) {
    for (java.util.Iterator vi = spanVec.iterator(); vi.hasNext();) {
    
    JCCellRange spanrange = (JCCellRange) vi.next();
    try {
    jctable.addSpannedRange(spanrange);
    } catch (java.lang.IllegalArgumentException e) {
    System.err.println("overlapping spanning ranges " + spanrange);
    }
    }
    }*/

    /*********************************************************************** wjr */
    /**
     * testing doc of setHeight
     *
     * @param rh
     * @title xxxx
     * */
    public void setHeight(int rh) /*
     * testing doc of setHeight 3
     * */ {
        jctable.setPixelHeight(JCTableEnum.ALLCELLS, rh);
    }
    /*
     * testing doc of setHeight 2
     * */
    /*********************************************************************** wjr */
    private int tw = 600;

    /**
     *
     * @return
     */
    @Override
    public Dimension getPreferredSize() {
        Dimension d = jctable.getPreferredSize();
//	d.height += 65;
//	d.width = 600;
        tw += 20;
        d.width = tw;
        Dimension p = getParent().getParent().getSize();
////System.out.println("gPS: called " + d + super.getSize());
////System.out.println("gPS: called " + d + getParent().getSize());
        if (p.width &gt; 20) {
            d.width = p.width - 20;
////System.out.println("gPS: p " + p.width + " d " + d.width);
//	jctable.setPreferredSize(d);
        }
        return d;
    }

    /*********************************************************************** wjr
     * @return  */
    @Override
    public Dimension getMaximumSize() {
        Dimension d = jctable.getMaximumSize();
////System.out.println("gMxS: called " + d);
        return d;
    }

    /*********************************************************************** wjr
     * @return  */
    @Override
    public Dimension getMinimumSize() {
//	Dimension d = jctable.getMinimumSize();
        Dimension d = new Dimension(300, 25);
        d.width = getParent().getSize().width - 40;
////System.out.println("gMnS: called " + d + getParent().getSize());
        return d;
    }

    /*********************************************************************** wjr
     * @param e */
    @Override
    public void actionPerformed(ActionEvent e) {
////System.out.println("aP:");
    }

    /*********************************************************************** wjr */
    /*********************************************************************** wjr
     * @param cntcol
     * @param ht
     * @return  */
    protected int[] getColumnWidths(int cntcol, Map&lt;String, String&gt; ht) {

        int[] rtnval = new int[cntcol];
        for (int idx = 0; idx &lt; cntcol; idx++) {
            rtnval[idx] = -1;
        }
        for (Map.Entry&lt;String, String&gt; entry : ht.entrySet()) {
            String key = entry.getKey();
            if (!key.startsWith("width")) {
                continue;
            }
            String inplin = entry.getValue();
            StringTokenizer st = new StringTokenizer(inplin, ";");
            if (st.countTokens() != 2) {
                System.err.println("sCW: invalid column width " + inplin);
                continue;
            } else {
//				//System.out.println("sCW: " + inplin);
            }
            String colstr = st.nextToken();
            String widstr = st.nextToken();
            int colidx = Integer.parseInt(colstr);
            int widval = Integer.parseInt(widstr);
            if (colidx == 0) {
                for (int jdx = 0; jdx &lt; cntcol; jdx++) {
                    if (rtnval[jdx] == -1) {
                        rtnval[jdx] = widval;
                    }
                }
            } else {
                rtnval[colidx] = widval;
            }
        }
        rtnval[0] = 0;
        for (int idx = 0; idx &lt; cntcol; idx++) {
//			//System.out.println("sCW: " + idx + " " + rtnval[idx]);
        }
        return rtnval;
    }

    /*********************************************************************** wjr */
    private void updateHeaderInfo(String key, String val) {
////System.out.println("T_uHI: &gt;" + key + " " + val);
        if (dataSource == null) {
            return;
        }
        Vector&lt;Vector&lt;String&gt;&gt; cells = Caster.&lt;Vector&lt;Vector&lt;String&gt;&gt;&gt;cast(dataSource.getCells());
        for (int rdx = 0; rdx &lt; hdrRows; rdx++) {
            Vector&lt;String&gt; cello = cells.elementAt(rdx);
            for (int cdx = 0; cdx &lt; cello.size(); cdx++) {
                String temp = cello.elementAt(cdx);
                if (temp.indexOf(key) &gt; -1) {
                    StringBuilder tempb = new StringBuilder(temp);
                    int pos = temp.indexOf(key);
                    tempb.delete(pos, pos + key.length());
                    tempb.insert(pos, val);
                    dataSource.setTableDataItem(tempb.toString(), rdx, cdx);
//					//System.out.println("T_uHI: &gt;&gt;" + tempb);
                }
//				if (temp.length() == 0) continue;
//				temp = Util.convertMetersToFeet(temp, Util.USUnits, 2);
//				dataSource.setTableDataItem(temp, rdx, cdx);
            }
        }

    }
    /*********************************************************************** wjr */
    private String userName;
    private String fieldID = null;
    private String farmID = null;
    private String tractID = null;
    private String soilFile;
    private String manageFile;
    private String units;
    // to do:  make placement depend on ~xx values in tableData
    /**
     *
     * @param e
     */
    @Override
    public void propertyChange(PropertyChangeEvent e) {
        if (e.getPropertyName().equals(ConfigData.Units)) {
            units = (String) e.getNewValue();
        } else if (e.getPropertyName().equals(RunFileData.RegionAngle)) {
            try {
                regionAngle = Double.parseDouble((String) e.getNewValue());
            } catch (NumberFormatException f) {
                System.err.println("T_pC: bad region angle " + f);
            }
        } else if (e.getPropertyName().equals(RunFileData.UserName)) {
            userName = (String) e.getNewValue();
            updateHeaderInfo("~CN", userName);
//			dataSource.setTableDataItem(new String(userName), 0, 1);
        } else if (e.getPropertyName().equals(RunFileData.FieldId)) {
            fieldID = (String) e.getNewValue();
            updateHeaderInfo("~FI", fieldID);
//			if (fieldID != null &amp;&amp; farmID != null &amp;&amp; tractID != null) {
//				dataSource.setTableDataItem(new String(
//					farmID + " - " + tractID + " - " + fieldID), 1, 1);
//			}
        } else if (e.getPropertyName().equals(RunFileData.FarmId)) {
            farmID = (String) e.getNewValue();
            updateHeaderInfo("~FN", farmID);
//			if (fieldID != null &amp;&amp; farmID != null &amp;&amp; tractID != null) {
//				dataSource.setTableDataItem(new String(
//					farmID + " - " + tractID + " - " + fieldID), 1, 1);
//			}
        } else if (e.getPropertyName().equals(RunFileData.TractId)) {
            tractID = (String) e.getNewValue();
            updateHeaderInfo("~TI", tractID);
//			if (fieldID != null &amp;&amp; farmID != null &amp;&amp; tractID != null) {
//				dataSource.setTableDataItem(new String(
//					farmID + " - " + tractID + " - " + fieldID), 1, 1);
//			}
        } else if (e.getPropertyName().equals(RunFileData.SoilFile)) {
            soilFile = (String) e.getNewValue();
            soilFile = new TFile(soilFile).getName();
            updateHeaderInfo("~SN", soilFile.substring(0, soilFile.lastIndexOf('.')));
//			dataSource.setTableDataItem(new String(soilFile), 2, 1);
        } else if (e.getPropertyName().equals(RunFileData.ManageFile)) {
            manageFile = (String) e.getNewValue();
            manageFile = new TFile(manageFile).getName();
            updateHeaderInfo("~MN", manageFile.substring(0, manageFile.lastIndexOf('.')));
//			dataSource.setTableDataItem(new String(manageFile), 3, 1);
        }
    }
    /*********************************************************************** wjr */
    private JCPrintTable pt = null;

    /**
     *
     */
    public void doPrint() {
        pt = new JCPrintTable(jctable);

        java.awt.print.PageFormat pgf = new java.awt.print.PageFormat();
        pgf.setOrientation(java.awt.print.PageFormat.LANDSCAPE);
        //    //System.out.println("Page Format:"+pgf.getPaper().getHeight());
        pt.setPageFormat(pgf);

//		pt.print();
        pt.addPrintListener(this);
        JCPrintPreview pf = new JCPrintPreview("Table Print Preview", pt);
        //	//System.out.println("Print Preview: " + pf.page_format);
        pf.showPage(0);
    }

    /*********************************************************************** wjr */
    /**
     * printEnd, printPageBody, printPageFooter and printPageHeader implement the JCPrintListener
     * interface and allow the reports to be printed in a nice, formatted manner.
     * @param event
     */
    public void printEnd(JCPrintEvent event) {
    }

    /**
     *
     * @param event
     */
    @Override
    public void printPageBody(JCPrintEvent event) {
    }

    /**
     *
     * @param e
     */
    @Override
    public void printPageFooter(JCPrintEvent e) {
        Graphics gc = e.getGraphics();
//		Rectangle r = gc.getClipRect();
        Rectangle r = gc.getClip().getBounds(); // fix to get rid of dep method
        FontMetrics fm = gc.getFontMetrics();
        String page = "Page " + e.getPage() + " of " + pt.getNumPages();
//		String note = "Use JCPrintListener to customize the footer!";
        String note = "Created: " + new Date(new TFile(runDir).lastModified()).toString() + "   ";
        // Pad the footer text to the right
        gc.drawString(page, 0, r.height / 2);
        gc.drawString(note, r.width - fm.stringWidth(note), r.height / 2);
    }

    /**
     *
     * @param e
     */
    @Override
    public void printPageHeader(JCPrintEvent e) {
        Graphics gc = e.getGraphics();
//		Rectangle r = gc.getClipRect();
        Rectangle r = gc.getClip().getBounds(); // fix to get rid of dep method
        FontMetrics fm = gc.getFontMetrics();
//		String page = "Page " + e.getPage();
//		String note = "Use JCPrintListener to customize the header!";
        String note = "Project: " + new TFile(new TFile(runDir).getParent()).getName()
                + " Run: " + new TFile(runDir).getName() + "   ";
        // Pad the footer text to the right
//		gc.drawString(page, 0, r.height/2);
        gc.drawString(reportName, 0, r.height / 2);
        gc.drawString(note, r.width - fm.stringWidth(note), r.height / 2);
    }
//	JTF_ProjectName.setText(new File(inpDirS).getParent().toString());
//	JTF_RunName.setText(new File(inpDirS).getName());
//	JTF_DateCreated.setText(new Date(inpDirF.lastModified()).toString());
//	new File(runDir, "gui_data.out")));

    /** Following function loads the ToolTip file into the hash table
     *
     * @param topLevel  : The table whose columns are supposed to be loaded with the tool tips.
     * @param inputFile : The file which has the details of the tool tips.
     * @return 
     *
     */
    public Map&lt;String, String&gt; loadToolTips(JFrame topLevel, TFile inputFile) {
        Map&lt;String, String&gt; ht = new java.util.Hashtable&lt;String, String&gt;();
        boolean mytest = false;

        try {
            BufferedReader in = new BufferedReader(new TFileReader(inputFile));
            String temp;
            while ((temp = in.readLine()) != null) {
                StringTokenizer st = new StringTokenizer(temp, "=");
                String id = st.nextToken().trim();
                try {
                    String value = st.nextToken().trim();
                    while (!mytest) {
                        mytest = true;
                    }

                    ht.put(id, value);
                } catch (java.util.NoSuchElementException e) {
                    // skip invalid lines - comments or nothing after =
                }
            }
            in.close();
        } catch (IOException e) {
            System.err.println("Unable to load tooltips file");
        }
        return ht;
    }

    /**
     *
     * @param topLevel
     * @param ht
     */
    public void setHTMLTag(JCTextFieldCellEditor topLevel, Hashtable&lt;String,String&gt; ht) {

        String tooltip = ((JComponent) topLevel).getToolTipText();
        if (tooltip != null) {
            if (ht.containsKey(tooltip)) {
                String newText = "&lt;html&gt;" + ht.get(tooltip) + "&lt;/html&gt;";
                topLevel.setToolTipText(newText);
            } else {
                topLevel.setToolTipText(null);
            }
        }
    }

    /**
     *
     * @param hdrRows
     * @param bodRows
     * @param bodCols
     * @param topLevel
     * @param inputFile
     */
    public void addToolTips(int hdrRows, int bodRows, int bodCols, JFrame topLevel, TFile inputFile) {
        //errorRange[] eR = inputRecord.getToolTipText(inputType);
        // Put loadtable 	functionality here

//        Hashtable ht = loadToolTips( topLevel, inputFile);
        for (int cdx = 0; cdx &lt; headerNames.length; cdx++) {

//            String colName = headerNames[cdx].trim();
            //System.out.println("Column Names: "+ colName);
            for (int rdx = hdrRows; rdx &lt; (hdrRows + bodRows); rdx++) {
//	    	//System.out.println("Header Rows: "+ hdrRows + "Total Columns: "+ bodCols + "Total Rows: "+ bodRows  );
                CellStyleModel csm = jctable.getUniqueCellStyle(rdx, cdx);
                JCTextFieldCellEditor tfce = new JCTextFieldCellEditor();

                //tfce.setToolTipText(eR[cdx].getToolTipText());
                //tfce.setToolTipText((String)ht.get(colNames[cdx])); changed on jun 11
//			tfce.setToolTipText((String)ht.get(colName));  // chnaged on jn 11
                tfce.setToolTipText("tool tip help");  // chnaged on jn 11

                csm.setCellEditor(tfce);
//			jctable.setCellStyle(hdrRows, bodCols-1, csm);
                jctable.setCellStyle(rdx, cdx, csm);
//			setHTMLTag(tfce,ht);

            }
        }
    }
}
</pre></body></html>