// TODO SAM 2009-05-08 Evaluate whether to allow passing in max coefficient value for check /// <summary> /// Performs specific data checks and returns a list of data that failed the data checks. </summary> /// <param name="count"> Index of the data vector currently being checked. </param> /// <param name="dataset"> StateCU dataset currently in memory. </param> /// <param name="props"> Extra properties to perform checks with. </param> /// <returns> List of invalid data. </returns> public virtual StateCU_ComponentValidation validateComponent(StateCU_DataSet dataset) { StateCU_ComponentValidation validation = new StateCU_ComponentValidation(); string id = getName(); // Name is used for ID because ID used to be numeric double[][] kcday = getKcday(); double[][] kcb = getKcb(); // Percent of growth stage for (int igs = 0; igs < kcday.Length; igs++) { for (int ipos = 0; ipos < kcday[igs].Length; ipos++) { if ((kcday[igs][ipos] < 0.0) || (kcday[igs][ipos] > 100.0)) { validation.add(new StateCU_ComponentValidationProblem(this, "Crop \"" + id + "\" percent of growth stage (" + kcday[igs][ipos] + ") is invalid.", "Specify as 0 to 100.")); } if ((kcb[igs][ipos] < 0) || (kcb[igs][ipos] > 3.0)) { validation.add(new StateCU_ComponentValidationProblem(this, "Crop \"" + id + "\" coefficient (" + kcb[igs][ipos] + ") is invalid.", "Specify as 0 to 3.0 (upper limit may vary by location).")); } } } return(validation); }
/// <summary> /// Constructor. </summary> /// <param name="crop"> StateCU_CropCharacteristics object to display </param> /// <param name="editable"> whether the display should be editable or not. </param> public StateCU_CropCharacteristics_JFrame(StateCU_DataSet dataset, StateCU_CropCharacteristics crop, bool editable) : base(dataset.getBaseName() + " - StateCU GUI - Crop Characteristics") { __currentCropIndex = -1; __editable = editable; __dataset = dataset; __cropComponent = __dataset.getComponentForComponentType(StateCU_DataSet.COMP_CROP_CHARACTERISTICS); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateCU_CropCharacteristics> cropsVector0 = (java.util.List<StateCU_CropCharacteristics>)__cropComponent.getData(); IList <StateCU_CropCharacteristics> cropsVector0 = (IList <StateCU_CropCharacteristics>)__cropComponent.getData(); __cropsVector = cropsVector0; __blaneyComponent = __dataset.getComponentForComponentType(StateCU_DataSet.COMP_BLANEY_CRIDDLE); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateCU_BlaneyCriddle> blaneyVector0 = (java.util.List<StateCU_BlaneyCriddle>)__blaneyComponent.getData(); IList <StateCU_BlaneyCriddle> blaneyVector0 = (IList <StateCU_BlaneyCriddle>)__blaneyComponent.getData(); __blaneyVector = blaneyVector0; string id = crop.getID(); int index = StateCU_Util.IndexOf(__cropsVector, id); setupGUI(index); }
/// <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); }
// TODO SAM 2009-05-08 Evaluate whether to allow passing in max coefficient value for check /// <summary> /// Performs specific data checks and returns a list of data that failed the data checks. </summary> /// <param name="count"> Index of the data vector currently being checked. </param> /// <param name="dataset"> StateCU dataset currently in memory. </param> /// <param name="props"> Extra properties to perform checks with. </param> /// <returns> List of invalid data. </returns> public virtual StateCU_ComponentValidation validateComponent(StateCU_DataSet dataset) { StateCU_ComponentValidation validation = new StateCU_ComponentValidation(); string id = getName(); // Name is used for ID because ID used to be numeric int[] nckca = getNckca(); int[] nckcp = getNckcp(); if (((nckca == null) || (nckca.Length == 0)) && ((nckcp == null) || (nckcp.Length == 0))) { validation.add(new StateCU_ComponentValidationProblem(this, "Crop \"" + id + "\" data are neither specified as day of year or percent of season.", "Specify coefficients for day of year OR percent of season.")); } else if (((nckca != null) && (nckca.Length > 0)) && ((nckcp != null) && (nckcp.Length > 0))) { validation.add(new StateCU_ComponentValidationProblem(this, "Crop \"" + id + "\" data are specified as day of year and percent of season.", "Specify coefficients for day of year OR percent of season.")); } else if (isAnnualCrop()) { // Annual - percent of season double[] ckca = getCkca(); for (int i = 0; i < nckca.Length; i++) { if ((nckca[i] < 0) || (nckca[i] > 100)) { validation.add(new StateCU_ComponentValidationProblem(this, "Crop \"" + id + "\" percent of season (" + nckca[i] + ") is invalid.", "Specify as 0 to 100.")); } if ((ckca[i] < 0) || (ckca[i] > 3.0)) { validation.add(new StateCU_ComponentValidationProblem(this, "Crop \"" + id + "\" coefficient (" + ckca[i] + ") is invalid.", "Specify as 0 to 3.0 (upper limit may vary by location).")); } } } else { // Perennial - day of year double[] ckcp = getCkcp(); for (int i = 0; i < nckcp.Length; i++) { if ((nckcp[i] < 1) || (nckcp[i] > 366)) { validation.add(new StateCU_ComponentValidationProblem(this, "Crop \"" + id + "\" day of year (" + nckcp[i] + ") is invalid.", "Specify as 1 to 366.")); } if ((ckcp[i] < 0) || (ckcp[i] > 3.0)) { validation.add(new StateCU_ComponentValidationProblem(this, "Crop \"" + id + "\" coefficient (" + ckcp[i] + ") is invalid.", "Specify as 0 to 3.0 (upper limit may vary by location).")); } } } // Check method int ktsw = getKtsw(); if ((ktsw < 0) || (ktsw > 4)) { validation.add(new StateCU_ComponentValidationProblem(this, "Crop \"" + id + "\" Blaney-Criddle method (" + ktsw + ") is invalid.", "Specify as 0 to 4 (refer to StateCU documentation).")); } return(validation); }
/// <summary> /// Constructor. This builds the model for displaying the given component data. </summary> /// <param name="dataset"> StateCU_DataSet that is being displayed. If not a group /// component, the group component will be determined. </param> /// <param name="comp"> the DataSetComponent to be displayed. </param> /// <exception cref="Exception"> an invalid component is passed in. </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public StateCU_DataSetComponent_TableModel(StateCU_DataSet dataset, RTi.Util.IO.DataSetComponent comp) throws Exception public StateCU_DataSetComponent_TableModel(StateCU_DataSet dataset, DataSetComponent comp) { System.Collections.IList data = null; string routine = "StateCU_DataSetComponent_TableModel"; // Make sure that the list is for a group component... if ((comp != null) && !comp.isGroup()) { __component_group = comp.getParentComponent(); Message.printStatus(1, routine, "Component is not a group. Parent is: " + __component_group); } else { __component_group = comp; } if (__component_group == null) { _rows = 0; _data = null; return; } // Figure out the data component that is actually used to get the list // of data objects. For example, if working on climate stations, there // is no list with the group so we need to use the climate stations component list... int comptype = dataset.lookupPrimaryComponentTypeForComponentGroup(__component_group.getComponentType()); if (comptype >= 0) { __component = dataset.getComponentForComponentType(comptype); } else { comp = null; Message.printWarning(2, routine, "Unable to find primary component for group: " + __component_group.getComponentName()); } if (__component == null) { _rows = 0; } else { data = ((System.Collections.IList)__component.getData()); if (data == null) { _rows = 0; } else { _rows = data.Count; } } _data = data; }
/// <summary> /// Construct a StateCU_DataSet_JFrame. </summary> /// <param name="parent"> JFrame from which this instance is constructed. </param> /// <param name="dataset"> StateCU_DataSet that is being displayed/managed. </param> /// <param name="display_data_objects"> If true, data objects are listed in the tree. If /// false, only the top-level data set components are listed. </param> /// <param name="isStateCU"> indicates whether the display is being used for a full StateCU data set (true) or /// StateMod GUI (false). </param> public StateCU_DataSet_JTree(JFrame parent, StateCU_DataSet dataset, bool display_data_objects, bool isStateCU) { __dataset = dataset; __display_data_objects = display_data_objects; __isStateCU = isStateCU; __folderIcon = getClosedIcon(); showRootHandles(true); addMouseListener(this); setLeafIcon(null); setTreeTextEditable(false); __popup_JPopupMenu = new JPopupMenu(); }
/// <summary> /// Performs specific data checks and returns a list of data that failed the data checks. </summary> /// <param name="dataset"> StateCU dataset currently in memory. </param> /// <returns> Validation results. </returns> public virtual StateCU_ComponentValidation validateComponent(StateCU_DataSet dataset) { StateCU_ComponentValidation validation = new StateCU_ComponentValidation(); string id = getID(); double latitude = getLatitude(); if (!((latitude >= -90.0) && (latitude <= 90.0))) { validation.add(new StateCU_ComponentValidationProblem(this, "Climate station \"" + id + "\" latitude (" + latitude + ") is invalid.", "Specify a latitude -90 to 90.")); } double elevation = getElevation(); if (!((elevation >= 0.0) && (elevation <= 15000.00))) { validation.add(new StateCU_ComponentValidationProblem(this, "Climate station \"" + id + "\" elevation (" + elevation + ") is invalid.", "Specify an elevation 0 to 15000 FT (maximum varies by location).")); } string name = getName(); if ((string.ReferenceEquals(name, null)) || name.Trim().Length == 0) { validation.add(new StateCU_ComponentValidationProblem(this, "Climate station \"" + id + "\" name is blank - may cause confusion.", "Specify the station name or use the ID for the name.")); } string region1 = getRegion1(); if ((string.ReferenceEquals(region1, null)) || region1.Trim().Length == 0) { validation.add(new StateCU_ComponentValidationProblem(this, "Climate station \"" + id + "\" region1 is blank - may cause region lookups to fail for other data.", "Specify as county or other region indicator.")); } double zh = getZh(); if (!(zh >= 0.0)) { validation.add(new StateCU_ComponentValidationProblem(this, "Climate station \"" + id + "\" zh (" + zh + ") is invalid.", "Specify a zh >= 0.")); } double zm = getZm(); if (!(zm >= 0.0)) { validation.add(new StateCU_ComponentValidationProblem(this, "Climate station \"" + id + "\" zm (" + zm + ") is invalid.", "Specify a zm >= 0.")); } return(validation); }
/// <summary> /// Set the data set to be displayed. </summary> /// <param name="dataset"> StateCU_DataSet that is being displayed/managed. </param> public virtual void setDataSet(StateCU_DataSet dataset) { __dataset = dataset; __popup_JPopupMenu = new JPopupMenu(); }
/// <summary> /// Performs specific data checks and returns a list of data that failed the data checks. </summary> /// <param name="dataset"> StateCU dataset currently in memory. </param> /// <returns> validation results. </returns> public virtual StateCU_ComponentValidation validateComponent(StateCU_DataSet dataset) { // TODO KAT 2007-04-12 Add specific checks here ... return(null); }
/// <summary> /// Construct a StateCU_DataSet_JFrame and optionally set visible. </summary> /// <param name="parent"> JFrame from which this instance is constructed. </param> /// <param name="dataset"> StateCU_DataSet that is being displayed/managed. </param> /// <param name="title"> Title to be displayed. </param> /// <param name="is_visible"> Indicates whether the display should be made visible at /// creation. </param> public StateCU_DataSet_JFrame(JFrame parent, StateCU_DataSet dataset, string title, bool is_visible) { __dataset = dataset; initialize(title, is_visible); }
/// <summary> /// Constructor that initializes the component type and CheckFile. /// The check file can contain data checks from several components. /// This class only checks data for one component. Each time this /// class is called to check a component the same check file should /// be sent if the data is to be appended to that check file. The /// CheckFile object is passed around the data checks and data /// that fails checks are added to it. </summary> /// <param name="comp"> StateCU component type. </param> /// <param name="file"> CheckFile to append data checks to. </param> public StateCU_ComponentDataCheck(int type, CheckFile file, StateCU_DataSet set) : base(type, file) { __check_file = file; __type = type; __dataset = set; }