/// <summary> /// Displays the annotation values from the annotation proplist in the components in the GUI. /// </summary> private void displayPropListValues() { PropList p = (PropList)__node.getAssociatedObject(); string temp = null; string val = null; val = p.getValue("Text").Trim(); __textTextField.setText(val); val = p.getValue("Point").Trim(); temp = StringUtil.getToken(val, ",", 0, 0); __xTextField.setText(StringUtil.formatString(temp, "%20.6f").Trim()); temp = StringUtil.getToken(val, ",", 0, 1); __yTextField.setText(StringUtil.formatString(temp, "%20.6f").Trim()); val = p.getValue("TextPosition").Trim(); __textPositionComboBox.select(val); val = p.getValue("FontName").Trim(); __fontNameComboBox.select(val); val = p.getValue("OriginalFontSize").Trim(); __fontSizeTextField.setText(val); val = p.getValue("FontStyle").Trim(); __fontStyleComboBox.select(val); }
/// <summary> /// Performs general and specific data checks on stream gage station data. </summary> /// <param name="props"> A property list for specific properties </param> /// <param name="data_vector"> Vector of data to check. /// on checking this data. </param> private void checkStreamGageStationData(PropList props, System.Collections.IList data_vector) { // Create elements for the checks and check file string[] header = StateMod_StreamGage.getDataHeader(); System.Collections.IList data = new List <object>(); string title = "Stream Gage Station"; // Perform the general validation using the Data Table Model StateMod_Data_TableModel tm = new StateMod_StreamGage_Data_TableModel(data_vector, false); System.Collections.IList @checked = performDataValidation(tm, title); //String [] columnHeader = getDataTableModelColumnHeader( tm ); string[] columnHeader = getColumnHeader(tm); // Do specific checks int size = 0; if (data_vector != null) { size = data_vector.Count; } data = doSpecificDataChecks(data_vector, props); // Add the data and checks to the check file. // Provides basic header information for this data check table string info = "The following " + title + " (" + 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); }
void LoadProps() { int idBodyStruct = actorScript.actorBody.BodyStructure; int idBodySubt = actorScript.actorBody.BodySubtype; List <PropTable.Prop> tList = tableProp.GetPropsByBodytype(idBodySubt, idBodyStruct); foreach (PropList tItem in propList) { Destroy(tItem.optObject.gameObject); } propList.Clear(); foreach (PropTable.Prop prop in tList) { PropList toAdd = new PropList(); toAdd.IDProp = prop.ID; toAdd.Name = prop.Name; Button optionList = Instantiate <Button>(optProp); Text tText = optionList.GetComponentInChildren <Text> (); tText.text = prop.Name; optionList.onClick.AddListener(() => ApplyProp(toAdd.IDProp)); optionList.transform.SetParent(propContent.transform, false); toAdd.optObject = optionList; propList.Add(toAdd); } }
public void StartEditor() { m_PropList = new PropList(); m_PropList.Initialize(); m_EnemyList = new EnemyList(); m_EnemyList.Initialize(); }
/// <summary> /// Deserialize fields from a FastTransferStream. /// </summary> /// <param name="stream">A FastTransferStream.</param> public override void Deserialize(FastTransferStream stream) { this.propList = new PropList(stream); if (EmbeddedMessage.Verify(stream)) { this.embeddedMessage = new EmbeddedMessage(stream); } }
/// <summary> /// Displays a graph for a time series. </summary> /// <param name="tslist"> Vector of time series to graph </param> /// <param name="title"> the title of the graph </param> /// <param name="dataset"> the dataset in which the ts data exists </param> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static void displayGraphForTS(java.util.List tslist, String title, StateMod_DataSet dataset) throws Exception public static void displayGraphForTS(System.Collections.IList tslist, string title, StateMod_DataSet dataset) { // add title to proplist PropList props = new PropList("displayGraphForTSProps"); props.set("titlestring", title); displayGraphForTS(tslist, props, dataset); }
public MessageContent() : base() { Props = FTFactory.Instance.CreatePropList(); MsgChildren = FTFactory.Instance.CreateMessageChildren(); Children.Add(Props); Children.Add(MsgChildren); }
public AttachmentContent() : base() { AttachmentPropList = FTFactory.Instance.CreatePropList(); EmbeddedMessage = FTFactory.Instance.CreateEmbeddedMessage(); Children.Add(AttachmentPropList); Children.Add(EmbeddedMessage); }
/// <summary> /// Deserialize fields from a FastTransferStream. /// </summary> /// <param name="stream">A FastTransferStream.</param> public override void Deserialize(FastTransferStream stream) { if (stream.ReadMarker(Markers.PidTagIncrSyncGroupInfo)) { this.propList = new PropList(stream); return; } AdapterHelper.Site.Assert.Fail("The stream cannot be deserialized successfully."); }
/// <summary> /// Finds out which check method to call based on the input type. </summary> /// <param name="props"> Property list for properties on data checks. </param> /// <returns> CheckFile A data check file object. </returns> public virtual CheckFile checkComponentType(PropList props) { // reset general data problem count __gen_problems = 0; // check for component data. If none exists then do no checks. IList <object> data_vector = getComponentData(__type); if (data_vector == null || data_vector.Count == 0) { return(__check_file); } switch (__type) { case StateCU_DataSet.COMP_BLANEY_CRIDDLE: checkBlaneyCriddleData(props, data_vector); break; case StateCU_DataSet.COMP_CLIMATE_STATIONS: checkClimateStationData(props, data_vector); break; case StateCU_DataSet.COMP_CROP_CHARACTERISTICS: checkCropCharacteristicsData(props, data_vector); break; case StateCU_DataSet.COMP_CROP_PATTERN_TS_YEARLY: checkCropPatternTSData(props, data_vector); break; case StateCU_DataSet.COMP_CU_LOCATIONS: checkLocationData(props, data_vector); break; case StateCU_DataSet.COMP_CU_LOCATION_CLIMATE_STATIONS: checkLocationClimateStationsData(props, data_vector); break; case StateCU_DataSet.COMP_CU_LOCATION_COLLECTIONS: checkLocationCollectionData(props, data_vector); break; case StateCU_DataSet.COMP_DELAY_TABLE_ASSIGNMENT_MONTHLY: checkDelayTableAssignmentData(props, data_vector); break; case StateCU_DataSet.COMP_IRRIGATION_PRACTICE_TS_YEARLY: checkIrrigationPracticeTSData(props, data_vector); break; default: ; // do nothing break; } return(__check_file); }
/// <summary> /// Helper method to check well rights component data. The following are checked: /// <ol> /// <li> Well stations without at least one right are listed. This requires that /// the dataset include well stations.</li> /// <li> Well rights with yield <= 0.0</li> /// <li> Well rights summary for a station is not equal to the well capacity. /// This requires that the dataset include well stations.<li> /// </ol> /// </summary> private void checkWellStationRights(PropList props, System.Collections.IList wer_Vector) { int size = 0; // create elements for the checks and check file string[] header = StateMod_WellRight.getDataHeader(); System.Collections.IList data = new List <object>(); string title = "Well Rights"; // Do the general data validation // using this components data table model StateMod_Data_TableModel tm = new StateMod_WellRight_Data_TableModel(wer_Vector, false); System.Collections.IList @checked = performDataValidation(tm, title); //String [] columnHeader = getDataTableModelColumnHeader( tm ); string[] columnHeader = getColumnHeader(tm); // check Well Station data PropList props_rights = new PropList("Well Rights"); props_rights.add("checkRights=true"); System.Collections.IList wes_Vector = getComponentData(StateMod_DataSet.COMP_WELL_STATIONS); if (wes_Vector != null && wes_Vector.Count > 0) { checkWellStationData(props_rights, wes_Vector); } props_rights = null; // cleanup // Check to make sure the sum of well rights equals the well station // capacity... checkWellRights_CapacityData(); // Since well rights are determined from parcel data, print a list of // well rights that do not have associated yield (decree)... size = 0; if (wer_Vector != null) { size = wer_Vector.Count; } // Do data checks listed in the StateMod_WellRight class // Remove all previous checks from StateMod_Well data.Clear(); data = doSpecificDataChecks(wer_Vector, props); // provides basic header information for this data check table string info = "The following well rights (" + data.Count + " out of " + size + ") have no decree (checked to StateMod file .XX precision).\n" + "Well yield data may not be available."; // 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); }
public Recipient() : base() { StartRecipientMarker = FTFactory.Instance.CreateStartRecipientMarker(); RecvPropList = FTFactory.Instance.CreatePropList(); EndRecipientMarker = FTFactory.Instance.CreateEndRecipientMarker(); Children.Add(StartRecipientMarker); Children.Add(RecvPropList); Children.Add(EndRecipientMarker); }
/// <summary> /// Displays a graph for a time series. </summary> /// <param name="ts"> the time series to graph. </param> /// <param name="title"> the title of the graph </param> /// <param name="dataset"> the dataset in which the ts data exists </param> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static void displayGraphForTS(RTi.TS.TS ts, String title, StateMod_DataSet dataset) throws Exception public static void displayGraphForTS(TS ts, string title, StateMod_DataSet dataset) { System.Collections.IList v = new List <object>(); v.Add(ts); // add title to proplist PropList props = new PropList("displayGraphForTSProps"); props.set("titlestring", title); displayGraphForTS(v, props, dataset); }
/// <summary> /// Deserialize fields from a FastTransferStream. /// </summary> /// <param name="stream">A FastTransferStream.</param> public override void Deserialize(FastTransferStream stream) { byte[] buffer = new byte[PidLength]; int len = stream.Read(buffer, 0, PidLength); if (len == SyntacticalBase.PidLength) { this.propList = new PropList(stream); return; } AdapterHelper.Site.Assert.Fail("The stream cannot be deserialized successfully."); }
public override int AttackNumberCalc(int num, HeroBase army) { // E技能被动伤害 var eAttack = EAttackByOnce() * num * (Level >= 11 ? 2 : 1); var propDamange = 0; PropList.ForEach(prop => { propDamange += prop.CalcByAttackOnce(this, army); }); return(ATK * num + eAttack + propDamange); }
public void MoveRange(int startIndex, int count, int newStartIndex) { PropList temp = new PropList(); for (int i = 0; i < count; i++) { temp.Add(this._colors.GetKey(startIndex), this._colors.GetByIndex(startIndex)); this._colors.RemoveAt(startIndex); } if (newStartIndex > startIndex) { newStartIndex -= count; } for (int i = 0; i < count; i++) { this._colors.Insert(newStartIndex, temp.GetKey(i), temp.GetByIndex(i)); } }
/// <summary> /// Performs general and specific data checks on well station data. </summary> /// <param name="props"> A property list for specific properties </param> /// <param name="wes_Vector"> Vector of data to check. /// on checking this data. </param> private void checkWellStationData(PropList props, System.Collections.IList wes_Vector) { // create elements for the checks and check file string[] header = StateMod_Well.getDataHeader(); string title = "Well Station"; // first do the general data validation // using this components data table model StateMod_Data_TableModel tm = new StateMod_Well_Data_TableModel(wes_Vector, false); System.Collections.IList @checked = performDataValidation(tm, title); //String [] columnHeader = getDataTableModelColumnHeader( tm ); string[] columnHeader = getColumnHeader(tm); // do specific checks int size = 0; if (wes_Vector != null) { size = wes_Vector.Count; } System.Collections.IList data = new List <object>(); data = doSpecificDataChecks(wes_Vector, props); // add the data and checks to the check file // provides basic header information for this data check table string info = "The following well stations (" + data.Count + " out of " + size + ") have no irrigated parcels served by wells.\n" + "Data may be OK if the station is an M&I or has no wells.\n" + "Parcel count and area in the following table are available " + "only if well stations are read from HydroBase.\n"; // 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); // Check to make sure the sum of well rights equals the well station // capacity.. checkWellRights_CapacityData(); }
private void TestStepChanged(object sender, SelectionChangedEventArgs e) { teststep_idx = (sender as ComboBox).SelectedIndex; if (teststep_idx == -1) { teststep_idx = 0; } var teststep = Node_TestSteps.ChildNodes[teststep_idx]; PropList.Clear(); foreach (var property in teststep.ChildNodes) { string n = (property as XmlNode).Attributes["Name"].Value; string d = (property as XmlNode).Attributes["DisplayName"].Value; string t = (property as XmlNode).Attributes["Type"].Value; PropList.Add(new Tuple <string, string, string>(n, d, t)); } }
/// <summary> /// 初始化道具,初始数量为0 /// </summary> private Packet() { //非消耗品 PropList.Add(new HoldProp(PropName.怪物侦测器, MotaElement.怪物探测器)); PropList.Add(new BookProp()); PropList.Add(new SkipProp()); PropList.Add(new HoldProp(PropName.自然之靴, MotaElement.自然之靴)); PropList.Add(new UpStair()); //消耗品 PropList.Add(new DestroyProp()); PropList.Add(new KeyProp(MotaElement.小红钥匙, PropName.红钥匙)); PropList.Add(new KeyProp(MotaElement.小蓝钥匙, PropName.蓝钥匙)); PropList.Add(new KeyProp(MotaElement.小黄钥匙, PropName.黄钥匙)); //绑定道具栏重绘事件 foreach (var item in PropList) { item.CountChangeEvent += new Property.CountChangeHandle(OnChange); } }
/// <summary> /// Saves the changes made in the GUI and applies them to the node in the parent GUI. /// </summary> private void applyChanges() { if (!validateData()) { // if the data are not valid, don't close return; } HydrologyNode node = new HydrologyNode(); PropList p = new PropList(""); string temp = null; temp = __textTextField.getText().Trim(); temp = StringUtil.replaceString(temp, "\"", "'"); p.set("Text", temp); temp = __xTextField.getText().Trim() + "," + __yTextField.getText().Trim(); p.set("Point", temp); temp = __textPositionComboBox.getSelected(); p.set("TextPosition", temp); temp = __fontNameComboBox.getSelected().Trim(); p.set("FontName", temp); temp = __fontSizeTextField.getText().Trim(); p.set("OriginalFontSize", temp); temp = __fontStyleComboBox.getSelected().Trim(); p.set("FontStyle", temp); node.setAssociatedObject(p); node.setDirty(true); __parent.updateAnnotation(__nodeNum, node); __applyButton.setEnabled(false); __okButton.setEnabled(false); }
/// <summary> /// Initializes the data and sets up the GUI, using values that were passed into /// the constructor. Alternately, if other setup needs done prior to the table /// models being built and the GUI set up, this can be called separately with /// the same parameters that would be into the GUI. </summary> /// <param name="data"> the data to display in the worksheet. Can be null or empty, in /// which case an empty worksheet is shown. </param> /// <param name="titleString"> the String to display as the GUI's title. </param> /// <param name="editable"> whether the data in the JFrame can be edited or not. If true /// the data can be edited, if false they can not. </param> /// <exception cref="Exception"> if there is an error building the worksheet. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void initialize(java.util.List data, String titleString, boolean editable) throws Exception public virtual void initialize(System.Collections.IList data, string titleString, bool editable) { if (data == null) { _data = new List <object>(); } else { _data = data; } createDataBackup(); _props = new PropList("Worksheet Props"); _props.add("JWorksheet.ShowPopupMenu=true"); _props.add("JWorksheet.AllowCopy=true"); _props.add("JWorksheet.ShowRowHeader=true"); _props.add("JWorksheet.SelectionMode=MultipleDiscontinuousRowSelection"); _titleString = titleString; _editable = editable; setupGUI(); }
public static void TreePack(Size textureSize, string[] filenames, string outputFilename) { System.Drawing.Image[] images = new Image[filenames.Length]; // for (int i=0; i<filenames.Length; i++) // { // files[i] = new System.IO.FileInfo(filenames[i]); // images[i] = System.Drawing.Bitmap.FromFile(filenames[i]); // } // ERectangle[] rects; // EPoint[] offsets; // Bitmap bmp = TreePack(images, out rects, out offsets); // bmp.Save(outputFilename); EPoint[] offsets = new EPoint[filenames.Length]; System.IO.FileInfo[] files = new System.IO.FileInfo[filenames.Length]; PropList originalOrder = new PropList(); for (int i=0; i<filenames.Length; i++) { files[i] = new System.IO.FileInfo(filenames[i]); images[i] = System.Drawing.Bitmap.FromFile(filenames[i]); EPoint pntMid = new EPoint(images[i].Width, images[i].Height)/2; EPoint pnt = new EPoint(); images[i] = Endogine.BitmapHelpers.BitmapHelper.TrimWhitespace((Bitmap)images[i], out pnt); offsets[i] = pntMid - pnt + new EPoint(1,1); originalOrder.Add(filenames[i], images[i]); } Image[] unpacked = null; int numPixelsMinimum; Size maxWnH, minWnH; GetImagesStatistics(images, out numPixelsMinimum, out maxWnH, out minWnH); if (textureSize.Width == 0 || textureSize.Height == 0) { int side = (int)Math.Sqrt(numPixelsMinimum); int asdas = (int)Math.Ceiling(Math.Log(side, 2)); textureSize = new Size(side,side); } if (numPixelsMinimum >= textureSize.Width*textureSize.Height) throw new Exception("Not enough space to pack in"); images = Endogine.BitmapHelpers.TexturePacking.SortImagesBySize(images); Random rnd = new Random(); int nNumTries = 1; for (int i=0; i<nNumTries; i++) { //Irritating, but since we can't find index of an item in a standard array...: ArrayList aImagesNewOrder = new ArrayList(); foreach (Image image in images) aImagesNewOrder.Add(image); EPoint[] locsInTexture = null; Bitmap bmp = Endogine.BitmapHelpers.TexturePacking.TreePack(textureSize, images, out unpacked, out locsInTexture); int areaExcluded = Endogine.BitmapHelpers.TexturePacking.GetTotalArea(unpacked); if (unpacked.Length > 0) throw new Exception("Couldn't fit all images. Total pixels excluded = "+areaExcluded.ToString() + " (side = "+((int)Math.Sqrt(areaExcluded)).ToString()+")"); ArrayList aUnpacked = new ArrayList(); foreach (Image image in unpacked) aUnpacked.Add(image); int areaUnused = 0; foreach (Image image in images) { if (!aUnpacked.Contains(image)) areaUnused+=image.Size.Width*image.Size.Height; } if (areaUnused > textureSize.Width*textureSize.Height/2) { //TODO: we could maybe make the texture at least half as big } Node infoNode = new Node(); infoNode = infoNode.CreateChild("Files"); //TODO: go by the list of images that was actually used! for (int orgIndex = 0; orgIndex<originalOrder.Count; orgIndex++) { Image image = (Image)originalOrder.GetByIndex(orgIndex); if (aUnpacked.Contains(image)) continue; int newIndex = aImagesNewOrder.IndexOf(image); //create the file entry (File, Rect, Offset) ERectangle rctInTexture = new ERectangle( locsInTexture[newIndex].X, locsInTexture[newIndex].Y, image.Width, image.Height); Node frameNode = infoNode.CreateChild("File"); //remove extension from filename: frameNode.Value = files[orgIndex].Name.Substring(0,files[orgIndex].Name.LastIndexOf(files[orgIndex].Extension)); //frameNode.Value = files[orgIndex].Name; Node subNode = frameNode.CreateChild("Rect"); subNode.Value = rctInTexture.ToString(); subNode = frameNode.CreateChild("Offset"); subNode.Value = offsets[orgIndex].ToString(); } System.Xml.XmlDocument doc = infoNode.RootNode.CreateXmlDocument(); string sOut = null; if (nNumTries > 1) sOut = outputFilename+areaExcluded.ToString()+"-"+i.ToString(); else sOut = outputFilename; doc.Save(sOut+".xml"); bmp.Save(sOut+".png"); //randomize order to see if we get better results: ArrayList aImages = new ArrayList(); for (int j=0; j<images.Length;j++) aImages.Add(images[j]); Image[] randomOrder = new Image[images.Length]; for (int j=images.Length-1;j>=0;j--) { int pos = 0; if (j > 0) pos = Math.Min(rnd.Next(j), j-1); randomOrder[j] = (Image)aImages[pos]; aImages.RemoveAt(pos); } images = randomOrder; } }
/// <summary> /// Sets up the GUI /// </summary> public virtual void setupGUI() { string routine = "setupGUI"; addWindowListener(this); __addDepletion = new JButton(__BUTTON_ADD_DEPLETION); __deleteDepletion = new JButton(__BUTTON_DELETE_DEPLETION); __deleteDepletion.setEnabled(false); __helpJButton = new JButton(__BUTTON_HELP); __helpJButton.setEnabled(false); __closeJButton = new JButton(__BUTTON_CLOSE); JButton cancelJButton = new JButton(__BUTTON_CANCEL); JButton applyJButton = new JButton(__BUTTON_APPLY); // AWT portion GridBagLayout gb = new GridBagLayout(); JPanel mainJPanel = new JPanel(); mainJPanel.setLayout(gb); FlowLayout fl = new FlowLayout(FlowLayout.RIGHT); JPanel p1 = new JPanel(); p1.setLayout(fl); GridLayout gl = new GridLayout(2, 2, 1, 1); JPanel info_panel = new JPanel(); info_panel.setLayout(gl); JPanel main_panel = new JPanel(); main_panel.setLayout(new BorderLayout()); info_panel.add(new JLabel("Well:")); info_panel.add(new JLabel(__currentWell.getID())); info_panel.add(new JLabel("Well name:")); info_panel.add(new JLabel(__currentWell.getName())); if (__editable) { p1.add(__addDepletion); p1.add(__deleteDepletion); } p1.add(applyJButton); p1.add(cancelJButton); // p1.add(__helpJButton); p1.add(__closeJButton); PropList p = new PropList("StateMod_Well_Depletion_JFrame.JWorksheet"); p.add("JWorksheet.ShowPopupMenu=true"); p.add("JWorksheet.AllowCopy=true"); p.add("JWorksheet.SelectionMode=SingleRowSelection"); int[] widths = null; JScrollWorksheet jsw = null; try { //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> nodes = (java.util.List<StateMod_RiverNetworkNode>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK).getData()); IList <StateMod_RiverNetworkNode> nodes = (IList <StateMod_RiverNetworkNode>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_RIVER_NETWORK).getData()); IList <StateMod_ReturnFlow> v = new List <StateMod_ReturnFlow>(); IList <StateMod_ReturnFlow> v2 = __currentWell.getDepletions(); StateMod_ReturnFlow rf; for (int i = 0; i < v2.Count; i++) { rf = (StateMod_ReturnFlow)v2[i].clone(); rf.setCrtnid(rf.getCrtnid() + StateMod_Util.findNameInVector(rf.getCrtnid(), nodes, true)); v.Add(rf); } StateMod_ReturnFlow_TableModel tmw = new StateMod_ReturnFlow_TableModel(__dataset, v, __editable, false); StateMod_ReturnFlow_CellRenderer crw = new StateMod_ReturnFlow_CellRenderer(tmw); jsw = new JScrollWorksheet(crw, tmw, p); __worksheet = jsw.getJWorksheet(); IList <string> ids = StateMod_Util.createIdentifierListFromStateModData(nodes, true, null); __worksheet.setColumnJComboBoxValues(StateMod_ReturnFlow_TableModel.COL_RIVER_NODE, ids, false); IList <StateMod_DelayTable> delayIDs = null; if (__dataset.getIday() == 1) { //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> delayIDs0 = (java.util.List<StateMod_DelayTable>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_DAILY).getData()); IList <StateMod_DelayTable> delayIDs0 = (IList <StateMod_DelayTable>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_DAILY).getData()); delayIDs = delayIDs0; } else { //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> delayIDs0 = (java.util.List<StateMod_DelayTable>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY).getData()); IList <StateMod_DelayTable> delayIDs0 = (IList <StateMod_DelayTable>)(__dataset.getComponentForComponentType(StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY).getData()); delayIDs = delayIDs0; } ids = StateMod_Util.createIdentifierListFromStateModData(delayIDs, true, null); __worksheet.setColumnJComboBoxValues(StateMod_ReturnFlow_TableModel.COL_RETURN_ID, ids, false); widths = crw.getColumnWidths(); } catch (Exception e) { Message.printWarning(2, routine, e); jsw = new JScrollWorksheet(0, 0, p); __worksheet = jsw.getJWorksheet(); } __worksheet.setPreferredScrollableViewportSize(null); __worksheet.setHourglassJFrame(this); __worksheet.addMouseListener(this); __worksheet.addKeyListener(this); main_panel.add(jsw, "Center"); main_panel.add(p1, "South"); JGUIUtil.addComponent(mainJPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); JGUIUtil.addComponent(mainJPanel, main_panel, 0, 1, 10, 10, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.SOUTH); getContentPane().add(mainJPanel); JPanel bottomJPanel = new JPanel(); bottomJPanel.setLayout(gb); __messageJTextField = new JTextField(); __messageJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); __statusJTextField = new JTextField(5); __statusJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST); getContentPane().add("South", bottomJPanel); __addDepletion.addActionListener(this); __deleteDepletion.addActionListener(this); __closeJButton.addActionListener(this); __helpJButton.addActionListener(this); applyJButton.addActionListener(this); cancelJButton.addActionListener(this); pack(); setSize(520, 280); JGUIUtil.center(this); setVisible(true); if (widths != null) { __worksheet.setColumnWidths(widths); } }
/// <summary> /// Sets up the GUI. /// </summary> private void setupGUI() { string routine = "setupGUI"; addWindowListener(this); __addOwner = new JButton(__BUTTON_ADD_OWNER); __deleteOwner = new JButton(__BUTTON_DEL_OWNER); __deleteOwner.setEnabled(false); __helpJButton = new JButton(__BUTTON_HELP); __helpJButton.setEnabled(false); __closeJButton = new JButton(__BUTTON_CLOSE); JButton cancelJButton = new JButton(__BUTTON_CANCEL); JButton applyJButton = new JButton(__BUTTON_APPLY); GridBagLayout gb = new GridBagLayout(); JPanel bigPanel = new JPanel(); bigPanel.setLayout(gb); FlowLayout fl = new FlowLayout(FlowLayout.RIGHT); JPanel p1 = new JPanel(); p1.setLayout(fl); GridLayout gl = new GridLayout(2, 2, 1, 1); JPanel info_panel = new JPanel(); info_panel.setLayout(gl); JPanel main_panel = new JPanel(); main_panel.setLayout(new BorderLayout()); info_panel.add(new JLabel("Reservoir ID:")); info_panel.add(new JLabel(__currentRes.getID())); info_panel.add(new JLabel("Reservoir name:")); info_panel.add(new JLabel(__currentRes.getName())); if (__editable) { p1.add(__addOwner); p1.add(__deleteOwner); } p1.add(applyJButton); p1.add(cancelJButton); // p1.add(__helpJButton); p1.add(__closeJButton); PropList p = new PropList("StateMod_Reservoir_JFrame.JWorksheet"); p.add("JWorksheet.ShowPopupMenu=true"); p.add("JWorksheet.AllowCopy=true"); p.add("JWorksheet.SelectionMode=SingleRowSelection"); int[] widths = null; JScrollWorksheet jsw = null; try { IList <StateMod_ReservoirAccount> v = new List <StateMod_ReservoirAccount>(); IList <StateMod_ReservoirAccount> v2 = __currentRes.getAccounts(); StateMod_ReservoirAccount ra; for (int i = 0; i < v2.Count; i++) { ra = (StateMod_ReservoirAccount)v2[i].clone(); v.Add(ra); } StateMod_ReservoirAccount_TableModel tmr = new StateMod_ReservoirAccount_TableModel(v, __editable, true); StateMod_ReservoirAccount_CellRenderer crr = new StateMod_ReservoirAccount_CellRenderer(tmr); jsw = new JScrollWorksheet(crr, tmr, p); __worksheet = jsw.getJWorksheet(); IList <string> owner = StateMod_ReservoirAccount.getN2ownChoices(true); __worksheet.setColumnJComboBoxValues(StateMod_ReservoirAccount_TableModel.COL_OWNERSHIP_TIE, owner, false); widths = crr.getColumnWidths(); } catch (Exception e) { Message.printWarning(2, routine, e); jsw = new JScrollWorksheet(0, 0, p); __worksheet = jsw.getJWorksheet(); } __worksheet.setPreferredScrollableViewportSize(null); __worksheet.setHourglassJFrame(this); __worksheet.addMouseListener(this); __worksheet.addKeyListener(this); main_panel.add(jsw, "Center"); main_panel.add(p1, "South"); JGUIUtil.addComponent(bigPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); JGUIUtil.addComponent(bigPanel, main_panel, 0, 1, 10, 10, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.SOUTH); __addOwner.addActionListener(this); __deleteOwner.addActionListener(this); __helpJButton.addActionListener(this); __closeJButton.addActionListener(this); applyJButton.addActionListener(this); cancelJButton.addActionListener(this); getContentPane().add(bigPanel); JPanel bottomJPanel = new JPanel(); bottomJPanel.setLayout(gb); __messageJTextField = new JTextField(); __messageJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); __statusJTextField = new JTextField(5); __statusJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST); getContentPane().add("South", bottomJPanel); pack(); setSize(700, 400); JGUIUtil.center(this); setVisible(true); if (widths != null) { __worksheet.setColumnWidths(widths); } }
/// <summary> /// Sets up the GUI. /// </summary> private void setupGUI() { string routine = "setupGUI"; addWindowListener(this); __addAreaCap = new JButton(__BUTTON_ADD_AREA_CAPACITY); __deleteAreaCap = new JButton(__BUTTON_DEL_AREA_CAPACITY); __deleteAreaCap.setEnabled(false); __helpJButton = new JButton(__BUTTON_HELP); __helpJButton.setEnabled(false); __closeJButton = new JButton(__BUTTON_CLOSE); JButton cancelJButton = new JButton(__BUTTON_CANCEL); JButton applyJButton = new JButton(__BUTTON_APPLY); GridBagLayout gb = new GridBagLayout(); JPanel bigPanel = new JPanel(); bigPanel.setLayout(gb); FlowLayout fl = new FlowLayout(FlowLayout.RIGHT); JPanel p0 = new JPanel(); p0.setLayout(fl); p0.add(__GraphArea_JButton = new SimpleJButton(__GraphArea_String, __GraphArea_String, this)); p0.add(__GraphSeepage_JButton = new SimpleJButton(__GraphSeepage_String, __GraphSeepage_String, this)); GridLayout gl = new GridLayout(2, 2, 1, 1); JPanel info_panel = new JPanel(); info_panel.setLayout(gl); //JPanel main_panel = new JPanel(); //main_panel.setLayout(new BorderLayout()); info_panel.add(new JLabel("Reservoir:")); info_panel.add(new JLabel(__currentRes.getID())); info_panel.add(new JLabel("Reservoir name:")); info_panel.add(new JLabel(__currentRes.getName())); JPanel p1 = new JPanel(); p1.setLayout(fl); if (__editable) { p1.add(__addAreaCap); p1.add(__deleteAreaCap); } p1.add(applyJButton); p1.add(cancelJButton); // p1.add(__helpJButton); p1.add(__closeJButton); PropList p = new PropList("StateMod_Reservoir__AreaCap_JFrame.JWorksheet"); /* * p.add("JWorksheet.CellFont=Courier"); * p.add("JWorksheet.CellStyle=Plain"); * p.add("JWorksheet.CellSize=11"); * p.add("JWorksheet.HeaderFont=Arial"); * p.add("JWorksheet.HeaderStyle=Plain"); * p.add("JWorksheet.HeaderSize=11"); * p.add("JWorksheet.HeaderBackground=LightGray"); * p.add("JWorksheet.RowColumnPresent=false"); */ p.add("JWorksheet.ShowPopupMenu=true"); p.add("JWorksheet.AllowCopy=true"); p.add("JWorksheet.SelectionMode=SingleRowSelection"); int[] widths = null; JScrollWorksheet jsw = null; try { IList <StateMod_ReservoirAreaCap> v = new List <StateMod_ReservoirAreaCap>(); IList <StateMod_ReservoirAreaCap> v2 = __currentRes.getAreaCaps(); for (int i = 0; i < v2.Count; i++) { v.Add((StateMod_ReservoirAreaCap)v2[i].clone()); } StateMod_ReservoirAreaCap_TableModel tmr = new StateMod_ReservoirAreaCap_TableModel(v, __editable, true); StateMod_ReservoirAreaCap_CellRenderer crr = new StateMod_ReservoirAreaCap_CellRenderer(tmr); jsw = new JScrollWorksheet(crr, tmr, p); __worksheet = jsw.getJWorksheet(); widths = crr.getColumnWidths(); } catch (Exception e) { Message.printWarning(2, routine, e); jsw = new JScrollWorksheet(0, 0, p); __worksheet = jsw.getJWorksheet(); } __worksheet.setPreferredScrollableViewportSize(null); __worksheet.setHourglassJFrame(this); __worksheet.addMouseListener(this); __worksheet.addKeyListener(this); //main_panel.add(jsw, "Center"); // Does not work well... //main_panel.add(p1, "South"); // assemble parts JGUIUtil.addComponent(bigPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTHWEST); JGUIUtil.addComponent(bigPanel, jsw, 0, 1, 10, 10, 1.0, 1.0, GridBagConstraints.BOTH, GridBagConstraints.SOUTH); JPanel button_panel = new JPanel(); button_panel.setLayout(gb); JGUIUtil.addComponent(button_panel, p0, 0, 0, 10, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.SOUTHEAST); JGUIUtil.addComponent(button_panel, p1, 0, 1, 10, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.SOUTHEAST); JGUIUtil.addComponent(bigPanel, button_panel, 0, 11, 10, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.SOUTHEAST); __addAreaCap.addActionListener(this); __deleteAreaCap.addActionListener(this); __helpJButton.addActionListener(this); __closeJButton.addActionListener(this); applyJButton.addActionListener(this); cancelJButton.addActionListener(this); getContentPane().add(bigPanel); JPanel bottomJPanel = new JPanel(); bottomJPanel.setLayout(gb); __messageJTextField = new JTextField(); __messageJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); __statusJTextField = new JTextField(5); __statusJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST); getContentPane().add("South", bottomJPanel); pack(); checkGUIState(); setSize(420, 400); JGUIUtil.center(this); setVisible(true); if (widths != null) { __worksheet.setColumnWidths(widths); } }
/// <summary> /// Finds out which check method to call based on the input type. Acts /// like a factory for StateMod data checks. </summary> /// <param name="props"> Property list for properties on data checks. </param> /// <returns> CheckFile A data check file object. </returns> public virtual CheckFile checkComponentType(PropList props) { // reset general data problem count __gen_problems = 0; // check for component data. If none exists then do no checks. System.Collections.IList data_vector = getComponentData(__type); if (data_vector == null || data_vector.Count == 0) { return(__check_file); } // find out which data type is being checked // and call the associated check method. switch (__type) { case StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY: checkDelayTableMonthlyData(props, data_vector); break; case StateMod_DataSet.COMP_DELAY_TABLES_DAILY: checkDelayTableDailyData(props, data_vector); break; case StateMod_DataSet.COMP_DIVERSION_STATIONS: checkDiversionStationData(props, data_vector); break; case StateMod_DataSet.COMP_DIVERSION_RIGHTS: checkDiversionRightsData(props, data_vector); break; case StateMod_DataSet.COMP_INSTREAM_STATIONS: checkInstreamFlowStationData(props, data_vector); break; case StateMod_DataSet.COMP_INSTREAM_RIGHTS: checkInstreamFlowRightData(props, data_vector); break; case StateMod_DataSet.COMP_RESERVOIR_STATIONS: checkReservoirStationData(props, data_vector); break; case StateMod_DataSet.COMP_RESERVOIR_RIGHTS: checkReservoirRightData(props, data_vector); break; case StateMod_DataSet.COMP_RIVER_NETWORK: checkRiverNetworkData(props, data_vector); break; case StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS: checkStreamEstimateStationData(props, data_vector); break; case StateMod_DataSet.COMP_STREAMESTIMATE_COEFFICIENTS: checkStreamEstimateCoefficientData(props, data_vector); break; case StateMod_DataSet.COMP_STREAMGAGE_STATIONS: checkStreamGageStationData(props, data_vector); break; case StateMod_DataSet.COMP_WELL_STATIONS: checkWellStationData(props, data_vector); break; case StateMod_DataSet.COMP_WELL_RIGHTS: checkWellStationRights(props, data_vector); break; default: ; break; } return(__check_file); }
/// <summary> /// Verify that a stream's current position contains a serialized attachmentContent. /// </summary> /// <param name="stream">A FastTransferStream.</param> /// <returns>If the stream's current position contains /// a serialized attachmentContent, return true, else false.</returns> public static bool Verify(FastTransferStream stream) { return(PropList.Verify(stream)); }
/// <summary> /// Write a list of StateCU_BlaneyCriddle to a file. The filename is adjusted to /// the working directory if necessary using IOUtil.getPathUsingWorkingDir(). </summary> /// <param name="filename_prev"> The name of the previous version of the file (for /// processing headers). Specify as null if no previous file is available. </param> /// <param name="filename"> The name of the file to write. </param> /// <param name="data_Vector"> A list of StateCU_BlaneyCriddle to write. </param> /// <param name="new_comments"> Comments to add to the top of the file. Specify as null /// if no comments are available. </param> /// <param name="props"> Properties to control the output. Currently only the /// optional Precision property can be set, indicating how many digits after the /// decimal should be printed (default is 3). </param> /// <exception cref="IOException"> if there is an error writing the file. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static void writeStateCUFile(String filename_prev, String filename, java.util.List<StateCU_BlaneyCriddle> data_Vector, java.util.List<String> new_comments, RTi.Util.IO.PropList props) throws java.io.IOException public static void writeStateCUFile(string filename_prev, string filename, IList <StateCU_BlaneyCriddle> data_Vector, IList <string> new_comments, PropList props) { IList <string> comment_str = new List <string>(1); comment_str.Add("#"); IList <string> ignore_comment_str = new List <string>(1); ignore_comment_str.Add("#>"); PrintWriter @out = null; string full_filename_prev = IOUtil.getPathUsingWorkingDir(filename_prev); string full_filename = IOUtil.getPathUsingWorkingDir(filename); @out = IOUtil.processFileHeaders(full_filename_prev, full_filename, new_comments, comment_str, ignore_comment_str, 0); if (@out == null) { throw new IOException("Error writing to \"" + full_filename + "\""); } writeVector(data_Vector, @out, props); @out.flush(); @out.close(); @out = null; }
/// <summary> /// Deserialize fields from a FastTransferStream. /// </summary> /// <param name="stream">A FastTransferStream.</param> public override void Deserialize(FastTransferStream stream) { this.propList = new PropList(stream); this.messageChildren = new MessageChildren(stream); }
/// <summary> /// Sets up the GUI. /// </summary> public virtual void setupGUI() { string routine = "setupGUI"; addWindowListener(this); __addPrecip = new JButton(__BUTTON_ADD_PRECIPITATION_STATION); __addEvap = new JButton(__BUTTON_ADD_EVAPORATION_STATION); __deleteStation = new JButton(__BUTTON_DELETE_PRECIPITATION_STATION); __deleteStation.setEnabled(false); __helpJButton = new JButton(__BUTTON_HELP); __helpJButton.setEnabled(false); __closeJButton = new JButton(__BUTTON_CLOSE); JButton cancelJButton = new JButton(__BUTTON_CANCEL); JButton applyJButton = new JButton(__BUTTON_APPLY); GridBagLayout gb = new GridBagLayout(); JPanel bigPanel = new JPanel(); bigPanel.setLayout(gb); FlowLayout fl = new FlowLayout(FlowLayout.RIGHT); JPanel p1 = new JPanel(); p1.setLayout(fl); GridLayout gl = new GridLayout(2, 2, 1, 1); JPanel info_panel = new JPanel(); info_panel.setLayout(gl); JPanel main_panel = new JPanel(); main_panel.setLayout(new BorderLayout()); info_panel.add(new JLabel("Reservoir:")); info_panel.add(new JLabel(__currentRes.getID())); info_panel.add(new JLabel("Reservoir name:")); info_panel.add(new JLabel(__currentRes.getName())); if (__editable) { p1.add(__addPrecip); p1.add(__addEvap); p1.add(__deleteStation); } p1.add(applyJButton); p1.add(cancelJButton); // p1.add(__helpJButton); p1.add(__closeJButton); PropList p = new PropList("StateMod_Reservoir_Climate_JFrame.JWorksheet"); p.add("JWorksheet.ShowPopupMenu=true"); p.add("JWorksheet.AllowCopy=true"); p.add("JWorksheet.SelectionMode=SingleRowSelection"); int[] widthsP = null; JScrollWorksheet jswP = null; //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<String> stations = StateMod_Util.createIdentifierListFromTS(combineData((java.util.List<RTi.TS.MonthTS>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY).getData(), (java.util.List<RTi.TS.MonthTS>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY).getData()), true, null); IList <string> stations = StateMod_Util.createIdentifierListFromTS(combineData((IList <MonthTS>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY).getData(), (IList <MonthTS>)__dataset.getComponentForComponentType(StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY).getData()), true, null); try { IList <StateMod_ReservoirClimate> temp = getPrecipitationStations(__currentRes.getClimates()); IList <StateMod_ReservoirClimate> clones = new List <StateMod_ReservoirClimate>(); StateMod_ReservoirClimate r = null; int size = temp.Count; for (int i = 0; i < size; i++) { r = temp[i]; clones.Add((StateMod_ReservoirClimate)r.clone()); } __tableModelP = new StateMod_ReservoirClimate_TableModel(clones, __editable, true); StateMod_ReservoirClimate_CellRenderer crr = new StateMod_ReservoirClimate_CellRenderer(__tableModelP); jswP = new JScrollWorksheet(crr, __tableModelP, p); __worksheetP = jswP.getJWorksheet(); __worksheetP.setColumnJComboBoxValues(StateMod_ReservoirClimate_TableModel.COL_STATION, stations, true); widthsP = crr.getColumnWidths(); } catch (Exception e) { Message.printWarning(1, routine, "Error building worksheet.", this); Message.printWarning(2, routine, e); jswP = new JScrollWorksheet(0, 0, p); __worksheetP = jswP.getJWorksheet(); } __worksheetP.setPreferredScrollableViewportSize(null); __worksheetP.setHourglassJFrame(this); __worksheetP.addMouseListener(this); __worksheetP.addKeyListener(this); int[] widthsE = null; JScrollWorksheet jswE = null; try { IList <StateMod_ReservoirClimate> temp = getEvaporationStations(__currentRes.getClimates()); IList <StateMod_ReservoirClimate> clones = new List <StateMod_ReservoirClimate>(); StateMod_ReservoirClimate r = null; int size = temp.Count; for (int i = 0; i < size; i++) { r = temp[i]; clones.Add((StateMod_ReservoirClimate)r.clone()); } __tableModelE = new StateMod_ReservoirClimate_TableModel(clones, __editable, true); StateMod_ReservoirClimate_CellRenderer crr = new StateMod_ReservoirClimate_CellRenderer(__tableModelE); jswE = new JScrollWorksheet(crr, __tableModelE, p); __worksheetE = jswE.getJWorksheet(); __worksheetE.setColumnJComboBoxValues(StateMod_ReservoirClimate_TableModel.COL_STATION, stations, true); widthsE = crr.getColumnWidths(); } catch (Exception e) { Message.printWarning(1, routine, "Error building worksheet.", this); Message.printWarning(2, routine, e); jswE = new JScrollWorksheet(0, 0, p); __worksheetE = jswE.getJWorksheet(); } __worksheetE.setPreferredScrollableViewportSize(null); __worksheetE.setHourglassJFrame(this); __worksheetE.addMouseListener(this); __worksheetE.addKeyListener(this); JPanel worksheets = new JPanel(); worksheets.setLayout(gb); JPanel panelP = new JPanel(); panelP.setLayout(gb); panelP.setBorder(BorderFactory.createTitledBorder("Precipitation Stations")); JGUIUtil.addComponent(panelP, jswP, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); JPanel panelE = new JPanel(); panelE.setLayout(gb); panelE.setBorder(BorderFactory.createTitledBorder("Evaporation Stations")); JGUIUtil.addComponent(panelE, jswE, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); JGUIUtil.addComponent(worksheets, panelP, 0, 0, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); JGUIUtil.addComponent(worksheets, panelE, 0, 1, 1, 1, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); main_panel.add(worksheets, "Center"); main_panel.add(p1, "South"); // assemble parts JGUIUtil.addComponent(bigPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); JGUIUtil.addComponent(bigPanel, main_panel, 0, 1, 10, 10, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.SOUTH); __addEvap.addActionListener(this); __addPrecip.addActionListener(this); __deleteStation.addActionListener(this); __helpJButton.addActionListener(this); __closeJButton.addActionListener(this); applyJButton.addActionListener(this); cancelJButton.addActionListener(this); getContentPane().add(bigPanel); JPanel bottomJPanel = new JPanel(); bottomJPanel.setLayout(gb); __messageJTextField = new JTextField(); __messageJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); __statusJTextField = new JTextField(5); __statusJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST); getContentPane().add("South", bottomJPanel); pack(); setSize(650, 400); JGUIUtil.center(this); setVisible(true); if (widthsP != null) { __worksheetP.setColumnWidths(widthsP); } if (widthsE != null) { __worksheetE.setColumnWidths(widthsE); } }
/// <summary> /// Sets up the GUI. </summary> /// <param name="index"> the index in the worksheet to first select </param> private void setupGUI(int index) { string routine = "setupGUI"; addWindowListener(this); JPanel p1 = new JPanel(); // first 6 months' effeciency //JPanel p2 = new JPanel(); // last 6 months' effeciency JPanel p3 = new JPanel(); // div sta id -> switch for diversion JPanel p4 = new JPanel(); // user name -> data type switch JPanel left_panel = new JPanel(); // multilist and search area JPanel right_panel = new JPanel(); // everything else __cropIDJTextField = new JTextField(12); __nameJTextField = new JTextField(24); __plantMonthJTextField = new JTextField(6); __plantDayJTextField = new JTextField(6); __harvestMonthJTextField = new JTextField(6); __harvestDayJTextField = new JTextField(6); __daysToCoverJTextField = new JTextField(6); __seasonLengthJTextField = new JTextField(6); __earliestValueJTextField = new JTextField(6); __latestValueJTextField = new JTextField(6); __maxRootFeetJTextField = new JTextField(6); __maxAppDepthJTextField = new JTextField(6); __firstDaysBetweenJTextField = new JTextField(6); __secondDaysBetweenJTextField = new JTextField(6); IList <string> v = new List <string>(); v.Add(__0_MEAN_TEMP); v.Add(__1_28_DEG_FROST); v.Add(__2_32_DEG_FROST); v.Add(__999_NONE); __earliestFlagComboBox = new SimpleJComboBox(v); __latestFlagComboBox = new SimpleJComboBox(v); __searchID = new JTextField(10); __searchName = new JTextField(10); __searchName.setEditable(false); __findNextCrop = new JButton(__BUTTON_FIND_NEXT); __searchCriteriaGroup = new ButtonGroup(); __searchIDJRadioButton = new JRadioButton(__BUTTON_ID, true); __searchNameJRadioButton = new JRadioButton(__BUTTON_NAME, false); __searchCriteriaGroup.add(__searchIDJRadioButton); __searchCriteriaGroup.add(__searchNameJRadioButton); JButton applyJButton = new JButton(__BUTTON_APPLY); JButton cancelJButton = new JButton(__BUTTON_CANCEL); JButton helpJButton = new JButton(__BUTTON_HELP); helpJButton.setEnabled(false); JButton closeJButton = new JButton(__BUTTON_CLOSE); GridBagLayout gb = new GridBagLayout(); JPanel mainJPanel = new JPanel(); mainJPanel.setLayout(gb); p1.setLayout(new GridLayout(4, 6, 2, 0)); p3.setLayout(gb); p4.setLayout(gb); right_panel.setLayout(gb); left_panel.setLayout(gb); int y; PropList p = new PropList("StateCU_CropCharacteristics_JFrame.JWorksheet"); p.add("JWorksheet.CellFont=Courier"); p.add("JWorksheet.CellStyle=Plain"); p.add("JWorksheet.CellSize=11"); p.add("JWorksheet.HeaderFont=Arial"); p.add("JWorksheet.HeaderStyle=Plain"); p.add("JWorksheet.HeaderSize=11"); p.add("JWorksheet.HeaderBackground=LightGray"); p.add("JWorksheet.RowColumnPresent=false"); p.add("JWorksheet.ShowPopupMenu=true"); p.add("JWorksheet.SelectionMode=SingleRowSelection"); int[] widths = null; try { StateCU_CropCharacteristics_TableModel tmw = new StateCU_CropCharacteristics_TableModel(__cropsVector); StateCU_CropCharacteristics_CellRenderer crw = new StateCU_CropCharacteristics_CellRenderer(tmw); __worksheet = new JWorksheet(crw, tmw, p); __worksheet.removeColumn(3); __worksheet.removeColumn(4); widths = crw.getColumnWidths(); } catch (Exception e) { Message.printWarning(2, routine, e); __worksheet = new JWorksheet(0, 0, p); Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } __worksheet.setPreferredScrollableViewportSize(null); __worksheet.setHourglassJFrame(this); __worksheet.addMouseListener(this); __worksheet.addKeyListener(this); JGUIUtil.addComponent(left_panel, new JScrollPane(__worksheet), 0, 0, 6, 14, 1, 1, 0, 0, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.CENTER); y = 0; JGUIUtil.addComponent(p3, new JLabel("Crop ID:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __cropIDJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); __cropIDJTextField.setEditable(false); y++; JGUIUtil.addComponent(p3, new JLabel("Name:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __nameJTextField, 1, y, 3, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Planting Month and Day:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __plantMonthJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, __plantDayJTextField, 2, y, 2, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Harvest Month and Day:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __harvestMonthJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, __harvestDayJTextField, 2, y, 2, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Days to Full Cover:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __daysToCoverJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Length of Season (days):"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __seasonLengthJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Earliest Moisture Use:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __earliestFlagComboBox, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, new JLabel("Value (F Deg.):"), 2, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, __earliestValueJTextField, 3, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Latest Moisture Use:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __latestFlagComboBox, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, new JLabel("Value (F Deg.):"), 2, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, __latestValueJTextField, 3, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Maximum Root Zone (feet):"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __maxRootFeetJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Maximum Application Depth (inches):"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __maxAppDepthJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Days between 1st and 2nd cuttings:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __firstDaysBetweenJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Days between 2nd and 3rd cuttings:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __secondDaysBetweenJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); // two top panels of info JGUIUtil.addComponent(right_panel, p3, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); int[] widths2 = null; try { __blaneyModel = new StateCU_CropCharacteristics_TableModel(__cropsVector); StateCU_CropCharacteristics_CellRenderer crw = new StateCU_CropCharacteristics_CellRenderer(__blaneyModel); __coeffWorksheet = new JWorksheet(crw, __blaneyModel, p); __coeffWorksheet.removeColumn(1); __coeffWorksheet.removeColumn(2); widths2 = crw.getColumnWidths(); } catch (Exception e) { Message.printWarning(2, routine, e); __coeffWorksheet = new JWorksheet(0, 0, p); Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } __coeffWorksheet.setPreferredScrollableViewportSize(null); __coeffWorksheet.setHourglassJFrame(this); JScrollPane jsp = new JScrollPane(__coeffWorksheet); jsp.setBorder(BorderFactory.createTitledBorder(jsp.getBorder(), "Blaney-Criddle Crop Coefficients")); JGUIUtil.addComponent(right_panel, jsp, 0, y, 4, 4, 1, 1, 0, 0, 0, 0, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); // add search areas y = 14; JPanel searchPanel = new JPanel(); searchPanel.setLayout(gb); searchPanel.setBorder(BorderFactory.createTitledBorder("Search above list for: ")); JGUIUtil.addComponent(left_panel, searchPanel, 0, y, 4, 1, 0, 0, 10, 10, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); int y2 = 0; JGUIUtil.addComponent(searchPanel, __searchIDJRadioButton, 0, y2, 1, 1, 0, 0, 5, 10, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); __searchIDJRadioButton.addActionListener(this); JGUIUtil.addComponent(searchPanel, __searchID, 1, y2, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); __searchID.addActionListener(this); y2++; JGUIUtil.addComponent(searchPanel, __searchNameJRadioButton, 0, y2, 1, 1, 0, 0, 5, 10, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); __searchNameJRadioButton.addActionListener(this); JGUIUtil.addComponent(searchPanel, __searchName, 1, y2, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); __searchName.addActionListener(this); y2++; JGUIUtil.addComponent(searchPanel, __findNextCrop, 0, y2, 4, 1, 0, 0, 20, 10, 20, 10, GridBagConstraints.NONE, GridBagConstraints.WEST); __findNextCrop.addActionListener(this); // add buttons which lead to crop // direct flow demand, and return flow information FlowLayout fl = new FlowLayout(FlowLayout.CENTER); // add help and close buttons y++; JPanel p6 = new JPanel(); p6.setLayout(fl); if (__editable) { p6.add(applyJButton); p6.add(cancelJButton); } p6.add(helpJButton); p6.add(closeJButton); JGUIUtil.addComponent(right_panel, p6, GridBagConstraints.RELATIVE, y, 4, 1, 1, 0, 30, 0, 0, 0, GridBagConstraints.BOTH, GridBagConstraints.SOUTH); applyJButton.addActionListener(this); cancelJButton.addActionListener(this); helpJButton.addActionListener(this); closeJButton.addActionListener(this); JGUIUtil.addComponent(mainJPanel, left_panel, 0, 0, 4, 10, 1, 1, 10, 10, 10, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST); JGUIUtil.addComponent(mainJPanel, right_panel, GridBagConstraints.RELATIVE, 0, 4, 10, 0, 1, 10, 10, 10, 10, GridBagConstraints.BOTH, GridBagConstraints.EAST); getContentPane().add(mainJPanel); JPanel bottomJPanel = new JPanel(); bottomJPanel.setLayout(gb); __messageJTextField = new JTextField(); __messageJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); __statusJTextField = new JTextField(5); __statusJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST); getContentPane().add("South", bottomJPanel); initializeDisables(); // JGUIUtil.center(this); pack(); setSize(850, 620); selectTableIndex(index); setVisible(true); if (widths != null) { __worksheet.setColumnWidths(widths); } if (widths2 != null) { __coeffWorksheet.setColumnWidths(widths2); } }
/// <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> /// Sets up the GUI. /// </summary> public virtual void setupGUI() { string routine = "setupGUI"; addWindowListener(this); PropList p = new PropList("StateMod_Reservoir_Return_JFrame.JWorksheet"); p.add("JWorksheet.AllowCopy=true"); p.add("JWorksheet.CellFont=Courier"); p.add("JWorksheet.CellStyle=Plain"); p.add("JWorksheet.CellSize=11"); p.add("JWorksheet.HeaderFont=Arial"); p.add("JWorksheet.HeaderStyle=Plain"); p.add("JWorksheet.HeaderSize=11"); p.add("JWorksheet.HeaderBackground=LightGray"); p.add("JWorksheet.RowColumnPresent=false"); p.add("JWorksheet.ShowPopupMenu=true"); p.add("JWorksheet.SelectionMode=SingleRowSelection"); int[] widths = null; JScrollWorksheet jsw = null; try { /* TODO SAM 2011-01-02 Comment out - might allow something similar if editing is enabled * and choices of IDs are provided * List accounts = __currentRes.getAccounts(); * List v3 = new Vector(); * int size = accounts.size(); * StateMod_ReservoirAccount ra = null; * for (int i = 0; i < size; i++) { * ra = (StateMod_ReservoirAccount)accounts.get(i); * v3.add("" + ra.getID() + " - " + ra.getName()); * } * for (int i = 1; i < size; i++) { * v3.add("-" + (i + 1) + " - Fill first " + (i + 1) + " accounts"); + } + + List v = new Vector(); + List v2 = __currentRes.getRights(); + StateMod_ReservoirRight rr; + for (int i = 0; i < v2.size(); i++) { + rr = (StateMod_ReservoirRight) + ((StateMod_ReservoirRight)v2.get(i)) + .clone(); + v.add(rr); + } */ // Get the list of all returns and filter for this reservoir // TODO SAM 2011-01-02 The code needs to use a table model with lists if editing is enabled StateMod_Reservoir_Return_Data_TableModel tmr = new StateMod_Reservoir_Return_Data_TableModel(__currentResReturnList, __editable); StateMod_Reservoir_Return_Data_CellRenderer crr = new StateMod_Reservoir_Return_Data_CellRenderer(tmr); jsw = new JScrollWorksheet(crr, tmr, p); __worksheet = jsw.getJWorksheet(); /* * List onOff = StateMod_ReservoirRight.getIrsrswChoices(true); * __worksheet.setColumnJComboBoxValues( * StateMod_ReservoirRight_TableModel.COL_ON_OFF, onOff, * false); * __worksheet.setColumnJComboBoxValues( * StateMod_ReservoirRight_TableModel.COL_ACCOUNT_DIST, * v3, false); * List rightTypes = * StateMod_ReservoirRight.getItyrsrChoices(true); * __worksheet.setColumnJComboBoxValues( * StateMod_ReservoirRight_TableModel.COL_RIGHT_TYPE, * rightTypes, false); * List fillTypes=StateMod_ReservoirRight.getN2fillChoices(true); * __worksheet.setColumnJComboBoxValues( * StateMod_ReservoirRight_TableModel.COL_FILL_TYPE, * fillTypes, false); */ widths = crr.getColumnWidths(); } catch (Exception e) { Message.printWarning(2, routine, e); jsw = new JScrollWorksheet(0, 0, p); __worksheet = jsw.getJWorksheet(); } __worksheet.setPreferredScrollableViewportSize(null); __worksheet.setHourglassJFrame(this); __worksheet.addMouseListener(this); __worksheet.addKeyListener(this); __addReturn_JButton = new JButton(__BUTTON_ADD_RETURN); __deleteReturn_JButton = new JButton(__BUTTON_DEL_RETURN); __deleteReturn_JButton.setEnabled(false); __help_JButton = new JButton(__BUTTON_HELP); __help_JButton.setEnabled(false); __close_JButton = new JButton(__BUTTON_CLOSE); JButton cancelJButton = new JButton(__BUTTON_CANCEL); JButton applyJButton = new JButton(__BUTTON_APPLY); GridBagLayout gb = new GridBagLayout(); JPanel bigPanel = new JPanel(); bigPanel.setLayout(gb); FlowLayout fl = new FlowLayout(FlowLayout.RIGHT); JPanel p1 = new JPanel(); p1.setLayout(fl); GridLayout gl = new GridLayout(2, 2, 1, 1); JPanel info_panel = new JPanel(); info_panel.setLayout(gl); JPanel main_panel = new JPanel(); main_panel.setLayout(new BorderLayout()); info_panel.add(new JLabel("Reservoir:")); info_panel.add(new JLabel(__currentRes.getID())); info_panel.add(new JLabel("Reservoir name:")); info_panel.add(new JLabel(__currentRes.getName())); if (__editable) { p1.add(__addReturn_JButton); p1.add(__deleteReturn_JButton); } p1.add(applyJButton); p1.add(cancelJButton); // p1.add(__helpJButton); p1.add(__close_JButton); if (!__editable) { applyJButton.setEnabled(false); applyJButton.setToolTipText("Editing reservoir return data is not implemented."); __close_JButton.setEnabled(false); __close_JButton.setToolTipText("Editing reservoir return data is not implemented."); } main_panel.add(jsw, "Center"); main_panel.add(p1, "South"); JGUIUtil.addComponent(bigPanel, info_panel, 0, 0, 1, 1, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); JGUIUtil.addComponent(bigPanel, main_panel, 0, 1, 10, 10, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.SOUTH); __addReturn_JButton.addActionListener(this); __deleteReturn_JButton.addActionListener(this); __help_JButton.addActionListener(this); __close_JButton.addActionListener(this); applyJButton.addActionListener(this); cancelJButton.addActionListener(this); getContentPane().add(bigPanel); JPanel bottomJPanel = new JPanel(); bottomJPanel.setLayout(gb); __messageJTextField = new JTextField(); __messageJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); __statusJTextField = new JTextField(5); __statusJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST); getContentPane().add("South", bottomJPanel); pack(); setSize(760, 400); JGUIUtil.center(this); setVisible(true); if (widths != null) { __worksheet.setColumnWidths(widths); } }
/// <summary> /// Performs specific data checks for a component. The /// intelligence and checks are stored in the component itself. </summary> /// <param name="data"> List of data objects to check. </param> /// <returns> List of data that failed the data checks. </returns> private System.Collections.IList doSpecificDataChecks(System.Collections.IList data, PropList props) { System.Collections.IList checks = new List <object>(); if (data == null) { return(checks); } // Check each component object by calling the // checkComponentData() method. Each component // needs to implement this method and extend from // the StateMod_Component interface. StateMod_ComponentValidator comp = null; for (int i = 0; i < data.Count; i++) { comp = (StateMod_ComponentValidator)data[i]; StateMod_ComponentValidation validation = comp.validateComponent(__dataset); if (validation.size() > 0) { checks.AddRange(validation.getAll()); } } return(checks); }
/// <summary> /// Write a list of StateCU_BlaneyCriddle to an opened file. </summary> /// <param name="data_Vector"> A Vector of StateCU_BlaneyCriddle to write. </param> /// <param name="out"> output PrintWriter. </param> /// <param name="props"> Properties to control the output. Currently only the /// optional Precision property can be set, indicating how many digits after the /// decimal should be printed (default is 3). </param> /// <exception cref="IOException"> if an error occurs. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private static void writeVector(java.util.List<StateCU_BlaneyCriddle> data_Vector, java.io.PrintWriter out, RTi.Util.IO.PropList props) throws java.io.IOException private static void writeVector(IList <StateCU_BlaneyCriddle> data_Vector, PrintWriter @out, PropList props) { int i, j; string cmnt = "#>"; // Missing data are handled by formatting all as strings (blank if necessary). bool version10 = false; // Indicate if old Version 10 format is written if (props == null) { props = new PropList("StateCU_BlaneyCriddle"); } string Precision = props.getValue("Precision"); string Version = props.getValue("Version"); if (!string.ReferenceEquals(Version, null) && Version.Equals("10")) { // Version 10 is an older version. version10 = true; } int Precision_int = 3; if ((!string.ReferenceEquals(Precision, null)) && StringUtil.isInteger(Precision)) { Precision_int = StringUtil.atoi(Precision); } @out.println(cmnt); @out.println(cmnt + " StateCU Blaney-Criddle Crop Coefficient (KBC) File"); @out.println(cmnt); @out.println(cmnt + " Record 1 format (a80)"); @out.println(cmnt); @out.println(cmnt + " Title remark: Title"); @out.println(cmnt); @out.println(cmnt + " Record 2 format (free format)"); @out.println(cmnt); @out.println(cmnt + " NumCurves nc: Number of crop coefficient curves"); @out.println(cmnt); @out.println(cmnt + " Record 3 format (free format)"); @out.println(cmnt); @out.println(cmnt + " ID id: Crop number (not used by StateCU)"); @out.println(cmnt + " CropName cropn: Crop name (e.g., ALFALFA)"); @out.println(cmnt + " CurveType flag: Growth curve type"); @out.println(cmnt + " Day = perennial; specify 25 values"); @out.println(cmnt + " for start, middle, end of month"); @out.println(cmnt + " Percent = annual; specify 21 values"); @out.println(cmnt + " for 0, 5, ..., 100% of season"); @out.println(cmnt); if (!version10) { // Include newer format information... @out.println(cmnt + " BCMethod ktsw: Blaney-Criddle Method"); @out.println(cmnt + " 0 = SCS Modified Blaney-Criddle"); @out.println(cmnt + " 1 = Original Blaney-Criddle"); @out.println(cmnt + " 2 = Modifed Blaney-Criddle w/ Elev. Adj."); @out.println(cmnt + " 3 = Original Blaney-Criddle w/ Elev. Adj."); @out.println(cmnt + " 4 = Pochop"); @out.println(cmnt); } @out.println(cmnt + " Record 4 format (free format)"); @out.println(cmnt); @out.println(cmnt + "Position nckca: Percent (0 to 100) of growing season for annual crop"); @out.println(cmnt + " nckcp: Day of year (1 to 366) for perennial crop"); @out.println(cmnt + "Coeff ckca: Crop coefficient for annual crop"); @out.println(cmnt + " OR ckcp: Crop coefficient for perennial crop"); @out.println(cmnt); @out.println(cmnt + "Title..."); @out.println(cmnt + "NumCurves"); @out.println(cmnt + "ID CropName CurveType"); @out.println(cmnt + "Position Coeff"); @out.println(cmnt + "----------------------------"); @out.println(cmnt + "EndHeader"); @out.println("Crop Coefficient Curves for Blaney-Criddle"); int num = 0; if (data_Vector != null) { num = data_Vector.Count; } @out.println(num); StateCU_BlaneyCriddle kbc = null; int[] nckca = null; int[] nckcp = null; double[] ckca = null; double[] ckcp = null; int size = 0; string value_format = "%9." + Precision_int + "f"; for (i = 0; i < num; i++) { kbc = (StateCU_BlaneyCriddle)data_Vector[i]; if (kbc == null) { continue; } // Just get all the data. Null arrays are used as a check // below to know what data to output... nckca = kbc.getNckca(); nckcp = kbc.getNckcp(); ckca = kbc.getCkca(); ckcp = kbc.getCkcp(); // Do not truncate the name to 20 characters if version 10 because // doing so may result in arbitrary cut of the current crop names and // result in different output from old anyhow. string name = kbc.getName(); // Since free format, the ID must always have something. If // we don't know, put -999... string id = "" + (i + 1); // Default to sequential number if (version10) { // Previously used -999 id = "-999"; } if (!StateCU_Util.isMissing(kbc.getID())) { // Changes elsewhere impact this so also use -999 unless it is a number if (StringUtil.isInteger(kbc.getID())) { id = "" + kbc.getID(); } else { id = "-999"; } // Can't use the crop name because StateCU expects a number (?) //id = kbc.getID(); } // Output based on the version because file comparisons may be done when verifying files. if (version10) { // No ktsw... @out.println(id + " " + name + " " + kbc.getFlag()); } else { // With ktsw, but OK if blank. @out.println(id + " " + name + " " + kbc.getFlag() + " " + kbc.getKtsw()); } if (nckca != null) { size = nckca.Length; } else { size = nckcp.Length; } for (j = 0; j < size; j++) { if (nckca != null) { // Print annual curve (Percent)... @out.println(StringUtil.formatString(nckca[j], "%-3d") + StringUtil.formatString(ckca[j], value_format)); } else { // Print perennial curve (Day)... @out.println(StringUtil.formatString((int)nckcp[j], "%-3d") + StringUtil.formatString(ckcp[j], value_format)); } } } }
private void UpdateSwatches() { if (this._swatches == null) this._swatches = new PropList(); // Dictionary<ColorBase, Swatch>(); int newNumColors = 0; if (this._palette != null) newNumColors = this._palette.Count; int diffNum = newNumColors - this._swatches.Count; this.SuspendLayout(); if (diffNum < 0) //less color in palette than we have swatches - remove! { for (int i = 0; i < -diffNum; i++) this.RemoveAtNoUpdate(this._swatches.Count - 1); Console.WriteLine("Less"); } else if (diffNum > 0) { for (int i = 0; i < diffNum; i++) this.InsertAtNoUpdate(this._swatches.Count, "", null); Console.WriteLine("More"); } else Console.WriteLine("No changre"); if (this._palette != null) { PropList newSwatches = new PropList(); Point currentLoc = new Point(); int i = 0; foreach (KeyValuePair<string, ColorBase> kv in this._palette) { Swatch s = (Swatch)this._swatches.GetByIndex(i); s.SuspendLayout(); s.Color = kv.Value; newSwatches.Add(s.Color, s); s.Size = this._swatchSize.ToSize(); s.Location = currentLoc; s.ResumeLayout(); currentLoc.X += this._swatchSize.X; if (currentLoc.X + this._swatchSize.X >= this.Right - 5) //TODO: why need -5? { currentLoc.Y += this._swatchSize.Y; currentLoc.X = 0; } i++; } this._swatches = newSwatches; this.Height = currentLoc.Y + this._swatchSize.Y; } this.ResumeLayout(); this.Invalidate(); }