/// <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 in the title of the GUI. </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>
        /// <param name="precip"> if true, then the climate stations to view are precip stations.
        /// If false, they are evap stations. </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_ReservoirClimate_Data_JFrame(java.util.List data, String titleString, boolean editable, boolean precip) throws Exception
        public StateMod_ReservoirClimate_Data_JFrame(System.Collections.IList data, string titleString, bool editable, bool precip) : base()
        {
            int j     = 0;
            int size  = 0;
            int size2 = 0;
            StateMod_Reservoir        r = null;
            StateMod_ReservoirClimate c = null;

            System.Collections.IList climates = 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];
                climates = r.getClimates();
                if (climates == null)
                {
                    continue;
                }

                size2 = climates.Count;

                for (j = 0; j < size2; j++)
                {
                    c = (StateMod_ReservoirClimate)climates[j];
                    if (c == null)
                    {
                        // skip
                    }
                    else if (!precip && c.getType() == StateMod_ReservoirClimate.CLIMATE_EVAP)
                    {
                        c.setCgoto(r.getID());
                        v.Add(c);
                    }
                    else if (precip && c.getType() == StateMod_ReservoirClimate.CLIMATE_PTPX)
                    {
                        c.setCgoto(r.getID());
                        v.Add(c);
                    }
                }
            }

            initialize(v, titleString, editable);
            setSize(377, getHeight());
        }
Ejemplo n.º 2
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());
        }
        /// <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);
        }
        /// <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();
        }
        /// <summary>
        /// Responds to action performed events. </summary>
        /// <param name="e"> the ActionEvent that happened. </param>
        public virtual void actionPerformed(ActionEvent e)
        {
            string routine = "StateMod_Reservoir_Return_JFrame::actionPerformed";

            string action = e.getActionCommand();

            if (action.Equals(__BUTTON_ADD_RETURN))
            {
                StateMod_ReturnFlow aReturn = new StateMod_ReturnFlow(StateMod_DataSet.COMP_RESERVOIR_RETURN);
                aReturn._isClone = true;
                StateMod_ReturnFlow last = (StateMod_ReturnFlow)__worksheet.getLastRowData();

                if (last == null)
                {
                    aReturn.setID(StateMod_Util.createNewID(__currentRes.getID()));
                    aReturn.setCgoto(__currentRes.getID());
                }
                else
                {
                    aReturn.setID(StateMod_Util.createNewID(last.getID()));
                    aReturn.setCgoto(last.getCgoto());
                }
                __worksheet.scrollToLastRow();
                __worksheet.addRow(aReturn);
                __worksheet.selectLastRow();
                __deleteReturn_JButton.setEnabled(true);
            }
            else if (action.Equals(__BUTTON_DEL_RETURN))
            {
                int row = __worksheet.getSelectedRow();
                if (row != -1)
                {
                    int x = (new ResponseJDialog(this, "Delete return", "Delete reservoir return?", ResponseJDialog.YES | ResponseJDialog.NO)).response();
                    if (x == ResponseJDialog.NO)
                    {
                        return;
                    }

                    __worksheet.cancelEditing();
                    __worksheet.deleteRow(row);
                    __deleteReturn_JButton.setEnabled(false);
                }
                else
                {
                    Message.printWarning(1, routine, "Must select desired return to delete.");
                }
            }
            else if (action.Equals(__BUTTON_CLOSE))
            {
                if (saveData())
                {
                    setVisible(false);
                    dispose();
                }
            }
            else if (action.Equals(__BUTTON_APPLY))
            {
                saveData();
            }
            else if (action.Equals(__BUTTON_CANCEL))
            {
                setVisible(false);
                dispose();
            }
            else if (e.getSource() == __help_JButton)
            {
                // TODO HELP (JTS - 2003-06-09)
            }
        }
Ejemplo n.º 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 data Vectors to display the reservoir collection data in the
        /// GUI.
        /// </summary>
        private void setupData()
        {
            int[] years                 = null;
            int   len                   = 0;
            int   size                  = _data.size();
            int   size2                 = 0;
            StateMod_Reservoir l        = null;
            string             colType  = null;
            string             id       = null;
            string             partType = null;

            System.Collections.IList ids = 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  = (StateMod_Reservoir)_data.get(i);
                id = l.getID();
                //		div = new Integer(l.getCollectionDiv());

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

                if (years == null)
                {
                    len = 0;
                }
                else
                {
                    len = years.Length;
                }

                for (int j = 0; j < len; j++)
                {
                    ids = l.getCollectionPartIDs(years[j]);
                    if (ids == null)
                    {
                        size2 = 0;
                    }
                    else
                    {
                        size2 = ids.Count;
                    }

                    for (int k = 0; k < size2; 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]);
                        rows++;
                    }
                }
            }
            _rows = rows;
        }
        /// <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);
            }
        }
Ejemplo n.º 9
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);
            }
        }
Ejemplo n.º 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);
        }