示例#1
0
        /// <summary>
        /// From AbstractTableModel; returns the data that should be placed in the JTable
        /// at the given row and column. </summary>
        /// <param name="row"> the row for which to return data. </param>
        /// <param name="col"> the column for which to return data. </param>
        /// <returns> the data that should be placed in the JTable at the given row and col. </returns>
        public virtual object getValueAt(int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }

            StateMod_GraphNode gn = (StateMod_GraphNode)_data.get(row);

            switch (col)
            {
            case COL_FILE:
                return(gn.getFileName());

            case COL_TYPE:
                return(gn.getType());

            case COL_PARM:
                string s = gn.getDtype();
                // FIXME SAM 2008-03-24 No need to do this with newer StateMod
                // since binary file uses underscores for data types.
                //s = (s.replace('_', ' ')).trim();
                return(s);

            case COL_YEAR:
                return(gn.getYrAve());

            case COL_ID:
                return(gn.getID());

            default:
                return("");
            }
        }
示例#2
0
        /// <summary>
        /// Checks to see if a row can be added to the table.  Rows cannot be added if the first row is not fully
        /// filled out.
        /// TODO (JTS - 2006-03-06)
        /// I think this is bad code.  I think the elementAt() call should return the
        /// last data value -- as it is, it is only checking that the first row is
        /// set up properly. </summary>
        /// <returns> true if a new row can be added, false if not. </returns>
        public virtual bool canAddRow()
        {
            if (_rows == 0)
            {
                return(true);
            }
            StateMod_GraphNode gn = (StateMod_GraphNode)_data.get(0);

            if (gn.getFileName().Trim().Equals(""))
            {
                return(false);
            }
            if (gn.getType().Trim().Equals(""))
            {
                return(false);
            }
            if (gn.getDtype().Trim().Equals(""))
            {
                return(false);
            }
            if (gn.getYrAve().Trim().Equals(""))
            {
                return(false);
            }
            if (gn.getID().Trim().Equals(""))
            {
                return(false);
            }
            return(true);
        }
示例#3
0
        /// <summary>
        /// Saves form data to the data set. </summary>
        /// <param name="worksheetData"> the data in the worksheet to save. </param>
        /// <returns> a list of data objects created from the data in the worksheet. </returns>
        public virtual IList <StateMod_GraphNode> formSaveData(IList <StateMod_GraphNode> worksheetData)
        {
            int rows = worksheetData.Count;

            if (rows == 0)
            {
                return(new List <StateMod_GraphNode>());
            }

            // gnw will be a node used to read data FROM the _W_orksheet nodes
            StateMod_GraphNode gnw = worksheetData[0];

            string pfile  = gnw.getFileName().Trim();
            string ptype  = gnw.getType().Trim();
            string pdtype = gnw.getDtype().Trim();
            string pyear  = gnw.getYrAve().Trim();
            string pid    = gnw.getID().Trim();

            string file  = null;
            string type  = null;
            string dtype = null;
            string year  = null;
            string id    = null;

            // gno will be a node used for creating the _O_utput nodes
            StateMod_GraphNode gno = new StateMod_GraphNode();

            gno.setFileName(pfile);
            gno.setType(ptype);
            gno.setDtype(pdtype);
            gno.setYrAve(pyear);
            int paren = pid.IndexOf("(", StringComparison.Ordinal);

            if (paren > -1)
            {
                gno.addID(pid.Substring(0, paren).Trim());
            }
            else
            {
                gno.addID(pid);
            }

            IList <StateMod_GraphNode> v = new List <StateMod_GraphNode>();

            for (int i = 1; i < rows; i++)
            {
                gnw = worksheetData[i];

                file = gnw.getFileName().Trim();
                if (file.Equals(""))
                {
                    file = pfile;
                }
                type = gnw.getType().Trim();
                if (type.Equals(""))
                {
                    type = ptype;
                }
                dtype = gnw.getDtype().Trim();
                if (dtype.Equals(""))
                {
                    dtype = pdtype;
                }
                year = gnw.getYrAve().Trim();
                if (year.Equals(""))
                {
                    year = pyear;
                }
                id = gnw.getID().Trim();
                if (id.Equals(""))
                {
                    id = pid;
                }

                if (file.Equals(pfile) && type.Equals(ptype) && dtype.Equals(pdtype) && year.Equals(pyear))
                {
                    // all the fields match, so this is a different ID
                    // added to the Vector of IDs in the node's vector.
                    paren = id.IndexOf("(", StringComparison.Ordinal);
                    if (paren > -1)
                    {
                        gno.addID(id.Substring(0, paren).Trim());
                    }
                    else
                    {
                        gno.addID(id);
                    }
                }
                else
                {
                    // otherwise, values other than just the ID are
                    // different, so a new node needs created
                    v.Add(gno);

                    gno = new StateMod_GraphNode();
                    gno.setFileName(file);
                    gno.setType(type);
                    gno.setDtype(dtype);
                    gno.setYrAve(year);
                    paren = id.IndexOf("(", StringComparison.Ordinal);
                    if (paren > -1)
                    {
                        gno.addID(id.Substring(0, paren).Trim());
                    }
                    else
                    {
                        gno.addID(id);
                    }
                }

                pfile  = file;
                ptype  = type;
                pdtype = dtype;
                pyear  = year;
                pid    = id;
            }

            v.Add(gno);

            return(v);
        }
示例#4
0
        /// <summary>
        /// Creates a list of objects suitable for use in the worksheet from the data
        /// read from a delta plot file. </summary>
        /// <param name="fileData"> the fileData to process. </param>
        /// <returns> a list of objects suitable for use within a form. </returns>
        public virtual IList <StateMod_GraphNode> formLoadData(IList <StateMod_GraphNode> fileData)
        {
            int rows = fileData.Count;

            if (rows == 0)
            {
                return(new List <StateMod_GraphNode>());
            }

            // gnf will be a node used to read data FROM the _F_ile nodes
            StateMod_GraphNode gnf = fileData[0];

            string pfile = "";
            string ptype = "";
            string pyear = "";

            string file  = null;
            string type  = null;
            string dtype = null;
            string year  = null;

            // gnw will be a node used for creating the _W_orksheet nodes
            StateMod_GraphNode gnw = null;

            IList <StateMod_GraphNode> v = new List <StateMod_GraphNode>();

            int ids = 0;

            for (int i = 0; i < rows; i++)
            {
                gnf = fileData[i];
                ids = gnf.getIDVectorSize();

                file  = gnf.getFileName().Trim();
                type  = gnf.getType().Trim();
                dtype = gnf.getDtype().Trim();
                year  = gnf.getYrAve().Trim();

                for (int j = 0; j < ids; j++)
                {
                    if (j == 0)
                    {
                        gnw = new StateMod_GraphNode();
                        if (!file.Equals(pfile))
                        {
                            gnw.setFileName(file);
                        }
                        else
                        {
                            gnw.setFileName("");
                        }
                        if (!type.Equals(ptype))
                        {
                            gnw.setType(type);
                        }
                        else
                        {
                            gnw.setType("");
                        }
                        if (!dtype.Equals(dtype))
                        {
                            gnw.setDtype(dtype);
                        }
                        else
                        {
                            gnw.setDtype("");
                        }
                        if (!year.Equals(pyear))
                        {
                            gnw.setYrAve(year);
                        }
                        else
                        {
                            gnw.setYrAve("");
                        }
                        gnw.setID(gnf.getID(0).Trim());
                    }
                    else
                    {
                        gnw.setFileName("");
                        gnw.setType("");
                        gnw.setDtype("");
                        gnw.setYrAve("");
                        gnw.setID(gnf.getID(j).Trim());
                    }
                    gnw.setSwitch(gnf.getSwitch());
                    v.Add(gnw);
                }

                pfile = file;
                ptype = type;
                pyear = year;
            }

            return(v);
        }