[chronojump] Better passing objects to CairoGraphs: GraphDo (added PassDataX methods)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Better passing objects to CairoGraphs: GraphDo (added PassDataX methods)
- Date: Wed, 23 Mar 2022 10:16:32 +0000 (UTC)
commit 394d6a9ae49be4d9b08f7599881b37a7c1d54c9a
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Mar 23 11:15:55 2022 +0100
Better passing objects to CairoGraphs: GraphDo (added PassDataX methods)
src/gui/cairo/bars.cs | 40 +++++++++++++++++++++++++++++++---------
src/gui/eventExecute.cs | 47 +++++++++++++++++++++++++----------------------
2 files changed, 56 insertions(+), 31 deletions(-)
---
diff --git a/src/gui/cairo/bars.cs b/src/gui/cairo/bars.cs
index 633f18f62..24e0f2b21 100644
--- a/src/gui/cairo/bars.cs
+++ b/src/gui/cairo/bars.cs
@@ -31,6 +31,7 @@ public abstract class CairoBars : CairoGeneric
protected int fontHeightForBottomNames;
protected int marginForBottomNames;
protected string title;
+ protected bool clickable;
//protected string jumpType;
//protected string runType;
protected string date;
@@ -249,10 +250,25 @@ public abstract class CairoBars : CairoGeneric
g.LineWidth = 1;
}
- public abstract void GraphDo (List<PointF> pointMain_l, List<List<PointF>> pointSecondary_ll, bool
mainAtLeft,
+ public virtual void PassData1Serie (List<PointF> pointMain_l,
+ List<Cairo.Color> colorMain_l, List<string> names_l,
+ int fontHeightForBottomNames, int marginForBottomNames, string title, bool clickable)
+ {
+ //defined in CairoBars1Series
+ }
+
+ public virtual void PassData2Series (List<PointF> pointMain_l, List<List<PointF>> pointSecondary_ll,
bool mainAtLeft,
+ List<Cairo.Color> colorMain_l, List<Cairo.Color> colorSecondary_l, List<string>
names_l,
+ string labelBarMain, string labelBarSecondary, bool labelRotateInFirstBar,
+ int fontHeightForBottomNames, int marginForBottomNames, string title, bool clickable)
+ {
+ //defined in CairoBarsNHSeries
+ }
+
+ public abstract void GraphDo();/* (List<PointF> pointMain_l, List<List<PointF>> pointSecondary_ll,
bool mainAtLeft,
List<Cairo.Color> colorMain_l, List<Cairo.Color> colorSecondary, List<string> names_l,
string labelBarMain, string labelBarSecondary, bool labelRotateInFirstBar,
- int fontHeightForBottomNames, int marginForBottomNames, string title, bool clickable);
+ int fontHeightForBottomNames, int marginForBottomNames, string title, bool
clickable);*/
protected void initGraph(string font, double widthPercent1)
{
@@ -790,21 +806,23 @@ public class CairoBars1Series : CairoBars
}
}
- public override void GraphDo (List<PointF> pointMain_l, List<List<PointF>> pointSecondary_ll, bool
mainAtLeft,
- List<Cairo.Color> colorMain_l, List<Cairo.Color> colorSecondary, List<string> names_l,
- string labelBarMain, string labelBarSecondary, bool labelRotateInFirstBar,
+ //done here and not in the constructor because most of this variables are known after construction
+ public override void PassData1Serie (List<PointF> pointMain_l,
+ List<Cairo.Color> colorMain_l, List<string> names_l,
int fontHeightForBottomNames, int marginForBottomNames, string title, bool clickable)
{
- LogB.Information("at CairoBars1Series.Do");
this.pointMain_l = pointMain_l;
- //this.pointSecondary_l = pointSecondary_l; //unused in this class
this.colorMain_l = colorMain_l;
- //this.colorSecondary_l = colorSecondary_l; //unused in this class
this.names_l = names_l;
this.fontHeightForBottomNames = fontHeightForBottomNames;
this.marginForBottomNames = marginForBottomNames;
this.title = title;
+ this.clickable = clickable;
+ }
+ public override void GraphDo ()
+ {
+ LogB.Information("at CairoBars1Series.Do");
LogB.Information(string.Format("bottomMargin pre: {0}, marginForBottomNames: {1}",
bottomMargin, marginForBottomNames));
bottomMargin += marginForBottomNames;
@@ -1147,7 +1165,8 @@ public class CairoBarsNHSeries : CairoBars
pAyStart = plotResultOnBar(p.X, p.Y, graphHeight -bottomMargin, p.Z,
resultFontHeight, barWidth, pAyStart);
}
- public override void GraphDo (List<PointF> pointMain_l, List<List<PointF>> pointSecondary_ll, bool
mainAtLeft,
+ //done here and not in the constructor because most of this variables are known after construction
+ public override void PassData2Series (List<PointF> pointMain_l, List<List<PointF>> pointSecondary_ll,
bool mainAtLeft,
List<Cairo.Color> colorMain_l, List<Cairo.Color> colorSecondary_l, List<string>
names_l,
string labelBarMain, string labelBarSecondary, bool labelRotateInFirstBar,
int fontHeightForBottomNames, int marginForBottomNames, string title, bool clickable)
@@ -1163,7 +1182,10 @@ public class CairoBarsNHSeries : CairoBars
this.fontHeightForBottomNames = fontHeightForBottomNames;
this.marginForBottomNames = marginForBottomNames;
this.title = title;
+ }
+ public override void GraphDo ()
+ {
bottomMargin += marginForBottomNames;
//LogB.Information(string.Format("NH GraphDo: pointA_l.Count: {0}, pointB_l.Count: {1}",
pointA_l.Count, pointB_l.Count));
diff --git a/src/gui/eventExecute.cs b/src/gui/eventExecute.cs
index c4abcf087..da7472e74 100644
--- a/src/gui/eventExecute.cs
+++ b/src/gui/eventExecute.cs
@@ -2637,20 +2637,20 @@ public class CairoPaintBarsPreJumpSimple : CairoPaintBarsPre
List<List<PointF>> pointSecondary_ll = new List<List<PointF>>();
pointSecondary_ll.Add(pointA_l);
- cb.GraphDo (pointB_l, pointSecondary_ll, false,
+ cb.PassData2Series (pointB_l, pointSecondary_ll, false,
new List<Cairo.Color>(), new List<Cairo.Color>(), names_l,
"", "", false,
fontHeightForBottomNames, bottomMargin, title, false);
} else if (showBarA) //takeOff, takeOffWeight
- cb.GraphDo (pointA_l, new List<List<PointF>>(), false,
- new List<Cairo.Color>(), new List<Cairo.Color>(), names_l,
- "", "", false,
+ cb.PassData1Serie (pointA_l,
+ new List<Cairo.Color>(), names_l,
fontHeightForBottomNames, bottomMargin, title, false);
else //rest of the jumps: sj, cmj, ..
- cb.GraphDo (pointB_l, new List<List<PointF>>(), false,
- new List<Cairo.Color>(), new List<Cairo.Color>(), names_l,
- "", "", false,
+ cb.PassData1Serie (pointB_l,
+ new List<Cairo.Color>(), names_l,
fontHeightForBottomNames, bottomMargin, title, false);
+
+ cb.GraphDo();
}
}
@@ -2776,10 +2776,11 @@ public class CairoPaintBarsPreJumpReactive : CairoPaintBarsPre
List<List<PointF>> pointSecondary_ll = new List<List<PointF>>();
pointSecondary_ll.Add(pointA1_l);
- cb.GraphDo (pointB_l, pointSecondary_ll, false,
+ cb.PassData2Series (pointB_l, pointSecondary_ll, false,
new List<Cairo.Color>(), new List<Cairo.Color>(), names_l,
"", "", false,
fontHeightForBottomNames, bottomMargin, title, false);
+ cb.GraphDo();
}
}
@@ -2877,10 +2878,10 @@ public class CairoPaintBarsPreRunSimple : CairoPaintBarsPre
eventGraphRunsStored.personAVGAtSQL,
eventGraphRunsStored.personMINAtSQL));
- cb.GraphDo (point_l, new List<List<PointF>>(), false,
- new List<Cairo.Color>(), new List<Cairo.Color>(), names_l,
- "", "", false,
+ cb.PassData1Serie (point_l,
+ new List<Cairo.Color>(), names_l,
fontHeightForBottomNames, bottomMargin, title, false);
+ cb.GraphDo();
}
}
@@ -2988,10 +2989,10 @@ public class CairoPaintBarsPreRunInterval : CairoPaintBarsPre
eventGraphRunsIntervalStored.personAVGAtSQL,
eventGraphRunsIntervalStored.personMINAtSQL));
- cb.GraphDo (point_l, new List<List<PointF>>(), false,
- new List<Cairo.Color>(), new List<Cairo.Color>(), names_l,
- "", "", false,
+ cb.PassData1Serie (point_l,
+ new List<Cairo.Color>(), names_l,
fontHeightForBottomNames, bottomMargin, title, false);
+ cb.GraphDo();
}
}
@@ -3117,10 +3118,11 @@ public class CairoPaintBarsPreJumpReactiveRealtimeCapture : CairoPaintBarsPre
List<List<PointF>> pointSecondary_ll = new List<List<PointF>>();
pointSecondary_ll.Add(pointA_l);
- cb.GraphDo (pointB_l, pointSecondary_ll, false,
+ cb.PassData2Series (pointB_l, pointSecondary_ll, false,
new List<Cairo.Color>(), new List<Cairo.Color>(), names_l,
"", "", false,
14, 8, title, false);
+ cb.GraphDo();
}
}
@@ -3289,10 +3291,10 @@ public class CairoPaintBarsPreRunIntervalRealtimeCapture : CairoPaintBarsPre
sum / speed_l.Count,
min));
- cb.GraphDo (point_l, new List<List<PointF>>(), false,
- new List<Cairo.Color>(), new List<Cairo.Color>(), names_l,
- "", "", false,
+ cb.PassData1Serie (point_l,
+ new List<Cairo.Color>(), names_l,
14, 22, title, false); //22 because there are two rows
+ cb.GraphDo();
}
}
@@ -3787,19 +3789,20 @@ public class CairoPaintBarplotPreEncoder : CairoPaintBarsPre
cb.Decs = decs;
if(pegbe.eccon == "c")
- cb.GraphDo (dataA_l, new List<List<PointF>>(), false,
- colorMain_l, new List<Cairo.Color>(), names_l,
- "", "", false,
+ cb.PassData1Serie (dataA_l,
+ colorMain_l, names_l,
14, 8, "my title", ! pegbe.capturing);
else {
List<List<PointF>> pointSecondary_ll = new List<List<PointF>>();
pointSecondary_ll.Add(dataA_l);
- cb.GraphDo (dataB_l, pointSecondary_ll, false,
+ cb.PassData2Series (dataB_l, pointSecondary_ll, false,
colorMain_l, colorSecondary_l, names_l,
"Ecc", "Con", true,
14, 8, "my title", ! pegbe.capturing);
}
+
+ cb.GraphDo();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]