Example #1
0
        /// <summary>
        /// Sets up the data Vectors to display the location climate station data in the GUI.
        /// </summary>
        private void setupData()
        {
            int num             = 0;
            int size            = _data.size();
            StateCU_Location l  = null;
            string           id = null;

            __data = new System.Collections.IList[__COLUMNS];
            for (int i = 0; i < __COLUMNS; i++)
            {
                __data[i] = new List <object>();
            }

            int rows = 0;

            for (int i = 0; i < size; i++)
            {
                l   = (StateCU_Location)_data.get(i);
                id  = l.getID();
                num = l.getNumClimateStations();

                for (int j = 0; j < num; j++)
                {
                    __data[__COL_ID].Add(id);
                    __data[__COL_STA_ID].Add(l.getClimateStationID(j));
                    __data[__COL_TEMP_WT].Add(new double?(l.getTemperatureStationWeight(j)));
                    __data[__COL_PRECIP_WT].Add(new double?(l.getPrecipitationStationWeight(j)));
                    __data[__COL_ORO_TEMP_ADJ].Add(new double?(l.getOrographicTemperatureAdjustment(j)));
                    __data[__COL_ORO_PRECIP_ADJ].Add(new double?(l.getOrographicPrecipitationAdjustment(j)));
                    rows++;
                }
            }
            _rows = rows;
        }
        /// <summary>
        /// From AbstractTableMode.  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];
            }

            if (__singleLocation)
            {
                switch (col)
                {
                case 1:
                case 2:
                    StateCU_Location location = (StateCU_Location)_data.get(row);
                    switch (col)
                    {
                    case 1:
                        return(location.getID());

                    case 2:
                        return(location.getName());
                    }

                case 3:
                    return(new double?(__delays.getDelayTablePercent(row)));

                case 4:
                    return(__delays.getDelayTableID(row));

                case 5:
                    return(__parentLocation.getClimateStationID(row));

                case 6:
                    int index = StateCU_Util.IndexOf(__stations, __parentLocation.getClimateStationID(row));
                    if (index == -1)
                    {
                        return("N/A");
                    }
                    return(((StateCU_ClimateStation)__stations[row]).getName());

                case 7:
                    return(new double?(__parentLocation.getPrecipitationStationWeight(row)));

                case 8:
                    return(new double?(__parentLocation.getTemperatureStationWeight(row)));

                case 9:
                case 10:
                case 11:
                case 12:
                case 13:
                    StateMod_DiversionRight right = (StateMod_DiversionRight)__rights[row];
                    switch (col)
                    {
                    case 9:
                        return(right.getID());

                    case 10:
                        return(right.getName());

                    case 11:
                        return(Convert.ToDouble(right.getIrtem()));

                    case 12:
                        return(new double?(right.getDcrdiv()));

                    case 13:
                        return(new int?(right.getSwitch()));
                    }

                default:
                    return("");
                }
            }
            else
            {
                StateCU_Location location = (StateCU_Location)_data.get(row);
                switch (col)
                {
                case __COL_ID:
                    return(location.getID());

                case __COL_NAME:
                    return(location.getName());

                case __COL_ELEVATION:
                    return(new double?(location.getElevation()));

                case __COL_LATITUDE:
                    return(new double?(location.getLatitude()));

                case __COL_REGION1:
                    return(location.getRegion1());

                case __COL_REGION2:
                    return(location.getRegion2());

                case __COL_NUM_STA:
                    return(new int?(location.getNumClimateStations()));

                case __COL_AWC:
                    return(new double?(location.getAwc()));
                }
            }
            return("");
        }
Example #3
0
        /// <summary>
        /// Sets up the data Vectors to display the location collection data in the GUI.
        /// </summary>
        private void setupData()
        {
            int?div = null;

            int[]            years        = null;
            int              yearArrayLen = 0;
            int              nculoc       = _data.size();
            int              nParts       = 0;
            int              nIdTypes     = 0;
            StateCU_Location culoc        = null;
            string           colType      = null;
            string           id           = null;
            string           partType     = null;

            System.Collections.IList ids     = null;
            System.Collections.IList idTypes = null;
            string idType = null;

            __data = new System.Collections.IList[__COLUMNS];
            for (int i = 0; i < __COLUMNS; i++)
            {
                __data[i] = new List <object>();
            }

            int rows = 0;

            for (int i = 0; i < nculoc; i++)
            {
                culoc = (StateCU_Location)_data.get(i);
                id    = culoc.getID();
                div   = new int?(culoc.getCollectionDiv());

                years    = culoc.getCollectionYears();
                colType  = culoc.getCollectionType();
                partType = culoc.getCollectionPartType();

                if (years == null)
                {
                    yearArrayLen = 1;             // Cause the loop below to go through once
                }
                else
                {
                    yearArrayLen = years.Length;
                }

                for (int j = 0; j < yearArrayLen; j++)
                {
                    // Part IDs for the year
                    if ((years == null) || (years.Length == 0))
                    {
                        ids = culoc.getCollectionPartIDsForYear(0);
                    }
                    else
                    {
                        ids = culoc.getCollectionPartIDsForYear(years[j]);
                    }
                    // Part ID types for the year.
                    idTypes = culoc.getCollectionPartIDTypes();
                    if (ids == null)
                    {
                        nParts = 0;
                    }
                    else
                    {
                        nParts = ids.Count;
                    }
                    if (idTypes == null)
                    {
                        nIdTypes = 0;
                    }
                    else
                    {
                        nIdTypes = idTypes.Count;
                    }

                    for (int k = 0; k < nParts; k++)
                    {
                        __data[__COL_ID].Add(id);
                        __data[__COL_DIV].Add(div);
                        __data[__COL_YEAR].Add(new int?(years[j]));
                        __data[__COL_COL_TYPE].Add(colType);
                        __data[__COL_PART_TYPE].Add(partType);
                        __data[__COL_PART_ID].Add(ids[k]);
                        idType = "";
                        if (nIdTypes != 0)
                        {
                            idType = (string)idTypes[k];                     // Should align with ids.get(k)
                        }
                        __data[__COL_PART_ID_TYPE].Add(idType);
                        rows++;
                    }
                }
            }
            _rows = rows;
        }