/// <summary>
        /// Constructor. </summary>
        /// <param name="dataset"> the dataset in which the data is contained. </param>
        /// <param name="res"> the reservoir for which to display data </param>
        /// <param name="editable"> whether the gui data is editable or not. </param>
        public StateMod_Reservoir_Owner_JFrame(StateMod_DataSet dataset, StateMod_Reservoir res, bool editable)
        {
            StateMod_GUIUtil.setTitle(this, dataset, res.getName() + " - Reservoir Owner Accounts", null);
            JGUIUtil.setIcon(this, JGUIUtil.getIconImage());
            __currentRes = res;

            __dataset = dataset;

            __editable = editable;

            setupGUI();
        }
Example #2
0
        /// <summary>
        /// Constructor. </summary>
        /// <param name="dataset"> the dataset in which the data is contained. </param>
        /// <param name="res"> the reservoir object to display in the frame. </param>
        /// <param name="editable"> whether the gui data is editable or not </param>
        public StateMod_Reservoir_AreaCap_JFrame(StateMod_DataSet dataset, StateMod_Reservoir res, bool editable)
        {
            StateMod_GUIUtil.setTitle(this, dataset, res.getName() + " - Reservoir Content/Area/Seepage", null);
            JGUIUtil.setIcon(this, JGUIUtil.getIconImage());
            __currentRes = res;

            __dataset = dataset;

            __editable = editable;

            setupGUI();
        }
        /// <summary>
        /// Constructor. </summary>
        /// <param name="dataset"> the dataset in which the data is contained. </param>
        /// <param name="res"> the Reservoir for which to display return information. </param>
        /// <param name="editable"> whether the gui data is editable or not. </param>
        public StateMod_Reservoir_Return_JFrame(StateMod_DataSet dataset, StateMod_Reservoir res, bool editable)
        {
            StateMod_GUIUtil.setTitle(this, dataset, res.getName() + " - Reservoir Return Flow Table Assignment", null);
            JGUIUtil.setIcon(this, JGUIUtil.getIconImage());
            __currentRes = res;
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_ReturnFlow> allReturns = (java.util.List<StateMod_ReturnFlow>)dataset.getComponentForComponentType(StateMod_DataSet.COMP_RESERVOIR_RETURN).getData();
            IList <StateMod_ReturnFlow> allReturns = (IList <StateMod_ReturnFlow>)dataset.getComponentForComponentType(StateMod_DataSet.COMP_RESERVOIR_RETURN).getData();

            __currentResReturnList = (IList <StateMod_ReturnFlow>)StateMod_Util.getDataList(allReturns, res.getID());
            Message.printStatus(2, "", "Have " + __currentResReturnList.Count + " return records for reservoir \"" + __currentRes.getID() + "\" uniquetempvar.");
            //__dataset = dataset;
            // TODO SAM 2011-01-02 For now editing is disabled...
            editable   = false;
            __editable = editable;
            setupGUI();
        }
Example #4
0
        /// <summary>
        /// Display a graph of reservoir content versus area or content versus seepage. </summary>
        /// <param name="dataset"> The dataset including the reservoir. </param>
        /// <param name="res"> StateMod_Reservoir with data to graph. </param>
        /// <param name="type"> "Area" or "Seepage", indicating the data to graph. </param>
        /// <param name="editable"> Indicate whether the data are editable or not (currently
        /// ignored and treated as not editable through the graph). </param>
        public StateMod_Reservoir_AreaCap_Graph_JFrame(StateMod_DataSet dataset, StateMod_Reservoir res, string type, bool editable)
        {
            StateMod_GUIUtil.setTitle(this, dataset, res.getName() + " - Reservoir Content/" + type + " Curve", null);
            JGUIUtil.setIcon(this, JGUIUtil.getIconImage());

            __res  = res;
            __type = type;

            DefaultTableXYDataset graph_dataset = createDataset();
            JFreeChart            chart         = createChart(graph_dataset);
            ChartPanel            chartPanel    = new ChartPanel(chart);

            chartPanel.setPreferredSize(new Dimension(500, 500));
            getContentPane().add("Center", chartPanel);
            pack();
            JGUIUtil.center(this);
            setVisible(true);
        }
        /// <summary>
        /// Sets up the GUI.
        /// </summary>
        public virtual void setupGUI()
        {
            string routine = "setupGUI";

            addWindowListener(this);

            PropList p = new PropList("StateMod_Reservoir_Return_JFrame.JWorksheet");

            p.add("JWorksheet.AllowCopy=true");
            p.add("JWorksheet.CellFont=Courier");
            p.add("JWorksheet.CellStyle=Plain");
            p.add("JWorksheet.CellSize=11");
            p.add("JWorksheet.HeaderFont=Arial");
            p.add("JWorksheet.HeaderStyle=Plain");
            p.add("JWorksheet.HeaderSize=11");
            p.add("JWorksheet.HeaderBackground=LightGray");
            p.add("JWorksheet.RowColumnPresent=false");
            p.add("JWorksheet.ShowPopupMenu=true");
            p.add("JWorksheet.SelectionMode=SingleRowSelection");

            int[]            widths = null;
            JScrollWorksheet jsw    = null;

            try
            {
                /* TODO SAM 2011-01-02 Comment out - might allow something similar if editing is enabled
                 * and choices of IDs are provided
                 * List accounts = __currentRes.getAccounts();
                 * List v3 = new Vector();
                 * int size = accounts.size();
                 * StateMod_ReservoirAccount ra = null;
                 * for (int i = 0; i < size; i++) {
                 *      ra = (StateMod_ReservoirAccount)accounts.get(i);
                 *      v3.add("" + ra.getID() + " - " + ra.getName());
                 * }
                 * for (int i = 1; i < size; i++) {
                 *      v3.add("-" + (i + 1) + " - Fill first " + (i + 1)
                 + " accounts");
                 + }
                 +
                 + List v = new Vector();
                 + List v2 = __currentRes.getRights();
                 + StateMod_ReservoirRight rr;
                 + for (int i = 0; i < v2.size(); i++) {
                 +      rr = (StateMod_ReservoirRight)
                 +              ((StateMod_ReservoirRight)v2.get(i))
                 +              .clone();
                 +      v.add(rr);
                 + }
                 */
                // Get the list of all returns and filter for this reservoir
                // TODO SAM 2011-01-02 The code needs to use a table model with lists if editing is enabled
                StateMod_Reservoir_Return_Data_TableModel   tmr = new StateMod_Reservoir_Return_Data_TableModel(__currentResReturnList, __editable);
                StateMod_Reservoir_Return_Data_CellRenderer crr = new StateMod_Reservoir_Return_Data_CellRenderer(tmr);

                jsw         = new JScrollWorksheet(crr, tmr, p);
                __worksheet = jsw.getJWorksheet();

                /*
                 * List onOff = StateMod_ReservoirRight.getIrsrswChoices(true);
                 * __worksheet.setColumnJComboBoxValues(
                 *      StateMod_ReservoirRight_TableModel.COL_ON_OFF, onOff,
                 *      false);
                 * __worksheet.setColumnJComboBoxValues(
                 *      StateMod_ReservoirRight_TableModel.COL_ACCOUNT_DIST,
                 *      v3, false);
                 * List rightTypes =
                 *      StateMod_ReservoirRight.getItyrsrChoices(true);
                 * __worksheet.setColumnJComboBoxValues(
                 *      StateMod_ReservoirRight_TableModel.COL_RIGHT_TYPE,
                 *      rightTypes, false);
                 * List fillTypes=StateMod_ReservoirRight.getN2fillChoices(true);
                 * __worksheet.setColumnJComboBoxValues(
                 *      StateMod_ReservoirRight_TableModel.COL_FILL_TYPE,
                 *      fillTypes, false);
                 */

                widths = crr.getColumnWidths();
            }
            catch (Exception e)
            {
                Message.printWarning(2, routine, e);
                jsw         = new JScrollWorksheet(0, 0, p);
                __worksheet = jsw.getJWorksheet();
            }
            __worksheet.setPreferredScrollableViewportSize(null);

            __worksheet.setHourglassJFrame(this);
            __worksheet.addMouseListener(this);
            __worksheet.addKeyListener(this);

            __addReturn_JButton    = new JButton(__BUTTON_ADD_RETURN);
            __deleteReturn_JButton = new JButton(__BUTTON_DEL_RETURN);
            __deleteReturn_JButton.setEnabled(false);
            __help_JButton = new JButton(__BUTTON_HELP);
            __help_JButton.setEnabled(false);
            __close_JButton = new JButton(__BUTTON_CLOSE);
            JButton cancelJButton = new JButton(__BUTTON_CANCEL);
            JButton applyJButton  = new JButton(__BUTTON_APPLY);

            GridBagLayout gb       = new GridBagLayout();
            JPanel        bigPanel = new JPanel();

            bigPanel.setLayout(gb);

            FlowLayout fl = new FlowLayout(FlowLayout.RIGHT);
            JPanel     p1 = new JPanel();

            p1.setLayout(fl);

            GridLayout gl         = new GridLayout(2, 2, 1, 1);
            JPanel     info_panel = new JPanel();

            info_panel.setLayout(gl);

            JPanel main_panel = new JPanel();

            main_panel.setLayout(new BorderLayout());

            info_panel.add(new JLabel("Reservoir:"));
            info_panel.add(new JLabel(__currentRes.getID()));
            info_panel.add(new JLabel("Reservoir name:"));
            info_panel.add(new JLabel(__currentRes.getName()));

            if (__editable)
            {
                p1.add(__addReturn_JButton);
                p1.add(__deleteReturn_JButton);
            }
            p1.add(applyJButton);
            p1.add(cancelJButton);
            //	p1.add(__helpJButton);
            p1.add(__close_JButton);
            if (!__editable)
            {
                applyJButton.setEnabled(false);
                applyJButton.setToolTipText("Editing reservoir return data is not implemented.");
                __close_JButton.setEnabled(false);
                __close_JButton.setToolTipText("Editing reservoir return data is not implemented.");
            }

            main_panel.add(jsw, "Center");
            main_panel.add(p1, "South");

            JGUIUtil.addComponent(bigPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
            JGUIUtil.addComponent(bigPanel, main_panel, 0, 1, 10, 10, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.SOUTH);
            __addReturn_JButton.addActionListener(this);
            __deleteReturn_JButton.addActionListener(this);
            __help_JButton.addActionListener(this);
            __close_JButton.addActionListener(this);
            applyJButton.addActionListener(this);
            cancelJButton.addActionListener(this);

            getContentPane().add(bigPanel);

            JPanel bottomJPanel = new JPanel();

            bottomJPanel.setLayout(gb);
            __messageJTextField = new JTextField();
            __messageJTextField.setEditable(false);
            JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
            __statusJTextField = new JTextField(5);
            __statusJTextField.setEditable(false);
            JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            getContentPane().add("South", bottomJPanel);

            pack();
            setSize(760, 400);
            JGUIUtil.center(this);
            setVisible(true);
            if (widths != null)
            {
                __worksheet.setColumnWidths(widths);
            }
        }
Example #6
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("");
            }
        }
        /// <summary>
        /// Sets up the GUI.
        /// </summary>
        private void setupGUI()
        {
            string routine = "setupGUI";

            addWindowListener(this);

            __addOwner    = new JButton(__BUTTON_ADD_OWNER);
            __deleteOwner = new JButton(__BUTTON_DEL_OWNER);
            __deleteOwner.setEnabled(false);
            __helpJButton = new JButton(__BUTTON_HELP);
            __helpJButton.setEnabled(false);
            __closeJButton = new JButton(__BUTTON_CLOSE);
            JButton cancelJButton = new JButton(__BUTTON_CANCEL);
            JButton applyJButton  = new JButton(__BUTTON_APPLY);

            GridBagLayout gb       = new GridBagLayout();
            JPanel        bigPanel = new JPanel();

            bigPanel.setLayout(gb);

            FlowLayout fl = new FlowLayout(FlowLayout.RIGHT);
            JPanel     p1 = new JPanel();

            p1.setLayout(fl);

            GridLayout gl         = new GridLayout(2, 2, 1, 1);
            JPanel     info_panel = new JPanel();

            info_panel.setLayout(gl);

            JPanel main_panel = new JPanel();

            main_panel.setLayout(new BorderLayout());

            info_panel.add(new JLabel("Reservoir ID:"));
            info_panel.add(new JLabel(__currentRes.getID()));
            info_panel.add(new JLabel("Reservoir name:"));
            info_panel.add(new JLabel(__currentRes.getName()));

            if (__editable)
            {
                p1.add(__addOwner);
                p1.add(__deleteOwner);
            }
            p1.add(applyJButton);
            p1.add(cancelJButton);
            //	p1.add(__helpJButton);
            p1.add(__closeJButton);

            PropList p = new PropList("StateMod_Reservoir_JFrame.JWorksheet");

            p.add("JWorksheet.ShowPopupMenu=true");
            p.add("JWorksheet.AllowCopy=true");
            p.add("JWorksheet.SelectionMode=SingleRowSelection");

            int[]            widths = null;
            JScrollWorksheet jsw    = null;

            try
            {
                IList <StateMod_ReservoirAccount> v  = new List <StateMod_ReservoirAccount>();
                IList <StateMod_ReservoirAccount> v2 = __currentRes.getAccounts();
                StateMod_ReservoirAccount         ra;
                for (int i = 0; i < v2.Count; i++)
                {
                    ra = (StateMod_ReservoirAccount)v2[i].clone();
                    v.Add(ra);
                }
                StateMod_ReservoirAccount_TableModel   tmr = new StateMod_ReservoirAccount_TableModel(v, __editable, true);
                StateMod_ReservoirAccount_CellRenderer crr = new StateMod_ReservoirAccount_CellRenderer(tmr);

                jsw         = new JScrollWorksheet(crr, tmr, p);
                __worksheet = jsw.getJWorksheet();

                IList <string> owner = StateMod_ReservoirAccount.getN2ownChoices(true);
                __worksheet.setColumnJComboBoxValues(StateMod_ReservoirAccount_TableModel.COL_OWNERSHIP_TIE, owner, false);

                widths = crr.getColumnWidths();
            }
            catch (Exception e)
            {
                Message.printWarning(2, routine, e);
                jsw         = new JScrollWorksheet(0, 0, p);
                __worksheet = jsw.getJWorksheet();
            }
            __worksheet.setPreferredScrollableViewportSize(null);

            __worksheet.setHourglassJFrame(this);
            __worksheet.addMouseListener(this);
            __worksheet.addKeyListener(this);

            main_panel.add(jsw, "Center");
            main_panel.add(p1, "South");

            JGUIUtil.addComponent(bigPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
            JGUIUtil.addComponent(bigPanel, main_panel, 0, 1, 10, 10, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.SOUTH);
            __addOwner.addActionListener(this);
            __deleteOwner.addActionListener(this);
            __helpJButton.addActionListener(this);
            __closeJButton.addActionListener(this);
            applyJButton.addActionListener(this);
            cancelJButton.addActionListener(this);

            getContentPane().add(bigPanel);

            JPanel bottomJPanel = new JPanel();

            bottomJPanel.setLayout(gb);
            __messageJTextField = new JTextField();
            __messageJTextField.setEditable(false);
            JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
            __statusJTextField = new JTextField(5);
            __statusJTextField.setEditable(false);
            JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            getContentPane().add("South", bottomJPanel);

            pack();
            setSize(700, 400);
            JGUIUtil.center(this);
            setVisible(true);

            if (widths != null)
            {
                __worksheet.setColumnWidths(widths);
            }
        }
Example #8
0
        /// <summary>
        /// Sets up the GUI.
        /// </summary>
        private void setupGUI()
        {
            string routine = "setupGUI";

            addWindowListener(this);

            __addAreaCap    = new JButton(__BUTTON_ADD_AREA_CAPACITY);
            __deleteAreaCap = new JButton(__BUTTON_DEL_AREA_CAPACITY);
            __deleteAreaCap.setEnabled(false);
            __helpJButton = new JButton(__BUTTON_HELP);
            __helpJButton.setEnabled(false);
            __closeJButton = new JButton(__BUTTON_CLOSE);
            JButton cancelJButton = new JButton(__BUTTON_CANCEL);
            JButton applyJButton  = new JButton(__BUTTON_APPLY);

            GridBagLayout gb       = new GridBagLayout();
            JPanel        bigPanel = new JPanel();

            bigPanel.setLayout(gb);

            FlowLayout fl = new FlowLayout(FlowLayout.RIGHT);
            JPanel     p0 = new JPanel();

            p0.setLayout(fl);
            p0.add(__GraphArea_JButton    = new SimpleJButton(__GraphArea_String, __GraphArea_String, this));
            p0.add(__GraphSeepage_JButton = new SimpleJButton(__GraphSeepage_String, __GraphSeepage_String, this));

            GridLayout gl         = new GridLayout(2, 2, 1, 1);
            JPanel     info_panel = new JPanel();

            info_panel.setLayout(gl);

            //JPanel main_panel = new JPanel();
            //main_panel.setLayout(new BorderLayout());

            info_panel.add(new JLabel("Reservoir:"));
            info_panel.add(new JLabel(__currentRes.getID()));
            info_panel.add(new JLabel("Reservoir name:"));
            info_panel.add(new JLabel(__currentRes.getName()));

            JPanel p1 = new JPanel();

            p1.setLayout(fl);
            if (__editable)
            {
                p1.add(__addAreaCap);
                p1.add(__deleteAreaCap);
            }
            p1.add(applyJButton);
            p1.add(cancelJButton);
            //	p1.add(__helpJButton);
            p1.add(__closeJButton);

            PropList p = new PropList("StateMod_Reservoir__AreaCap_JFrame.JWorksheet");

            /*
             * p.add("JWorksheet.CellFont=Courier");
             * p.add("JWorksheet.CellStyle=Plain");
             * p.add("JWorksheet.CellSize=11");
             * p.add("JWorksheet.HeaderFont=Arial");
             * p.add("JWorksheet.HeaderStyle=Plain");
             * p.add("JWorksheet.HeaderSize=11");
             * p.add("JWorksheet.HeaderBackground=LightGray");
             * p.add("JWorksheet.RowColumnPresent=false");
             */
            p.add("JWorksheet.ShowPopupMenu=true");
            p.add("JWorksheet.AllowCopy=true");
            p.add("JWorksheet.SelectionMode=SingleRowSelection");

            int[]            widths = null;
            JScrollWorksheet jsw    = null;

            try
            {
                IList <StateMod_ReservoirAreaCap> v  = new List <StateMod_ReservoirAreaCap>();
                IList <StateMod_ReservoirAreaCap> v2 = __currentRes.getAreaCaps();
                for (int i = 0; i < v2.Count; i++)
                {
                    v.Add((StateMod_ReservoirAreaCap)v2[i].clone());
                }
                StateMod_ReservoirAreaCap_TableModel   tmr = new StateMod_ReservoirAreaCap_TableModel(v, __editable, true);
                StateMod_ReservoirAreaCap_CellRenderer crr = new StateMod_ReservoirAreaCap_CellRenderer(tmr);

                jsw         = new JScrollWorksheet(crr, tmr, p);
                __worksheet = jsw.getJWorksheet();

                widths = crr.getColumnWidths();
            }
            catch (Exception e)
            {
                Message.printWarning(2, routine, e);
                jsw         = new JScrollWorksheet(0, 0, p);
                __worksheet = jsw.getJWorksheet();
            }
            __worksheet.setPreferredScrollableViewportSize(null);

            __worksheet.setHourglassJFrame(this);
            __worksheet.addMouseListener(this);
            __worksheet.addKeyListener(this);

            //main_panel.add(jsw, "Center");
            // Does not work well...
            //main_panel.add(p1, "South");

            // assemble parts
            JGUIUtil.addComponent(bigPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST);
            JGUIUtil.addComponent(bigPanel, jsw, 0, 1, 10, 10, 1.0, 1.0, GridBagConstraints.BOTH, GridBagConstraints.SOUTH);
            JPanel button_panel = new JPanel();

            button_panel.setLayout(gb);
            JGUIUtil.addComponent(button_panel, p0, 0, 0, 10, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.SOUTHEAST);
            JGUIUtil.addComponent(button_panel, p1, 0, 1, 10, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.SOUTHEAST);
            JGUIUtil.addComponent(bigPanel, button_panel, 0, 11, 10, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.SOUTHEAST);
            __addAreaCap.addActionListener(this);
            __deleteAreaCap.addActionListener(this);
            __helpJButton.addActionListener(this);
            __closeJButton.addActionListener(this);
            applyJButton.addActionListener(this);
            cancelJButton.addActionListener(this);

            getContentPane().add(bigPanel);

            JPanel bottomJPanel = new JPanel();

            bottomJPanel.setLayout(gb);
            __messageJTextField = new JTextField();
            __messageJTextField.setEditable(false);
            JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
            __statusJTextField = new JTextField(5);
            __statusJTextField.setEditable(false);
            JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            getContentPane().add("South", bottomJPanel);

            pack();
            checkGUIState();
            setSize(420, 400);
            JGUIUtil.center(this);
            setVisible(true);

            if (widths != null)
            {
                __worksheet.setColumnWidths(widths);
            }
        }
        /// <summary>
        /// Sets up the GUI.
        /// </summary>
        public virtual void setupGUI()
        {
            string routine = "setupGUI";

            addWindowListener(this);

            __addPrecip     = new JButton(__BUTTON_ADD_PRECIPITATION_STATION);
            __addEvap       = new JButton(__BUTTON_ADD_EVAPORATION_STATION);
            __deleteStation = new JButton(__BUTTON_DELETE_PRECIPITATION_STATION);
            __deleteStation.setEnabled(false);
            __helpJButton = new JButton(__BUTTON_HELP);
            __helpJButton.setEnabled(false);
            __closeJButton = new JButton(__BUTTON_CLOSE);
            JButton cancelJButton = new JButton(__BUTTON_CANCEL);
            JButton applyJButton  = new JButton(__BUTTON_APPLY);

            GridBagLayout gb       = new GridBagLayout();
            JPanel        bigPanel = new JPanel();

            bigPanel.setLayout(gb);

            FlowLayout fl = new FlowLayout(FlowLayout.RIGHT);
            JPanel     p1 = new JPanel();

            p1.setLayout(fl);

            GridLayout gl         = new GridLayout(2, 2, 1, 1);
            JPanel     info_panel = new JPanel();

            info_panel.setLayout(gl);

            JPanel main_panel = new JPanel();

            main_panel.setLayout(new BorderLayout());

            info_panel.add(new JLabel("Reservoir:"));
            info_panel.add(new JLabel(__currentRes.getID()));
            info_panel.add(new JLabel("Reservoir name:"));
            info_panel.add(new JLabel(__currentRes.getName()));

            if (__editable)
            {
                p1.add(__addPrecip);
                p1.add(__addEvap);
                p1.add(__deleteStation);
            }
            p1.add(applyJButton);
            p1.add(cancelJButton);
            //	p1.add(__helpJButton);
            p1.add(__closeJButton);

            PropList p = new PropList("StateMod_Reservoir_Climate_JFrame.JWorksheet");

            p.add("JWorksheet.ShowPopupMenu=true");
            p.add("JWorksheet.AllowCopy=true");
            p.add("JWorksheet.SelectionMode=SingleRowSelection");

            int[]            widthsP = null;
            JScrollWorksheet jswP    = null;
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<String> stations = StateMod_Util.createIdentifierListFromTS(combineData((java.util.List<RTi.TS.MonthTS>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY).getData(), (java.util.List<RTi.TS.MonthTS>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY).getData()), true, null);
            IList <string> stations = StateMod_Util.createIdentifierListFromTS(combineData((IList <MonthTS>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY).getData(), (IList <MonthTS>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY).getData()), true, null);

            try
            {
                IList <StateMod_ReservoirClimate> temp   = getPrecipitationStations(__currentRes.getClimates());
                IList <StateMod_ReservoirClimate> clones = new List <StateMod_ReservoirClimate>();
                StateMod_ReservoirClimate         r      = null;
                int size = temp.Count;
                for (int i = 0; i < size; i++)
                {
                    r = temp[i];
                    clones.Add((StateMod_ReservoirClimate)r.clone());
                }

                __tableModelP = new StateMod_ReservoirClimate_TableModel(clones, __editable, true);
                StateMod_ReservoirClimate_CellRenderer crr = new StateMod_ReservoirClimate_CellRenderer(__tableModelP);

                jswP         = new JScrollWorksheet(crr, __tableModelP, p);
                __worksheetP = jswP.getJWorksheet();

                __worksheetP.setColumnJComboBoxValues(StateMod_ReservoirClimate_TableModel.COL_STATION, stations, true);

                widthsP = crr.getColumnWidths();
            }
            catch (Exception e)
            {
                Message.printWarning(1, routine, "Error building worksheet.", this);
                Message.printWarning(2, routine, e);
                jswP         = new JScrollWorksheet(0, 0, p);
                __worksheetP = jswP.getJWorksheet();
            }
            __worksheetP.setPreferredScrollableViewportSize(null);

            __worksheetP.setHourglassJFrame(this);
            __worksheetP.addMouseListener(this);
            __worksheetP.addKeyListener(this);

            int[]            widthsE = null;
            JScrollWorksheet jswE    = null;

            try
            {
                IList <StateMod_ReservoirClimate> temp   = getEvaporationStations(__currentRes.getClimates());
                IList <StateMod_ReservoirClimate> clones = new List <StateMod_ReservoirClimate>();
                StateMod_ReservoirClimate         r      = null;
                int size = temp.Count;
                for (int i = 0; i < size; i++)
                {
                    r = temp[i];
                    clones.Add((StateMod_ReservoirClimate)r.clone());
                }

                __tableModelE = new StateMod_ReservoirClimate_TableModel(clones, __editable, true);
                StateMod_ReservoirClimate_CellRenderer crr = new StateMod_ReservoirClimate_CellRenderer(__tableModelE);

                jswE         = new JScrollWorksheet(crr, __tableModelE, p);
                __worksheetE = jswE.getJWorksheet();

                __worksheetE.setColumnJComboBoxValues(StateMod_ReservoirClimate_TableModel.COL_STATION, stations, true);
                widthsE = crr.getColumnWidths();
            }
            catch (Exception e)
            {
                Message.printWarning(1, routine, "Error building worksheet.", this);
                Message.printWarning(2, routine, e);
                jswE         = new JScrollWorksheet(0, 0, p);
                __worksheetE = jswE.getJWorksheet();
            }
            __worksheetE.setPreferredScrollableViewportSize(null);

            __worksheetE.setHourglassJFrame(this);
            __worksheetE.addMouseListener(this);
            __worksheetE.addKeyListener(this);

            JPanel worksheets = new JPanel();

            worksheets.setLayout(gb);

            JPanel panelP = new JPanel();

            panelP.setLayout(gb);
            panelP.setBorder(BorderFactory.createTitledBorder("Precipitation Stations"));
            JGUIUtil.addComponent(panelP, jswP, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);

            JPanel panelE = new JPanel();

            panelE.setLayout(gb);
            panelE.setBorder(BorderFactory.createTitledBorder("Evaporation Stations"));
            JGUIUtil.addComponent(panelE, jswE, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);

            JGUIUtil.addComponent(worksheets, panelP, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);
            JGUIUtil.addComponent(worksheets, panelE, 0, 1, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST);

            main_panel.add(worksheets, "Center");
            main_panel.add(p1, "South");

            // assemble parts
            JGUIUtil.addComponent(bigPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);

            JGUIUtil.addComponent(bigPanel, main_panel, 0, 1, 10, 10, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.SOUTH);
            __addEvap.addActionListener(this);
            __addPrecip.addActionListener(this);
            __deleteStation.addActionListener(this);
            __helpJButton.addActionListener(this);
            __closeJButton.addActionListener(this);
            applyJButton.addActionListener(this);
            cancelJButton.addActionListener(this);

            getContentPane().add(bigPanel);

            JPanel bottomJPanel = new JPanel();

            bottomJPanel.setLayout(gb);
            __messageJTextField = new JTextField();
            __messageJTextField.setEditable(false);
            JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
            __statusJTextField = new JTextField(5);
            __statusJTextField.setEditable(false);
            JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            getContentPane().add("South", bottomJPanel);

            pack();
            setSize(650, 400);
            JGUIUtil.center(this);
            setVisible(true);

            if (widthsP != null)
            {
                __worksheetP.setColumnWidths(widthsP);
            }
            if (widthsE != null)
            {
                __worksheetE.setColumnWidths(widthsE);
            }
        }
        /// <summary>
        /// Creates a list of the available IDs for a Vector of StateMod_Data-extending
        /// objects.  Reservoirs will include an identifier for each reservoir total and each account for the reservoir. </summary>
        /// <param name="nodes"> the nodes for which to create a list of IDs. </param>
        /// <param name="include_accounts"> If true, the </param>
        /// <returns> a Vector of Strings, each of which contains an ID followed by the name of Structure in parentheses </returns>
        private System.Collections.IList createAvailableIDsList(System.Collections.IList nodes)
        {
            System.Collections.IList v = new List <object>();

            int  num          = 0;
            bool is_reservoir = false;     // To allow check below

            if (nodes != null)
            {
                num = nodes.Count;
                if ((num > 0) && ((StateMod_Data)nodes[0]) is StateMod_Reservoir)
                {
                    is_reservoir = true;
                }
            }

            StateMod_Reservoir res = null;     // These are used if reservoirs.
            int nowner             = 0;
            int ia = 0;

            for (int i = 0; i < num; i++)
            {
                // Add the normal item...
                v.Add(StateMod_Util.formatDataLabel(((StateMod_Data)nodes[i]).getID(), ((StateMod_Data)nodes[i]).getName()));
                if (is_reservoir)
                {
                    // Also add reservoir owner/accounts...
                    res    = (StateMod_Reservoir)nodes[i];
                    nowner = res.getAccounts().Count;
                    for (ia = 0; ia < nowner; ia++)
                    {
                        v.Add(StateMod_Util.formatDataLabel(res.getID() + "-" + (ia + 1), res.getName() + " - " + res.getAccount(ia).getName()));
                    }
                }
            }
            return(v);
        }
Example #11
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);
        }
        /// <summary>
        /// Sets up the GUI.
        /// </summary>
        public virtual void setupGUI()
        {
            string routine = "setupGUI";

            addWindowListener(this);

            PropList p = new PropList("StateMod_Reservoir_JFrame.JWorksheet");

            p.add("JWorksheet.AllowCopy=true");
            p.add("JWorksheet.CellFont=Courier");
            p.add("JWorksheet.CellStyle=Plain");
            p.add("JWorksheet.CellSize=11");
            p.add("JWorksheet.HeaderFont=Arial");
            p.add("JWorksheet.HeaderStyle=Plain");
            p.add("JWorksheet.HeaderSize=11");
            p.add("JWorksheet.HeaderBackground=LightGray");
            p.add("JWorksheet.RowColumnPresent=false");
            p.add("JWorksheet.ShowPopupMenu=true");
            p.add("JWorksheet.SelectionMode=SingleRowSelection");

            int[]            widths = null;
            JScrollWorksheet jsw    = null;

            try
            {
                IList <StateMod_ReservoirAccount> accounts = __currentRes.getAccounts();
                IList <string>            v3   = new List <string>();
                int                       size = accounts.Count;
                StateMod_ReservoirAccount ra   = null;
                for (int i = 0; i < size; i++)
                {
                    ra = accounts[i];
                    v3.Add("" + ra.getID() + " - " + ra.getName());
                }
                for (int i = 1; i < size; i++)
                {
                    v3.Add("-" + (i + 1) + " - Fill first " + (i + 1) + " accounts");
                }

                IList <StateMod_ReservoirRight> v  = new List <StateMod_ReservoirRight>();
                IList <StateMod_ReservoirRight> v2 = __currentRes.getRights();
                StateMod_ReservoirRight         rr;
                for (int i = 0; i < v2.Count; i++)
                {
                    rr = (StateMod_ReservoirRight)v2[i].clone();
                    v.Add(rr);
                }
                StateMod_ReservoirRight_TableModel   tmr = new StateMod_ReservoirRight_TableModel(v, __editable);
                StateMod_ReservoirRight_CellRenderer crr = new StateMod_ReservoirRight_CellRenderer(tmr);

                jsw         = new JScrollWorksheet(crr, tmr, p);
                __worksheet = jsw.getJWorksheet();

                IList <string> onOff = StateMod_ReservoirRight.getIrsrswChoices(true);
                __worksheet.setColumnJComboBoxValues(StateMod_ReservoirRight_TableModel.COL_ON_OFF, onOff, false);
                __worksheet.setColumnJComboBoxValues(StateMod_ReservoirRight_TableModel.COL_ACCOUNT_DIST, v3, false);
                IList <string> rightTypes = StateMod_ReservoirRight.getItyrsrChoices(true);
                __worksheet.setColumnJComboBoxValues(StateMod_ReservoirRight_TableModel.COL_RIGHT_TYPE, rightTypes, false);
                IList <string> fillTypes = StateMod_ReservoirRight.getN2fillChoices(true);
                __worksheet.setColumnJComboBoxValues(StateMod_ReservoirRight_TableModel.COL_FILL_TYPE, fillTypes, false);

                widths = crr.getColumnWidths();
            }
            catch (Exception e)
            {
                Message.printWarning(2, routine, e);
                jsw         = new JScrollWorksheet(0, 0, p);
                __worksheet = jsw.getJWorksheet();
            }
            __worksheet.setPreferredScrollableViewportSize(null);

            __worksheet.setHourglassJFrame(this);
            __worksheet.addMouseListener(this);
            __worksheet.addKeyListener(this);

            __addRight    = new JButton(__BUTTON_ADD_RIGHT);
            __deleteRight = new JButton(__BUTTON_DEL_RIGHT);
            __deleteRight.setEnabled(false);
            __helpJButton = new JButton(__BUTTON_HELP);
            __helpJButton.setEnabled(false);
            __closeJButton = new JButton(__BUTTON_CLOSE);
            JButton cancelJButton = new JButton(__BUTTON_CANCEL);
            JButton applyJButton  = new JButton(__BUTTON_APPLY);

            GridBagLayout gb       = new GridBagLayout();
            JPanel        bigPanel = new JPanel();

            bigPanel.setLayout(gb);

            FlowLayout fl = new FlowLayout(FlowLayout.RIGHT);
            JPanel     p1 = new JPanel();

            p1.setLayout(fl);

            GridLayout gl         = new GridLayout(2, 2, 1, 1);
            JPanel     info_panel = new JPanel();

            info_panel.setLayout(gl);

            JPanel main_panel = new JPanel();

            main_panel.setLayout(new BorderLayout());

            info_panel.add(new JLabel("Reservoir:"));
            info_panel.add(new JLabel(__currentRes.getID()));
            info_panel.add(new JLabel("Reservoir name:"));
            info_panel.add(new JLabel(__currentRes.getName()));

            if (__editable)
            {
                p1.add(__addRight);
                p1.add(__deleteRight);
            }
            p1.add(applyJButton);
            p1.add(cancelJButton);
            //	p1.add(__helpJButton);
            p1.add(__closeJButton);

            main_panel.add(jsw, "Center");
            main_panel.add(p1, "South");

            JGUIUtil.addComponent(bigPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST);
            JGUIUtil.addComponent(bigPanel, main_panel, 0, 1, 10, 10, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.SOUTH);
            __addRight.addActionListener(this);
            __deleteRight.addActionListener(this);
            __helpJButton.addActionListener(this);
            __closeJButton.addActionListener(this);
            applyJButton.addActionListener(this);
            cancelJButton.addActionListener(this);

            getContentPane().add(bigPanel);

            JPanel bottomJPanel = new JPanel();

            bottomJPanel.setLayout(gb);
            __messageJTextField = new JTextField();
            __messageJTextField.setEditable(false);
            JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
            __statusJTextField = new JTextField(5);
            __statusJTextField.setEditable(false);
            JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST);
            getContentPane().add("South", bottomJPanel);

            pack();
            setSize(760, 400);
            JGUIUtil.center(this);
            setVisible(true);
            if (widths != null)
            {
                __worksheet.setColumnWidths(widths);
            }
        }