Example #1
0
        /// <summary>
        /// Constructor. </summary>
        /// <param name="data"> the data to display in the worksheet.  Can be null or empty, in
        /// which case an empty worksheet is shown. </param>
        /// <param name="titleString"> the String to display as the GUI title. </param>
        /// <param name="editable"> whether the data in the JFrame can be edited or not.  If true
        /// the data can be edited, if false they can not. </param>
        /// <exception cref="Exception"> if there is an error building the worksheet. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public StateMod_ReservoirAreaCap_Data_JFrame(java.util.List data, String titleString, boolean editable) throws Exception
        public StateMod_ReservoirAreaCap_Data_JFrame(System.Collections.IList data, string titleString, bool editable) : base()
        {
            int j     = 0;
            int size  = 0;
            int size2 = 0;
            StateMod_Reservoir        r = null;
            StateMod_ReservoirAreaCap a = null;

            System.Collections.IList areacaps = null;
            System.Collections.IList v        = new List <object>();

            if (data != null)
            {
                size = data.Count;
            }

            for (int i = 0; i < size; i++)
            {
                r        = (StateMod_Reservoir)data[i];
                areacaps = r.getAreaCaps();
                if (areacaps == null)
                {
                    continue;
                }

                size2 = areacaps.Count;

                for (j = 0; j < size2; j++)
                {
                    a = (StateMod_ReservoirAreaCap)areacaps[j];
                    a.setCgoto(r.getID());
                    v.Add(a);
                }
            }

            initialize(v, titleString, editable);
            setSize(400, getHeight());
        }
Example #2
0
        /// <summary>
        /// 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_Reservoir r = (StateMod_Reservoir)_data.get(row);

            switch (col)
            {
            case COL_ID:
                return(r.getID());

            case COL_NAME:
                return(r.getName());

            case COL_NODE_ID:
                return(r.getCgoto());

            case COL_SWITCH:
                return(new int?(r.getSwitch()));

            case COL_ONE_FILL_DATE:
                return(new int?((int)r.getRdate()));

            case COL_MIN_CONTENT:
                return(new double?(r.getVolmin()));

            case COL_MAX_CONTENT:
                return(new double?(r.getVolmax()));

            case COL_MAX_RELEASE:
                return(new double?(r.getFlomax()));

            case COL_DEAD_STORAGE:
                return(new double?(r.getDeadst()));

            case COL_DAILY_ID:
                return(r.getCresdy());

            case COL_NUM_OWNERS:
                return(new int?(r.getNowner()));

            case COL_NUM_PRECIP_STA:
                int nptpx = StateMod_ReservoirClimate.getNumPrecip(r.getClimates());
                return(new int?(nptpx));

            case COL_NUM_EVAP_STA:
                int nevap = StateMod_ReservoirClimate.getNumEvap(r.getClimates());
                return(new int?(nevap));

            case COL_NUM_CURVE_ROWS:
                System.Collections.IList v = r.getAreaCaps();
                if (v == null)
                {
                    return(new int?(0));
                }
                else
                {
                    return(new int?(v.Count));
                }

            default:
                return("");
            }
        }
Example #3
0
        /// <summary>
        /// Check the GUI state.  In particular, indicate whether the graph buttons should
        /// be enabled.
        /// </summary>
        private void checkGUIState()
        {
            IList <StateMod_ReservoirAreaCap> rv = __currentRes.getAreaCaps();

            if ((rv != null) && (rv.Count > 0))
            {
                bool area_ok = true, seepage_ok = true;
                // Check for data all one value...
                int size = rv.Count;
                StateMod_ReservoirAreaCap ac = null;
                double value;
                // REVISIT SAM 2006-08-20
                // JFreeChart has a problem when the values are the same as
                // the previous values.  However, for now, increment the values
                // slightly when graphing rather than disabling the graph.
                // Go ahead and disable if all values are the same.
                double area0 = 0.0, seepage0 = 0.0;
                bool   area_all_same = true, seepage_all_same = true;
                for (int i = 0; i < size; i++)
                {
                    ac    = (StateMod_ReservoirAreaCap)rv[i];
                    value = ac.getSurarea();

                    /*
                     * if ( value == value_prev ) {
                     *      area_ok = false;
                     *      break;
                     * }
                     */
                    if (i == 0)
                    {
                        area0 = value;
                    }
                    else
                    {
                        if (value != area0)
                        {
                            area_all_same = false;
                        }
                    }
                }
                for (int i = 0; i < size; i++)
                {
                    ac    = (StateMod_ReservoirAreaCap)rv[i];
                    value = ac.getSeepage();

                    /*
                     * if ( value == value_prev ) {
                     *      seepage_ok = false;
                     *      break;
                     * }
                     */
                    if (i == 0)
                    {
                        seepage0 = value;
                    }
                    else
                    {
                        if (value != seepage0)
                        {
                            seepage_all_same = false;
                        }
                    }
                }
                if (area_all_same)
                {
                    area_ok = false;
                }
                if (seepage_all_same)
                {
                    seepage_ok = false;
                }
                JGUIUtil.setEnabled(__GraphArea_JButton, area_ok);
                JGUIUtil.setEnabled(__GraphSeepage_JButton, seepage_ok);
            }
            else
            {
                JGUIUtil.setEnabled(__GraphArea_JButton, false);
                JGUIUtil.setEnabled(__GraphSeepage_JButton, false);
            }
            // Only enable the graph buttons if the new charting package is in the
            // path.  This will allow for some graceful transition to distribution
            // of the new software.
            if (!IOUtil.classCanBeLoaded("org.jfree.chart.ChartPanel"))
            {
                JGUIUtil.setEnabled(__GraphArea_JButton, false);
                JGUIUtil.setEnabled(__GraphSeepage_JButton, false);
            }
        }
Example #4
0
        /// <summary>
        /// Create a dataset to display in the chart.  Extract the values from the
        /// StateMod_Reservoir curve data.
        /// </summary>
        private DefaultTableXYDataset createDataset()
        {
            string routine = "StateMod_Reservoir_AreaCap_Graph_JFrame.createDataSet";
            DefaultTableXYDataset dataset = new DefaultTableXYDataset();

            IList <StateMod_ReservoirAreaCap> v = __res.getAreaCaps();
            int size = 0;

            if (v != null)
            {
                size = v.Count;
            }
            XYSeries series = new XYSeries("Reservoir " + __res.getID() + " (" + __res.getName() + ") Content/" + __type + " Curve", false, false);
            StateMod_ReservoirAreaCap ac = null;
            // Speed up checks in loop...
            bool do_area = true;

            if (__type.Equals("Seepage", StringComparison.OrdinalIgnoreCase))
            {
                do_area = false;
            }
            double value_prev = -10000000.0, value = 0.0, value2 = 0.0;
            double content     = 0.0;
            int    match_count = 0;

            for (int i = 0; i < size; i++)
            {
                ac = (StateMod_ReservoirAreaCap)v[i];
                // Curves will often have a very large content to protect
                // against out of bounds for interpolation.  However, if this
                // point is graphed, it causes the other values to appear
                // miniscule.  Therefore, omit the last point if it is much
                // larger than the previous value.
                if ((size > 4) && (i == (size - 1)) && ac.getConten() > 9000000.0)
                {
                    Message.printStatus(2, routine, "Skipping last point.  Seems to be very large bounding" + " value and might skew the graph.");
                    continue;
                }
                // Add X first, then Y...
                if (do_area)
                {
                    value = ac.getSurarea();
                }
                else
                {
                    value = ac.getSeepage();
                }
                if (value == value_prev)
                {
                    // This is needed because JFreeChart will not allow
                    // adjacent X values to be the same.
                    ++match_count;
                    value2 = value + match_count * .00001;
                }
                else
                {
                    value2 = value;
                }
                content = ac.getConten();
                // REVISIT SAM 2006-08-20
                // Not sure if content needs to be checked the same way for
                // duplicates.
                Message.printStatus(2, routine, "X=" + value2 + " y=" + content);
                series.add(value2, content);
                value_prev = value;
            }
            dataset.addSeries(series);

            return(dataset);
        }