int MeasureTicksSize(TickEnumerator e, AxisDimension ad)
        {
            int max = 0;

            Pango.Layout layout = new Pango.Layout(this.PangoContext);
            layout.FontDescription = Pango.FontDescription.FromString("Tahoma 8");

            double start = GetStart(ad);
            double end   = GetEnd(ad);

            e.Init(GetOrigin(ad));

            while (e.CurrentValue > start)
            {
                e.MovePrevious();
            }

            for ( ; e.CurrentValue <= end; e.MoveNext())
            {
                int tw = 0, th = 0;

                layout.SetMarkup(e.CurrentLabel);
                layout.GetPixelSize(out tw, out th);

                if (ad == AxisDimension.X)
                {
                    if (th > max)
                    {
                        max = th;
                    }
                }
                else
                {
                    if (tw > max)
                    {
                        max = tw;
                    }
                }
            }
            return(max);
        }
예제 #2
0
파일: BasicChart.cs 프로젝트: Clancey/xwt
        double MeasureTicksSize(Context ctx, TickEnumerator e, AxisDimension ad)
        {
            double     max    = 0;
            TextLayout layout = new TextLayout(ctx);

            layout.Font = chartFont;

            double start = GetStart(ad);
            double end   = GetEnd(ad);

            e.Init(GetOrigin(ad));

            while (e.CurrentValue > start)
            {
                e.MovePrevious();
            }

            for ( ; e.CurrentValue <= end; e.MoveNext())
            {
                layout.Text = e.CurrentLabel;
                Size ts = layout.GetSize();

                if (ad == AxisDimension.X)
                {
                    if (ts.Height > max)
                    {
                        max = ts.Height;
                    }
                }
                else
                {
                    if (ts.Width > max)
                    {
                        max = ts.Width;
                    }
                }
            }
            return(max);
        }
예제 #3
0
        void GetValueRange(AxisDimension ad, out double min, out double max)
        {
            min = double.MaxValue;
            max = double.MinValue;

            foreach (Serie serie in series)
            {
                if (!serie.HasData || !serie.Visible)
                {
                    continue;
                }

                double lmin, lmax;
                serie.GetRange(ad, out lmin, out lmax);
                if (lmin < min)
                {
                    min = lmin;
                }
                if (lmax > max)
                {
                    max = lmax;
                }
            }
        }
예제 #4
0
		public void AddCursor (ChartCursor cursor, AxisDimension dimension)
		{
			widget.AddCursor (cursor, dimension);
		}
예제 #5
0
 public void SetAutoScale(AxisDimension ad, bool autoStart, bool autoEnd)
 {
     widget.SetAutoScale(ad, autoStart, autoEnd);
 }
예제 #6
0
        int MeasureTicksSize(TickEnumerator e, AxisDimension ad)
        {
            int max = 0;
            Pango.Layout layout = new Pango.Layout (this.PangoContext);
            layout.FontDescription = Pango.FontDescription.FromString ("Tahoma 8");

            double start = GetStart (ad);
            double end = GetEnd (ad);

            e.Init (GetOrigin (ad));

            while (e.CurrentValue > start)
                e.MovePrevious ();

            for ( ; e.CurrentValue <= end; e.MoveNext ())
            {
                int tw = 0, th = 0;

                layout.SetMarkup (e.CurrentLabel);
                layout.GetPixelSize (out tw, out th);

                if (ad == AxisDimension.X) {
                    if (th > max)
                        max = th;
                } else {
                    if (tw > max)
                        max = tw;
                }
            }
            return max;
        }
예제 #7
0
 string GetValueLabel(AxisDimension ad, double value)
 {
     foreach (Axis ax in axis)
         if (ax.Dimension == ad)
             return ax.GetValueLabel (value);
     return null;
 }
예제 #8
0
 double GetOrigin(AxisDimension ad)
 {
     if (ad == AxisDimension.X)
         return OriginX;
     else
         return OriginY;
 }
예제 #9
0
 double GetEnd(AxisDimension ad)
 {
     if (ad == AxisDimension.X)
         return endX;
     else
         return endY;
 }
예제 #10
0
		public void GetRange (AxisDimension axis, out double min, out double max)
		{
			min = double.MaxValue;
			max = double.MinValue;
			foreach (Data d in dataArray) {
				double v = d.GetValue (axis);
				if (v > max) max = v;
				if (v < min) min = v;
			}
		}
예제 #11
0
파일: BasicChart.cs 프로젝트: m13253/xwt
		double MeasureTicksSize (Context ctx, TickEnumerator e, AxisDimension ad)
		{
			double max = 0;
			TextLayout layout = new TextLayout ();
			layout.Font = chartFont;
			
			double start = GetStart (ad);
			double end = GetEnd (ad);
			
			e.Init (GetOrigin (ad));
			
			while (e.CurrentValue > start)
				e.MovePrevious ();
			
			for ( ; e.CurrentValue <= end; e.MoveNext ())
			{
				layout.Text = e.CurrentLabel;
				Size ts = layout.GetSize ();
				
				if (ad == AxisDimension.X) {
					if (ts.Height > max)
						max = ts.Height;
				} else {
					if (ts.Width > max)
						max = ts.Width;
				}
			}
			return max;
		}
예제 #12
0
파일: BasicChart.cs 프로젝트: m13253/xwt
		void DrawTicks (Context ctx, TickEnumerator e, AxisPosition pos, AxisDimension ad, int tickSize, bool showLabels)
		{
			double rheight = Bounds.Height;
			
			TextLayout layout = null;
			
			if (showLabels) {
				layout = new TextLayout ();
				layout.Font = chartFont;
			}
			
			bool isX = pos == AxisPosition.Top || pos == AxisPosition.Bottom;
			bool isTop = pos == AxisPosition.Top || pos == AxisPosition.Right;
			
			double start = GetStart (ad);
			double end = GetEnd (ad);
			
			e.Init (GetOrigin (ad));
			
			while (e.CurrentValue > start)
				e.MovePrevious ();
			
			double lastPosLabel;
			double lastPos;
			double lastTw = 0;
			
			if (isX) {
				lastPosLabel = reverseXAxis ? left + width + MinLabelGapX : left - MinLabelGapX;
				lastPos = left - minTickStep*2;
			}
			else {
				lastPosLabel = reverseYAxis ? top - MinLabelGapY : rheight + MinLabelGapY;
				lastPos = top + height + minTickStep*2;
			}
			
			for ( ; e.CurrentValue <= end; e.MoveNext ())
			{
				double px, py;
				double tw = 0, th = 0;
				int tick = tickSize;
				
				GetPoint (e.CurrentValue, e.CurrentValue, out px, out py);
				
				if (showLabels) {
					layout.Text = e.CurrentLabel;
					var ts = layout.GetSize ();
					tw = ts.Width;
					th = ts.Height;
				}

				if (isX) {
					if (Math.Abs ((long)px - (long)lastPos) < minTickStep || px < left || px > left + width)
						continue;
					lastPos = px;
					
					bool labelFits = false;
					if ((Math.Abs (px - lastPosLabel) - (tw/2) - (lastTw/2)) >= MinLabelGapX) {
						lastPosLabel = px;
						lastTw = tw;
						labelFits = true;
					}
					
					if (isTop) {
						if (showLabels) {
							if (labelFits)
								ctx.DrawTextLayout (layout, px - (tw/2), top - AreaBorderWidth - th);
							else
								tick = tick / 2;
						}
						ctx.MoveTo (px, top);
						ctx.LineTo (px, top + tick);
						ctx.Stroke ();
					}
					else {
						if (showLabels) {
							if (labelFits)
								ctx.DrawTextLayout (layout, px - (tw/2), top + height + AreaBorderWidth);
							else
								tick = tick / 2;
						}
						ctx.MoveTo (px, top + height);
						ctx.LineTo (px, top + height - tick);
						ctx.Stroke ();
					}
				}
				else {
					if (Math.Abs ((long)lastPos - (long)py) < minTickStep || py < top || py > top + height)
						continue;
					lastPos = py;
					
					bool labelFits = false;
					if ((Math.Abs (py - lastPosLabel) - (th/2) - (lastTw/2)) >= MinLabelGapY) {
						lastPosLabel = py;
						lastTw = th;
						labelFits = true;
					}
					
					if (isTop) {
						if (showLabels) {
							if (labelFits)
								ctx.DrawTextLayout (layout, left + width + AreaBorderWidth + 1, py - (th/2));
							else
								tick = tick / 2;
						}
						ctx.MoveTo (left + width, py);
						ctx.LineTo (left + width - tick, py);
						ctx.Stroke ();
					}
					else {
						if (showLabels) {
							if (labelFits)
								ctx.DrawTextLayout (layout, left - AreaBorderWidth - tw - 1, py - (th/2));
							else
								tick = tick / 2;
						}
						ctx.MoveTo (left, py);
						ctx.LineTo (left + tick, py);
						ctx.Stroke ();
					}
				}
			}
		}
 private double GetValue(IRun run, AxisDimension axisDimension) {
   double value = double.NaN;
   switch (axisDimension) {
     case AxisDimension.Index: {
         value = runToIndexMapping[run];
         break;
       }
     default: {
         throw new ArgumentException("No handling strategy for " + axisDimension.ToString() + " is defined.");
       }
   }
   return value;
 }
예제 #14
0
		public void SetAutoScale (AxisDimension ad, bool autoStart, bool autoEnd)
		{
			widget.SetAutoScale (ad, autoStart, autoEnd);
		}
예제 #15
0
        void DrawTicks(Gdk.Window win, Gdk.GC gc, TickEnumerator e, AxisPosition pos, AxisDimension ad, int tickSize, bool showLabels)
        {
            int rwidth, rheight;
            win.GetSize (out rwidth, out rheight);

            Pango.Layout layout = null;

            if (showLabels) {
                layout = new Pango.Layout (this.PangoContext);
                layout.FontDescription = Pango.FontDescription.FromString ("Tahoma 8");
            }

            bool isX = pos == AxisPosition.Top || pos == AxisPosition.Bottom;
            bool isTop = pos == AxisPosition.Top || pos == AxisPosition.Right;

            double start = GetStart (ad);
            double end = GetEnd (ad);

            e.Init (GetOrigin (ad));

            while (e.CurrentValue > start)
                e.MovePrevious ();

            int lastPosLabel;
            int lastPos;
            int lastTw = 0;

            if (isX) {
                lastPosLabel = reverseXAxis ? left + width + MinLabelGapX : left - MinLabelGapX;
                lastPos = left - minTickStep*2;
            }
            else {
                lastPosLabel = reverseYAxis ? top - MinLabelGapY : rheight + MinLabelGapY;
                lastPos = top + height + minTickStep*2;
            }

            for ( ; e.CurrentValue <= end; e.MoveNext ())
            {
                int px, py;
                int tw = 0, th = 0;
                int tick = tickSize;

                GetPoint (e.CurrentValue, e.CurrentValue, out px, out py);

                if (showLabels) {
                    layout.SetMarkup (e.CurrentLabel);
                    layout.GetPixelSize (out tw, out th);
                }

                if (isX) {
                    if (Math.Abs ((long)px - (long)lastPos) < minTickStep || px < left || px > left + width)
                        continue;
                    lastPos = px;

                    bool labelFits = false;
                    if ((Math.Abs (px - lastPosLabel) - (tw/2) - (lastTw/2)) >= MinLabelGapX) {
                        lastPosLabel = px;
                        lastTw = tw;
                        labelFits = true;
                    }

                    if (isTop) {
                        if (showLabels) {
                            if (labelFits)
                                win.DrawLayout (gc, px - (tw/2), top - AreaBorderWidth - th, layout);
                            else
                                tick = tick / 2;
                        }
                        win.DrawLine (gc, px, top, px, top + tick);
                    }
                    else {
                        if (showLabels) {
                            if (labelFits)
                                win.DrawLayout (gc, px - (tw/2), top + height + AreaBorderWidth, layout);
                            else
                                tick = tick / 2;
                        }
                        win.DrawLine (gc, px, top + height, px, top + height - tick);
                    }
                }
                else {
                    if (Math.Abs ((long)lastPos - (long)py) < minTickStep || py < top || py > top + height)
                        continue;
                    lastPos = py;

                    bool labelFits = false;
                    if ((Math.Abs (py - lastPosLabel) - (th/2) - (lastTw/2)) >= MinLabelGapY) {
                        lastPosLabel = py;
                        lastTw = th;
                        labelFits = true;
                    }

                    if (isTop) {
                        if (showLabels) {
                            if (labelFits)
                                win.DrawLayout (gc, left + width + AreaBorderWidth + 1, py - (th/2), layout);
                            else
                                tick = tick / 2;
                        }
                        win.DrawLine (gc, left + width, py, left + width - tick, py);
                    }
                    else {
                        if (showLabels) {
                            if (labelFits)
                                win.DrawLayout (gc, left - AreaBorderWidth - tw - 1, py - (th/2), layout);
                            else
                                tick = tick / 2;
                        }
                        win.DrawLine (gc, left, py, left + tick, py);
                    }
                }
            }
        }
예제 #16
0
 int GetAreaSize(AxisDimension ad)
 {
     if (ad == AxisDimension.X)
         return width;
     else
         return height;
 }
예제 #17
0
		public double GetValue (AxisDimension a) {
			if (a == AxisDimension.X) return x;
			else return y;
		}
예제 #18
0
 double GetMinTickStep(AxisDimension ad)
 {
     return (((double) minTickStep) * (GetEnd (ad) - GetStart (ad))) / (double) GetAreaSize (ad);
 }
 private double GetValue(IRun run, AxisDimension axisDimension) {
   double value = double.NaN;
   switch (axisDimension) {
     case AxisDimension.Color: {
         value = GetCategoricalValue(-1, run.Color.ToString());
         break;
       }
     default: {
         throw new ArgumentException("No handling strategy for " + axisDimension + " is defined.");
       }
   }
   return value;
 }
예제 #20
0
 double GetStart(AxisDimension ad)
 {
     if (ad == AxisDimension.X)
         return startX;
     else
         return startY;
 }
예제 #21
0
파일: BasicChart.cs 프로젝트: Clancey/xwt
        void DrawTicks(Context ctx, TickEnumerator e, AxisPosition pos, AxisDimension ad, int tickSize, bool showLabels)
        {
            double rheight = Bounds.Height;

            TextLayout layout = null;

            if (showLabels)
            {
                layout      = new TextLayout(ctx);
                layout.Font = chartFont;
            }

            bool isX   = pos == AxisPosition.Top || pos == AxisPosition.Bottom;
            bool isTop = pos == AxisPosition.Top || pos == AxisPosition.Right;

            double start = GetStart(ad);
            double end   = GetEnd(ad);

            e.Init(GetOrigin(ad));

            while (e.CurrentValue > start)
            {
                e.MovePrevious();
            }

            double lastPosLabel;
            double lastPos;
            double lastTw = 0;

            if (isX)
            {
                lastPosLabel = reverseXAxis ? left + width + MinLabelGapX : left - MinLabelGapX;
                lastPos      = left - minTickStep * 2;
            }
            else
            {
                lastPosLabel = reverseYAxis ? top - MinLabelGapY : rheight + MinLabelGapY;
                lastPos      = top + height + minTickStep * 2;
            }

            for ( ; e.CurrentValue <= end; e.MoveNext())
            {
                double px, py;
                double tw = 0, th = 0;
                int    tick = tickSize;

                GetPoint(e.CurrentValue, e.CurrentValue, out px, out py);

                if (showLabels)
                {
                    layout.Text = e.CurrentLabel;
                    var ts = layout.GetSize();
                    tw = ts.Width;
                    th = ts.Height;
                }

                if (isX)
                {
                    if (Math.Abs((long)px - (long)lastPos) < minTickStep || px < left || px > left + width)
                    {
                        continue;
                    }
                    lastPos = px;

                    bool labelFits = false;
                    if ((Math.Abs(px - lastPosLabel) - (tw / 2) - (lastTw / 2)) >= MinLabelGapX)
                    {
                        lastPosLabel = px;
                        lastTw       = tw;
                        labelFits    = true;
                    }

                    if (isTop)
                    {
                        if (showLabels)
                        {
                            if (labelFits)
                            {
                                ctx.DrawTextLayout(layout, px - (tw / 2), top - AreaBorderWidth - th);
                            }
                            else
                            {
                                tick = tick / 2;
                            }
                        }
                        ctx.MoveTo(px, top);
                        ctx.LineTo(px, top + tick);
                        ctx.Stroke();
                    }
                    else
                    {
                        if (showLabels)
                        {
                            if (labelFits)
                            {
                                ctx.DrawTextLayout(layout, px - (tw / 2), top + height + AreaBorderWidth);
                            }
                            else
                            {
                                tick = tick / 2;
                            }
                        }
                        ctx.MoveTo(px, top + height);
                        ctx.LineTo(px, top + height - tick);
                        ctx.Stroke();
                    }
                }
                else
                {
                    if (Math.Abs((long)lastPos - (long)py) < minTickStep || py < top || py > top + height)
                    {
                        continue;
                    }
                    lastPos = py;

                    bool labelFits = false;
                    if ((Math.Abs(py - lastPosLabel) - (th / 2) - (lastTw / 2)) >= MinLabelGapY)
                    {
                        lastPosLabel = py;
                        lastTw       = th;
                        labelFits    = true;
                    }

                    if (isTop)
                    {
                        if (showLabels)
                        {
                            if (labelFits)
                            {
                                ctx.DrawTextLayout(layout, left + width + AreaBorderWidth + 1, py - (th / 2));
                            }
                            else
                            {
                                tick = tick / 2;
                            }
                        }
                        ctx.MoveTo(left + width, py);
                        ctx.LineTo(left + width - tick, py);
                        ctx.Stroke();
                    }
                    else
                    {
                        if (showLabels)
                        {
                            if (labelFits)
                            {
                                ctx.DrawTextLayout(layout, left - AreaBorderWidth - tw - 1, py - (th / 2));
                            }
                            else
                            {
                                tick = tick / 2;
                            }
                        }
                        ctx.MoveTo(left, py);
                        ctx.LineTo(left + tick, py);
                        ctx.Stroke();
                    }
                }
            }
        }
예제 #22
0
        void GetValueRange(AxisDimension ad, out double min, out double max)
        {
            min = double.MaxValue;
            max = double.MinValue;

            foreach (Serie serie in series) {
                if (!serie.HasData || !serie.Visible)
                    continue;

                double lmin, lmax;
                serie.GetRange (ad, out lmin, out lmax);
                if (lmin < min) min = lmin;
                if (lmax > max) max = lmax;
            }
        }
    private double? GetValue(IRun run, AxisDimension axisDimension) {
      double? value = double.NaN;
      switch (axisDimension) {
        case AxisDimension.Color: {
            const int colorDimension = -1;
            if (!categoricalMapping.ContainsKey(colorDimension)) {
              categoricalMapping[colorDimension] = Content.Where(r => r.Visible)
                  .Select(r => r.Color.Name)
                  .Distinct()
                  .OrderBy(c => c, new NaturalStringComparer())
                  .Select((c, i) => new { Color = c, Index = i })
                  .ToDictionary(a => (object)a.Color, a => (double)a.Index);

            }
            value = GetCategoricalValue(colorDimension, run.Color.Name);
            break;
          }
        default: {
            throw new ArgumentException("No handling strategy for " + axisDimension.ToString() + " is defined.");
          }
      }
      return value;
    }
예제 #24
0
 public void AddCursor(ChartCursor cursor, AxisDimension dimension)
 {
     widget.AddCursor(cursor, dimension);
 }
예제 #25
0
 public void AddCursor(ChartCursor cursor, AxisDimension dimension)
 {
     cursor.Dimension = dimension;
     cursor.ValueChanged += new EventHandler (OnCursorChanged);
     cursor.LayoutChanged += new EventHandler (OnCursorChanged);
     cursors.Add (cursor);
     xrangeChanged = yrangeChanged = true;
     QueueDraw ();
 }
예제 #26
0
 double GetMinTickStep(AxisDimension ad)
 {
     return((((double)minTickStep) * (GetEnd(ad) - GetStart(ad))) / (double)GetAreaSize(ad));
 }
예제 #27
0
 public void SetAutoScale(AxisDimension ad, bool autoStart, bool autoEnd)
 {
     if (ad == AxisDimension.X) {
         autoStartX = autoStart;
         autoEndX = autoEnd;
     } else {
         autoStartY = autoStart;
         autoEndY = autoEnd;
     }
 }
예제 #28
0
        void DrawTicks(Gdk.Window win, Gdk.GC gc, TickEnumerator e, AxisPosition pos, AxisDimension ad, int tickSize, bool showLabels)
        {
            int rwidth, rheight;

            win.GetSize(out rwidth, out rheight);

            Pango.Layout layout = null;

            if (showLabels)
            {
                layout = new Pango.Layout(this.PangoContext);
                layout.FontDescription = Pango.FontDescription.FromString("Tahoma 8");
            }

            bool isX   = pos == AxisPosition.Top || pos == AxisPosition.Bottom;
            bool isTop = pos == AxisPosition.Top || pos == AxisPosition.Right;

            double start = GetStart(ad);
            double end   = GetEnd(ad);

            e.Init(GetOrigin(ad));

            while (e.CurrentValue > start)
            {
                e.MovePrevious();
            }

            int lastPosLabel;
            int lastPos;
            int lastTw = 0;

            if (isX)
            {
                lastPosLabel = reverseXAxis ? left + width + MinLabelGapX : left - MinLabelGapX;
                lastPos      = left - minTickStep * 2;
            }
            else
            {
                lastPosLabel = reverseYAxis ? top - MinLabelGapY : rheight + MinLabelGapY;
                lastPos      = top + height + minTickStep * 2;
            }

            for ( ; e.CurrentValue <= end; e.MoveNext())
            {
                int px, py;
                int tw = 0, th = 0;
                int tick = tickSize;

                GetPoint(e.CurrentValue, e.CurrentValue, out px, out py);

                if (showLabels)
                {
                    layout.SetMarkup(e.CurrentLabel);
                    layout.GetPixelSize(out tw, out th);
                }

                if (isX)
                {
                    if (Math.Abs((long)px - (long)lastPos) < minTickStep || px < left || px > left + width)
                    {
                        continue;
                    }
                    lastPos = px;

                    bool labelFits = false;
                    if ((Math.Abs(px - lastPosLabel) - (tw / 2) - (lastTw / 2)) >= MinLabelGapX)
                    {
                        lastPosLabel = px;
                        lastTw       = tw;
                        labelFits    = true;
                    }

                    if (isTop)
                    {
                        if (showLabels)
                        {
                            if (labelFits)
                            {
                                win.DrawLayout(gc, px - (tw / 2), top - AreaBorderWidth - th, layout);
                            }
                            else
                            {
                                tick = tick / 2;
                            }
                        }
                        win.DrawLine(gc, px, top, px, top + tick);
                    }
                    else
                    {
                        if (showLabels)
                        {
                            if (labelFits)
                            {
                                win.DrawLayout(gc, px - (tw / 2), top + height + AreaBorderWidth, layout);
                            }
                            else
                            {
                                tick = tick / 2;
                            }
                        }
                        win.DrawLine(gc, px, top + height, px, top + height - tick);
                    }
                }
                else
                {
                    if (Math.Abs((long)lastPos - (long)py) < minTickStep || py < top || py > top + height)
                    {
                        continue;
                    }
                    lastPos = py;

                    bool labelFits = false;
                    if ((Math.Abs(py - lastPosLabel) - (th / 2) - (lastTw / 2)) >= MinLabelGapY)
                    {
                        lastPosLabel = py;
                        lastTw       = th;
                        labelFits    = true;
                    }

                    if (isTop)
                    {
                        if (showLabels)
                        {
                            if (labelFits)
                            {
                                win.DrawLayout(gc, left + width + AreaBorderWidth + 1, py - (th / 2), layout);
                            }
                            else
                            {
                                tick = tick / 2;
                            }
                        }
                        win.DrawLine(gc, left + width, py, left + width - tick, py);
                    }
                    else
                    {
                        if (showLabels)
                        {
                            if (labelFits)
                            {
                                win.DrawLayout(gc, left - AreaBorderWidth - tw - 1, py - (th / 2), layout);
                            }
                            else
                            {
                                tick = tick / 2;
                            }
                        }
                        win.DrawLine(gc, left, py, left + tick, py);
                    }
                }
            }
        }
예제 #29
0
 protected AxisModel(AxisDimension dimension, string label, IEnumerable <AxisTickModel> ticks)
 {
     Dimension = dimension;
     Label     = label;
     _ticks    = new List <AxisTickModel>(ticks);
 }