[chronojump] Refactorized cairo jumpsEvolution.cs to allow run simple evolution graph
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Refactorized cairo jumpsEvolution.cs to allow run simple evolution graph
- Date: Wed, 21 Apr 2021 05:50:47 +0000 (UTC)
commit d4182253e176dc238dac33f74968a9ea1ca38e30
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Apr 21 07:42:09 2021 +0200
Refactorized cairo jumpsEvolution.cs to allow run simple evolution graph
src/Makefile.am | 2 +-
.../{jumpsEvolution.cs => jumpsRunsEvolution.cs} | 0
.../{jumpsEvolution.cs => jumpsRunsEvolution.cs} | 124 ++++++++++++++-------
src/gui/cairo/xy.cs | 5 +-
src/{jumpsEvolution.cs => jumpsRunsEvolution.cs} | 0
5 files changed, 91 insertions(+), 40 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index ab85275f..ebc5da9b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -37,7 +37,7 @@ SOURCES = \
gui/app1/shortcuts.cs\
gui/cairo/generic.cs\
gui/cairo/jumpsDjOptimalFall.cs\
- gui/cairo/jumpsEvolution.cs\
+ gui/cairo/jumpsRunsEvolution.cs\
gui/cairo/jumpsProfile.cs\
gui/cairo/jumpsRjFatigue.cs\
gui/cairo/jumpsWeightFVProfile.cs\
diff --git a/src/gui/app1/jumpsEvolution.cs b/src/gui/app1/jumpsRunsEvolution.cs
similarity index 100%
rename from src/gui/app1/jumpsEvolution.cs
rename to src/gui/app1/jumpsRunsEvolution.cs
diff --git a/src/gui/cairo/jumpsEvolution.cs b/src/gui/cairo/jumpsRunsEvolution.cs
similarity index 74%
rename from src/gui/cairo/jumpsEvolution.cs
rename to src/gui/cairo/jumpsRunsEvolution.cs
index 990fb3e5..3deffbee 100644
--- a/src/gui/cairo/jumpsEvolution.cs
+++ b/src/gui/cairo/jumpsRunsEvolution.cs
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Copyright (C) 2004-2020 Xavier de Blas <xaviblas gmail com>
+ * Copyright (C) 2004-2021 Xavier de Blas <xaviblas gmail com>
*/
using System;
@@ -25,45 +25,11 @@ using Gtk;
using Cairo;
-public class JumpsEvolutionGraph : CairoXY
+public abstract class EvolutionGraph : CairoXY
{
- //constructor when there are no points
- public JumpsEvolutionGraph (DrawingArea area, string jumpType, string font)//, string title, string
jumpType, string date)
- {
- this.area = area;
-
- initGraph(font, .8);
-
- g.SetFontSize(16);
- printText(area.Allocation.Width /2, area.Allocation.Height /2, 24, textHeight,
- needToExecuteJumpsStr + " " + jumpType + ".", g, alignTypes.CENTER);
-
- endGraphDisposing(g);
- }
-
- //regular constructor
- public JumpsEvolutionGraph (
- List<PointF> point_l, double slope, double intercept,
- DrawingArea area, string title, string jumpType, string date)
- {
- this.point_l = point_l;
- this.slope = slope;
- this.intercept = intercept;
- this.area = area;
- this.title = title;
- this.jumpType = jumpType;
- this.date = date;
- this.colorBackground = colorFromGdk(Config.ColorBackground); //but note if we are using
system colors, this will not match
-
- xVariable = dateStr;
- yVariable = heightStr;
- xUnits = "";
- yUnits = "cm";
- }
-
public override void Do (string font)
{
- LogB.Information("at JumpsEvolutionGraph.Do");
+ LogB.Information("at Jumps or runs EvolutionGraph.Do");
initGraph(font, .8);
findPointMaximums(false);
@@ -91,7 +57,7 @@ public class JumpsEvolutionGraph : CairoXY
}
//a bit recursive function ;)
- private void paintGridDatetime()
+ protected void paintGridDatetime()
{
g.Save();
g.SetDash(new double[]{1, 2}, 0);
@@ -144,6 +110,43 @@ public class JumpsEvolutionGraph : CairoXY
g.Stroke ();
g.Restore();
}
+}
+
+public class JumpsEvolutionGraph : EvolutionGraph
+{
+ //constructor when there are no points
+ public JumpsEvolutionGraph (DrawingArea area, string jumpType, string font)//, string title, string
jumpType, string date)
+ {
+ this.area = area;
+
+ initGraph(font, .8);
+
+ g.SetFontSize(16);
+ printText(area.Allocation.Width /2, area.Allocation.Height /2, 24, textHeight,
+ needToExecuteJumpsStr + " " + jumpType + ".", g, alignTypes.CENTER);
+
+ endGraphDisposing(g);
+ }
+
+ //regular constructor
+ public JumpsEvolutionGraph (
+ List<PointF> point_l, double slope, double intercept,
+ DrawingArea area, string title, string jumpType, string date)
+ {
+ this.point_l = point_l;
+ this.slope = slope;
+ this.intercept = intercept;
+ this.area = area;
+ this.title = title;
+ this.jumpType = jumpType;
+ this.date = date;
+ this.colorBackground = colorFromGdk(Config.ColorBackground); //but note if we are using
system colors, this will not match
+
+ xVariable = dateStr;
+ yVariable = heightStr;
+ xUnits = "";
+ yUnits = "cm";
+ }
protected override void writeTitle()
{
@@ -153,5 +156,50 @@ public class JumpsEvolutionGraph : CairoXY
writeTextAtRight(ypos++, jumpTypeStr + " " + jumpType, false);
writeTextAtRight(ypos++, date, false);
}
+}
+public class RunsEvolutionGraph : EvolutionGraph
+{
+ //constructor when there are no points
+ public RunsEvolutionGraph (DrawingArea area, string runType, string font)//, string title, string
runType, string date)
+ {
+ this.area = area;
+
+ initGraph(font, .8);
+
+ g.SetFontSize(16);
+ printText(area.Allocation.Width /2, area.Allocation.Height /2, 24, textHeight,
+ needToExecuteRunsStr + " " + runType + ".", g, alignTypes.CENTER);
+
+ endGraphDisposing(g);
+ }
+
+ //regular constructor
+ public RunsEvolutionGraph (
+ List<PointF> point_l, double slope, double intercept,
+ DrawingArea area, string title, string runType, string date)
+ {
+ this.point_l = point_l;
+ this.slope = slope;
+ this.intercept = intercept;
+ this.area = area;
+ this.title = title;
+ this.runType = runType;
+ this.date = date;
+ this.colorBackground = colorFromGdk(Config.ColorBackground); //but note if we are using
system colors, this will not match
+
+ xVariable = dateStr;
+ yVariable = speedStr;
+ xUnits = "";
+ yUnits = "m/s"; //TODO: can be km/h depending on preferences
+ }
+
+ protected override void writeTitle()
+ {
+ int ypos = -6;
+
+ writeTextAtRight(ypos++, title, true);
+ writeTextAtRight(ypos++, runTypeStr + " " + runType, false);
+ writeTextAtRight(ypos++, date, false);
+ }
}
diff --git a/src/gui/cairo/xy.cs b/src/gui/cairo/xy.cs
index 4336925a..403ca8a1 100644
--- a/src/gui/cairo/xy.cs
+++ b/src/gui/cairo/xy.cs
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * Copyright (C) 2004-2020 Xavier de Blas <xaviblas gmail com>
+ * Copyright (C) 2004-2021 Xavier de Blas <xaviblas gmail com>
*/
using System;
@@ -50,6 +50,7 @@ public abstract class CairoXY : CairoGeneric
protected DrawingArea area;
protected string title;
protected string jumpType;
+ protected string runType;
protected string date;
protected Cairo.Color colorBackground;
@@ -88,6 +89,7 @@ public abstract class CairoXY : CairoGeneric
//done to use Catalog just only on gui/cairo/xy.cs
//but jumpsWeightFVProfile has many messages, so done also there
protected string needToExecuteJumpsStr = Catalog.GetString("Need to execute jumps:");
+ protected string needToExecuteRunsStr = Catalog.GetString("Need to execute races:");
protected string optimalFallHeightStr = Catalog.GetString("Optimal fall height");
protected string heightStr = Catalog.GetString("Height");
protected string extraWeightStr = Catalog.GetString("Extra weight");
@@ -101,6 +103,7 @@ public abstract class CairoXY : CairoGeneric
protected string tcStr = Catalog.GetString("TC");
protected string countStr = Catalog.GetString("Num");
protected string jumpTypeStr = Catalog.GetString("Jump type:");
+ protected string runTypeStr = Catalog.GetString("Race type:");
protected string font;
//protected static int lastPointPainted;
diff --git a/src/jumpsEvolution.cs b/src/jumpsRunsEvolution.cs
similarity index 100%
rename from src/jumpsEvolution.cs
rename to src/jumpsRunsEvolution.cs
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]