示例#1
0
 public void ExpandY(AxisLimits2D source)
 {
     if (source != null)
     {
         ExpandY(source.y1, source.y2);
     }
 }
示例#2
0
        public void AxisAuto(
            double horizontalMargin = .1, double verticalMargin = .1,
            bool xExpandOnly        = false, bool yExpandOnly   = false,
            bool autoX = true, bool autoY = true
            )
        {
            var oldLimits = new Config.AxisLimits2D(axes.ToArray());
            var newLimits = new Config.AxisLimits2D();

            foreach (var plottable in plottables)
            {
                Config.AxisLimits2D plottableLimits = plottable.GetLimits();
                if (autoX && !yExpandOnly)
                {
                    newLimits.ExpandX(plottableLimits);
                }
                if (autoY && !xExpandOnly)
                {
                    newLimits.ExpandY(plottableLimits);
                }
            }

            newLimits.MakeRational();

            if (axes.equalAxes)
            {
                var xUnitsPerPixel = newLimits.xSpan / (dataSize.Width * (1 - horizontalMargin));
                var yUnitsPerPixel = newLimits.ySpan / (dataSize.Height * (1 - verticalMargin));
                axes.Set(newLimits);
                if (yUnitsPerPixel > xUnitsPerPixel)
                {
                    axes.Zoom((1 - horizontalMargin) * xUnitsPerPixel / yUnitsPerPixel, 1 - verticalMargin);
                }
                else
                {
                    axes.Zoom(1 - horizontalMargin, (1 - verticalMargin) * yUnitsPerPixel / xUnitsPerPixel);
                }
                return;
            }

            if (xExpandOnly)
            {
                oldLimits.ExpandX(newLimits);
                axes.Set(oldLimits.x1, oldLimits.x2, null, null);
                axes.Zoom(1 - horizontalMargin, 1);
            }

            if (yExpandOnly)
            {
                oldLimits.ExpandY(newLimits);
                axes.Set(null, null, oldLimits.y1, oldLimits.y2);
                axes.Zoom(1, 1 - verticalMargin);
            }

            if ((!xExpandOnly) && (!yExpandOnly))
            {
                axes.Set(newLimits);
                axes.Zoom(1 - horizontalMargin, 1 - verticalMargin);
            }
        }
示例#3
0
 public AxisLimits2D(AxisLimits2D source)
 {
     x1 = source.x1;
     x2 = source.x2;
     y1 = source.y1;
     y2 = source.y2;
 }
示例#4
0
 public void ExpandX(AxisLimits2D source)
 {
     if (source != null)
     {
         ExpandX(source.x1, source.x2);
     }
 }
示例#5
0
        public void AxisAuto(
            double horizontalMargin = .1, double verticalMargin = .1,
            bool xExpandOnly        = false, bool yExpandOnly   = false,
            bool autoX = true, bool autoY = true
            )
        {
            var oldLimits = new Config.AxisLimits2D(axes.ToArray());
            var newLimits = new Config.AxisLimits2D();

            foreach (var plottable in plottables)
            {
                Config.AxisLimits2D plottableLimits = plottable.GetLimits();
                if (autoX && !yExpandOnly)
                {
                    newLimits.ExpandX(plottableLimits);
                }
                if (autoY && !xExpandOnly)
                {
                    newLimits.ExpandY(plottableLimits);
                }
            }

            newLimits.MakeRational();

            if (xExpandOnly)
            {
                oldLimits.ExpandX(newLimits);
                axes.Set(oldLimits.x1, oldLimits.x2, null, null);
                axes.Zoom(1 - horizontalMargin, 1);
            }

            if (yExpandOnly)
            {
                oldLimits.ExpandY(newLimits);
                axes.Set(null, null, oldLimits.y1, oldLimits.y2);
                axes.Zoom(1, 1 - verticalMargin);
            }

            if ((!xExpandOnly) && (!yExpandOnly))
            {
                axes.Set(newLimits);
                axes.Zoom(1 - horizontalMargin, 1 - verticalMargin);
            }
        }
示例#6
0
        public void Resize(int width, int height, bool useMeasuredStrings = false)
        {
            if (useMeasuredStrings && gfxData != null)
            {
                // this section was added before display scaling issues (pixel-referenced font sizes) were figured out.
                // it is probably not needed...

                string sampleString = "IPjg8.8";
                layout.yLabelWidth  = (int)gfxData.MeasureString(sampleString, yLabel.font).Height;
                layout.y2LabelWidth = (int)gfxData.MeasureString(sampleString, yLabel.font).Height; // currently y2 isn't supported
                layout.titleHeight  = (int)gfxData.MeasureString(sampleString, title.font).Height;
                layout.xLabelHeight = (int)gfxData.MeasureString(sampleString, xLabel.font).Height;

                var tickSize = gfxData.MeasureString("0.001", ticks.font);
                layout.yScaleWidth  = (int)tickSize.Width;
                layout.y2ScaleWidth = (int)tickSize.Height; // currently y2 isn't supported
                layout.xScaleHeight = (int)tickSize.Height;
            }

            layout.Update(width, height);

            if (axes.equalAxes)
            {
                var limits = new Config.AxisLimits2D(axes.ToArray());

                double xUnitsPerPixel = limits.xSpan / dataSize.Width;
                double yUnitsPerPixel = limits.ySpan / dataSize.Height;

                if (yUnitsPerPixel > xUnitsPerPixel)
                {
                    axes.Zoom(xUnitsPerPixel / yUnitsPerPixel, 1);
                }
                else
                {
                    axes.Zoom(1, yUnitsPerPixel / xUnitsPerPixel);
                }
            }
        }
示例#7
0
 public void Set(AxisLimits2D limits)
 {
     limits.MakeRational();
     Set(limits.x1, limits.x2, limits.y1, limits.y2);
 }
示例#8
0
 public void SetX(AxisLimits2D source)
 {
     SetX(source.x1, source.x2);
 }
示例#9
0
 public void ExpandXY(AxisLimits2D source)
 {
     ExpandX(source.x1, source.x2);
     ExpandY(source.y1, source.y2);
 }
示例#10
0
 public void ExpandX(AxisLimits2D source)
 {
     ExpandX(source.x1, source.x2);
 }
示例#11
0
 public void SetY(AxisLimits2D source)
 {
     SetY(source.y1, source.y2);
 }