[chronojump] Preferences refactoring to export/report. Now metersSecondsPreferred in report
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Preferences refactoring to export/report. Now metersSecondsPreferred in report
- Date: Mon, 1 Sep 2014 15:06:47 +0000 (UTC)
commit ce0b15bad328e5be56b087e1971be21565157591
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Sep 1 17:04:38 2014 +0200
Preferences refactoring to export/report. Now metersSecondsPreferred in report
src/exportSession.cs | 64 +++++++++++++++++-------------------------
src/gui/chronojump.cs | 14 ++-------
src/gui/report.cs | 6 +---
src/gui/stats.cs | 8 +----
src/report.cs | 45 +----------------------------
src/statType.cs | 68 ++++++++++++++++----------------------------
src/stats/main.cs | 10 +++---
src/stats/sjCmjAbkPlus.cs | 2 +-
8 files changed, 65 insertions(+), 152 deletions(-)
---
diff --git a/src/exportSession.cs b/src/exportSession.cs
index 3b11156..dc0ebc6 100644
--- a/src/exportSession.cs
+++ b/src/exportSession.cs
@@ -41,19 +41,17 @@ public class ExportSession
protected static Gtk.Window app1;
protected string fileName;
- protected int prefsDigitsNumber;
- public bool heightPreferred;
- public bool weightStatsPercent;
+ public Preferences preferences;
protected string spreadsheetString;
public ExportSession() {
}
- public ExportSession(Session mySession, Gtk.Window app1, int prefsDigitsNumber)
+ public ExportSession(Session mySession, Gtk.Window app1, Preferences preferences)
{
this.mySession = mySession;
- this.prefsDigitsNumber = prefsDigitsNumber;
+ this.preferences = preferences;
spreadsheetString = "";
@@ -250,10 +248,10 @@ public class ExportSession
protected void printJumps(string title)
{
- int dec=prefsDigitsNumber; //decimals
+ int dec=preferences.digitsNumber; //decimals
string weightName = Catalog.GetString("Weight");
- if(weightStatsPercent)
+ if(preferences.weightStatsPercent)
weightName += " %";
else
weightName += " Kg";
@@ -294,7 +292,7 @@ public class ExportSession
personWeight);
string myWeight = "";
- if(weightStatsPercent)
+ if(preferences.weightStatsPercent)
myWeight = myStr[8];
else
myWeight = weightInKg.ToString();
@@ -302,8 +300,7 @@ public class ExportSession
double fall = Convert.ToDouble(myStr[7]);
double tc = Convert.ToDouble(myStr[6]);
double tf = Convert.ToDouble(myStr[5]);
-
-
+
string power = "-";
if(tf > 0) {
if(tc > 0) //dj
@@ -320,7 +317,7 @@ public class ExportSession
Util.TrimDecimals(myWeight, dec) + ":" +
Util.TrimDecimals(Util.GetHeightInCentimeters(myStr[5]), dec)
+ ":" +
power + ":" +
- Util.TrimDecimals(Util.GetInitialSpeed(myStr[5], true), dec)
+ ":" + //true: m/s
+ Util.TrimDecimals(Util.GetInitialSpeed(myStr[5],
preferences.metersSecondsPreferred), dec) + ":" + //true: m/s
Util.RemoveNewLine(myStr[9], true) + ":" +
//jump.description
Util.TrimDecimals(myStr[10],dec) + ":" + //jump.angle
Util.SimulatedTestNoYes(Convert.ToInt32(myStr[11]))
//jump.simulated
@@ -336,7 +333,7 @@ public class ExportSession
protected void printJumpsRj(bool showSubjumps, string title)
{
- int dec=prefsDigitsNumber; //decimals
+ int dec=preferences.digitsNumber; //decimals
ArrayList myData = new ArrayList(1);
bool isFirstHeader = true;
@@ -352,7 +349,7 @@ public class ExportSession
}
string weightName = Catalog.GetString("Weight");
- if(weightStatsPercent)
+ if(preferences.weightStatsPercent)
weightName += " %";
else
weightName += " Kg";
@@ -387,7 +384,7 @@ public class ExportSession
string [] myStr = jump.Split(new char[] {':'});
string myWeight = "";
- if(weightStatsPercent)
+ if(preferences.weightStatsPercent)
myWeight = myStr[8];
else
myWeight = Util.WeightFromPercentToKg(
@@ -407,11 +404,13 @@ public class ExportSession
Util.TrimDecimals(myStr[6], dec) + ":" +
//jumpRj.tcMax
Util.TrimDecimals(myStr[5], dec) + ":" + //jumpRj.tvMax
Util.TrimDecimals(Util.GetHeightInCentimeters(myStr[5]), dec) + ":" +
//Max height
- Util.TrimDecimals(Util.GetInitialSpeed(myStr[5], true), dec) + ":" +
//Max initial speed (true:m/s)
+ Util.TrimDecimals(Util.GetInitialSpeed(
+ myStr[5], preferences.metersSecondsPreferred), dec) +
":" + //Max initial speed (true:m/s)
Util.TrimDecimals(myStr[11], dec) + ":" + //jumpRj.tcAvg
Util.TrimDecimals(myStr[10], dec) + ":" + //jumpRj.tvAvg
Util.TrimDecimals(Util.GetHeightInCentimeters(myStr[10]), dec) + ":"
+ //Avg height
- Util.TrimDecimals(Util.GetInitialSpeed(myStr[10], true), dec) + ":" +
//Avg Initial speed (true:m/s)
+ Util.TrimDecimals(Util.GetInitialSpeed(
+ myStr[10], preferences.metersSecondsPreferred), dec)
+ ":" + //Avg Initial speed (true:m/s)
myStr[7] + ":" + //jumpRj.Fall
//myStr[8] + ":" + myStr[14] + ":" + //jumpRj.Weight, jumpRj.Jumps
Util.TrimDecimals(myWeight,dec) + ":" + myStr[14] + ":" +
//jumpRj.Weight, jumpRj.Jumps
@@ -471,7 +470,7 @@ public class ExportSession
protected void printRuns(string title)
{
- int dec=prefsDigitsNumber; //decimals
+ int dec=preferences.digitsNumber; //decimals
if(myRuns.Length > 0) {
printTitles(title);
@@ -513,7 +512,7 @@ public class ExportSession
protected void printRunsInterval(bool showSubruns, string title)
{
- int dec=prefsDigitsNumber; //decimals
+ int dec=preferences.digitsNumber; //decimals
ArrayList myData = new ArrayList(1);
bool isFirstHeader = true;
@@ -620,7 +619,7 @@ public class ExportSession
protected void printReactionTimes(string title)
{
- int dec=prefsDigitsNumber; //decimals
+ int dec=preferences.digitsNumber; //decimals
if(myReactionTimes.Length > 0) {
printTitles(title);
@@ -656,7 +655,7 @@ public class ExportSession
//no need of bool because all the info is in the sub values
protected void printPulses(string title)
{
- int dec=prefsDigitsNumber; //decimals
+ int dec=preferences.digitsNumber; //decimals
ArrayList myData = new ArrayList(1);
@@ -718,7 +717,7 @@ public class ExportSession
protected void printMCs(string title)
{
- int dec=prefsDigitsNumber; //decimals
+ int dec=preferences.digitsNumber; //decimals
ArrayList myData = new ArrayList(1);
@@ -844,18 +843,7 @@ public class ExportSession
{
((IDisposable)writer).Dispose();
}
-
- public int PrefsDigitsNumber {
- set { prefsDigitsNumber = value; }
- }
-
- public bool HeightPreferred {
- set { heightPreferred = value; }
- }
-
- public bool WeightStatsPercent {
- set { weightStatsPercent = value; }
- }
+
~ExportSession() {}
}
@@ -864,10 +852,10 @@ public class ExportSession
public class ExportSessionCSV : ExportSession
{
- public ExportSessionCSV(Session mySession, Gtk.Window app1, int prefsDigitsNumber)
+ public ExportSessionCSV(Session mySession, Gtk.Window app1, Preferences preferences)
{
this.mySession = mySession;
- this.prefsDigitsNumber = prefsDigitsNumber;
+ this.preferences = preferences;
spreadsheetString = Constants.SpreadsheetString;
@@ -920,11 +908,11 @@ public class ExportSessionXML : ExportSession
{
private XmlTextWriter xr;
- public ExportSessionXML(Session mySession, Gtk.Window app1, int prefsDigitsNumber)
- //public ExportXML(Session mySession, Gtk.Window app1)
+ public ExportSessionXML(Session mySession, Gtk.Window app1, Preferences preferences)
{
this.mySession = mySession;
- this.prefsDigitsNumber = prefsDigitsNumber;
+ this.preferences = preferences;
+
//this.app1 = app1;
//xr = new XmlTextWriter(fileExport, null);
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index ac12a7e..09a9681 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -859,11 +859,7 @@ public partial class ChronoJumpWindow
// languageChange();
//pass to report
- report.PrefsDigitsNumber = preferences.digitsNumber;
- report.HeightPreferred = preferences.heightPreferred;
- report.WeightStatsPercent = preferences.weightStatsPercent;
- report.GraphTranslate = preferences.RGraphsTranslate;
- report.UseHeightsOnJumpIndexes = preferences.useHeightsOnJumpIndexes;
+ report.preferences = preferences;
report.Progversion = progVersion;
Log.WriteLine ( Catalog.GetString ("Preferences loaded") );
@@ -2480,7 +2476,7 @@ public partial class ChronoJumpWindow
}
private void on_export_session_accepted(object o, EventArgs args) {
- new ExportSessionCSV(currentSession, app1, preferences.digitsNumber);
+ new ExportSessionCSV(currentSession, app1, preferences);
}
@@ -2746,11 +2742,7 @@ public partial class ChronoJumpWindow
}
//pass to report
- report.PrefsDigitsNumber = preferences.digitsNumber;
- report.HeightPreferred = preferences.heightPreferred;
- report.WeightStatsPercent = preferences.weightStatsPercent;
- report.GraphTranslate = preferences.RGraphsTranslate;
- report.UseHeightsOnJumpIndexes = preferences.useHeightsOnJumpIndexes;
+ report.preferences = preferences;
createTreeView_jumps (treeview_jumps);
diff --git a/src/gui/report.cs b/src/gui/report.cs
index 696e9c4..6d5f5ad 100644
--- a/src/gui/report.cs
+++ b/src/gui/report.cs
@@ -320,19 +320,15 @@ public class ReportWindow {
statRow[2], //statisticApplyTo,
treeviewFake,
sendSelectedSessions,
- 3, //prefsDigitsNumber, don't care, it's
a graph
showSex,
statsJumpsType,
limit,
- report.heightPreferred,
- report.weightStatsPercent,
arrayListMarkedRows,
rj_evolution_mark_consecutives,
graphROptions,
true, //graph
false, //always false in this class
- report.GraphTranslate,
- report.UseHeightsOnJumpIndexes
+ report.preferences
);
myStatType.ChooseStat();
}
diff --git a/src/gui/stats.cs b/src/gui/stats.cs
index 1c34c7d..2cbf0b1 100644
--- a/src/gui/stats.cs
+++ b/src/gui/stats.cs
@@ -852,26 +852,22 @@ public partial class ChronoJumpWindow {
button_add_to_report.Sensitive = true;
GraphROptions graphROptions = fillGraphROptions();
-
+
myStatType = new StatType(
statisticType,
statisticSubType,
statisticApplyTo,
treeview_stats,
sendSelectedSessions,
- preferences.digitsNumber,
checkbutton_stats_sex.Active,
statsJumpsType,
limit,
- preferences.heightPreferred,
- preferences.weightStatsPercent,
markedRows,
evolution_mark_consecutives,
graphROptions,
graph,
toReport, //always false in this class
- preferences.RGraphsTranslate,
- preferences.useHeightsOnJumpIndexes
+ preferences
);
//if we just made a graph, store is not made,
diff --git a/src/report.cs b/src/report.cs
index cad9ac8..37633f9 100644
--- a/src/report.cs
+++ b/src/report.cs
@@ -41,8 +41,6 @@ public class Report : ExportSession
public bool ShowIntervalRunsWithSubruns;
public bool ShowReactionTimes;
public bool ShowPulses;
- private bool graphTranslate = true;
- private bool useHeightsOnJumpIndexes = true;
bool toReport = true;
@@ -73,27 +71,6 @@ public class Report : ExportSession
mySession = SqliteSession.Select(sessionID.ToString());
}
-/*
- public Report(int sessionID, bool showCurrentSessionData, bool showCurrentSessionJumpers,
- bool showSimpleJumps, bool showReactiveJumps, bool showSimpleRuns, bool
showIntervalRuns,
- bool showReactionTimes, bool showPulses, ArrayList statisticsData)
- {
- this.sessionID = sessionID;
- this.ShowCurrentSessionData = showCurrentSessionData;
- this.ShowCurrentSessionJumpers = showCurrentSessionJumpers;
- this.ShowSimpleJumps = showSimpleJumps;
- this.ShowReactiveJumps = showReactiveJumps;
- this.ShowSimpleRuns = showSimpleRuns;
- this.ShowIntervalRuns = showIntervalRuns;
- this.ShowReactionTimes = showReactionTimes;
- this.ShowPulses = showPulses;
- this.StatisticsData = statisticsData;
-
- spreadsheetString = "";
-
- mySession = SqliteSession.Select(sessionID.ToString());
- }
- */
public void PrepareFile () {
checkFile("report");
@@ -356,19 +333,15 @@ public class Report : ExportSession
subType, //statisticSubType
strFull[2], //statisticApplyTo
sendSelectedSessions,
- prefsDigitsNumber,
showSex,
statsJumpsType,
limit,
- heightPreferred,
- weightStatsPercent,
arrayListMarkedRows,
rj_evolution_mark_consecutives,
graphROptions,
false, //graph
toReport,
- graphTranslate,
- useHeightsOnJumpIndexes,
+ preferences,
writer,
"",
statCount
@@ -387,19 +360,15 @@ public class Report : ExportSession
subType, //statisticSubType
strFull[2], //statisticApplyTo
sendSelectedSessions,
- prefsDigitsNumber,
showSex,
statsJumpsType,
limit,
- heightPreferred,
- weightStatsPercent,
arrayListMarkedRows,
rj_evolution_mark_consecutives,
graphROptions,
true, //graph
toReport,
- graphTranslate,
- useHeightsOnJumpIndexes,
+ preferences,
writer,
fileName, //fileName for exporting there
statCount
@@ -435,16 +404,6 @@ public class Report : ExportSession
set { progversion = value; }
}
- public bool GraphTranslate {
- set { graphTranslate = value; }
- get { return graphTranslate; }
- }
-
- public bool UseHeightsOnJumpIndexes {
- set { useHeightsOnJumpIndexes = value; }
- get { return useHeightsOnJumpIndexes; }
- }
-
~Report() {}
}
diff --git a/src/statType.cs b/src/statType.cs
index b607f96..e6be07f 100644
--- a/src/statType.cs
+++ b/src/statType.cs
@@ -30,40 +30,32 @@ public class StatTypeStruct
{
public string StatisticApplyTo;
public ArrayList SendSelectedSessions;
- public int PrefsDigitsNumber;
public bool Sex_active;
public int StatsJumpsType;
public int Limit;
- public bool HeightPreferred;
- public bool WeightStatsPercent;
public ArrayList MarkedRows;
public GraphROptions GRO;
public bool ToReport;
- public bool GraphTranslate;
- public bool UseHeightsOnJumpIndexes;
+
+ public Preferences preferences;
public StatTypeStruct (string statisticApplyTo,
- ArrayList sendSelectedSessions, int prefsDigitsNumber, bool sex_active,
- int statsJumpsType, int limit, bool heightPreferred, bool weightStatsPercent,
- ArrayList markedRows,
- GraphROptions gRO,
- bool toReport, bool graphTranslate, bool useHeightsOnJumpIndexes)
+ ArrayList sendSelectedSessions, bool sex_active,
+ int statsJumpsType, int limit,
+ ArrayList markedRows, GraphROptions gRO,
+ bool toReport, Preferences preferences)
{
this.StatisticApplyTo = statisticApplyTo;
this.SendSelectedSessions = sendSelectedSessions;
- this.PrefsDigitsNumber = prefsDigitsNumber;
this.Sex_active = sex_active;
this.StatsJumpsType = statsJumpsType;
this.Limit = limit;
- this.HeightPreferred = heightPreferred;
- this.WeightStatsPercent = weightStatsPercent;
this.MarkedRows = markedRows;
this.GRO = gRO;
this.ToReport = toReport;
- this.GraphTranslate = graphTranslate;
- this.UseHeightsOnJumpIndexes = useHeightsOnJumpIndexes;
+ this.preferences = preferences;
}
}
@@ -80,8 +72,7 @@ public class StatType {
bool graph;
bool toReport;
- bool graphTranslate;
- bool useHeightsOnJumpIndexes;
+ Preferences preferences;
TextWriter writer;
string fileName;
@@ -110,12 +101,9 @@ public class StatType {
//comes from gui/stats.cs
public StatType (string statisticType, string statisticSubType, string statisticApplyTo, Gtk.TreeView
treeview_stats,
- ArrayList sendSelectedSessions, int prefsDigitsNumber, bool sex_active,
- int statsJumpsType, int limit, bool heightPreferred, bool weightStatsPercent,
- ArrayList markedRows,
- int evolution_mark_consecutives,
- GraphROptions gRO,
- bool graph, bool toReport, bool graphTranslate, bool useHeightsOnJumpIndexes)
+ ArrayList sendSelectedSessions, bool sex_active, int statsJumpsType, int limit,
+ ArrayList markedRows, int evolution_mark_consecutives, GraphROptions gRO,
+ bool graph, bool toReport, Preferences preferences)
{
//some of this will disappear when we use myStatTypeStruct in all classes:
this.statisticType = statisticType;
@@ -129,16 +117,14 @@ public class StatType {
this.graph = graph;
this.toReport = toReport;
- this.graphTranslate = graphTranslate;
- this.useHeightsOnJumpIndexes = useHeightsOnJumpIndexes;
+ this.preferences = preferences;
myStatTypeStruct = new StatTypeStruct (
statisticApplyTo,
- sendSelectedSessions, prefsDigitsNumber, sex_active,
- statsJumpsType, limit, heightPreferred, weightStatsPercent,
- markedRows,
- gRO,
- toReport, graphTranslate, useHeightsOnJumpIndexes);
+ sendSelectedSessions, sex_active,
+ statsJumpsType, limit,
+ markedRows, gRO,
+ toReport, preferences);
myStat = new Stat(); //create an instance of myStat
@@ -167,12 +153,10 @@ public class StatType {
//comes from report.cs
public StatType (string statisticType, string statisticSubType, string statisticApplyTo,
- ArrayList sendSelectedSessions, int prefsDigitsNumber, bool sex_active,
- int statsJumpsType, int limit, bool heightPreferred, bool weightStatsPercent,
- ArrayList markedRows,
- int evolution_mark_consecutives,
- GraphROptions gRO,
- bool graph, bool toReport, bool graphTranslate, bool useHeightsOnJumpIndexes,
+ ArrayList sendSelectedSessions, bool sex_active,
+ int statsJumpsType, int limit,
+ ArrayList markedRows, int evolution_mark_consecutives, GraphROptions gRO,
+ bool graph, bool toReport, Preferences preferences,
TextWriter writer, string fileName,
int statCount
)
@@ -187,8 +171,7 @@ public class StatType {
this.graph = graph;
this.toReport = toReport;
- this.graphTranslate = graphTranslate;
- this.useHeightsOnJumpIndexes = useHeightsOnJumpIndexes;
+ this.preferences = preferences;
this.writer = writer;
this.fileName = fileName;
@@ -196,11 +179,10 @@ public class StatType {
myStatTypeStruct = new StatTypeStruct (
statisticApplyTo,
- sendSelectedSessions, prefsDigitsNumber, sex_active,
- statsJumpsType, limit, heightPreferred, weightStatsPercent,
- markedRows,
- gRO,
- toReport, graphTranslate, useHeightsOnJumpIndexes);
+ sendSelectedSessions, sex_active,
+ statsJumpsType, limit,
+ markedRows, gRO,
+ toReport, preferences);
myStat = new Stat(); //create and instance of myStat
}
diff --git a/src/stats/main.cs b/src/stats/main.cs
index b0de712..5cbe863 100644
--- a/src/stats/main.cs
+++ b/src/stats/main.cs
@@ -109,11 +109,11 @@ public class Stat
{
//TODO: check, this is weird...
this.sessions = myStatTypeStruct.SendSelectedSessions;
- pDN = myStatTypeStruct.PrefsDigitsNumber;
+ pDN = myStatTypeStruct.preferences.digitsNumber;
this.showSex = myStatTypeStruct.Sex_active;
this.statsJumpsType = myStatTypeStruct.StatsJumpsType;
- this.heightPreferred = myStatTypeStruct.HeightPreferred;
- this.weightStatsPercent = myStatTypeStruct.WeightStatsPercent;
+ this.heightPreferred = myStatTypeStruct.preferences.heightPreferred;
+ this.weightStatsPercent = myStatTypeStruct.preferences.weightStatsPercent;
this.statsJumpsType = myStatTypeStruct.StatsJumpsType;
this.limit = myStatTypeStruct.Limit;
this.jumpType = myStatTypeStruct.StatisticApplyTo;
@@ -122,8 +122,8 @@ public class Stat
this.gRO = myStatTypeStruct.GRO;
this.toReport = myStatTypeStruct.ToReport;
- this.graphTranslate = myStatTypeStruct.GraphTranslate;
- this.useHeightsOnJumpIndexes = myStatTypeStruct.UseHeightsOnJumpIndexes;
+ this.graphTranslate = myStatTypeStruct.preferences.RGraphsTranslate;
+ this.useHeightsOnJumpIndexes = myStatTypeStruct.preferences.useHeightsOnJumpIndexes;
this.treeview = treeview;
diff --git a/src/stats/sjCmjAbkPlus.cs b/src/stats/sjCmjAbkPlus.cs
index 86bdae5..a8f7220 100644
--- a/src/stats/sjCmjAbkPlus.cs
+++ b/src/stats/sjCmjAbkPlus.cs
@@ -53,7 +53,7 @@ public class StatSjCmjAbkPlus : Stat
store = getStore(dataColumns +1); //jumper, height, TF, weight (this col has
characters '%' and 'Kg') solved in sqlite
}
- weightPercentPreferred = myStatTypeStruct.WeightStatsPercent;
+ weightPercentPreferred = myStatTypeStruct.preferences.weightStatsPercent;
string weightName = Catalog.GetString("Extra weight");
if(weightPercentPreferred)
weightName += " %";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]