/// <summary> /// Copy constructor. </summary> /// <param name="deep_copy"> If true, make a deep copy including secondary vectors of data. /// Currently only false is recognized, in which primitive data are copied. This is /// suitable to allow the StateMod_Diversion_JFrame class to know when changes have /// been made to data on the main screen. </param> public StateMod_Diversion(StateMod_Diversion div, bool deep_copy) : this() { // Base class... // TODO // Local data members... _cdividy = div._cdividy; _divcap = div._divcap; _username = div._username; _idvcom = div._idvcom; _divefc = div._divefc; for (int i = 0; i < 12; i++) { _diveff[i] = div._diveff[i]; } _area = div._area; _irturn = div._irturn; _rivret = div._rivret; _rights = div._rights; _demsrc = div._demsrc; _ireptype = div._ireptype; // For time series, the references are pointed to the original but data are not copied. _demand_MonthTS = div._demand_MonthTS; _demand_override_MonthTS = div._demand_override_MonthTS; _demand_average_MonthTS = div._demand_average_MonthTS; _demand_DayTS = div._demand_DayTS; _diversion_MonthTS = div._diversion_MonthTS; _diversion_DayTS = div._diversion_DayTS; _cwr_MonthTS = div._cwr_MonthTS; _cwr_DayTS = div._cwr_DayTS; //_ipy_YearTS = div._ipy_YearTS; _awc = div._awc; //_georecord = div._georecord; }
/// <summary> /// Connect monthly baseflow time series. </summary> /// <param name="tslist"> baseflow time series. </param> public virtual void connectBaseflowMonthTS(IList <MonthTS> tslist) { if (tslist == null) { return; } int num_TS = tslist.Count; _baseflow_MonthTS = null; MonthTS ts = null; for (int i = 0; i < num_TS; i++) { ts = tslist[i]; if (ts == null) { continue; } if (_id.Equals(ts.getLocation(), StringComparison.OrdinalIgnoreCase)) { // Set this because the original file does not have... ts.setDescription(getName()); _baseflow_MonthTS = ts; break; } } }
/// <summary> /// Connect the historical monthly TS pointer to the appropriate TS. /// A connection is made if the node identifier matches the time series location. </summary> /// <param name="tslist"> Vector of MonthTS. </param> public virtual void connectHistoricalMonthTS(IList <MonthTS> tslist) { if (tslist == null) { return; } MonthTS ts; _historical_MonthTS = null; int size = tslist.Count; for (int i = 0; i < size; i++) { ts = tslist[i]; if (ts == null) { continue; } if (_id.Equals(ts.getLocation(), StringComparison.OrdinalIgnoreCase)) { // The name is usually not set when reading the time series... ts.setDescription(getName()); _historical_MonthTS = ts; break; } } }
/// <summary> /// Connect monthly demand time series to the instream flow. /// The time series description is set to the station name. /// </summary> public virtual void connectDemandMonthTS(IList <MonthTS> tslist) { if (tslist == null) { return; } int numTS = tslist.Count; MonthTS ts; _demand_MonthTS = null; for (int i = 0; i < numTS; i++) { ts = tslist[i]; if (ts == null) { continue; } if (_id.Equals(ts.getLocation())) { _demand_MonthTS = ts; ts.setDescription(getName()); break; } } }
/// <summary> /// Initialize data members. </summary> /// <param name="initialize_defaults"> If true, initialize data to reasonable defaults /// (e.g., zero dead storage) - this is suitable for defaults in the StateMod GUI. /// If false, don't initialize data - this is suitable for filling in StateDMI. </param> private void initialize(bool initialize_defaults) { _smdata_type = StateMod_DataSet.COMP_RESERVOIR_STATIONS; _owners = new List <StateMod_ReservoirAccount>(); _climate_Vector = new List <StateMod_ReservoirClimate>(); _areacapvals = new List <StateMod_ReservoirAreaCap>(); _rights = new List <StateMod_ReservoirRight>(); _content_MonthTS = null; _content_DayTS = null; _mintarget_MonthTS = null; _maxtarget_MonthTS = null; _mintarget_DayTS = null; _maxtarget_DayTS = null; //_georecord = null; if (initialize_defaults) { _cresdy = "0"; // Use monthly TS for daily _switch = 1; // In base class _rdate = -1; _volmin = 0; _volmax = 0; _flomax = 99999.0; // As per old SMGUI new reservoir _deadst = 0; } else { _cresdy = ""; _rdate = StateMod_Util.MISSING_INT; _volmin = StateMod_Util.MISSING_DOUBLE; _volmax = StateMod_Util.MISSING_DOUBLE; _flomax = StateMod_Util.MISSING_DOUBLE; _deadst = StateMod_Util.MISSING_DOUBLE; } }
/// <summary> /// Initialize data. Sets the smdata_type to _dataset.COMP_DIVERSION_STATIONS. </summary> /// <param name="initialize_defaults"> If true, assign data to reasonable defaults. /// If false, all data are set to missing. </param> private void initialize(bool initialize_defaults) { _smdata_type = StateMod_DataSet.COMP_DIVERSION_STATIONS; if (initialize_defaults) { _divefc = -60.0; // Ray Bennett, Ray Alvarado, 2003-10-07 progress mtg. _diveff = new double[12]; for (int i = 0; i < 12; i++) { _diveff[i] = 60.0; // See above } _username = ""; _cdividy = "0"; // Use the average monthly TS for daily TS _divcap = 0; _idvcom = 1; _area = 0; _irturn = 1; _demsrc = DEMSRC_UNKNOWN; _ireptype = -1; // Provide depletion replacement } else { _divefc = StateMod_Util.MISSING_DOUBLE; _diveff = new double[12]; for (int i = 0; i < 12; i++) { _diveff[i] = StateMod_Util.MISSING_DOUBLE; } _username = StateMod_Util.MISSING_STRING; _cdividy = StateMod_Util.MISSING_STRING; _divcap = StateMod_Util.MISSING_INT; _idvcom = StateMod_Util.MISSING_INT; _area = StateMod_Util.MISSING_DOUBLE; _irturn = StateMod_Util.MISSING_INT; _demsrc = StateMod_Util.MISSING_INT; _ireptype = StateMod_Util.MISSING_INT; } _rivret = new List <StateMod_ReturnFlow>(); _rights = new List <StateMod_DiversionRight>(); _diversion_MonthTS = null; _diversion_DayTS = null; _demand_MonthTS = null; _demand_override_MonthTS = null; _demand_average_MonthTS = null; _demand_DayTS = null; //_ipy_YearTS = null; _cwr_MonthTS = null; _cwr_DayTS = null; //_georecord = null; }
/// <summary> /// Set default values for all arguments </summary> /// <param name="initialize_defaults"> If true, initialize data to reasonable values. If /// false, initialize to missing values. </param> private void initialize(bool initialize_defaults) { _smdata_type = StateMod_DataSet.COMP_WELL_STATIONS; _rivret = new List <StateMod_ReturnFlow>(10); _depl = new List <StateMod_ReturnFlow>(10); _pumping_MonthTS = null; _pumping_DayTS = null; _demand_MonthTS = null; _demand_DayTS = null; //_ipy_YearTS = null; _cwr_MonthTS = null; _cwr_DayTS = null; _rights = new List <StateMod_WellRight>(); //_georecord = null; if (initialize_defaults) { _cdividyw = "0"; // Estimate average daily from monthly data. _idvcow2 = "N/A"; _diveff = new double[12]; for (int i = 0; i < 12; i++) { _diveff[i] = 60.0; } _divcapw = 0; _idvcomw = 1; _divefcw = -60.0; // Indicate to use monthly efficiencies _areaw = 0.0; _irturnw = 0; _demsrcw = 1; _primary = 0; } else { _cdividyw = ""; _idvcow2 = ""; _diveff = new double[12]; for (int i = 0; i < 12; i++) { _diveff[i] = StateMod_Util.MISSING_DOUBLE; } _divcapw = StateMod_Util.MISSING_DOUBLE; _idvcomw = StateMod_Util.MISSING_INT; _divefcw = StateMod_Util.MISSING_DOUBLE; _areaw = StateMod_Util.MISSING_DOUBLE; _irturnw = StateMod_Util.MISSING_INT; _demsrcw = StateMod_Util.MISSING_INT; _primary = StateMod_Util.MISSING_INT; } }
/// <summary> /// Initialize data. </summary> /// <param name="initialize_defaults"> If true, the time series are set to null and other /// information is empty strings - this is suitable for the StateMod GUI. If false, /// the data are set to missing - this is suitable for StateDMI where data will be filled. </param> private void initialize(bool initialize_defaults) { _smdata_type = StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS; _cgoto = ""; _baseflow_MonthTS = null; _baseflow_DayTS = null; _related_smdata_type = StateMod_DataSet.COMP_UNKNOWN; if (initialize_defaults) { // Reasonable defaults... _crunidy = "0"; // Estimate average daily from monthly data. } else { // Missing... _crunidy = ""; } //_georecord = null; }
/// <summary> /// Initialize data. </summary> /// <param name="initialize_defaults"> If true, the time series are set to null and other /// information to empty strings or other reasonable defaults - this is suitable /// for the StateMod GUI when creating new instances. If false, the /// data values are set to missing - this is suitable for use with StateDMI, where /// data will be filled with commands. </param> private void initialize(bool initialize_defaults) { _smdata_type = StateMod_DataSet.COMP_STREAMGAGE_STATIONS; _cgoto = ""; _historical_MonthTS = null; _historical_DayTS = null; _baseflow_MonthTS = null; _baseflow_DayTS = null; if (initialize_defaults) { // Set to reasonable defaults... _crunidy = "0"; // Use monthly data } else { // Initialize to missing _crunidy = ""; } _georecord = null; }
/// <summary> /// Initialize data. </summary> /// <param name="initializeDefaults"> If true, then data values are initialized to /// reasonable defaults - this is suitable for adding a new instance in the /// StateMod GUI. If false, data values are initialized to missing - this is /// suitable for a new instance in StateDMI. </param> private void initialize(bool initializeDefaults) { _smdata_type = StateMod_DataSet.COMP_INSTREAM_STATIONS; _ifrrdn = ""; if (initializeDefaults) { _cifridy = "0"; // Estimate average daily data from monthly _iifcom = 2; // Default to annual } else { _cifridy = ""; _iifcom = StateMod_Util.MISSING_INT; } _rights = new List <StateMod_InstreamFlowRight>(); _demand_DayTS = null; _demand_MonthTS = null; _demand_average_MonthTS = null; //_georecord = null; }
/// <summary> /// Set the historical monthly TS pointer. </summary> /// <param name="ts"> historical monthly TS. </param> public virtual void setHistoricalMonthTS(MonthTS ts) { _historical_MonthTS = ts; }
/// <summary> /// Set the monthly baseflow TS. </summary> /// <param name="ts"> monthly baseflow TS. </param> public virtual void setBaseflowMonthTS(MonthTS ts) { _baseflow_MonthTS = ts; }
/// <summary> /// Sets monthly demand ts /// </summary> public virtual void setDemandMonthTS(MonthTS demand_MonthTS) { _demand_MonthTS = demand_MonthTS; }
/// <summary> /// Sets average monthly demand ts /// </summary> public virtual void setDemandAverageMonthTS(MonthTS demand_average_MonthTS) { _demand_average_MonthTS = demand_average_MonthTS; }
/// <summary> /// Responds to action performed events. </summary> /// <param name="e"> the ActionEvent that happened. </param> public virtual void actionPerformed(ActionEvent e) { string routine = "StateMod_DelayTable_JFrame" + ".actionPerformed"; if (Message.isDebugOn) { Message.printDebug(1, routine, "In actionPerformed: " + e.getActionCommand()); } string action = e.getActionCommand(); if (action.Equals(__BUTTON_HELP)) { // REVISIT HELP (JTS - 2003-06-09) } else if (action.Equals(__BUTTON_CLOSE)) { closeWindow(); } else if (action.Equals(__BUTTON_APPLY)) { saveDelayTable(); int size = __delaysVector.Count; StateMod_DelayTable dt = null; bool changed = false; for (int i = 0; i < size; i++) { dt = (StateMod_DelayTable)__delaysVector[i]; if (!changed && dt.changed()) { changed = true; } dt.createBackup(); } if (changed) { __dataset.setDirty(__componentType, true); } } else if (action.Equals(__BUTTON_CANCEL)) { __worksheetR.deselectAll(); int size = __delaysVector.Count; StateMod_DelayTable dt = null; bool changed = false; for (int i = 0; i < size; i++) { dt = (StateMod_DelayTable)__delaysVector[i]; if (!changed && dt.changed()) { changed = true; } dt.restoreOriginal(); } if (__dataset_wm != null) { __dataset_wm.closeWindow(__window_type); } else { JGUIUtil.close(this); } } else if (action.Equals(__BUTTON_ADD_RETURN)) { int row = __worksheetR.getSelectedRow(); int total_num_rows = __worksheetR.getRowCount() - 1; if (row == -1) { row = total_num_rows; } if (row != -1) { if (row == total_num_rows) { int x = new ResponseJDialog(this, "Insert row", "Do you wish to add a new row above " + "the last row?\n" + "uniquetempvar.response(); if (x == ResponseJDialog.CANCEL) { return; } else if (x == ResponseJDialog.NO) { row += 1; } } __worksheetR.insertRowAt(new double?(0), row); __worksheetR.scrollToRow(row); __worksheetR.selectRow(row); } else { __worksheetR.addRow(new double?(0)); __worksheetR.scrollToRow(0); __worksheetR.selectRow(0); } __deleteReturn.setEnabled(true); } else if (action.Equals(__BUTTON_DELETE_RETURN)) { int row = __worksheetR.getSelectedRow(); if (row != -1) { int x = (new ResponseJDialog(this, "Delete Return", "Delete return?", ResponseJDialog.YES | ResponseJDialog.NO)).response(); if (x == ResponseJDialog.NO) { return; } //StateMod_DelayTable dt = (StateMod_DelayTable) //__worksheetL.getRowData( //__worksheetL.getSelectedRow()); __worksheetR.deleteRow(row); __deleteReturn.setEnabled(false); } else { Message.printWarning(1, routine, "Must select desired right to delete."); } } else if (e.getSource() == __findNextDelay) { searchLeftWorksheet(__worksheetL.getSelectedRow() + 1); } else if (e.getSource() == __searchID) { searchLeftWorksheet(); } else { if (__worksheetL.getSelectedRow() == -1) { new ResponseJDialog(this, "You must first select a delay from the list.", ResponseJDialog.OK); return; } else if (e.getSource() == __graphDelayJButton) { try { __worksheetR.deselectAll(); int index = __worksheetL.getSelectedRow(); if (index == -1) { return; } StateMod_DelayTable currentDelay = ((StateMod_DelayTable) __delaysVector[index]); int j; DateTime date; TSIdent tsident = new TSIdent(); tsident.setLocation(currentDelay.getID()); tsident.setSource("StateMod"); if (__monthly_data) { tsident.setInterval("Month"); } else { tsident.setInterval("Day"); } tsident.setType("Delay"); DateTime date1 = null; DateTime date2 = null; int interval_base; if (__monthly_data) { date1 = new DateTime(DateTime.PRECISION_MONTH); date2 = new DateTime(DateTime.PRECISION_MONTH); interval_base = TimeInterval.MONTH; } else { date1 = new DateTime(DateTime.PRECISION_DAY); date2 = new DateTime(DateTime.PRECISION_DAY); interval_base = TimeInterval.DAY; } date1.setMonth(1); date1.setYear(1); date2.setMonth(1); date2.setYear(1); date2.addInterval(interval_base, (currentDelay.getNdly() - 1)); TS ts = null; if (__monthly_data) { ts = new MonthTS(); } else { ts = new DayTS(); } ts.setDate1(date1); ts.setDate2(date2); ts.setIdentifier(tsident); if (__monthly_data) { ts.setDescription(ts.getLocation() + " Monthly Delay Table"); } else { ts.setDescription(ts.getLocation() + " Daily Delay Table"); } ts.setDataType("Delay"); ts.setDataUnits(currentDelay.getUnits()); ts.allocateDataSpace(); double max = 0.0; for (date = new DateTime(date1), j = 0; date.lessThanOrEqualTo(date2); date.addInterval(interval_base, 1), j++) { ts.setDataValue(date, currentDelay.getRet_val(j)); if (currentDelay.getRet_val(j) > max) { max = currentDelay.getRet_val(j); } } IList<TS> tslist = new List<TS>(); tslist.Add(ts); PropList graphProps = new PropList("TSView"); // If dealing with small values, use a high // of precision... if (max < 1.0) { graphProps.set("YAxisPrecision","6"); graphProps.set("OutputPrecision","6"); } else { graphProps.set("YAxisPrecision","3"); graphProps.set("OutputPrecision","3"); } graphProps.set("InitialView", "Graph"); graphProps.set("TotalWidth", "600"); graphProps.set("TotalHeight", "400"); if (__monthly_data) { graphProps.set("Title", ts.getLocation() + " Monthly Delay Table"); } else { graphProps.set("Title", ts.getLocation() + " Daily Delay Table"); } graphProps.set("DisplayFont", "Courier"); graphProps.set("DisplaySize", "11"); graphProps.set("PrintFont", "Courier"); graphProps.set("PrintSize", "7"); graphProps.set("PageLength", "100"); new TSViewJFrame(tslist, graphProps); } catch (Exception) { Message.printWarning(1, routine, "Unable to graph delay. "); } } } }