コード例 #1
0
        /***************************************************************************
         * Text boxes are dealt with here
         **************************************************************************/
        private SGTextBoxCollection GetXLTextBoxes(Chart chart)
        {
            SGTextBoxCollection sg_textbox_collection = new SGTextBoxCollection();
            IEnumerator         text_box_enumerator   = ((TextBoxes)chart.TextBoxes
                                                             (Type.Missing)).GetEnumerator();
            int ctr = 0;

            if (chart.HasTitle)
            {
                ChartTitle ct    = chart.ChartTitle;
                SGTextBox  tibox = new SGTextBox();
                tibox.ID       = ctr;
                tibox.Geometry = new SGGeometry(0F, 0F, 0F, 0F);
                tibox.Text     = ct.Text;
                sg_textbox_collection.AddTextBox(tibox);
                ctr++;
            }

            while (text_box_enumerator.MoveNext())
            {
                SGTextBox sg_textbox = new SGTextBox();
                sg_textbox.ID = ctr;
                TextBox xl_textbox = (TextBox)text_box_enumerator.Current;

                // TextBox without text :)
                if (xl_textbox.Text.Length == 0)
                {
                    continue;
                }

                sg_textbox.Text    = xl_textbox.Text.Trim().Replace("\n", "");
                sg_textbox.BoxSize = new Size(xl_textbox.Width, xl_textbox.Height);
                SGGeometry txtbox_geom = new SGGeometry(xl_textbox.Left,
                                                        xl_textbox.Top, xl_textbox.Height, xl_textbox.Width);
                sg_textbox.Geometry = txtbox_geom;

                /**
                 * Excel constants for horizontal alignment are found at
                 * \latexonly
                 * \url{http://msdn.microsoft.com/en-us/library/aa221100(office.11).spx}
                 * \endlatexonly
                 */

                switch (xl_textbox.HorizontalAlignment.ToString())
                {
                case "-4131":
                    sg_textbox.Justification = SGTextBox.HorizontalAlignment.LEFT;
                    break;

                case "-4108":
                    sg_textbox.Justification = SGTextBox.HorizontalAlignment.CENTER;
                    break;

                case "-4152":
                    sg_textbox.Justification = SGTextBox.HorizontalAlignment.RIGHT;
                    break;

                case "-4130":
                    sg_textbox.Justification = SGTextBox.HorizontalAlignment.JUSTIFIED;
                    break;
                }
                sg_textbox_collection.AddTextBox(sg_textbox);
                log.Debug(sg_textbox.ReturnAsString());
                ctr++;
            }
            log.Debug(ctr + " legal text box(es) found.");
            return(sg_textbox_collection);
        }
コード例 #2
0
ファイル: TextboxCleaner.cs プロジェクト: TomOMara/iGraph
        private void RecognizeFunction(SGTextBox tb, int idx)
        {
            string tb_txt = cleanString(tb.Text);

            // If graph have a title (MainTitle != "none" and != "", don't run this code
            if ((g.MainTitle == "none" || g.MainTitle == "") && isAbovePlotArea(tb) && idx == 0 && !isRightOfPlotArea(tb))
            {
                tb.Function = SGTextBox.SemanticFunction.MAIN_TITLE_PRIMARY;
                log.Debug("Probable main title recognized: " + chopString(tb_txt));
                g.MainTitle = tb.Text;
                return;
            }

            if (isAbovePlotArea(tb) &&
                idx != 0 && !isRightOfPlotArea(tb) &&
                !g.Series.existsSeriesType(57) &&
                g.ValueAxis.Title == "none")
            {
                tb.Function = SGTextBox.SemanticFunction.Y_AXIS_TITLE_PRIMARY;
                log.Debug("Probable value axis title recognized: "
                          + chopString(tb_txt));
                g.ValueAxis.Title = tb.Text;
                return;
            }

            // is it a year?
            Regex year_pattern = new Regex(@"^(19|20)?\d\d$");

            if (isBelowXAxis(tb) &&
                year_pattern.IsMatch(tb_txt))
            {
                log.Debug("Probable year recognized: " + tb.Text);
                tb.Function = SGTextBox.SemanticFunction.YEAR;
                return;
            }

            // is it a footnote?
            Regex footnote_pattern = new Regex(@"\d\.");

            if (isBelowXAxis(tb) && footnote_pattern.IsMatch(tb_txt))
            {
                tb.Function = SGTextBox.SemanticFunction.FOOTNOTE;
                log.Info("Probable footnote recognized: " + chopString(tb.Text));
                return;
            }

            // is it a note?
            if (isBelowXAxis(tb) && tb_txt.StartsWith("Note:"))
            {
                tb.Function = SGTextBox.SemanticFunction.INFORMATION_NOTE;
                log.Debug("Probable note recognized: " + chopString(tb.Text));
                return;
            }

            // is it the value axis title of a horizontal bar graph?
            if (isBelowXAxis(tb) && g.Prologue.GetGraphType() == "skeleton")
            {
                tb.Function = SGTextBox.SemanticFunction.Y_AXIS_TITLE_PRIMARY;
                log.Debug("Probable value axis title recognized: "
                          + chopString(tb.Text));
                g.ValueAxis.Title = tb.Text;
                return;
            }

            // @FIX why this?
            tb.Function = SGTextBox.SemanticFunction.ORPHAN_BOX;
            log.Warn("Orphan textbox: " + chopString(tb.Text));
        }
コード例 #3
0
ファイル: TextboxCleaner.cs プロジェクト: TomOMara/iGraph
 private bool isBelowXAxis(SGTextBox tb)
 {
     return(tb.Geometry.PosY > (g.PlotArea.Geometry.Height
                                + g.PlotArea.Geometry.PosY));
 }
コード例 #4
0
ファイル: TextboxCleaner.cs プロジェクト: TomOMara/iGraph
 private bool isRightOfPlotArea(SGTextBox tb)
 {
     return(tb.Geometry.PosX > g.PlotArea.Geometry.Width / 2);
 }
コード例 #5
0
ファイル: TextboxCleaner.cs プロジェクト: TomOMara/iGraph
 private bool isAbovePlotArea(SGTextBox tb)
 {
     return(tb.Geometry.PosY <= g.PlotArea.Geometry.PosY);
 }