/// <summary> /// Performs data checks on diversion station data. </summary> /// <param name="props"> A property list for specific properties /// on checking this data. </param> /// <param name="des_vector"> Vector of data to check. </param> private void checkDiversionStationData(PropList props, System.Collections.IList des_vector) { // create elements for the checks and check file string[] header = StateMod_Diversion.getDataHeader(); System.Collections.IList data = new List <object>(); string title = "Diversion Station"; // perform the general validation using the Data Table Model StateMod_Data_TableModel tm = new StateMod_Diversion_Data_TableModel(des_vector, false); System.Collections.IList @checked = performDataValidation(tm, title); //String [] columnHeader = getDataTableModelColumnHeader( tm ); string[] columnHeader = getColumnHeader(tm); // do specific checks int size = 0; if (des_vector != null) { size = des_vector.Count; } data = doSpecificDataChecks(des_vector, props); // add the data and checks to the check file // provides basic header information for this data check table string info = "The following diversion stations (" + data.Count + " out of " + size + ") have no ....."; // create data models for Check file CheckFile_DataModel dm = new CheckFile_DataModel(data, header, title, info, data.Count, size); CheckFile_DataModel gen_dm = new CheckFile_DataModel(@checked, columnHeader, title + " Missing or Invalid Data", "", __gen_problems, size); __check_file.addData(dm, gen_dm); }
/// <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> /// Called when the cancel button is pressed. This discards any changes made to /// the data objects. /// </summary> protected internal override void cancel() { StateMod_Diversion div = null; int size = _data.Count; for (int i = 0; i < size; i++) { div = (StateMod_Diversion)_data[i]; div.restoreOriginal(); } }
/// <summary> /// Called when the Apply button is pressed. This commits any changes to the data /// objects. /// </summary> protected internal override void apply() { StateMod_Diversion div = null; int size = _data.Count; for (int i = 0; i < size; i++) { div = (StateMod_Diversion)_data[i]; div.createBackup(); } }
/// <summary> /// Constructor. </summary> /// <param name="dataset"> the dataset in which the data are contained. </param> /// <param name="div"> the diversion to display. </param> /// <param name="editable"> whether the form data can be edited or not </param> public StateMod_Diversion_Right_JFrame(StateMod_DataSet dataset, StateMod_Diversion div, bool editable) { StateMod_GUIUtil.setTitle(this, dataset, div.getName() + " - Diversion Water Rights", null); JGUIUtil.setIcon(this, JGUIUtil.getIconImage()); __currentDiv = div; __dataset = dataset; __editable = editable; setupGUI(); }
/// <summary> /// Sets up the data to be displayed in the table. /// </summary> private void setupData() { int num = 0; int size = _data.size(); StateMod_Diversion dt = null; string id = null; __data = new System.Collections.IList[__COLUMNS]; for (int i = 0; i < __COLUMNS; i++) { __data[i] = new List <object>(); } __rowMap = new List <object>(); double total = 0; int rowCount = 0; StateMod_ReturnFlow rf = null; System.Collections.IList returnFlows = null; for (int i = 0; i < size; i++) { total = 0; dt = (StateMod_Diversion)_data.get(i); id = dt.getID(); num = dt.getNrtn(); returnFlows = dt.getReturnFlows(); for (int j = 0; j < num; j++) { rf = (StateMod_ReturnFlow)returnFlows[j]; __data[__COL_ID].Add(id); __data[__COL_NODE_ID].Add(rf.getCrtnid()); __data[__COL_PERCENT].Add(new double?(rf.getPcttot())); __data[__COL_DELAY_ID].Add("" + rf.getIrtndl()); total += rf.getPcttot(); __rowMap.Add(new int?(rowCount)); rowCount++; } __data[__COL_ID].Add(id); __data[__COL_NODE_ID].Add("TOTAL"); __data[__COL_PERCENT].Add(new double?(total)); __data[__COL_DELAY_ID].Add(""); rowCount++; } _rows = rowCount; }
/// <summary> /// Create an InputFilter_JPanel for creating where clauses /// for StateMod diversion station queries. This is used by the StateMod GUI. </summary> /// <param name="dataset"> StateMod_DataSet instance. </param> /// <returns> a JPanel containing InputFilter instances for StateMod_Diversion queries. </returns> /// <exception cref="Exception"> if there is an error. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public StateMod_Diversion_InputFilter_JPanel(StateMod_DataSet dataset) throws Exception public StateMod_Diversion_InputFilter_JPanel(StateMod_DataSet dataset) : base() { IList <InputFilter> input_filters = new List <InputFilter>(15); InputFilter filter = null; input_filters.Add(new InputFilter("", "", StringUtil.TYPE_STRING, null, null, true)); // Blank to disable filter input_filters.Add(new InputFilter("ID", "ID", StringUtil.TYPE_STRING, null, null, true)); input_filters.Add(new InputFilter("Name", "Name", StringUtil.TYPE_STRING, null, null, true)); input_filters.Add(new InputFilter("River Node ID", "RiverNodeID", StringUtil.TYPE_STRING, null, null, true)); filter = new InputFilter("On/Off Switch", "OnOff", StringUtil.TYPE_INTEGER, StateMod_Diversion.getIdivswChoices(true), StateMod_Diversion.getIdivswChoices(false), true); filter.setTokenInfo(" ", 0); input_filters.Add(filter); input_filters.Add(new InputFilter("Capacity", "Capacity", StringUtil.TYPE_DOUBLE, null, null, true)); filter = new InputFilter("Replacement Reservoir Option", "ReplaceResOption", StringUtil.TYPE_INTEGER, StateMod_Diversion.getIreptypeChoices(true), StateMod_Diversion.getIreptypeChoices(false), true); filter.setTokenInfo(" ", 0); input_filters.Add(filter); input_filters.Add(new InputFilter("Daily ID", "DailyID", StringUtil.TYPE_STRING, null, null, true)); input_filters.Add(new InputFilter("User Name", "UserName", StringUtil.TYPE_STRING, null, null, true)); filter = new InputFilter("Demand Type", "DemandType", StringUtil.TYPE_INTEGER, StateMod_Diversion.getIdvcomChoices(true), StateMod_Diversion.getIdvcomChoices(false), true); filter.setTokenInfo(" ", 0); input_filters.Add(filter); /* * input_filters.addElement ( new InputFilter ( * "Number of Returns", "NumReturns", * StringUtil.TYPE_INTEGER, * null, null, true ) ); */ input_filters.Add(new InputFilter("Efficiency (Annual)", "EffAnnual", StringUtil.TYPE_DOUBLE, null, null, true)); input_filters.Add(new InputFilter("Area (ACRE)", "Area", StringUtil.TYPE_DOUBLE, null, null, true)); filter = new InputFilter("Use Type", "UseType", StringUtil.TYPE_INTEGER, StateMod_Diversion.getIrturnChoices(true), StateMod_Diversion.getIrturnChoices(false), true); filter.setTokenInfo(" ", 0); input_filters.Add(filter); filter = new InputFilter("Demand Source", "DemandSource", StringUtil.TYPE_INTEGER, StateMod_Diversion.getDemsrcChoices(true), StateMod_Diversion.getDemsrcChoices(false), true); filter.setTokenInfo(" ", 0); input_filters.Add(filter); // TODO SAM 2004-10-25 monthly efficiencies? Returns? setToolTipText("<html>HydroBase queries can be filtered<br>based on station data.</html>"); setInputFilters(input_filters, 3, -1); }
/// <summary> /// Perform the query. Currently only diversion stations are supported. /// </summary> private void doQuery() { string routine = "StateMod_QueryTool_JFrame.doQuery", message; InputFilter_JPanel ifp = __input_filter_diversion_JPanel; InputFilter filter = null; int size; // Size of data Vector int i; // Loop for data items. DataSetComponent comp = null; string where, @operator, input; int where_length = 0; // Length of "where", to optimize code. bool do_int, do_double, do_string; string input_string; // Data parameters to check, as int input_int; // transferred from the data objects. double input_double; bool do_ID, do_Name, do_RiverNodeID, do_OnOff, do_Capacity, do_ReplaceResOption, do_DailyID, do_UserName, do_DemandType, do_EffAnnual, do_Area, do_UseType, do_DemandSource; bool[] matches = null; // Indicates if a data item matches all // the filter criteria. bool item_matches; // Indicates whether the itme matches a // single filter criteria. bool[] @checked = null; // Indicates whether a data item has // already been checked for a criteria. // If checked and false, then a "true" // should not reset the false. int nfg = 0; // Number of filter groups. do_int = false; // Whether the data item is an integer. do_double = false; // Whether the data item is a double. do_string = false; // Whether the data item is a string. StateMod_Diversion dds = null; __status_JTextField.setText(__Wait); JGUIUtil.setWaitCursor(this, true); if (ifp is StateMod_Diversion_InputFilter_JPanel) { input_int = StateMod_Util.MISSING_INT; input_double = StateMod_Util.MISSING_DOUBLE; input_string = StateMod_Util.MISSING_STRING; comp = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DIVERSION_STATIONS); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Diversion> dds_Vector = (java.util.List<StateMod_Diversion>)comp.getData(); IList <StateMod_Diversion> dds_Vector = (IList <StateMod_Diversion>)comp.getData(); size = 0; if (dds_Vector != null) { size = dds_Vector.Count; } // REVISIT SAM 2004-10-27 Remove when debugging is complete //Message.printStatus ( 2, routine, //"Searching " + size + " diversion stations." ); // Initialize the arrays indicating if data objects have been // checked and whether they matched the filter(s)... if (size > 0) { matches = new bool[size]; @checked = new bool[size]; } for (i = 0; i < size; i++) { matches[i] = false; @checked[i] = false; } // Loop through the where clauses... nfg = ifp.getNumFilterGroups(); for (int ifg = 0; ifg < nfg; ifg++) { // Get the filter information... filter = ifp.getInputFilter(ifg); where = filter.getWhereInternal(); where_length = where.Length; @operator = ifp.getOperator(ifg); input = filter.getInput(false); // REVISIT SAM 2004-10-27 Remove when debugging is // complete //Message.printStatus ( 2, routine, //"where=" + where + " operator=" + operator + //" input=" + input ); // Initialize flags to indicate what data will be // checked... do_int = false; do_double = false; do_string = false; do_ID = false; do_Name = false; do_RiverNodeID = false; do_OnOff = false; do_Capacity = false; do_ReplaceResOption = false; do_DailyID = false; do_UserName = false; do_DemandType = false; do_EffAnnual = false; do_Area = false; do_UseType = false; do_DemandSource = false; // The following checks on "where" need to match the // input filter internal where labels assigned in // StateMod_Diversion_InputFilter_JPanel. // List in the order of the StateMod documentation... if (where.Equals("ID", StringComparison.OrdinalIgnoreCase)) { do_string = true; do_ID = true; } else if (where.Equals("Name", StringComparison.OrdinalIgnoreCase)) { do_string = true; do_Name = true; } else if (where.Equals("RiverNodeID", StringComparison.OrdinalIgnoreCase)) { do_string = true; do_RiverNodeID = true; } else if (where.Equals("OnOff", StringComparison.OrdinalIgnoreCase) && StringUtil.isInteger(input)) { do_int = true; do_OnOff = true; } else if (where.Equals("Capacity", StringComparison.OrdinalIgnoreCase) && StringUtil.isDouble(input)) { do_double = true; do_Capacity = true; } else if (where.Equals("ReplaceResOption", StringComparison.OrdinalIgnoreCase) && StringUtil.isInteger(input)) { do_int = true; do_ReplaceResOption = true; } else if (where.Equals("DailyID", StringComparison.OrdinalIgnoreCase)) { do_string = true; do_DailyID = true; } else if (where.Equals("UserName", StringComparison.OrdinalIgnoreCase)) { do_string = true; do_UserName = true; } else if (where.Equals("DemandType", StringComparison.OrdinalIgnoreCase)) { do_int = true; do_DemandType = true; } else if (where.Equals("EffAnnual", StringComparison.OrdinalIgnoreCase) && StringUtil.isDouble(input)) { do_double = true; do_EffAnnual = true; } else if (where.Equals("Area", StringComparison.OrdinalIgnoreCase) && StringUtil.isDouble(input)) { do_double = true; do_Area = true; } else if (where.Equals("UseType", StringComparison.OrdinalIgnoreCase) && StringUtil.isInteger(input)) { do_int = true; do_UseType = true; } else if (where.Equals("DemandSource", StringComparison.OrdinalIgnoreCase) && StringUtil.isInteger(input)) { do_int = true; do_DemandSource = true; } else if (where_length == 0) { // WIll match anything. } else { // Unrecognized where... continue; } // REVISIT SAM 2004-10-27 Remove when debugging is // complete /* * Message.printStatus ( 2, routine, * "do_string=" + do_string + " do_int=" + do_int + * "do_double=" + do_double + * " " + do_ID + * " " + do_Name + * " " + do_RiverNodeID + * " " + do_OnOff + * " " + do_Capacity + * " " + do_ReplaceResOption + * " " + do_DailyID + * " " + do_UserName + * " " + do_DemandType + * " " + do_EffAnnual + * " " + do_Area + * " " + do_UseType + * " " + do_DemandSource ); */ for (i = 0; i < size; i++) { dds = (StateMod_Diversion)dds_Vector[i]; // Get the specific data to compare... if (do_ID) { input_string = dds.getID(); } else if (do_Name) { input_string = dds.getName(); } else if (do_RiverNodeID) { input_string = dds.getCgoto(); } else if (do_OnOff) { input_int = dds.getSwitch(); } else if (do_Capacity) { input_double = dds.getDivcap(); } else if (do_ReplaceResOption) { input_int = dds.getIreptype(); } else if (do_DailyID) { input_string = dds.getCdividy(); } else if (do_UserName) { input_string = dds.getUsername(); } else if (do_DemandType) { input_int = dds.getIdvcom(); } else if (do_EffAnnual) { input_double = dds.getDivefc(); } else if (do_Area) { input_double = dds.getArea(); } else if (do_UseType) { input_int = dds.getIrturn(); } else if (do_DemandSource) { input_int = dds.getDemsrc(); } else { // Unrecognized... continue; } // Compare the data with the input filter... item_matches = false; if (do_string) { item_matches = filter.matches(input_string, @operator, true); } else if (do_int) { item_matches = filter.matches(input_int, @operator); } else if (do_double) { item_matches = filter.matches(input_double, @operator); } if (where_length == 0) { // Always consider a match... item_matches = true; } if (item_matches && (!@checked[i] || (@checked[i] && matches[i]))) { // So far the item matches all // filters... matches[i] = true; } else if (@checked[i] && !item_matches) { // Does not match this filter to reset // result to false... matches[i] = false; } // Indicate that we have checked the item // against at least one filter... @checked[i] = true; } } // Get a count so the Vector can be sized appropriately (this // should be fast)... int match_count = 0; for (i = 0; i < size; i++) { if (matches[i]) { ++match_count; } } // Loop through and set up the matches_Vector... __matches_Vector = null; if (match_count > 0) { __matches_Vector = new List <StateMod_Diversion> (match_count); for (i = 0; i < size; i++) { if (matches[i]) { // The diversion station matches so add // to the list... __matches_Vector.Add(dds_Vector[i]); } } } message = "Matched " + match_count + " diversion stations (from original " + size + ")."; Message.printStatus(2, routine, message); __message_JTextField.setText(message); __status_JTextField.setText(__Ready); JGUIUtil.setWaitCursor(this, false); } if (__matches_Vector == null) { __display_JButton.setEnabled(false); } else { __display_JButton.setEnabled(true); } }
/// <summary> /// Read diversion information in and store in a java vector. /// The new diversions are added to the end of the previously stored diversions. </summary> /// <param name="filename"> filename containing diversion information </param> /// <exception cref="Exception"> if an error occurs </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static java.util.List<StateMod_Diversion> readStateModFile(String filename) throws Exception public static IList <StateMod_Diversion> readStateModFile(string filename) { string routine = "StateMod_Diversion.readStateModFile"; string iline = null; IList <object> v = new List <object>(9); IList <StateMod_Diversion> theDiversions = new List <StateMod_Diversion>(); int i; int linecount = 0; string s = null; int[] format_0 = new int[] { StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_INTEGER, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING }; int[] format_0w = new int[] { 12, 24, 12, 8, 8, 8, 8, 1, 12 }; int[] format_1 = new int[] { StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER }; int[] format_1w = new int[] { 12, 24, 12, 8, 8, 8, 8, 8, 8 }; int[] format_2 = new int[] { StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER }; int[] format_2w = new int[] { 36, 12, 8, 8 }; StateMod_Diversion aDiversion = null; StateMod_ReturnFlow aReturnNode = null; StreamReader @in = null; Message.printStatus(1, routine, "Reading diversion file: " + filename); try { @in = new StreamReader(IOUtil.getPathUsingWorkingDir(filename)); while (!string.ReferenceEquals((iline = @in.ReadLine()), null)) { ++linecount; // check for comments if (iline.StartsWith("#", StringComparison.Ordinal) || iline.Trim().Length == 0) { continue; } // allocate new diversion node aDiversion = new StateMod_Diversion(); // line 1 if (Message.isDebugOn) { Message.printDebug(50, routine, "line 1: " + iline); } StringUtil.fixedRead(iline, format_0, format_0w, v); aDiversion.setID(((string)v[0]).Trim()); aDiversion.setName(((string)v[1]).Trim()); aDiversion.setCgoto(((string)v[2]).Trim()); aDiversion.setSwitch((int?)v[3]); aDiversion.setDivcap((double?)v[4]); aDiversion.setIreptype(((int?)v[6])); aDiversion.setCdividy(((string)v[8]).Trim()); // line 2 iline = @in.ReadLine(); ++linecount; if (Message.isDebugOn) { Message.printDebug(50, routine, "line 2: " + iline); } StringUtil.fixedRead(iline, format_1, format_1w, v); aDiversion.setUsername(((string)v[1]).Trim()); aDiversion.setIdvcom(((int?)v[3])); int nrtn = ((int?)v[4]).Value; aDiversion.setDivefc(((double?)v[5])); aDiversion.setArea(((double?)v[6])); aDiversion.setIrturn(((int?)v[7])); aDiversion.setDemsrc(((int?)v[8])); // get the efficiency information if (aDiversion.getDivefc() < 0) { // Negative value indicates monthly efficiencies will follow... iline = @in.ReadLine(); ++linecount; // Free format... char[] seps = { ' ', '\t', '\n', '\r', '\f' }; string[] split = iline.Split(seps); if (split != null && split.Length == 12) { for (i = 0; i < 12; i++) { aDiversion.setDiveff(i, split[0]); } } } else { // Annual efficiency so set monthly efficiencies to the annual... aDiversion.setDiveff(0, aDiversion.getDivefc()); aDiversion.setDiveff(1, aDiversion.getDivefc()); aDiversion.setDiveff(2, aDiversion.getDivefc()); aDiversion.setDiveff(3, aDiversion.getDivefc()); aDiversion.setDiveff(4, aDiversion.getDivefc()); aDiversion.setDiveff(5, aDiversion.getDivefc()); aDiversion.setDiveff(6, aDiversion.getDivefc()); aDiversion.setDiveff(7, aDiversion.getDivefc()); aDiversion.setDiveff(8, aDiversion.getDivefc()); aDiversion.setDiveff(9, aDiversion.getDivefc()); aDiversion.setDiveff(10, aDiversion.getDivefc()); aDiversion.setDiveff(11, aDiversion.getDivefc()); } // get the return information for (i = 0; i < nrtn; i++) { iline = @in.ReadLine(); ++linecount; StringUtil.fixedRead(iline, format_2, format_2w, v); aReturnNode = new StateMod_ReturnFlow(StateMod_DataSet.COMP_DIVERSION_STATIONS); s = ((string)v[1]).Trim(); if (s.Length <= 0) { aReturnNode.setCrtnid(((string)v[0]).Trim()); Message.printWarning(3, routine, "Return node for structure \"" + aDiversion.getID() + "\" is blank. "); } else { aReturnNode.setCrtnid(s); } aReturnNode.setPcttot(((double?)v[2])); aReturnNode.setIrtndl(((int?)v[3])); aDiversion.addReturnFlow(aReturnNode); } // Set the diversion to not dirty because it was just initialized... aDiversion.setDirty(false); // add the diversion to the vector of diversions theDiversions.Add(aDiversion); } } catch (Exception e) { Message.printWarning(3, routine, "Error reading line " + linecount + " \"" + iline + "\""); Message.printWarning(3, routine, e); throw e; } finally { if (@in != null) { @in.Close(); } } return(theDiversions); }
/// <summary> /// Inserts the specified value into the table at the given position. </summary> /// <param name="value"> the object to store in the table cell. </param> /// <param name="row"> the row of the cell in which to place the object. </param> /// <param name="col"> the column of the cell in which to place the object. </param> public virtual void setValueAt(object value, int row, int col) { if (_sortOrder != null) { row = _sortOrder[row]; } int ival; int index; StateMod_Diversion smd = (StateMod_Diversion)_data.get(row); switch (col) { case COL_ID: smd.setID((string)value); break; case COL_NAME: smd.setName((string)value); break; case COL_RIVER_NODE_ID: smd.setCgoto((string)value); break; case COL_ON_OFF: if (value is int?) { ival = ((int?)value).Value; smd.setSwitch(ival); } else if (value is string) { string onOff = (string)value; index = onOff.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(onOff.Substring(0, index))); smd.setSwitch(ival); } break; case COL_CAPACITY: smd.setDivcap((double?)value); break; case COL_REPLACE_RES_OPTION: if (value is int?) { ival = ((int?)value).Value; smd.setIreptype(ival); } else if (value is string) { string ireptyp = (string)value; index = ireptyp.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(ireptyp.Substring(0, index))); smd.setIreptype(ival); } break; case COL_DAILY_ID: smd.setCdividy((string)value); break; case COL_USER_NAME: smd.setUsername((string)value); break; case COL_DEMAND_TYPE: if (value is int?) { ival = ((int?)value).Value; smd.setIdvcom(ival); } else if (value is string) { string idvcom = (string)value; index = idvcom.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(idvcom.Substring(0, index))); smd.setIdvcom(ival); } break; case COL_EFF_ANNUAL: smd.setDivefc((double?)value); break; case COL_AREA: smd.setArea((double?)value); break; case COL_USE_TYPE: if (value is int?) { ival = ((int?)value).Value; smd.setIrturn(ival); } else if (value is string) { string irturn = (string)value; index = irturn.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(irturn.Substring(0, index))); smd.setIrturn(ival); } break; case COL_DEMAND_SOURCE: if (value is int?) { ival = ((int?)value).Value; smd.setDemsrc(ival); } else if (value is string) { string demsrc = (string)value; index = demsrc.IndexOf(" -", StringComparison.Ordinal); ival = (Convert.ToInt32(demsrc.Substring(0, index))); smd.setDemsrc(ival); } break; case COL_EFF_01: smd.setDiveff(0, (double?)value); break; case COL_EFF_02: smd.setDiveff(1, (double?)value); break; case COL_EFF_03: smd.setDiveff(2, (double?)value); break; case COL_EFF_04: smd.setDiveff(3, (double?)value); break; case COL_EFF_05: smd.setDiveff(4, (double?)value); break; case COL_EFF_06: smd.setDiveff(5, (double?)value); break; case COL_EFF_07: smd.setDiveff(6, (double?)value); break; case COL_EFF_08: smd.setDiveff(7, (double?)value); break; case COL_EFF_09: smd.setDiveff(8, (double?)value); break; case COL_EFF_10: smd.setDiveff(9, (double?)value); break; case COL_EFF_11: smd.setDiveff(10, (double?)value); break; case COL_EFF_12: smd.setDiveff(11, (double?)value); break; } base.setValueAt(value, row, col); }
/// <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_Diversion smd = (StateMod_Diversion)_data.get(row); switch (col) { case COL_ID: return(smd.getID()); case COL_NAME: return(smd.getName()); case COL_RIVER_NODE_ID: return(smd.getCgoto()); case COL_ON_OFF: return(new int?(smd.getSwitch())); case COL_CAPACITY: return(new double?(smd.getDivcap())); case COL_REPLACE_RES_OPTION: return(new int?(smd.getIreptype())); case COL_DAILY_ID: return(smd.getCdividy()); case COL_USER_NAME: return(smd.getUsername()); case COL_DEMAND_TYPE: return(new int?(smd.getIdvcom())); case COL_AREA: return(new double?(smd.getArea())); case COL_USE_TYPE: return(new int?(smd.getIrturn())); case COL_DEMAND_SOURCE: return(new int?(smd.getDemsrc())); case COL_EFF_ANNUAL: return(new double?(smd.getDivefc())); case COL_EFF_01: return(new double?(smd.getDiveff(0))); case COL_EFF_02: return(new double?(smd.getDiveff(1))); case COL_EFF_03: return(new double?(smd.getDiveff(2))); case COL_EFF_04: return(new double?(smd.getDiveff(3))); case COL_EFF_05: return(new double?(smd.getDiveff(4))); case COL_EFF_06: return(new double?(smd.getDiveff(5))); case COL_EFF_07: return(new double?(smd.getDiveff(6))); case COL_EFF_08: return(new double?(smd.getDiveff(7))); case COL_EFF_09: return(new double?(smd.getDiveff(8))); case COL_EFF_10: return(new double?(smd.getDiveff(9))); case COL_EFF_11: return(new double?(smd.getDiveff(10))); case COL_EFF_12: return(new double?(smd.getDiveff(11))); default: return(""); } }
/// <summary> /// Sets up the data Vectors to display the diversion collection data in the /// GUI. /// </summary> private void setupData() { int[] years = null; int len = 0; int size = _data.size(); int size2 = 0; StateMod_Diversion 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_Diversion)_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; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void saveComponent(RTi.Util.IO.DataSetComponent comp, String oldFilename,String newFilename, java.util.List<String> comments) throws Exception private void saveComponent(DataSetComponent comp, string oldFilename, string newFilename, IList <string> comments) { bool daily = false; int type = comp.getComponentType(); object data = comp.getData(); string name = null; switch (type) { //////////////////////////////////////////////////////// // StateMod_* classes case StateMod_DataSet.COMP_CONTROL: StateMod_DataSet.writeStateModControlFile(__dataset, oldFilename, newFilename, comments); name = "Control"; break; case StateMod_DataSet.COMP_DELAY_TABLES_DAILY: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DelayTable> delayTablesDaily = (java.util.List<StateMod_DelayTable>)data; IList <StateMod_DelayTable> delayTablesDaily = (IList <StateMod_DelayTable>)data; StateMod_DelayTable.writeStateModFile(oldFilename, newFilename, delayTablesDaily, comments, __dataset.getInterv(), -1); name = "Delay Tables Daily"; break; case StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DelayTable> delayTablesMonthly = (java.util.List<StateMod_DelayTable>)data; IList <StateMod_DelayTable> delayTablesMonthly = (IList <StateMod_DelayTable>)data; StateMod_DelayTable.writeStateModFile(oldFilename, newFilename, delayTablesMonthly, comments, __dataset.getInterv(), -1); name = "Delay Tables Monthly"; break; case StateMod_DataSet.COMP_DIVERSION_STATIONS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Diversion> diversionStations = (java.util.List<StateMod_Diversion>)data; IList <StateMod_Diversion> diversionStations = (IList <StateMod_Diversion>)data; StateMod_Diversion.writeStateModFile(oldFilename, newFilename, diversionStations, comments, daily); name = "Diversion"; break; case StateMod_DataSet.COMP_DIVERSION_RIGHTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DiversionRight> diversionRights = (java.util.List<StateMod_DiversionRight>)data; IList <StateMod_DiversionRight> diversionRights = (IList <StateMod_DiversionRight>)data; StateMod_DiversionRight.writeStateModFile(oldFilename, newFilename, diversionRights, comments, daily); name = "Diversion Rights"; break; case StateMod_DataSet.COMP_INSTREAM_STATIONS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_InstreamFlow> instreamFlow = (java.util.List<StateMod_InstreamFlow>)data; IList <StateMod_InstreamFlow> instreamFlow = (IList <StateMod_InstreamFlow>)data; StateMod_InstreamFlow.writeStateModFile(oldFilename, newFilename, instreamFlow, comments, daily); name = "Instream"; break; case StateMod_DataSet.COMP_INSTREAM_RIGHTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_InstreamFlowRight> instreamFlowRights = (java.util.List<StateMod_InstreamFlowRight>)data; IList <StateMod_InstreamFlowRight> instreamFlowRights = (IList <StateMod_InstreamFlowRight>)data; StateMod_InstreamFlowRight.writeStateModFile(oldFilename, newFilename, instreamFlowRights, comments); name = "Instream Rights"; break; case StateMod_DataSet.COMP_OPERATION_RIGHTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_OperationalRight> operationalRights = (java.util.List<StateMod_OperationalRight>)data; IList <StateMod_OperationalRight> operationalRights = (IList <StateMod_OperationalRight>)data; // 2 is the file version (introduced for StateMod version 12 change) StateMod_OperationalRight.writeStateModFile(oldFilename, newFilename, 2, operationalRights, comments, __dataset); name = "Operational Rights"; break; case StateMod_DataSet.COMP_PLANS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Plan> planStations = (java.util.List<StateMod_Plan>)data; IList <StateMod_Plan> planStations = (IList <StateMod_Plan>)data; StateMod_Plan.writeStateModFile(oldFilename, newFilename, planStations, comments); name = "Plan"; break; case StateMod_DataSet.COMP_RESERVOIR_STATIONS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Reservoir> reservoirStations = (java.util.List<StateMod_Reservoir>)data; IList <StateMod_Reservoir> reservoirStations = (IList <StateMod_Reservoir>)data; StateMod_Reservoir.writeStateModFile(oldFilename, newFilename, reservoirStations, comments, daily); name = "Reservoir"; break; case StateMod_DataSet.COMP_RESERVOIR_RIGHTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_ReservoirRight> reservoirRights = (java.util.List<StateMod_ReservoirRight>)data; IList <StateMod_ReservoirRight> reservoirRights = (IList <StateMod_ReservoirRight>)data; StateMod_ReservoirRight.writeStateModFile(oldFilename, newFilename, reservoirRights, comments); name = "Reservoir Rights"; break; case StateMod_DataSet.COMP_RESPONSE: StateMod_DataSet.writeStateModFile(__dataset, oldFilename, newFilename, comments); name = "Response"; break; case StateMod_DataSet.COMP_RIVER_NETWORK: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_RiverNetworkNode> riverNodes = (java.util.List<StateMod_RiverNetworkNode>)data; IList <StateMod_RiverNetworkNode> riverNodes = (IList <StateMod_RiverNetworkNode>)data; StateMod_RiverNetworkNode.writeStateModFile(oldFilename, newFilename, riverNodes, comments, true); name = "River Network"; break; case StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_StreamEstimate> streamEstimateStations = (java.util.List<StateMod_StreamEstimate>)data; IList <StateMod_StreamEstimate> streamEstimateStations = (IList <StateMod_StreamEstimate>)data; StateMod_StreamEstimate.writeStateModFile(oldFilename, newFilename, streamEstimateStations, comments, daily); name = "Stream Estimate"; break; case StateMod_DataSet.COMP_STREAMESTIMATE_COEFFICIENTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_StreamEstimate_Coefficients> streamEstimateCoefficients = (java.util.List<StateMod_StreamEstimate_Coefficients>)data; IList <StateMod_StreamEstimate_Coefficients> streamEstimateCoefficients = (IList <StateMod_StreamEstimate_Coefficients>)data; StateMod_StreamEstimate_Coefficients.writeStateModFile(oldFilename, newFilename, streamEstimateCoefficients, comments); name = "Stream Estimate Coefficients"; break; case StateMod_DataSet.COMP_STREAMGAGE_STATIONS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_StreamGage> streamGageStations = (java.util.List<StateMod_StreamGage>)data; IList <StateMod_StreamGage> streamGageStations = (IList <StateMod_StreamGage>)data; StateMod_StreamGage.writeStateModFile(oldFilename, newFilename, streamGageStations, comments, daily); name = "Streamgage Stations"; break; case StateMod_DataSet.COMP_WELL_STATIONS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Well> wellStations = (java.util.List<StateMod_Well>)data; IList <StateMod_Well> wellStations = (IList <StateMod_Well>)data; StateMod_Well.writeStateModFile(oldFilename, newFilename, wellStations, comments); name = "Well"; break; case StateMod_DataSet.COMP_WELL_RIGHTS: //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_WellRight> wellRights = (java.util.List<StateMod_WellRight>)data; IList <StateMod_WellRight> wellRights = (IList <StateMod_WellRight>)data; StateMod_WellRight.writeStateModFile(oldFilename, newFilename, wellRights, comments, (PropList)null); name = "Well Rights"; break; ////////////////////////////////////////////////////// // StateMod Time Series case StateMod_DataSet.COMP_CONSUMPTIVE_WATER_REQUIREMENT_TS_DAILY: case StateMod_DataSet.COMP_CONSUMPTIVE_WATER_REQUIREMENT_TS_MONTHLY: case StateMod_DataSet.COMP_DEMAND_TS_DAILY: case StateMod_DataSet.COMP_DEMAND_TS_AVERAGE_MONTHLY: case StateMod_DataSet.COMP_DEMAND_TS_MONTHLY: case StateMod_DataSet.COMP_DEMAND_TS_OVERRIDE_MONTHLY: case StateMod_DataSet.COMP_DIVERSION_TS_DAILY: case StateMod_DataSet.COMP_DIVERSION_TS_MONTHLY: case StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY: case StateMod_DataSet.COMP_INSTREAM_DEMAND_TS_AVERAGE_MONTHLY: case StateMod_DataSet.COMP_INSTREAM_DEMAND_TS_DAILY: case StateMod_DataSet.COMP_INSTREAM_DEMAND_TS_MONTHLY: case StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY: case StateMod_DataSet.COMP_RESERVOIR_CONTENT_TS_DAILY: case StateMod_DataSet.COMP_RESERVOIR_CONTENT_TS_MONTHLY: case StateMod_DataSet.COMP_RESERVOIR_TARGET_TS_DAILY: case StateMod_DataSet.COMP_RESERVOIR_TARGET_TS_MONTHLY: case StateMod_DataSet.COMP_STREAMESTIMATE_NATURAL_FLOW_TS_DAILY: case StateMod_DataSet.COMP_STREAMESTIMATE_NATURAL_FLOW_TS_MONTHLY: case StateMod_DataSet.COMP_STREAMGAGE_NATURAL_FLOW_TS_DAILY: case StateMod_DataSet.COMP_STREAMGAGE_NATURAL_FLOW_TS_MONTHLY: case StateMod_DataSet.COMP_STREAMGAGE_HISTORICAL_TS_DAILY: case StateMod_DataSet.COMP_STREAMGAGE_HISTORICAL_TS_MONTHLY: case StateMod_DataSet.COMP_WELL_DEMAND_TS_DAILY: case StateMod_DataSet.COMP_WELL_DEMAND_TS_MONTHLY: case StateMod_DataSet.COMP_WELL_PUMPING_TS_DAILY: case StateMod_DataSet.COMP_WELL_PUMPING_TS_MONTHLY: double missing = -999.0; YearType yearType = null; if (__dataset.getCyrl() == YearType.CALENDAR) { yearType = YearType.CALENDAR; } else if (__dataset.getCyrl() == YearType.WATER) { yearType = YearType.WATER; } else if (__dataset.getCyrl() == YearType.NOV_TO_OCT) { yearType = YearType.NOV_TO_OCT; } int precision = 2; // Do the following to avoid warnings IList <TS> tslist = null; if (data != null) { //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<RTi.TS.TS> tslist0 = (java.util.List<RTi.TS.TS>)data; IList <TS> tslist0 = (IList <TS>)data; if (tslist0.Count > 0) { TS ts = tslist0[0]; missing = ts.getMissing(); } tslist = tslist0; } StateMod_TS.writeTimeSeriesList(oldFilename, newFilename, comments, tslist, null, null, yearType, missing, precision); name = "TS (" + type + ")"; break; default: name = "(something: " + type + ")"; break; } comp.setDirty(false); Message.printStatus(1, "", "Component '" + name + "' written"); }