/// <summary> /// Processes a table selection (either via a mouse press or programmatically /// from selectTableIndex() by getting the next selection's data out of the /// data and displaying it on the form. </summary> /// <param name="index"> the index of the delay table info to display on the form. </param> private void processLeftTableSelection(int index, bool tryToSave) { if (index == -1) { return; } if (tryToSave && (checkInput() > 0)) { if (__currentIndex > -1) { selectLeftTableIndex(__currentIndex, false, false); } return; } // if gotten this far, then the delay table can be saved back // (if it has changed) saveDelayTable(); __currentIndex = index; StateMod_DelayTable dt = (StateMod_DelayTable) __worksheetL.getRowData(index); updateRightTable(dt); }
/// <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]; } switch (col) { case COL_ID: StateMod_DelayTable dt = (StateMod_DelayTable)_data.get(row); return(dt.getTableID()); case COL_DATE: return(new int?(row + 1)); case COL_RETURN_AMT: if (__subDelays != null) { return(__subDelays[row]); } else { return(new double?(0.0)); } default: return(""); } }
/// <summary> /// Constructor. </summary> /// <param name="delay"> the Delay to show </param> /// <param name="monthly_data"> If true, display the monthly delay tables. If false, /// display the daily delay tables. </param> /// <param name="editable"> whether the gui data is editable or not </param> public StateMod_DelayTable_JFrame(StateMod_DelayTable delay, bool monthly_data, bool editable) { __monthly_data = monthly_data; JGUIUtil.setIcon(this, JGUIUtil.getIconImage()); string interval = " (Monthly)"; if (__monthly_data) { __window_type = StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY; __componentType = StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY; } else { __window_type = StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY; __componentType = StateMod_DataSet.COMP_DELAY_TABLES_DAILY; interval = " (Daily)"; } StateMod_GUIUtil.setTitle(this, null, "Delay Table" + interval, null); __delaysVector = new List<StateMod_DelayTable>(); __delaysVector.Add(delay); int size = __delaysVector.Count; StateMod_DelayTable dt = null; for (int i = 0; i < size; i++) { dt = __delaysVector[i]; dt.createBackup(); } __editable = editable; setupGUI(0); }
/// <summary> /// Called when the cancel button is pressed. This discards any changes made to the data objects. /// </summary> protected internal override void cancel() { StateMod_DelayTable delay = null; int size = _data.Count; for (int i = 0; i < size; i++) { delay = (StateMod_DelayTable)_data[i]; delay.restoreOriginal(); } }
/// <summary> /// Creates backups of all the data objects in the Vector so that changes can later be cancelled if necessary. /// </summary> protected internal override void createDataBackup() { StateMod_DelayTable delay = null; int size = _data.Count; for (int i = 0; i < size; i++) { delay = (StateMod_DelayTable)_data[i]; delay.createBackup(); } }
/// <summary> /// Selects the desired ID in the table and displays the appropriate data /// in the remainder of the window. </summary> /// <param name="id"> the identifier to select in the list. </param> public virtual void selectID(string id) { int rows = __worksheetL.getRowCount(); StateMod_DelayTable dt = null; for (int i = 0; i < rows; i++) { dt = (StateMod_DelayTable)__worksheetL.getRowData(i); if (dt.getID().Trim().Equals(id.Trim())) { selectLeftTableIndex(i, true, true); return; } } }
/// <summary> /// Updates the right table based on a new selection from the left table, /// or if rows were added or deleted to the right table. </summary> /// <param name="dt"> the StateMod_DelayTable object selected in the left table. </param> private void updateRightTable(StateMod_DelayTable dt) { IList<double?> v = dt.getRet_val(); IList<double?> v2 = new List<double?>(); for (int i = 0; i < v.Count; i++) { v2.Add(new double?(v[i].Value)); } ((StateMod_DelayTable_TableModel)__worksheetR.getModel()).setSubDelays(v2); ((StateMod_DelayTable_TableModel)__worksheetR.getModel()).fireTableDataChanged(); ((StateMod_DelayTable_TableModel)__worksheetR.getModel()).fireTableDataChanged(); __deleteReturn.setEnabled(false); }
/// <summary> /// Cancels any changes made to this object within a GUI since createBackup() /// was caled and sets _original to null. /// </summary> public override void restoreOriginal() { StateMod_DelayTable d = (StateMod_DelayTable)_original; base.restoreOriginal(); _ndly = d._ndly; _ret_val = d._ret_val; _units = d._units; _isMonthly = d._isMonthly; _isClone = false; _original = null; }
/// <summary> /// Sets up the data to be displayed in the table. </summary> /// <param name="data"> a Vector of StateMod_DelayTable objects from which the data to b /// be displayed in the table will be gathered. </param> private void setupData(System.Collections.IList data) { int num = 0; int size = data.Count; StateMod_DelayTable 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; for (int i = 0; i < size; i++) { total = 0; dt = (StateMod_DelayTable)data[i]; id = dt.getID(); num = dt.getNdly(); for (int j = 0; j < num; j++) { __data[COL_ID].Add(id); __data[COL_DATE].Add(new int?(j + 1)); __data[COL_RETURN_AMT].Add(new double?(dt.getRet_val(j))); total += dt.getRet_val(j); __rowMap.Add(new int?(rowCount)); rowCount++; } __data[COL_ID].Add("TOTAL " + id); __data[COL_DATE].Add(new int?(-999)); __data[COL_RETURN_AMT].Add(new double?(total)); rowCount++; } _rows = rowCount; }
/// <summary> /// Clones the data object. </summary> /// <returns> a cloned object. </returns> public override object clone() { StateMod_DelayTable d = (StateMod_DelayTable)base.clone(); if (_ret_val == null) { d._ret_val = null; } else { d._ret_val = new List <double?>(); int size = _ret_val.Count; for (int i = 0; i < size; i++) { d._ret_val.Add(new double?(_ret_val[i].Value)); } } return(d); }
/// <summary> /// Constructor. </summary> /// <param name="dataset"> the dataset containing the data to display </param> /// <param name="dataset_wm"> the dataset window manager or null if the data set windows /// are not being managed. </param> /// <param name="delayTable"> the delay table to display. </param> /// <param name="monthly_data"> If true, display the monthly delay tables. If false, /// display the daily delay tables. </param> /// <param name="editable"> whether the data is editable or not </param> public StateMod_DelayTable_JFrame(StateMod_DataSet dataset, StateMod_DataSet_WindowManager dataset_wm, StateMod_DelayTable delayTable, bool monthly_data, bool editable) { __dataset = dataset; __dataset_wm = dataset_wm; __monthly_data = monthly_data; JGUIUtil.setIcon(this, JGUIUtil.getIconImage()); string interval = " (Monthly)"; if (__monthly_data) { __window_type = StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY; __delayComponent = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY); __componentType = StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY; } else { __window_type = StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY; __delayComponent = __dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_DAILY); __componentType = StateMod_DataSet.COMP_DELAY_TABLES_DAILY; interval = " (Daily)"; } StateMod_GUIUtil.setTitle(this, dataset, "Delay Tables" + interval, null); //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> delaysList = (java.util.List<StateMod_DelayTable>)__delayComponent.getData(); IList<StateMod_DelayTable> delaysList = (IList<StateMod_DelayTable>)__delayComponent.getData(); __delaysVector = delaysList; int size = __delaysVector.Count; StateMod_DelayTable dt = null; for (int i = 0; i < size; i++) { dt = __delaysVector[i]; dt.createBackup(); } string id = delayTable.getID(); int index = StateMod_Util.IndexOf(__delaysVector, id); __editable = editable; setupGUI(index); }
/// <summary> /// Closes the window. /// </summary> private void closeWindow() { if (checkInput() <= 0) { saveDelayTable(); __worksheetR.deselectAll(); } else { return; } 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.acceptChanges(); } if (changed) { __dataset.setDirty(__componentType, true); } if (__dataset_wm != null) { __dataset_wm.closeWindow(__window_type); } else { JGUIUtil.close(this); } }
/// <summary> /// Responds to action performed events sent by popup menus of the tree nodes. </summary> /// <param name="event"> the ActionEvent that happened. </param> public virtual void actionPerformed(ActionEvent @event) { string action = @event.getActionCommand(); string routine = "StateMod_DataSet_JTree.actionPerformed"; object data = __popup_Node.getData(); if (data is DataSetComponent) { DataSetComponent comp = (DataSetComponent)data; int comp_type = comp.getComponentType(); if (comp_type == StateMod_DataSet.COMP_CONTROL_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_CONTROL, __editable); } else if (comp_type == StateMod_DataSet.COMP_STREAMGAGE_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMGAGE, __editable); } else if (comp_type == StateMod_DataSet.COMP_DELAY_TABLE_MONTHLY_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY, __editable); } else if (comp_type == StateMod_DataSet.COMP_DELAY_TABLE_DAILY_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY, __editable); } else if (comp_type == StateMod_DataSet.COMP_DIVERSION_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DIVERSION, __editable); } else if (comp_type == StateMod_DataSet.COMP_PRECIPITATION_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_PRECIPITATION, __editable); } else if (comp_type == StateMod_DataSet.COMP_EVAPORATION_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_EVAPORATION, __editable); } else if (comp_type == StateMod_DataSet.COMP_RESERVOIR_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_RESERVOIR, __editable); } else if (comp_type == StateMod_DataSet.COMP_INSTREAM_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_INSTREAM, __editable); } else if (comp_type == StateMod_DataSet.COMP_WELL_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_WELL, __editable); } else if (comp_type == StateMod_DataSet.COMP_PLAN_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_PLAN, __editable); } else if (comp_type == StateMod_DataSet.COMP_STREAMESTIMATE_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMESTIMATE, __editable); } else if (comp_type == StateMod_DataSet.COMP_RIVER_NETWORK_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK, __editable); } else if (comp_type == StateMod_DataSet.COMP_OPERATION_GROUP) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_OPERATIONAL_RIGHT, __editable); } } // Below here are specific instances of objects. Similar to above, // display the main window but then also select the specific object... else if (data is StateMod_StreamGage) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMGAGE, __editable); ((StateMod_StreamGage_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMGAGE)).selectID(((StateMod_StreamGage)data).getID()); } else if (data is StateMod_DelayTable) { StateMod_DelayTable dt = (StateMod_DelayTable)data; if (dt.isMonthly()) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY, __editable); ((StateMod_DelayTable_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_MONTHLY)).selectID(dt.getID()); } else { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY, __editable); ((StateMod_DelayTable_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_DELAY_TABLE_DAILY)).selectID(dt.getID()); } } else if (data is StateMod_Diversion) { if (action.IndexOf(__SUMMARIZE_HOW1, StringComparison.Ordinal) >= 0) { PropList props = new PropList("Diversion"); props.set("Title=" + ((StateMod_Diversion)data).getID() + " Diversion use in Data Set"); new ReportJFrame(__dataset.getDataObjectDetails(StateMod_DataSet.COMP_DIVERSION_STATIONS, ((StateMod_Diversion)data).getID()), props); } else { // Assume properties... __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_DIVERSION, __editable); ((StateMod_Diversion_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_DIVERSION)).selectID(((StateMod_Diversion)data).getID()); } } else if (data is TS) { // Might be precipitation or evaporation. Check the data type to determine... TS ts = (TS)data; PropList props = new PropList("Precipitation/Evaporation"); if (action.IndexOf(__SUMMARIZE_HOW1, StringComparison.Ordinal) >= 0) { if (StringUtil.startsWithIgnoreCase(ts.getDataType(), "e")) { props.set("Title=" + ts.getLocation() + " Evaporation TS use in Data Set"); new ReportJFrame(__dataset.getDataObjectDetails(StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY, ts.getLocation()), props); } else if (StringUtil.startsWithIgnoreCase(ts.getDataType(), "p")) { props.set("Title=" + ts.getLocation() + " Precipitation TS use in Data Set"); new ReportJFrame(__dataset.getDataObjectDetails(StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY, ts.getLocation()), props); } } else if (action.IndexOf(__PROPERTIES, StringComparison.Ordinal) >= 0) { if (StringUtil.startsWithIgnoreCase(ts.getDataType(), "e")) { props.set("Title=Evaporation"); } else if (StringUtil.startsWithIgnoreCase(ts.getDataType(), "p")) { props.set("Title=Precipitation"); } props.set("InitialView=Graph"); props.set("GraphType=Bar"); System.Collections.IList tslist = new List <object>(1); tslist.Add(ts); try { new TSViewJFrame(tslist, props); } catch (Exception) { Message.printWarning(1, routine, "Error displaying data."); } } } else if (data is StateMod_Reservoir) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_RESERVOIR, __editable); ((StateMod_Reservoir_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_RESERVOIR)).selectID(((StateMod_Reservoir)data).getID()); } else if (data is StateMod_InstreamFlow) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_INSTREAM, __editable); ((StateMod_InstreamFlow_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_INSTREAM)).selectID(((StateMod_InstreamFlow)data).getID()); } else if (data is StateMod_Well) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_WELL, __editable); ((StateMod_Well_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_WELL)).selectID(((StateMod_Well)data).getID()); } else if (data is StateMod_Plan) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_PLAN, __editable); ((StateMod_Plan_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_PLAN)).selectID(((StateMod_Plan)data).getID()); } else if (data is StateMod_StreamEstimate) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMESTIMATE, __editable); ((StateMod_StreamEstimate_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_STREAMESTIMATE)).selectID(((StateMod_StreamEstimate)data).getID()); } else if (data is StateMod_RiverNetworkNode) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK, __editable); ((StateMod_RiverNetworkNode_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_RIVER_NETWORK)).selectID(((StateMod_RiverNetworkNode)data).getID()); } else if (data is StateMod_OperationalRight) { __dataset_wm.displayWindow(StateMod_DataSet_WindowManager.WINDOW_OPERATIONAL_RIGHT, __editable); ((StateMod_OperationalRight_JFrame)__dataset_wm.getWindow(StateMod_DataSet_WindowManager.WINDOW_OPERATIONAL_RIGHT)).selectID(((StateMod_OperationalRight)data).getID()); } }
/// <summary> /// Writes a list of StateMod_DelayTable objects to a list file. A header is /// printed to the top of the file, containing the commands used to generate the /// file. Any strings in the body of the file that contain the field delimiter will be wrapped in "...". </summary> /// <param name="filename"> the name of the file to which the data will be written. </param> /// <param name="delimiter"> the delimiter to use for separating field values. </param> /// <param name="update"> whether to update an existing file, retaining the current /// header (true) or to create a new file with a new header. </param> /// <param name="data"> the list of objects to write. </param> /// <param name="newComments"> the list of new comments to write to the header, or null if none. </param> /// <param name="comp"> the component type being written (to distinguish between daily and monthly delay tables), /// either StateMod_DataSet.COMP_DELAY_TABLES_DAILY or StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY. </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 void writeListFile(String filename, String delimiter, boolean update, java.util.List<StateMod_DelayTable> data, java.util.List<String> newComments, int comp) throws Exception public static void writeListFile(string filename, string delimiter, bool update, IList <StateMod_DelayTable> data, IList <string> newComments, int comp) { int size = 0; if (data != null) { size = data.Count; } IList <string> fields = new List <string>(); fields.Add("DelayTableID"); fields.Add("Date"); fields.Add("ReturnAmount"); int fieldCount = fields.Count; string[] names = new string[fieldCount]; string[] formats = new string[fieldCount]; string s = null; for (int i = 0; i < fieldCount; i++) { s = (string)fields[i]; names[i] = StateMod_Util.lookupPropValue(comp, "FieldName", s); formats[i] = StateMod_Util.lookupPropValue(comp, "Format", s); } string oldFile = null; if (update) { oldFile = IOUtil.getPathUsingWorkingDir(filename); } int j = 0; int k = 0; int num = 0; PrintWriter @out = null; StateMod_DelayTable delay = null; IList <string> commentIndicators = new List <string>(1); commentIndicators.Add("#"); IList <string> ignoredCommentIndicators = new List <string>(1); ignoredCommentIndicators.Add("#>"); string[] line = new string[fieldCount]; string id = null; StringBuilder buffer = new StringBuilder(); try { // Add some basic comments at the top of the file. Do this to a copy of the // incoming comments so that they are not modified in the calling code. IList <string> newComments2 = null; if (newComments == null) { newComments2 = new List <string>(); } else { newComments2 = new List <string>(newComments); } newComments2.Insert(0, ""); if (comp == StateMod_DataSet.COMP_DELAY_TABLES_DAILY) { newComments2.Insert(1, "StateMod delay tables (daily) as a delimited list file."); } else { newComments2.Insert(1, "StateMod delay tables (monthly) as a delimited list file."); } newComments2.Insert(2, ""); @out = IOUtil.processFileHeaders(IOUtil.getPathUsingWorkingDir(oldFile), IOUtil.getPathUsingWorkingDir(filename), newComments2, commentIndicators, ignoredCommentIndicators, 0); for (int i = 0; i < fieldCount; i++) { buffer.Append("\"" + names[i] + "\""); if (i < (fieldCount - 1)) { buffer.Append(delimiter); } } @out.println(buffer.ToString()); for (int i = 0; i < size; i++) { delay = (StateMod_DelayTable)data[i]; id = delay.getID(); num = delay.getNdly(); for (j = 0; j < num; j++) { line[0] = StringUtil.formatString(id, formats[0]).Trim(); line[1] = StringUtil.formatString((j + 1), formats[1]).Trim(); line[2] = StringUtil.formatString(delay.getRet_val(j), formats[2]).Trim(); buffer = new StringBuilder(); for (k = 0; k < fieldCount; k++) { if (k > 0) { buffer.Append(delimiter); } if (line[k].IndexOf(delimiter, StringComparison.Ordinal) > -1) { line[k] = "\"" + line[k] + "\""; } buffer.Append(line[k]); } @out.println(buffer.ToString()); } } @out.flush(); @out.close(); @out = null; } catch (Exception e) { // TODO SAM 2009-01-11 Log it? throw e; } finally { if (@out != null) { @out.flush(); @out.close(); } } }
/// <summary> /// Write the new (updated) delay table file. This routine writes the new delay table file. /// If an original file is specified, then the original header is carried into the new file. /// The writing of data is done by the dumpDelayFile routine which now does not mess with headers. </summary> /// <param name="inputFile"> old file (used as input) </param> /// <param name="outputFile"> new file to create </param> /// <param name="dly"> list of delays </param> /// <param name="newcomments"> new comments to save with the header of the file </param> /// <param name="interv"> interv variable specified in control file (if negative, include the number /// of entries at the start of each record). </param> /// <param name="precision"> number of digits after the decimal to write. If negative, 2 is assumed. </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 void writeStateModFile(String inputFile, String outputFile, java.util.List<StateMod_DelayTable> dly, java.util.List<String> newcomments, int interv, int precision) throws Exception public static void writeStateModFile(string inputFile, string outputFile, IList <StateMod_DelayTable> dly, IList <string> newcomments, int interv, int precision) { PrintWriter @out = null; IList <string> commentIndicators = new List <string>(1); commentIndicators.Add("#"); IList <string> ignoredCommentIndicators = new List <string>(1); ignoredCommentIndicators.Add("#>"); string routine = "StateMod_DelayTable.writeStateModFile"; if (precision < 0) { precision = 2; } Message.printStatus(2, routine, "Writing delay tables to file \"" + outputFile + "\" using \"" + inputFile + "\" header..."); try { // Process the header from the old file... @out = IOUtil.processFileHeaders(inputFile, outputFile, newcomments, commentIndicators, ignoredCommentIndicators, 0); // Now write the new data... string delayVal = null; string cmnt = "#>"; string idFormat = "%8.8s"; // Right justify because StateMod actually uses integers string delayValueFormat0 = "%8."; // no precision string delayValueFormat = "%8." + precision + "f"; string countFormat = "%4d"; @out.println(cmnt); @out.println(cmnt + " *******************************************************"); @out.println(cmnt + " StateMod Delay (Return flow) Table"); @out.println(cmnt); @out.println(cmnt + " Format (a8, i4, (12f8.2)"); @out.println(cmnt); @out.println(cmnt + " ID idly: Delay table id"); @out.println(cmnt + " Ndly ndly: Number of entries in delay table idly."); @out.println(cmnt + " Include only if \"interv\" in the"); @out.println(cmnt + " control file is equal to -1."); @out.println(cmnt + " interv = -1 = Variable number of entries"); @out.println(cmnt + " as percent (0-100)"); @out.println(cmnt + " interv = -100 = Variable number of entries"); @out.println(cmnt + " as fraction (0-1)"); @out.println(cmnt + " Ret dlyrat(1-n,idl): Return for month n, station idl"); @out.println(cmnt); @out.println(cmnt + " ID Ndly Ret1 Ret2 Ret3 Ret4 Ret5 Ret6 Ret7 Ret8 Ret9 Ret10 Ret11 Ret12"); @out.println(cmnt + "-----eb--eb------eb------eb------eb------eb------eb------eb------eb------eb------eb------eb------eb------e...next line"); @out.println(cmnt + "EndHeader"); @out.println(cmnt); int ndly = 0; if (dly != null) { ndly = dly.Count; } int numWritten, numToWrite; if (Message.isDebugOn) { Message.printDebug(3, routine, "Writing " + ndly + " delay table entries."); } StringBuilder iline = new StringBuilder(); StateMod_DelayTable delay = null; for (int i = 0; i < ndly; i++) { delay = dly[i]; // Clear out the string buffer for the new delay table iline.Length = 0; // Create one delay table entry with ID, Nvals, and 12 return values per line. if (interv < 0) { iline.Append(StringUtil.formatString(delay.getTableID(), idFormat)); iline.Append(StringUtil.formatString(delay.getNdly(), countFormat)); } else { iline.Append(StringUtil.formatString(delay.getTableID(), idFormat)); } numWritten = 0; // Number of values written for this delay table int numDelayVals = delay.getNdly(); while (true) { if (numWritten > 0) { // Clear lines 2+ before adding values iline.Length = 0; // Add spaces as per the record header info if (interv < 0) { iline.Append(" "); } else { iline.Append(" "); } } // Number of values remaining to write numToWrite = numDelayVals - numWritten; if (numToWrite > 12) { // Have more than 12 so only write 12 on this line numToWrite = 12; } for (int j = 0; j < numToWrite; j++) { delayVal = StringUtil.formatString(delay.getRet_val(numWritten + j), delayValueFormat); if (delayVal.IndexOf(' ') < 0) { // There are no spaces - this will be a problem because the file is free format. // Do a little more work here to reduce the precision until there is a leading // space. for (int iprecision = precision - 1; iprecision >= 0; iprecision--) { delayVal = StringUtil.formatString(delay.getRet_val(numWritten + j), delayValueFormat0 + iprecision + ".f"); if (delayVal.IndexOf(' ') >= 0) { // Done break; } } } iline.Append(delayVal); } // Now output the line: @out.println(iline); numWritten += numToWrite; if (numWritten == numDelayVals) { // Done writing so break out break; } } } } catch (Exception e) { if (@out != null) { @out.close(); } Message.printWarning(3, routine, e); throw e; } finally { if (@out != null) { @out.flush(); @out.close(); } } }
/// <summary> /// Returns the value for nrtn to be compared against the interv in the control file. Either a value /// is returned (if every nrtn is the same) or a -1 is returned (variable values for nrtn). /// </summary> /* TODO SAM 2007-03-01 Evaluate use * private int checkDelayInterv(Vector delaysVector) { * int ndly = -999; * if (delaysVector == null) { * return ndly; * } * * int ndelay = delaysVector.size(); * StateMod_DelayTable delayTable; * * for (int i = 0; i < ndelay; i++) { * delayTable =(StateMod_DelayTable)delaysVector.elementAt(i); * if (ndly == -999) { * ndly = delayTable.getNdly(); * } * if (ndly != delayTable.getNdly()) { * delayTable = null; * return(-1); * } * } * delayTable = null; * return ndly; * } */ /// <summary> /// Read delay information in and store in a java vector. The new delay entries are /// added to the end of the previously stored delays. Returns the delay table information. </summary> /// <param name="filename"> the filename to read from. </param> /// <param name="isMonthly"> Set to true if the delay table contains monthly data, false if it contains daily data. </param> /// <param name="interv"> The control file interv parameter. +n indicates the number of /// values in each delay pattern. -1 indicates variable number of values with /// values as percent (0-100). -100 indicates variable number of values with values as fraction (0-1). </param> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static java.util.List<StateMod_DelayTable> readStateModFile(String filename, boolean isMonthly, int interv) throws Exception public static IList <StateMod_DelayTable> readStateModFile(string filename, bool isMonthly, int interv) { string routine = "StateMod_DelayTable.readStateModFile"; string iline; IList <StateMod_DelayTable> theDelays = new List <StateMod_DelayTable>(1); StateMod_DelayTable aDelay = new StateMod_DelayTable(isMonthly); int numRead = 0, totalNumToRead = 0; bool reading = false; StreamReader @in = null; StringTokenizer split = null; if (Message.isDebugOn) { Message.printDebug(10, routine, "in readStateModFile reading file: " + filename); } try { @in = new StreamReader(filename); while (!string.ReferenceEquals((iline = @in.ReadLine()), null)) { // check for comments iline = iline.Trim(); if (iline.StartsWith("#", StringComparison.Ordinal) || iline.Length == 0) { continue; } split = new StringTokenizer(iline); if ((split == null) || (split.countTokens() == 0)) { continue; } if (!reading) { // allocate new delay node aDelay = new StateMod_DelayTable(isMonthly); numRead = 0; reading = true; theDelays.Add(aDelay); aDelay.setTableID(split.nextToken()); if (interv < 0) { aDelay.setNdly(split.nextToken()); } else { aDelay.setNdly(interv); } totalNumToRead = aDelay.getNdly(); // Set the delay table units(default is percent)... aDelay.setUnits("PCT"); if (interv == -100) { aDelay.setUnits("FRACTION"); } } while (split.hasMoreTokens()) { aDelay.addRet_val(split.nextToken()); numRead++; } if (numRead >= totalNumToRead) { reading = false; } } } catch (Exception e) { Message.printWarning(3, routine, e); throw e; } finally { if (@in != null) { @in.Close(); } @in = null; } return(theDelays); }
/// <summary> /// Compares this object to another StateMod_DelayTable object. </summary> /// <param name="data"> the object to compare against. </param> /// <returns> 0 if they are the same, 1 if this object is greater than the other object, or -1 if it is less. </returns> public virtual int CompareTo(StateMod_Data data) { int res = base.CompareTo(data); if (res != 0) { return(res); } /* FIXME SAM 2009-01-11 Determine what to do with this code * StateMod_DelayTable dt = (StateMod_DelayTable)_original; * * Message.printStatus(1, "", "'" + _ndly + "' '" + dt._ndly + "'"); * Message.printStatus(1, "", "'" + _units + "' '" + dt._units + "'"); * Message.printStatus(1, "", "'" + _is_monthly + "' '" + dt._is_monthly + "'"); + + if (_ret_val == null && dt._ret_val == null) { + Message.printStatus(1, "", "Both are null"); + } + else if (_ret_val == null) { + Message.printStatus(1, "", "Mine is null"); + } + else if (dt._ret_val == null) { + Message.printStatus(1, "", "Hers is null"); + } + else { + int size1 = _ret_val.size(); + int size2 = dt._ret_val.size(); + Message.printStatus(1, "", "" + size1 + " " + size2); + if (size1 == size2) { + for (int i = 0; i < size1; i++) { + Message.printStatus(1, "", " " + (i + 1) + ") " + _ret_val.elementAt(i) + " " + dt._ret_val.elementAt(i)); + } + } + } */ StateMod_DelayTable d = (StateMod_DelayTable)data; if (_ndly < d._ndly) { return(-1); } else if (_ndly > d._ndly) { return(1); } res = _units.CompareTo(d._units); if (res != 0) { return(res); } if (_isMonthly != d._isMonthly) { return(-1); } if (_ret_val == null && d._ret_val == null) { // ok } else if (_ret_val == null) { return(-1); } else if (d._ret_val == null) { return(1); } else { double d1 = 0; double d2 = 0; double?D1 = null; double?D2 = null; int size1 = _ret_val.Count; int size2 = d._ret_val.Count; if (size1 < size2) { return(-1); } else if (size1 > size2) { return(1); } for (int i = 0; i < size1; i++) { D1 = (double?)_ret_val[i]; d1 = D1.Value; D2 = (double?)d._ret_val[i]; d2 = D2.Value; if (d1 < d2) { return(-1); } else if (d1 > d2) { return(1); } } } return(0); }
//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"); }
/// <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. "); } } } }