Пример #1
0
        public void RemovePlot(IPlot plot)
        {
            if (plot == null)
            {
                return;
            }

            int index = plots.IndexOf(plot);

            if (index < 0)
            {
                return;
            }

            RemovePlotListeners(plot);
            plots.RemoveAt(index);

            if (Allocation.X >= 0 && Allocation.Y >= 0)
            {
                foreach (IAxis axis in axes)
                {
                    axis.SetRange(Plots, Allocation);
                }
            }

            if (PlotsChanged != null)
            {
                PlotsChanged(this, Plots);
            }

            QueueResize();
        }
Пример #2
0
        private void graph_PlotAreaMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (graph.Plots.Count() == 0)
            {
                return;
            }
            Point     screenPosition   = e.GetPosition(graph);
            Point     relativePosition = graph.ScreenToRelative(screenPosition);
            PlotValue nearestValue     = graph.FindNearestValue(graph.Plots[0], relativePosition, query);
            IPlot     plot1            = nearestValue.PlotObserver;
            var       plot             = (Plot)graph.Plots[plot1.Index];

            if (plot == null || plot == _SelectedPlot)
            {
                return;
            }
            _SelectedPlot = plot;
            foreach (Plot p in graph.Plots)
            {
                ((LinePlotRenderer)p.Renderer).StrokeThickness = 1.0;
            }
            ((LinePlotRenderer)_SelectedPlot.Renderer).StrokeThickness = 2.0;
            int index = graph.Plots.IndexOf(plot);

            lstYxis.SelectedIndex = index;
        }
Пример #3
0
    private IEnumerator Start()
    {
        PlotQueue = new Queue <MonoBehaviour>(PlotList);
        PlayerInput.Instance.ReleaseControl(true);
        PlayerInput.Instance.Interact.GainControl();
        yield return(new WaitForSeconds(2f));

        IPlot plot = null;

        if (PlotQueue.Count > 0)
        {
            plot = PlotQueue.Dequeue() as IPlot;
        }
        while (plot != null)
        {
            yield return(StartCoroutine(plot.DoPlot()));

            if (PlotQueue.Count > 0)
            {
                plot = PlotQueue.Dequeue() as IPlot;
            }
            else
            {
                plot = null;
                break;
            }
        }
        PlayerInput.Instance.GainControl();
        yield break;
    }
 // param specify reference or name of axis.
 public void Add(IPlot p, XAxisPosition xp, YAxisPosition yp)
 {
     plots_.Add(p);
     xAxisPositions_.Add(xp);
     yAxisPositions_.Add(yp);
     UpdateAxes();
 }
Пример #5
0
        /// <summary>
        /// Returns the y-axis associated with a given plot.
        /// </summary>
        /// <param name="plot">the plot to get associated y-axis.</param>
        /// <returns>the axis associated with the plot.</returns>
        public Axis WhichYAxis(IPlot plot)
        {
            int           index = drawables_.IndexOf(plot);
            YAxisPosition p     = (YAxisPosition)yAxisPositions_[index];

            return((yAxisOverrides_[index] != null) ? (Axis)yAxisOverrides_[index] :
                   (p == YAxisPosition.Left) ? this.yAxis1_ : this.yAxis2_);
        }
Пример #6
0
        /// <summary>
        /// Returns the x-axis associated with a given plot.
        /// </summary>
        /// <param name="plot">the plot to get associated x-axis.</param>
        /// <returns>the axis associated with the plot.</returns>
        public Axis WhichXAxis(IPlot plot)
        {
            int           index = drawables_.IndexOf(plot);
            XAxisPosition p     = (XAxisPosition)xAxisPositions_[index];

            return((xAxisOverrides_[index] != null) ? (Axis)xAxisOverrides_[index] :
                   (p == XAxisPosition.Bottom) ? this.xAxis1_ : this.xAxis2_);
        }
Пример #7
0
        private static IPlot GetInstance()
        {
            IPlot result = Implementation.Value;

            if (result == null)
            {
                throw new NotImplementedException();
            }
            return(result);
        }
Пример #8
0
 public ProcessPlot(IPlot newPlot, List <OBBox> obbs)
 {
     plot            = newPlot;
     this.obbs       = obbs;
     shortSplit      = true;
     longSplit       = false;
     variationA      = false;
     variationB      = false;
     variationAmount = 0.5f;
 }
Пример #9
0
 public ProcessPlot(IPlot newPlot)
 {
     plot            = newPlot;
     obbs            = new List <OBBox>();
     shortSplit      = true;
     longSplit       = false;
     variationA      = false;
     variationB      = false;
     variationAmount = 0.5f;
 }
Пример #10
0
        public AddPlotWindow()
        {
            InitializeComponent();

            this.dbInit = new DatabaseInitializer();
            this.repo   = new LandRepository();
            this.plot   = new Plot();

            PopulateFormFields();
        }
Пример #11
0
        protected virtual void RemovePlotListeners(IPlot plot)
        {
            plot.Changed          -= new EventHandler(OnPlotChanged);
            plot.SelectionChanged -= new EventHandler(OnPlotSelectionChanged);

            if (plot is ITreeModelPlot)
            {
                ((ITreeModelPlot)plot).ModelChanged -= new EventHandler(OnModelChanged);
            }
        }
Пример #12
0
        public AddPlotWindow()
        {
            InitializeComponent();

            this.dbInit = new DatabaseInitializer();
            this.repo = new LandRepository();
            this.plot = new Plot();

            PopulateFormFields();
        }
Пример #13
0
        private IPlot GetPlotById(int plotId)
        {
            IPlot plot = ObjectFactory.Instance.CreatePlot();


            try
            {
                conn.Open();

                SqlCommand command = new SqlCommand("CH_SP_GetPlotById", conn);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add(new SqlParameter("@PlotId", plotId));

                SqlDataReader reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();
                    string   zipcode      = reader.GetString(0);
                    string   address      = reader.GetString(1);
                    string   city         = reader.GetString(2);
                    int      area         = reader.GetInt32(3);
                    string   municipality = reader.GetString(4);
                    DateTime?availabilityDate;
                    if (reader.IsDBNull(5))
                    {
                        availabilityDate = null;
                    }
                    else
                    {
                        availabilityDate = reader.GetDateTime(5);
                    }

                    plot.Zipcode          = zipcode;
                    plot.Address          = address;
                    plot.City             = city;
                    plot.Area             = area;
                    plot.Municipality     = municipality;
                    plot.AvailabilityDate = availabilityDate;
                }
                reader.Close();
                reader.Dispose();
            }
            catch (SqlException)
            {
            }
            finally
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(plot);
        }
Пример #14
0
        public APlotVM(IPlot plot)
        {
            _plot = plot;
            _lastKeyboardInput = new KeyboardInput();
            _lastMouseInput    = new MouseInput();
            _selection         = new SelectionManager(plot);
            _plotPoints        = new PlotPoints();

            Update();
            Step = new Vector3D(0, 0, 1);
        }
Пример #15
0
        /// <summary>
        /// Returns the y-axis associated with a given plot.
        /// </summary>
        /// <param name="plot">the plot to get associated y-axis.</param>
        /// <returns>the axis associated with the plot.</returns>
        public Axis WhichYAxis(IPlot plot)
        {
            int           index = drawables_.IndexOf(plot);
            YAxisPosition p     = (YAxisPosition)yAxisPositions_[index];

            if (p == YAxisPosition.Left)
            {
                return(yAxis1_);
            }
            else
            {
                return(yAxis2_);
            }
        }
Пример #16
0
        /// <summary>
        /// Returns the x-axis associated with a given plot.
        /// </summary>
        /// <param name="plot">the plot to get associated x-axis.</param>
        /// <returns>the axis associated with the plot.</returns>
        public Axis WhichXAxis(IPlot plot)
        {
            int           index = drawables_.IndexOf(plot);
            XAxisPosition p     = (XAxisPosition)xAxisPositions_[index];

            if (p == XAxisPosition.Bottom)
            {
                return(xAxis1_);
            }
            else
            {
                return(xAxis2_);
            }
        }
Пример #17
0
        protected override void OnFocusGrabbed()
        {
            base.OnFocusGrabbed();

            if (plots.Count < 1)
            {
                return;
            }

            // don't switch focus if any plot already has focus
            foreach (IPlot plot in plots)
            {
                if (plot.HasFocus)
                {
                    return;
                }
            }

            // find the plot with the smallest x value, and focus it
            int min_plot = -1;
            int min_x    = Int32.MaxValue;
            int min_y    = Int32.MaxValue;

            for (int i = 0; i < plots.Count; i++)
            {
                IPlot plot = (IPlot)plots[i];
                if (!plot.CanFocus)
                {
                    continue;
                }

                int x, y;
                plot.GetGrabFocusRequest(out x, out y);

                if ((min_x > x) || (min_x == x && min_y > y))
                {
                    min_x    = x;
                    min_y    = y;
                    min_plot = i;
                }
            }

            if (min_plot == -1)
            {
                return;
            }

            ((IPlot)plots[min_plot]).GrabFocus();
            focused_plot_index = min_plot;
        }
Пример #18
0
        public void InitializePlotControl(IPlot iPlot)
        {
            this.iPlot = iPlot;
            ArrayList oxVars = iPlot.GetOxVariables();
            ArrayList oyVars = iPlot.GetOyVariables();

            this.comboBoxOxVariables.Items.Clear();
            this.comboBoxOyVariables.Items.Clear();

            // populate the ox variables
            IEnumerator e1 = oxVars.GetEnumerator();

            while (e1.MoveNext())
            {
                this.comboBoxOxVariables.Items.Add(e1.Current);
            }
            if (oxVars != null && oxVars.Count > 0)
            {
                this.comboBoxOxVariables.SelectedIndex = 0;
            }

            // populate the oy variables
            IEnumerator e2 = oyVars.GetEnumerator();

            while (e2.MoveNext())
            {
                this.comboBoxOyVariables.Items.Add(e2.Current);
            }
            if (oyVars != null && oyVars.Count > 0)
            {
                this.comboBoxOyVariables.SelectedIndex = 0;
            }

            PlotData plotData = iPlot.GetPlotData(this.OxVariable, this.OyVariable);

            // update the ranges
            this.UpdateRangesOnUI(this.OxVariable, this.OyVariable);

            // update the plot
            this.plotGraph.UpdatePlot(plotData, this.OxVariable, this.OyVariable);

            //
            this.UpdateFamiliesList(plotData);

            if (this.iPlot != null)
            {
                this.iPlot.PlotChanged += new PlotChangedEventHandler(iPlot_PlotChanged);
            }
        }
Пример #19
0
        private static string plotFigure(string caption, IPlot plot, string pictureText)
        {
            var tex = new StringBuilder();

            tex.Append(Helper.Begin(Helper.Environments.figure));
            tex.AppendFormat((string)"[{0}]\n", (object)plot.Position);
            tex.Append(Helper.NoIndent());
            tex.Append(Helper.Centering());
            tex.Append(setSubfolderForPlots());
            tex.Append(pictureText);
            tex.Append(Helper.Caption(caption));
            tex.Append(Helper.Label(plot.Label));
            tex.Append(Helper.End(Helper.Environments.figure));
            return(tex.ToString());
        }
Пример #20
0
        public void Create(IPlot plot)
        {
            MinMaxRange xRange = new MinMaxRange();
            MinMaxRange yRange = new MinMaxRange();
            MinMaxRange zRange = new MinMaxRange();

            foreach (ISeries series in plot.Series)
            {
                foreach (IPoint point in series.Points)
                {
                    xRange.Update(point.Position.X);
                    yRange.Update(point.Position.Y);
                    zRange.Update(point.Position.Z);
                }
            }

            //foreach( xRange.Min =
        }
Пример #21
0
        public AutoRenderPolicy(IPlot plot)
            : base(plot)
        {
            task = Task.Factory.StartNew(async() =>
            {
                try
                {
                    var channel = Channel.CreateUnbounded <int>(new UnboundedChannelOptions
                    {
                        SingleReader = true,
                        SingleWriter = true
                    });

                    var reader = channel.Reader;
                    writer     = channel.Writer;

                    var token = cancellationTokenSource.Token;

                    while (await reader.WaitToReadAsync(token).ConfigureAwait(false))
                    {
                        while (reader.TryRead(out _))
                        {
                        }

                        plot.Render();

                        Interlocked.Exchange(ref render, 1);

                        await plot.StateHasChangedAsync().ConfigureAwait(false);

                        try
                        {
                            await semaphore.WaitAsync(token).ConfigureAwait(false);
                        }
                        finally
                        {
                        }
                    }
                }
                catch (Exception e)
                {
                }
            }, TaskCreationOptions.LongRunning);
        }
Пример #22
0
        public static RawMeshData GeneratePlot(IPlot plot)
        {
            int pointSize = plot.numberOfEdges;

            int[]     sortedIndexes = BuildrUtils.SortPointByAngle(plot.pointsV2, plot.center);
            Vector2[] sortedPoints  = new Vector2[pointSize];
            for (int i = 0; i < pointSize; i++)
            {
                sortedPoints[i] = plot.pointsV2[sortedIndexes[i]];
            }
            bool clockwise = Clockwise(sortedPoints);

            int vertCount = pointSize + 1;
            int triCount  = pointSize * 3;

            RawMeshData output = new RawMeshData(vertCount, triCount);

            for (int v = 0; v < vertCount - 1; v++)
            {
                output.vertices[v] = new Vector3(sortedPoints[v].x, 0, sortedPoints[v].y);
            }
            output.vertices[vertCount - 1] = new Vector3(plot.center.x, 0, plot.center.y);

            int vertIndex = 0;

            for (int t = 0; t < triCount; t += 3)
            {
                output.triangles[t + 0] = vertCount - 1;
                if (clockwise)
                {
                    output.triangles[t + 1] = vertIndex;
                    output.triangles[t + 2] = (vertIndex < vertCount - 2) ? vertIndex + 1 : 0;
                }
                else
                {
                    output.triangles[t + 1] = (vertIndex < vertCount - 2) ? vertIndex + 1 : 0;
                    output.triangles[t + 2] = vertIndex;
                }
                vertIndex++;
            }

            return(output);
        }
Пример #23
0
        /**
         * Add a plot to the graph.  This plot will use the specified
         * axes when drawing.  The axes specified must have already
         * been appended to the Graph's axes list.
         */
        public void AddPlot(IPlot plot, params IAxis[] axes)
        {
            if (plot == null || axes == null || axes.Length == 0)
            {
                return;
            }

            plots.Add(plot);

            plot.SetAxes(axes);
            plot.Style = style_prov;
            AddPlotListeners(plot);

            if (PlotsChanged != null)
            {
                PlotsChanged(this, Plots);
            }

            QueueResize();
        }
Пример #24
0
        public String DoItRight(INumericMethod <TFunc> method, IShape <TFunc> func, IPlot plotSpace, Conditions conditions, IReportGenerator reporter, bool stepByStep = false)
        {
            var actualPoints = conditions.InitialPoints.ToArray();

            UpdateDomain(func, actualPoints);
            reporter.Init(actualPoints, func, conditions);

            var iterationsCounter = 0;

            while (!IsAnyPointPrettyCloseToRoot(func.Generator, conditions, actualPoints) && iterationsCounter++ < conditions.MaxNumberOfIteration)
            {
                var newPoint = method.ComputeNext(actualPoints, func.Generator);

                if (!newPoint.Any())
                {
                    break;
                }

                actualPoints = actualPoints.Concat(newPoint).ToArray();
                UpdateDomain(func, actualPoints);

                var pictureOfStep = method.GenerateIllustrationForCurrentStep(actualPoints, func.Generator, iterationsCounter + conditions.InitialPoints.Count());

                reporter.AddIntermidiateStep(actualPoints, pictureOfStep, iterationsCounter);

                plotSpace.DrawShape(func);
                foreach (var shape in pictureOfStep)
                {
                    plotSpace.DrawShape(shape);
                    if (stepByStep)
                    {
                        Console.WriteLine("Press Enter to make step");
                        Console.ReadLine();
                    }
                }
            }

            return(reporter.GenerateReport(actualPoints.Last(), iterationsCounter, DistanceToRoot(func.Generator, actualPoints.Last(), conditions)));
        }
Пример #25
0
        private int InsertPlot(IPlot plot)
        {
            SqlCommand command = new SqlCommand("CH_SP_InsertOrEditPlot", conn);

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@ZipCode", plot.Zipcode));
            command.Parameters.Add(new SqlParameter("@PlotAddress", plot.Address));
            command.Parameters.Add(new SqlParameter("@City", plot.City));
            command.Parameters.Add(new SqlParameter("@Area", plot.Area));
            command.Parameters.Add(new SqlParameter("@Municipality", plot.Municipality));
            command.Parameters.Add(new SqlParameter("@AvailabilityDate", plot.AvailabilityDate));

            SqlParameter returnParameter = command.Parameters.Add("@PlotId", SqlDbType.Int);

            returnParameter.Direction = ParameterDirection.ReturnValue;

            command.ExecuteNonQuery();

            command.Dispose();

            return(int.Parse(returnParameter.Value.ToString()));
        }
Пример #26
0
        /// <summary>
        /// Coppies data in the current plot surface view window to the clipboard
        /// as text.
        /// </summary>
        public void CopyDataToClipboard()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            for (int i = 0; i < this.InteractivePlotSurface2D.Drawables.Count; ++i)
            {
                IPlot plot = this.InteractivePlotSurface2D.Drawables[i] as IPlot;
                if (plot != null)
                {
                    Axis xAxis = this.InteractivePlotSurface2D.WhichXAxis(plot);
                    Axis yAxis = this.InteractivePlotSurface2D.WhichYAxis(plot);

                    RectangleD region = new RectangleD(
                        xAxis.WorldMin,
                        yAxis.WorldMin,
                        xAxis.WorldMax - xAxis.WorldMin,
                        yAxis.WorldMax - yAxis.WorldMin);

                    plot.WriteData(sb, region, true);
                }
            }

            Clipboard.SetDataObject(sb.ToString(), true);
        }
Пример #27
0
 /// <summary>
 /// Returns the x-axis associated with a given plot (XAxis1 is at Bottom).
 /// </summary>
 /// <param name="plot">the plot to get associated x-axis.</param>
 /// <returns>the axis associated with the plot.</returns>
 public Axis WhichXAxis(IPlot plot)
 {
     int index = drawables.IndexOf (plot);
     XAxisPosition p = (XAxisPosition)xAxisPositions[index];
     if (p == XAxisPosition.Bottom)
         return xAxis1;
     else
         return xAxis2;
 }
Пример #28
0
 public PolarGrapher(IPlot plotter)
 {
     this.plotter = plotter;
     plotter.plot_axes();
 }
Пример #29
0
 /// <summary>
 /// Returns the y-axis associated with a given plot.
 /// </summary>
 /// <param name="plot">the plot to get associated y-axis.</param>
 /// <returns>the axis associated with the plot.</returns>
 public Axis WhichYAxis( IPlot plot )
 {
     int index = drawables_.IndexOf( plot );
     YAxisPosition p = (YAxisPosition)yAxisPositions_[index];
     if ( p == YAxisPosition.Left )
         return this.yAxis1_;
     else
         return this.yAxis2_;
 }
Пример #30
0
 /// <summary>
 /// Returns the x-axis associated with a given plot.
 /// </summary>
 /// <param name="plot">the plot to get associated x-axis.</param>
 /// <returns>the axis associated with the plot.</returns>
 public Axis WhichXAxis( IPlot plot )
 {
     int index = drawables_.IndexOf( plot );
     XAxisPosition p = (XAxisPosition)xAxisPositions_[index];
     if ( p == XAxisPosition.Bottom )
         return this.xAxis1_;
     else
         return this.xAxis2_;
 }
Пример #31
0
        /// <summary>
        /// Draw The legend
        /// </summary>
        /// <param name="g">The graphics surface on which to draw</param>
        /// <param name="position">The position of the top left of the axis.</param>
        /// <param name="plots">Array of plot objects to appear in the legend.</param>
        /// <param name="scale">if the legend is set to scale, the amount to scale by.</param>
        /// <returns>bounding box</returns>
        public Rectangle Draw(Graphics g, Point position, ArrayList plots, float scale)
        {
            // first of all determine the Font to use in the legend.
            Font textFont;

            if (this.AutoScaleText)
            {
                textFont = Utils.ScaleFont(this.font_, scale);
            }
            else
            {
                textFont = this.font_;
            }

            // determine max width and max height of label strings and
            // count the labels.
            int labelCount   = 0;
            int maxHt        = 0;
            int maxWd        = 0;
            int unnamedCount = 0;

            for (int i = 0; i < plots.Count; ++i)
            {
                if (!(plots[i] is IPlot))
                {
                    continue;
                }

                IPlot p = (IPlot)plots[i];

                if (!p.ShowInLegend)
                {
                    continue;
                }
                string label = p.Label;
                if (label == "")
                {
                    unnamedCount += 1;
                    label         = "Series " + unnamedCount.ToString();
                }
                SizeF labelSize = g.MeasureString(label, textFont);
                if (labelSize.Height > maxHt)
                {
                    maxHt = (int)labelSize.Height;
                }
                if (labelSize.Width > maxWd)
                {
                    maxWd = (int)labelSize.Width;
                }

                ++labelCount;
            }

            bool extendingHorizontally = numberItemsHorizontally_ == -1;
            bool extendingVertically   = numberItemsVertically_ == -1;

            // determine width in legend items count units.
            int widthInItemCount = 0;

            if (extendingVertically)
            {
                if (labelCount >= numberItemsHorizontally_)
                {
                    widthInItemCount = numberItemsHorizontally_;
                }
                else
                {
                    widthInItemCount = labelCount;
                }
            }
            else if (extendingHorizontally)
            {
                widthInItemCount = labelCount / numberItemsVertically_;
                if (labelCount % numberItemsVertically_ != 0)
                {
                    widthInItemCount += 1;
                }
            }
            else
            {
                throw new NPlotException("logic error in legend base");
            }

            // determine height of legend in items count units.
            int heightInItemCount = 0;

            if (extendingHorizontally)
            {
                if (labelCount >= numberItemsVertically_)
                {
                    heightInItemCount = numberItemsVertically_;
                }
                else
                {
                    heightInItemCount = labelCount;
                }
            }
            else             // extendingVertically
            {
                heightInItemCount = labelCount / numberItemsHorizontally_;
                if (labelCount % numberItemsHorizontally_ != 0)
                {
                    heightInItemCount += 1;
                }
            }

            int lineLength = 20;
            int hSpacing   = (int)(5.0f * scale);
            int vSpacing   = (int)(3.0f * scale);
            int boxWidth   = (int)((float)widthInItemCount * (lineLength + maxWd + hSpacing * 2.0f) + hSpacing);
            int boxHeight  = (int)((float)heightInItemCount * (maxHt + vSpacing) + vSpacing);

            int totalWidth  = boxWidth;
            int totalHeight = boxHeight;

            // draw box around the legend.

            if (this.BorderStyle == BorderType.Line)
            {
                g.FillRectangle(new SolidBrush(this.bgColor_), position.X, position.Y, boxWidth, boxHeight);
                g.DrawRectangle(new Pen(this.borderColor_), position.X, position.Y, boxWidth, boxHeight);
            }
            else if (this.BorderStyle == BorderType.Shadow)
            {
                int offset = (int)(4.0f * scale);
                g.FillRectangle(new SolidBrush(Color.FromArgb(128, Color.Gray)), position.X + offset, position.Y + offset, boxWidth, boxHeight);
                g.FillRectangle(new SolidBrush(this.bgColor_), position.X, position.Y, boxWidth, boxHeight);
                g.DrawRectangle(new Pen(this.borderColor_), position.X, position.Y, boxWidth, boxHeight);

                totalWidth  += offset;
                totalHeight += offset;
            }

            /*
             * else if ( this.BorderStyle == BorderType.Curved )
             * {
             *         // TODO. make this nice.
             * }
             */
            else
            {
                // do nothing.
            }

            // now draw entries in box..
            labelCount   = 0;
            unnamedCount = 0;

            int plotCount = -1;

            for (int i = 0; i < plots.Count; ++i)
            {
                if (!(plots[i] is IPlot))
                {
                    continue;
                }

                IPlot p = (IPlot)plots[i];

                if (!p.ShowInLegend)
                {
                    continue;
                }

                plotCount += 1;

                int xpos, ypos;
                if (extendingVertically)
                {
                    xpos = plotCount % numberItemsHorizontally_;
                    ypos = plotCount / numberItemsHorizontally_;
                }
                else
                {
                    xpos = plotCount / numberItemsVertically_;
                    ypos = plotCount % numberItemsVertically_;
                }

                int lineXPos = (int)(position.X + hSpacing + xpos * (lineLength + maxWd + hSpacing * 2.0f));
                int lineYPos = (int)(position.Y + vSpacing + ypos * (vSpacing + maxHt));
                p.DrawInLegend(g, new Rectangle(lineXPos, lineYPos, lineLength, maxHt));

                int    textXPos = lineXPos + hSpacing + lineLength;
                int    textYPos = lineYPos;
                string label    = p.Label;
                if (label == "")
                {
                    unnamedCount += 1;
                    label         = "Series " + unnamedCount.ToString();
                }

                g.DrawString(label, textFont,
                             new SolidBrush(this.textColor_), textXPos, textYPos);

                ++labelCount;
            }
            return(new Rectangle(position.X, position.Y, totalWidth, totalHeight));
        }
 public SliderAction(IPlot pc)
     : base(pc)
 {
 }
Пример #33
0
        /* XXX: Uncomment when ximian bug #81343 is closed and usable.
         * protected override void OnActivate ()
         * {
         *      foreach (IPlot plot in plots)
         *      {
         *              plot.UnselectAll ();
         *      }
         *
         *      foreach (IPlot plot in plots)
         *      {
         *              if (plot.HasFocus) {
         *                      int x, y;
         *                      plot.GetFocusedPoint (axes, out x, out y);
         *                      plot.SelectPoint (axes, x, y);
         *                      break;
         *              }
         *      }
         * }
         */

        protected override bool OnFocused(DirectionType dir)
        {
            if (plots.Count < 1)
            {
                return(false);
            }

            if (!HasFocus)
            {
                GrabFocus();
                return(true);
            }

            int visits;
            int focused_x = -1, focused_y = -1;

            switch (dir)
            {
            case DirectionType.Left:
                ((IPlot)plots[focused_plot_index]).FocusPrev();
                return(true);

            case DirectionType.Right:
                ((IPlot)plots[focused_plot_index]).FocusNext();
                return(true);

            case DirectionType.Up:
                // Don't move selection if there is only one
                // plot
                if (plots.Count <= 1)
                {
                    return(true);
                }

                // get the currently focused point
                ((IPlot)plots[focused_plot_index]).GetFocusedPoint(out focused_x,
                                                                   out focused_y);

                // Iterate through the plots in the zorder,
                // looking for the next plot which CanFocus.
                // Also, make sure we don't see plots twice, or
                // infinite loop.
                visits = 0;
                do
                {
                    // move to the next plot in the z-order
                    focused_plot_index--;
                    if (focused_plot_index < 0)
                    {
                        focused_plot_index = plots.Count - 1;
                    }

                    visits++;

                    IPlot plot = (IPlot)plots[focused_plot_index];
                    if (!plot.CanFocus)
                    {
                        continue;
                    }

                    // clear focus on all the plots
                    foreach (IPlot p in plots)
                    {
                        if (p.HasFocus)
                        {
                            p.ReleaseFocus();
                        }
                    }

                    // focus the nearest to the last
                    // focused point
                    plot.FocusNearest(focused_x, focused_y);
                    break;
                } while (visits <= plots.Count);

                return(true);

            case DirectionType.Down:
                // Don't move selection if there is only one
                // plot
                if (plots.Count <= 1)
                {
                    return(true);
                }

                // get the currently focused point
                ((IPlot)plots[focused_plot_index]).GetFocusedPoint(out focused_x,
                                                                   out focused_y);

                // Iterate through the plots in the zorder,
                // looking for the next plot which CanFocus.
                // Also, make sure we don't see plots more than
                // once, or worse, infinite loop.
                visits = 0;
                do
                {
                    // move to the previous plot in the z-order
                    focused_plot_index++;
                    if (focused_plot_index >= plots.Count)
                    {
                        focused_plot_index = 0;
                    }


                    visits++;

                    IPlot plot = (IPlot)plots[focused_plot_index];
                    if (!plot.CanFocus)
                    {
                        continue;
                    }

                    // clear focus on all the plots
                    foreach (IPlot p in plots)
                    {
                        if (p.HasFocus)
                        {
                            p.ReleaseFocus();
                        }
                    }

                    // focus the nearest to the last
                    // focused point
                    plot.FocusNearest(focused_x, focused_y);
                    break;
                } while (visits <= plots.Count);

                return(true);

            case DirectionType.TabForward:
            default:
                // let focus jump to the next widget
                return(false);
            }
        }
 public void Add(IPlot p, XAxisPosition xp, YAxisPosition yp)
 {
     ps_.Add(p, xp, yp);
 }
        public RectangleF Draw(Graphics g, int xPos, int yPos, ArrayList plots, float scale)
        {
            // determine max width and max height of label strings.
            float maxHt = 0.0f;
            float maxWd = 0.0f;

            for (int i = 0; i < plots.Count; ++i)
            {
                IPlot p   = (IPlot)plots[i];
                float lHt = g.MeasureString(p.Label, FontScaler.scaleFont(font_, scale)).Height;
                float lWd = g.MeasureString(p.Label, FontScaler.scaleFont(font_, scale)).Width;
                if (lHt > maxHt)
                {
                    maxHt = lHt;
                }
                if (lWd > maxWd)
                {
                    maxWd = lWd;
                }
            }

            float lineLength = 20.0f;
            float lineHeight = maxHt;
            float hSpacing   = 5.0f * scale;
            float vSpacing   = 3.0f * scale;
            float boxWidth   = hSpacing * 3.0f + lineLength + maxWd;
            float boxHeight  = vSpacing * (float)(plots.Count + 1) + maxHt * (float)plots.Count;

            float totalWidth  = boxWidth;
            float totalHeight = boxHeight;

            // draw box..
            if (BorderStyle == BorderType.Line)
            {
                g.FillRectangle(new SolidBrush(Color.White), xPos, yPos, boxWidth, boxHeight);
                g.DrawRectangle(new Pen(Color.Black), xPos, yPos, boxWidth, boxHeight);
            }
            else if (BorderStyle == BorderType.Shadow)
            {
                float offset = 4.0f * (float)scale;
                g.FillRectangle(new SolidBrush(Color.LightGray), xPos + offset, yPos + offset, boxWidth, boxHeight);
                g.FillRectangle(new SolidBrush(Color.White), xPos, yPos, boxWidth, boxHeight);
                g.DrawRectangle(new Pen(Color.Black), xPos, yPos, boxWidth, boxHeight);

                totalWidth  += offset;
                totalHeight += offset;
            }

            /*
             * else if ( this.BorderStyle == BorderType.Curved )
             * {
             *      // TODO. make this nice.
             * }
             */
            else
            {
                // do nothing.
            }

            // now draw entries in box..
            int unnamedCount = 0;

            for (int i = 0; i < plots.Count; ++i)
            {
                IPlot p        = (IPlot)plots[i];
                float lineXPos = xPos + hSpacing;
                float lineYPos = yPos + vSpacing + (float)i * (vSpacing + maxHt);
                p.DrawLegendLine(g, new RectangleF(lineXPos, lineYPos, lineLength, lineHeight));
                float  textXPos = lineXPos + hSpacing + lineLength;
                float  textYPos = lineYPos;
                string label    = p.Label;
                if (label == "")
                {
                    unnamedCount += 1;
                    label         = "Series " + unnamedCount.ToString();
                }
                g.DrawString(label, FontScaler.scaleFont(Font, scale),
                             new SolidBrush(Color.Black), textXPos, textYPos);
            }

            return(new RectangleF(xPos, yPos, totalWidth, totalHeight));
        }
Пример #36
0
 public PolarGrapher(IPlot plotter)
 {
     this.plotter = plotter;
     plotter.plot_axes();
 }
Пример #37
0
 public SkewPlotter(IPlot base_plotter, Point skew)
 {
     this.base_plotter = base_plotter;
     this.skew = skew;
 }
Пример #38
0
 /// <summary>
 /// Returns the y-axis associated with a given plot (YAxis1 is at Left).
 /// </summary>
 /// <param name="plot">the plot to get associated y-axis.</param>
 /// <returns>the axis associated with the plot.</returns>
 public Axis WhichYAxis(IPlot plot)
 {
     int index = drawables.IndexOf (plot);
     YAxisPosition p = (YAxisPosition)yAxisPositions[index];
     if (p == YAxisPosition.Left)
         return yAxis1;
     else
         return yAxis2;
 }
Пример #39
0
 public Story(IPlot plot)
 {
     this.Plot = plot;
     setTarget();
 }