Example #1
0
 /// <summary>
 /// Add big picture nodes.
 /// </summary>
 public virtual void addNode(StateMod_DeltaPlotNode node)
 {
     if (node != null)
     {
         _nodes.Add(node);
     }
 }
Example #2
0
        /// <summary>
        /// Read delplt output information and store.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public int readStateModDeltaOutputFile(String filename) throws java.io.IOException
        public virtual int readStateModDeltaOutputFile(string filename)
        {
            string         rtn    = "StateMod_DeltaPlot.readStateModDeltaOutputFile";
            string         iline  = null;
            StreamReader   @in    = null;
            IList <string> list1  = null;
            string         a      = null;
            int?           b      = null;
            string         format = "s12s1s24s1d10s1d10s1d10s1d10s1d10s1d10s1d10" +
                                    "s1d10s1d10s1d10s1d10s1d10s1d10s1d10s1d10s1d10s1d10" +
                                    "s1d10s1d10s1d10";
            IList <object> v = null;

            Message.printStatus(1, rtn, "Reading delplt output file: " + filename);
            try
            {
                @in = new StreamReader(filename);

                iline = @in.ReadLine().Trim();
                list1 = StringUtil.breakStringList(iline, " ", StringUtil.DELIM_SKIP_BLANKS);
                if (list1.Count < 2)
                {
                    Message.printWarning(1, rtn, "Unknown format for first line in delplt output file: " + iline);
                    @in.Close();
                    return(1);
                }

                // first line: nz, nbigtitles
                if (Message.isDebugOn)
                {
                    Message.printDebug(50, rtn, iline);
                }

                a = list1[0];
                //Message.printDebug ( 10, rtn, a );
                b = Convert.ToInt32(a);
                int nz = b.Value;
                //Message.printDebug ( 10, rtn, "" + nz );
                int nbigtitles = (Convert.ToInt32((string)list1[1]));

                // second line: type
                iline = @in.ReadLine();
                setType(iline.Trim());

                // line 3 through nbigtitles:
                for (int i = 0; i < nbigtitles; i++)
                {
                    iline = @in.ReadLine();
                    addColumnTitle(iline.Trim());
                }

                // CAT !!!  Don't forget to come back to this ...
                // check here for props.BP_GET_COLUMN_TITLES_ONLY
                // CAT !!!

                // now read data
                while (!string.ReferenceEquals((iline = @in.ReadLine()), null))
                {
                    try
                    {
                        StateMod_DeltaPlotNode node = new StateMod_DeltaPlotNode();
                        v = StringUtil.fixedRead(iline, format);

                        /* some names may contain commas; use fixed format read
                         * Vector list2 = StringUtil.breakStringList (
                         *      iline, ",", StringUtil.DELIM_SKIP_BLANKS );
                         */
                        if (v.Count < 2 + nz)
                        {
                            Message.printWarning(1, rtn, "Unknown format for input line in " + "delplt output file: " + iline);
                            return(1);
                        }
                        node.setID(((string)v[0]).Trim());
                        node.setName(((string)v[2]).Trim());
                        for (int j = 2; j < 2 + nz; j++)
                        {
                            node.addZ((double?)v[2 * j]);
                        }

                        _nodes.Add(node);
                    }
                    catch (Exception e)
                    {
                        Message.printWarning(2, rtn, "Trouble parsing xgr line \"" + iline + "\"");
                        Message.printWarning(5, rtn, e);
                    }
                }
            }
            catch (Exception e)
            {
                rtn   = null;
                iline = null;
                if (@in != null)
                {
                    @in.Close();
                }
                @in    = null;
                list1  = null;
                a      = null;
                b      = null;
                format = null;
                Message.printWarning(2, rtn, e);
                throw new IOException(e.Message);
            }

            rtn   = null;
            iline = null;
            if (@in != null)
            {
                @in.Close();
            }
            @in    = null;
            list1  = null;
            a      = null;
            b      = null;
            format = null;
            return(0);
        }
Example #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public int writeArcViewFile(java.io.PrintWriter out) throws java.io.IOException
        public virtual int writeArcViewFile(PrintWriter @out)
        {
            string                 rtn      = "StateMod_DeltaPlot.writeArcViewFile";
            string                 iline    = null;
            string                 type     = null;
            string                 yrOrAve  = null;
            string                 colTitle = null;
            IList <string>         list     = null;
            StateMod_DeltaPlotNode node     = null;
            string                 id       = null;
            string                 name     = null;

            try
            {
                type = getType();
                bool include_type = false;
                if (type.Equals("Difference", StringComparison.OrdinalIgnoreCase) || type.Equals("Merge", StringComparison.OrdinalIgnoreCase) || type.Equals("Diffx", StringComparison.OrdinalIgnoreCase))
                {
                    include_type = true;
                }

                // print header
                yrOrAve  = "";
                colTitle = "";
                iline    = "Identifier, Name";
                if (include_type)
                {
                    iline += ", " + type;
                }
                int size = _columnTitles.Count;
                for (int i = 0; i < size; i++)
                {
                    list     = StringUtil.breakStringList(_columnTitles[i], " ", StringUtil.DELIM_SKIP_BLANKS);
                    yrOrAve  = list[0];
                    colTitle = list[1].Replace(',', '_');
                    if (!include_type)
                    {
                        iline += ",";
                    }
                    iline += " " + yrOrAve + " " + colTitle;
                }
                @out.println(iline);

                // print data
                int num = _nodes.Count;
                for (int i = 0; i < num; i++)
                {
                    node = (StateMod_DeltaPlotNode)_nodes[i];
                    id   = node.getID();
                    name = node.getName();
                    if (string.ReferenceEquals(id, null) || id.Length == 0)
                    {
                        id = " ";
                    }
                    if (string.ReferenceEquals(name, null) || name.Length == 0)
                    {
                        name = " ";
                    }
                    else
                    {
                        name = name.Replace(',', '_');
                    }

                    iline = "\"" + id + "\"," + name;
                    int numz = node.getZsize();
                    for (int j = 0; j < numz; j++)
                    {
                        iline += "," + node.getZ(j);
                    }

                    @out.println(iline);
                }
            }
            catch (Exception e)
            {
                rtn      = null;
                iline    = null;
                type     = null;
                yrOrAve  = null;
                colTitle = null;
                list     = null;
                node     = null;
                id       = null;
                name     = null;
                Message.printWarning(2, rtn, e);
                throw new IOException(e.Message);
            }

            rtn      = null;
            iline    = null;
            type     = null;
            yrOrAve  = null;
            colTitle = null;
            list     = null;
            node     = null;
            id       = null;
            name     = null;
            return(0);
        }