Ejemplo n.º 1
0
        /// <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);
	}
        /// <summary>
        /// Helper method to return the data list for the component
        /// type.  This is maintained by the StateCU dataset. </summary>
        /// <param name="type"> Component type to get data for. </param>
        /// <returns> list of data for a specific component. </returns>
        private IList <object> getComponentData(int type)
        {
            DataSetComponent comp = __dataset.getComponentForComponentType(type);
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<Object> data_vector = (java.util.List<Object>)comp.getData();
            IList <object> data_vector = (IList <object>)comp.getData();

            return(data_vector);
        }
        /// <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>
        /// Display all the information in the data set.  This can be called, for example,
        /// after a data set has been read.
        /// </summary>
        public virtual void displayDataSet()
        {
            string routine = "StateCU_DataSet_JTree.displayDataSet";

            System.Collections.IList v = __dataset.getComponentGroups();
            int size = 0;

            if (v != null)
            {
                size = v.Count;
            }
            SimpleJTree_Node node = null, node2 = null;
            DataSetComponent comp    = null;
            string           name    = "";
            bool             isGroup = false;
            bool             hasData = false;
            int type;

            // Add each component group...
            setFastAdd(true);
            for (int i = 0; i < size; i++)
            {
                isGroup = false;
                hasData = false;
                comp    = (DataSetComponent)v[i];
                if ((comp == null) || !comp.isVisible())
                {
                    continue;
                }

                if (comp.isGroup())
                {
                    isGroup = true;
                }

                type = comp.getComponentType();
                // Show the control data at the high level.
                if (type == StateCU_DataSet.COMP_GIS_GROUP)
                {
                    // Don't want to list the GIS data...
                    continue;
                }
                if ((type == StateCU_DataSet.COMP_GIS_GROUP) && __display_data_objects)
                {
                    // Currently don't want to list GIS data in
                    // results...
                    continue;
                }
                node = new SimpleJTree_Node(comp.getComponentName());
                node.setData(comp);
                try
                {
                    addNode(node);
                }
                catch (Exception e)
                {
                    Message.printWarning(2, routine, "Error adding component group " + comp.getComponentName());
                    Message.printWarning(2, routine, e);
                    continue;
                }
                if (__display_data_objects)
                {
                    // Display the primary object in each group
                    int primary_type = __dataset.lookupPrimaryComponentTypeForComponentGroup(comp.getComponentType());
                    if (primary_type >= 0)
                    {
                        comp = __dataset.getComponentForComponentType(primary_type);
                    }
                    if ((comp == null) || !comp.isVisible())
                    {
                        continue;
                    }
                    object data_Object = comp.getData();
                    if (data_Object == null)
                    {
                        continue;
                    }
                    System.Collections.IList data = null;
                    if (data_Object is System.Collections.IList)
                    {
                        data = (System.Collections.IList)comp.getData();
                    }
                    else
                    {             // Continue (REVISIT - what components would
                        // this happen for?)...
                        Message.printWarning(2, routine, "Unexpected non-Vector for " + comp.getComponentName());
                    }
                    StateCU_Data  cudata;
                    StateMod_Data smdata;
                    int           dsize = 0;
                    if (data != null)
                    {
                        dsize = data.Count;
                    }
                    for (int idata = 0; idata < dsize; idata++)
                    {
                        if (comp.getComponentType() == StateCU_DataSet.COMP_DELAY_TABLES_MONTHLY)
                        {
                            // StateMod data object so have to
                            // handle separately because StateCU
                            // uses the StateMod group...
                            smdata = (StateMod_Data)data[idata];
                            name   = smdata.getName();
                            node2  = new SimpleJTree_Node(name);
                            node2.setData(smdata);
                        }
                        else
                        {                 // StateCU data object...
                            cudata = (StateCU_Data)data[idata];
                            name   = cudata.getName();
                            node2  = new SimpleJTree_Node(name);
                            node2.setData(cudata);
                        }
                        try
                        {
                            addNode(node2, node);
                        }
                        catch (Exception e)
                        {
                            Message.printWarning(2, routine, "Error adding data " + name);
                            Message.printWarning(2, routine, e);
                            continue;
                        }
                    }
                    if (dsize > 0)
                    {
                        hasData = true;
                    }
                    // Collapse the node because the lists are
                    // usually pretty long...
                    try
                    {
                        collapseNode(node);
                    }
                    catch (Exception)
                    {
                        // Ignore.
                    }
                }
                else
                {         // Add the components in the group...
                    Message.printStatus(1, "", "Not displaying data objects");
                    System.Collections.IList v2 = (System.Collections.IList)comp.getData();
                    int size2 = 0;
                    if (v2 != null)
                    {
                        size2 = v2.Count;
                    }
                    Message.printStatus(1, "", "group has " + size2 + " subcomponents");
                    for (int j = 0; j < size2; j++)
                    {
                        comp = (DataSetComponent)v2[j];
                        if (!comp.isVisible())
                        {
                            continue;
                        }
                        node2 = new SimpleJTree_Node(comp.getComponentName());
                        node2.setData(comp);
                        try
                        {
                            addNode(node2, node);
                        }
                        catch (Exception e)
                        {
                            Message.printWarning(2, routine, "Error adding component " + comp.getComponentName());
                            Message.printWarning(2, routine, e);
                            continue;
                        }
                    }
                    if (size2 > 0)
                    {
                        hasData = true;
                    }
                }

                if (isGroup && !hasData)
                {
                    node.setIcon(__folderIcon);
                }
            }
            setFastAdd(false);
        }
	/// <summary>
	/// Display the time series. </summary>
	/// <param name="action"> Event action that initiated the display. </param>
	private void displayTSViewJFrame(string action)
	{
		string routine = "displayTSViewJFrame";

		// Initialize the display...

		PropList display_props = new PropList("ClimateStation");
		if (action.Equals(__BUTTON_GRAPH))
		{
			display_props.set("InitialView", "Graph");
		}
		else if (action.Equals(__BUTTON_TABLE))
		{
			display_props.set("InitialView", "Table");
		}
		else if (action.Equals(__BUTTON_SUMMARY))
		{
			display_props.set("InitialView", "Summary");
		}
		// display_props.set("HelpKey", "TSTool.ExportMenu");
		display_props.set("TotalWidth", "600");
		display_props.set("TotalHeight", "400");
		display_props.set("Title", "Demand");
		display_props.set("DisplayFont", "Courier");
		display_props.set("DisplaySize", "11");
		display_props.set("PrintFont", "Courier");
		display_props.set("PrintSize", "7");
		display_props.set("PageLength", "100");

		PropList props = new PropList("ClimateStation");

		IList<TS> tslist = new List<TS>();

		// Get the time series to display and set plot properties if graphing.
		// For now need to find in the lists because references to time series
		// are not implemented...

		IList<TS> v = null;
		TS ts = null;
		int sub = 0;
		int pos;
		StateCU_ClimateStation station = __stationsVector[__currentStationIndex];
		if (__precipitationCheckBox.isSelected())
		{
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<RTi.TS.TS> v0 = (java.util.List<RTi.TS.TS>)__dataset.getComponentForComponentType(StateCU_DataSet.COMP_PRECIPITATION_TS_MONTHLY).getData();
			IList<TS> v0 = (IList<TS>)__dataset.getComponentForComponentType(StateCU_DataSet.COMP_PRECIPITATION_TS_MONTHLY).getData();
			v = v0;
			pos = TSUtil.IndexOf(v, station.getID(), "Location", 1);
			if (pos >= 0)
			{
				ts = (TS)v[pos];
			}
			if (ts != null)
			{
				// Add a graph for precipitation...
				++sub;
				ts.setDataType("Precipitation");
				props.set("SubProduct " + sub + ".GraphType=Bar");
				props.set("SubProduct " + sub + ".SubTitleString=Monthly Precipitation");
				props.set("Data " + sub + ".1.TSID=" + ts.getIdentifierString());
				tslist.Add(ts);
			}
		}
		if (__temperatureCheckBox.isSelected())
		{
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<RTi.TS.TS> v0 = (java.util.List<RTi.TS.TS>)__dataset.getComponentForComponentType(StateCU_DataSet.COMP_TEMPERATURE_TS_MONTHLY_AVERAGE).getData();
			IList<TS> v0 = (IList<TS>)__dataset.getComponentForComponentType(StateCU_DataSet.COMP_TEMPERATURE_TS_MONTHLY_AVERAGE).getData();
			v = v0;
			pos = TSUtil.IndexOf(v, station.getID(), "Location", 1);
			if (pos >= 0)
			{
				ts = (TS)v[pos];
			}
			if (ts != null)
			{
				// Add a graph for temperature...
				++sub;
				ts.setDataType("Temperature");
				props.set("SubProduct " + sub + ".GraphType=Line");
				props.set("SubProduct " + sub + ".SubTitleString=Monthly Average Temperature");
				props.set("Data " + sub + ".1.TSID=" + ts.getIdentifierString());
				tslist.Add(ts);
			}
		}
		if (__frostDatesCheckBox.isSelected())
		{
			// REVISIT - no way to graph currently
		}

		// Display the time series...

		try
		{
			TSProduct tsproduct = new TSProduct(props, display_props);
			tsproduct.setTSList(tslist);
			new TSViewJFrame(tsproduct);
		}
		catch (Exception e)
		{
			Message.printWarning(1,routine,"Error displaying time series.");
			Message.printWarning(2, routine, e);
		}
	}