public TickEnumerator GetTickEnumerator(double minTickStep) { TickEnumerator e = CreateTickEnumerator(minTickStep); e.axis = this; return(e); }
public TickEnumerator GetTickEnumerator(double minTickStep) { TickEnumerator e = CreateTickEnumerator(minTickStep); if (e != null) { e.axis = this; } return(e); }
void DrawCursorLabel(Context ctx, ChartCursor cursor) { ctx.SetColor(cursor.Color); int x, y; GetPoint(cursor.Value, cursor.Value, out x, out y); if (cursor.Dimension == AxisDimension.X) { string text; if (cursor.LabelAxis != null) { double minStep = GetMinTickStep(cursor.Dimension); TickEnumerator tenum = cursor.LabelAxis.GetTickEnumerator(minStep); tenum.Init(cursor.Value); text = tenum.CurrentLabel; } else { text = GetValueLabel(cursor.Dimension, cursor.Value); } if (text != null && text.Length > 0) { TextLayout layout = new TextLayout(ctx); layout.Font = chartFont; layout.Text = text; Size ts = layout.GetSize(); double tl = x - ts.Width / 2; double tt = top + 4; if (tl + ts.Width + 2 >= left + width) { tl = left + width - ts.Width - 1; } if (tl < left + 1) { tl = left + 1; } ctx.SetColor(Colors.White); ctx.Rectangle(tl - 1, tt - 1, ts.Width + 2, ts.Height + 2); ctx.Fill(); ctx.Rectangle(tl - 2, tt - 2, ts.Width + 3, ts.Height + 3); ctx.SetColor(Colors.Black); ctx.DrawTextLayout(layout, tl, tt); } } else { throw new NotSupportedException(); } }
void DrawCursorLabel(ChartCursor cursor) { using (Gdk.GC gc = new Gdk.GC(GdkWindow)) { gc.RgbFgColor = cursor.Color; int x, y; GetPoint(cursor.Value, cursor.Value, out x, out y); if (cursor.Dimension == AxisDimension.X) { string text; if (cursor.LabelAxis != null) { double minStep = GetMinTickStep(cursor.Dimension); TickEnumerator tenum = cursor.LabelAxis.GetTickEnumerator(minStep); tenum.Init(cursor.Value); text = tenum.CurrentLabel; } else { text = GetValueLabel(cursor.Dimension, cursor.Value); } if (text != null && text.Length > 0) { Pango.Layout layout = new Pango.Layout(this.PangoContext); layout.FontDescription = IdeServices.FontService.SansFont.CopyModified(Ide.Gui.Styles.FontScale11); layout.SetMarkup(text); int tw, th; layout.GetPixelSize(out tw, out th); int tl = x - tw / 2; int tt = top + 4; if (tl + tw + 2 >= left + width) { tl = left + width - tw - 1; } if (tl < left + 1) { tl = left + 1; } GdkWindow.DrawRectangle(Style.WhiteGC, true, tl - 1, tt - 1, tw + 2, th + 2); GdkWindow.DrawRectangle(Style.BlackGC, false, tl - 2, tt - 2, tw + 3, th + 3); GdkWindow.DrawLayout(gc, tl, tt, layout); layout.Dispose(); } } else { throw new NotSupportedException(); } } }
int MeasureTicksSize(TickEnumerator e, AxisDimension ad) { int max = 0; Pango.Layout layout = new Pango.Layout(this.PangoContext); layout.FontDescription = IdeServices.FontService.SansFont.CopyModified(Ide.Gui.Styles.FontScale11); 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; } } } layout.Dispose(); return(max); }
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); }
int MeasureAxisSize(Axis ax) { double minStep = GetMinTickStep(ax.Dimension); TickEnumerator enumSmall = ax.GetTickEnumerator(minStep); if (enumSmall == null) { return(0); } TickEnumerator enumBig = ax.GetTickEnumerator(minStep * 2); if (enumBig == null) { return(MeasureTicksSize(enumSmall, ax.Dimension)); } else { return(MeasureTicksSize(enumBig, ax.Dimension)); } }
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); }
void DrawAxis(Gdk.Window win, Gdk.GC gc, Axis ax) { double minStep = GetMinTickStep(ax.Dimension); TickEnumerator enumSmall = ax.GetTickEnumerator(minStep); if (enumSmall == null) { return; } TickEnumerator enumBig = ax.GetTickEnumerator(minStep * 2); if (enumBig == null) { DrawTicks(win, gc, enumSmall, ax.Position, ax.Dimension, ax.TickSize, ax.ShowLabels); } else { DrawTicks(win, gc, enumSmall, ax.Position, ax.Dimension, ax.TickSize / 2, false); DrawTicks(win, gc, enumBig, ax.Position, ax.Dimension, ax.TickSize, ax.ShowLabels); } }
void DrawAxis(Context ctx, Axis ax) { ctx.SetLineWidth(1); double minStep = GetMinTickStep(ax.Dimension); TickEnumerator enumSmall = ax.GetTickEnumerator(minStep); if (enumSmall == null) { return; } TickEnumerator enumBig = ax.GetTickEnumerator(minStep * 2); if (enumBig == null) { DrawTicks(ctx, enumSmall, ax.Position, ax.Dimension, ax.TickSize, ax.ShowLabels); } else { DrawTicks(ctx, enumSmall, ax.Position, ax.Dimension, ax.TickSize / 2, false); DrawTicks(ctx, enumBig, ax.Position, ax.Dimension, ax.TickSize, ax.ShowLabels); } }
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); } } } }
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; }
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); } } } }
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(); } } } }
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; }
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 (); } } } }