/// <summary> /// Constructor. </summary> /// <param name="title"> Title for JFrame. If null, an appropriate default is used. </param> /// <param name="dataset"> dataset containing data to display </param> /// <param name="station"> StateCU_ClimateStation object to display </param> /// <param name="editable"> whether the display should be editable or not. </param> public StateCU_ClimateStation_JFrame(string title, StateCU_DataSet dataset, StateCU_ClimateStation station, bool editable) { if (string.ReferenceEquals(title, null)) { setTitle("StateCU Climate Stations"); } else { setTitle(title); } __dataset = dataset; __currentStationIndex = -1; __stationComponent = __dataset.getComponentForComponentType(StateCU_DataSet.COMP_CLIMATE_STATIONS); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateCU_ClimateStation> stationsVector0 = (java.util.List<StateCU_ClimateStation>)__stationComponent.getData(); IList<StateCU_ClimateStation> stationsVector0 = (IList<StateCU_ClimateStation>)__stationComponent.getData(); __stationsVector = stationsVector0; string id = station.getID(); int index = StateCU_Util.IndexOf(__stationsVector, id); __editable = editable; setupGUI(index); }
/// <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]; } StateCU_ClimateStation station = (StateCU_ClimateStation)_data.get(row); switch (col) { case __COL_ID: return(station.getID()); case __COL_NAME: return(station.getName()); case __COL_ELEVATION: return(new double?(station.getElevation())); case __COL_LATITUDE: return(new double?(station.getLatitude())); case __COL_REGION1: return(station.getRegion1()); case __COL_REGION2: return(station.getRegion2()); case __COL_ZH: if (StateCU_Util.isMissing(station.getZh())) { return(null); } else { return(new double?(station.getZh())); } case __COL_ZM: if (StateCU_Util.isMissing(station.getZm())) { return(null); } else { return(new double?(station.getZm())); } } return(""); }
/// <summary> /// Processes a table selection (either via a mouse press or programmatically /// from selectTableIndex() by writing the old data back to the data set component /// and getting the next selection's data out of the data and displaying it on the form. </summary> /// <param name="index"> the index of the reservoir to display on the form. </param> private void processTableSelection(int index) { __lastStationIndex = __currentStationIndex; __currentStationIndex = __worksheet.getOriginalRowNumber(index); saveLastRecord(); if (__worksheet.getSelectedRow() == -1) { nothingSelected(); return; } somethingSelected(); StateCU_ClimateStation station = __stationsVector[__currentStationIndex]; __stationIDJTextField.setText(station.getID()); __nameJTextField.setText(station.getName()); StateCU_Util.checkAndSet(station.getLatitude(), __latitudeJTextField); StateCU_Util.checkAndSet(station.getElevation(), __elevationJTextField); __region1JTextField.setText(station.getRegion1()); __region2JTextField.setText(station.getRegion2()); }
/// <summary> /// Writes a list of StateCU_ClimateStation 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 </param> /// header (true) or to create a new file with a new header<param name="data"> the Vector of objects to write. </param> /// <param name="outputComments"> Comments to add to the header, usually the command file and database 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 void writeListFile(String filename, String delimiter, boolean update, java.util.List<StateCU_ClimateStation> data, java.util.List<String> outputComments) throws Exception public static void writeListFile(string filename, string delimiter, bool update, IList <StateCU_ClimateStation> data, IList <string> outputComments) { int size = 0; if (data != null) { size = data.Count; } IList <string> fields = new List <string>(); fields.Add("ID"); fields.Add("Name"); fields.Add("Latitude"); fields.Add("Elevation"); fields.Add("Region1"); fields.Add("Region2"); fields.Add("HeightHumidity"); fields.Add("HeightWind"); int fieldCount = fields.Count; string[] names = new string[fieldCount]; string[] formats = new string[fieldCount]; int comp = StateCU_DataSet.COMP_CLIMATE_STATIONS; string s = null; for (int i = 0; i < fieldCount; i++) { s = fields[i]; names[i] = StateCU_Util.lookupPropValue(comp, "FieldName", s); formats[i] = StateCU_Util.lookupPropValue(comp, "Format", s); } string oldFile = null; if (update) { oldFile = IOUtil.getPathUsingWorkingDir(filename); } int j = 0; PrintWriter @out = null; StateCU_ClimateStation cli = null; IList <string> commentString = new List <string>(1); commentString.Add("#"); IList <string> ignoreCommentString = new List <string>(1); ignoreCommentString.Add("#>"); string[] line = new string[fieldCount]; StringBuilder buffer = new StringBuilder(); try { // Add some basic comments at the top of the file. However, do this to a copy of the // incoming comments so that they are not modified in the calling code. IList <string> newComments2 = null; if (outputComments == null) { newComments2 = new List <string>(); } else { newComments2 = new List <string>(outputComments); } newComments2.Insert(0, ""); newComments2.Insert(1, "StateCU climate stations as a delimited list file."); newComments2.Insert(2, ""); @out = IOUtil.processFileHeaders(oldFile, IOUtil.getPathUsingWorkingDir(filename), newComments2, commentString, ignoreCommentString, 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++) { cli = data[i]; line[0] = StringUtil.formatString(cli.getID(), formats[0]).Trim(); line[1] = StringUtil.formatString(cli.getName(), formats[1]).Trim(); line[2] = StringUtil.formatString(cli.getLatitude(), formats[2]).Trim(); line[3] = StringUtil.formatString(cli.getElevation(), formats[3]).Trim(); line[4] = StringUtil.formatString(cli.getRegion1(), formats[4]).Trim(); line[5] = StringUtil.formatString(cli.getRegion2(), formats[5]).Trim(); line[6] = StringUtil.formatString(cli.getZh(), formats[6]).Trim(); line[7] = StringUtil.formatString(cli.getZm(), formats[7]).Trim(); buffer = new StringBuilder(); for (j = 0; j < fieldCount; j++) { if (line[j].IndexOf(delimiter, StringComparison.Ordinal) > -1) { line[j] = "\"" + line[j] + "\""; } buffer.Append(line[j]); if (j < (fieldCount - 1)) { buffer.Append(delimiter); } } @out.println(buffer.ToString()); } } finally { if (@out != null) { @out.flush(); @out.close(); } } }
/// <summary> /// Display the time series. </summary> /// <param name="action"> Event action that initiated the display. </param> private void displayTSViewJFrame(string action) { string routine = "displayTSViewJFrame"; // Initialize the display... PropList display_props = new PropList("ClimateStation"); if (action.Equals(__BUTTON_GRAPH)) { display_props.set("InitialView", "Graph"); } else if (action.Equals(__BUTTON_TABLE)) { display_props.set("InitialView", "Table"); } else if (action.Equals(__BUTTON_SUMMARY)) { display_props.set("InitialView", "Summary"); } // display_props.set("HelpKey", "TSTool.ExportMenu"); display_props.set("TotalWidth", "600"); display_props.set("TotalHeight", "400"); display_props.set("Title", "Demand"); display_props.set("DisplayFont", "Courier"); display_props.set("DisplaySize", "11"); display_props.set("PrintFont", "Courier"); display_props.set("PrintSize", "7"); display_props.set("PageLength", "100"); PropList props = new PropList("ClimateStation"); IList<TS> tslist = new List<TS>(); // Get the time series to display and set plot properties if graphing. // For now need to find in the lists because references to time series // are not implemented... IList<TS> v = null; TS ts = null; int sub = 0; int pos; StateCU_ClimateStation station = __stationsVector[__currentStationIndex]; if (__precipitationCheckBox.isSelected()) { //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> v0 = (java.util.List<RTi.TS.TS>)__dataset.getComponentForComponentType(StateCU_DataSet.COMP_PRECIPITATION_TS_MONTHLY).getData(); IList<TS> v0 = (IList<TS>)__dataset.getComponentForComponentType(StateCU_DataSet.COMP_PRECIPITATION_TS_MONTHLY).getData(); v = v0; pos = TSUtil.IndexOf(v, station.getID(), "Location", 1); if (pos >= 0) { ts = (TS)v[pos]; } if (ts != null) { // Add a graph for precipitation... ++sub; ts.setDataType("Precipitation"); props.set("SubProduct " + sub + ".GraphType=Bar"); props.set("SubProduct " + sub + ".SubTitleString=Monthly Precipitation"); props.set("Data " + sub + ".1.TSID=" + ts.getIdentifierString()); tslist.Add(ts); } } if (__temperatureCheckBox.isSelected()) { //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> v0 = (java.util.List<RTi.TS.TS>)__dataset.getComponentForComponentType(StateCU_DataSet.COMP_TEMPERATURE_TS_MONTHLY_AVERAGE).getData(); IList<TS> v0 = (IList<TS>)__dataset.getComponentForComponentType(StateCU_DataSet.COMP_TEMPERATURE_TS_MONTHLY_AVERAGE).getData(); v = v0; pos = TSUtil.IndexOf(v, station.getID(), "Location", 1); if (pos >= 0) { ts = (TS)v[pos]; } if (ts != null) { // Add a graph for temperature... ++sub; ts.setDataType("Temperature"); props.set("SubProduct " + sub + ".GraphType=Line"); props.set("SubProduct " + sub + ".SubTitleString=Monthly Average Temperature"); props.set("Data " + sub + ".1.TSID=" + ts.getIdentifierString()); tslist.Add(ts); } } if (__frostDatesCheckBox.isSelected()) { // REVISIT - no way to graph currently } // Display the time series... try { TSProduct tsproduct = new TSProduct(props, display_props); tsproduct.setTSList(tslist); new TSViewJFrame(tsproduct); } catch (Exception e) { Message.printWarning(1,routine,"Error displaying time series."); Message.printWarning(2, routine, e); } }