[longomatch] Start refactoring
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [longomatch] Start refactoring
- Date: Mon, 2 Nov 2009 00:03:26 +0000 (UTC)
commit eafa2539a6fd737eda91149626830e1c3cfbbb48
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sun Nov 1 16:13:05 2009 +0100
Start refactoring
LongoMatch/DB/Project.cs | 41 ++++++++------
LongoMatch/Time/Drawing.cs | 6 ++
LongoMatch/Time/HotKey.cs | 28 ++++++----
LongoMatch/Time/MediaTimeNode.cs | 103 +++++++++++++++++++++++++++++------
LongoMatch/Time/PlayListTimeNode.cs | 12 ++--
LongoMatch/Time/Player.cs | 11 +++-
LongoMatch/Time/Time.cs | 38 ++++++--------
LongoMatch/Time/TimeNode.cs | 60 ++++++++------------
8 files changed, 187 insertions(+), 112 deletions(-)
---
diff --git a/LongoMatch/DB/Project.cs b/LongoMatch/DB/Project.cs
index 5e99c95..312ee25 100644
--- a/LongoMatch/DB/Project.cs
+++ b/LongoMatch/DB/Project.cs
@@ -62,9 +62,11 @@ namespace LongoMatch.DB
//Keep this fiel for DB retrocompatibility
private List<MediaTimeNode>[] dataSectionArray;
-
- public Project(PreviewMediaFile file, String localName, String visitorName, String season, String competition, int localGoals,
- int visitorGoals, DateTime matchDate, Sections sections, TeamTemplate localTeamTemplate, TeamTemplate visitorTeamTemplate) {
+ #region Constructors
+ public Project(PreviewMediaFile file, String localName, String visitorName,
+ String season, String competition, int localGoals,
+ int visitorGoals, DateTime matchDate, Sections sections,
+ TeamTemplate localTeamTemplate, TeamTemplate visitorTeamTemplate) {
this.file = file;
this.localName = localName;
@@ -85,21 +87,9 @@ namespace LongoMatch.DB
this.Title = System.IO.Path.GetFileNameWithoutExtension(this.file.FilePath);
}
+ #endregion
- public void Clear(){
- //Help the GC freeing objects
- foreach (List<MediaTimeNode> list in sectionPlaysList)
- list.Clear();
- sectionPlaysList.Clear();
- Sections.Clear();
- visitorTeamTemplate.Clear();
- localTeamTemplate.Clear();
- sectionPlaysList=null;
- Sections=null;
- visitorTeamTemplate=null;
- localTeamTemplate=null;
- }
-
+ #region Properties
public PreviewMediaFile File {
get{return file;}
set{file=value;}
@@ -159,6 +149,22 @@ namespace LongoMatch.DB
get{return visitorTeamTemplate;}
set{visitorTeamTemplate=value;}
}
+ #endregion
+
+ #region Public Methods
+ public void Clear(){
+ //Help the GC freeing objects
+ foreach (List<MediaTimeNode> list in sectionPlaysList)
+ list.Clear();
+ sectionPlaysList.Clear();
+ Sections.Clear();
+ visitorTeamTemplate.Clear();
+ localTeamTemplate.Clear();
+ sectionPlaysList=null;
+ Sections=null;
+ visitorTeamTemplate=null;
+ localTeamTemplate=null;
+ }
public void AddSection(SectionsTimeNode tn){
AddSectionAtPos(tn,sections.Count);
@@ -264,5 +270,6 @@ namespace LongoMatch.DB
else
throw new ArgumentException("object is not a Project and cannot be compared");
}
+ #endregion
}
}
diff --git a/LongoMatch/Time/Drawing.cs b/LongoMatch/Time/Drawing.cs
index a6a0aca..a1f0f94 100644
--- a/LongoMatch/Time/Drawing.cs
+++ b/LongoMatch/Time/Drawing.cs
@@ -21,6 +21,12 @@ using Gdk;
namespace LongoMatch.TimeNodes
{
+ /* Represent a drawing in the database using a { Gdk Pixbuf} stored
+ in a bytes array in PNG format for serialization. { Drawings}
+ are used by { MediaTimeNodes} to store the key frame drawing
+ which stop time time is stored in a int value
+ */
+
[Serializable]
public class Drawing
{
diff --git a/LongoMatch/Time/HotKey.cs b/LongoMatch/Time/HotKey.cs
index 9f666d2..9e762ac 100644
--- a/LongoMatch/Time/HotKey.cs
+++ b/LongoMatch/Time/HotKey.cs
@@ -28,22 +28,25 @@ using Mono.Unix;
namespace LongoMatch.TimeNodes
{
-
+ /* Represent a key combination shortcut used to tag plays using the keyboard
+ using an int to map to a { Gdk Key} and another int to map to a { Gdk Modifier}
+ Only Shift and Alt can be used as modifiers.
+ When a hotkey is not defined key and modifier are set to -1
+ */
public class HotKey : IEquatable<HotKey>
{
private int key;
private int modifier;
-#region Constructors
+ #region Constructors
public HotKey()
{
this.key = -1;
this.modifier = -1;
}
-#endregion
-
+ #endregion
-#region Properties
+ #region Properties
public Gdk.Key Key{
get{return (Gdk.Key)key;}
set{key = (int)value;}
@@ -57,22 +60,25 @@ namespace LongoMatch.TimeNodes
public Boolean Defined{
get{return (key!=-1 && modifier != -1);}
}
+ #endregion
+ #region Public Methods
public bool Equals(HotKey hotkeyComp){
return (this.Key == hotkeyComp.Key && this.Modifier == hotkeyComp.Modifier);
}
+ #endregion
+ #region Operators
static public bool operator == (HotKey hk1, HotKey hk2){
return hk1.Equals(hk2);
}
static public bool operator != (HotKey hk1, HotKey hk2){
return !hk1.Equals(hk2);
- }
-
-#endregion
+ }
+ #endregion
-#region Override
+ #region Overrides
public override bool Equals (object obj)
{
HotKey hotkey= obj as HotKey;
@@ -86,7 +92,6 @@ namespace LongoMatch.TimeNodes
{
return key ^ modifier;
}
-
public override string ToString ()
{
@@ -100,7 +105,6 @@ namespace LongoMatch.TimeNodes
return string.Format("<{0}>+{1}", modifierS,(Key.ToString()).ToLower());
}
-
-#endregion
+ #endregion
}
}
diff --git a/LongoMatch/Time/MediaTimeNode.cs b/LongoMatch/Time/MediaTimeNode.cs
index 2aa0a11..4b03337 100644
--- a/LongoMatch/Time/MediaTimeNode.cs
+++ b/LongoMatch/Time/MediaTimeNode.cs
@@ -30,11 +30,10 @@ namespace LongoMatch.TimeNodes
VISITOR = 2,
}
- /* MediaTimeNode is the main object of the database for { LongoMatch} It' s used to
- store the name of each reference point we want to remind with its start time
- and its stop time, and the data type it belowns to. When we mark a segment in the
- video, this object contains all the information we need to reproduce the
- video sequence again.
+ /* Plays are represented and stored in the database using { MediaTimeNode} objects.
+ It stores the name and the start and stop { Time} of a play and
+ it's used to replay the video segment of the play. A play can have
+ tagged several players storing the { Player} number in a list.
*/
[Serializable]
public class MediaTimeNode : PixbufTimeNode
@@ -53,7 +52,7 @@ namespace LongoMatch.TimeNodes
private string notes;
- private List<int> localPlayersList; //Used to multitag: one play and several players
+ private List<int> localPlayersList; //Used for multitagging: one play and several players
// We use the int index of the player in the template,
private List<int> visitorPlayersList;// because it's the only unmutable variable
@@ -61,7 +60,7 @@ namespace LongoMatch.TimeNodes
-#region Constructors
+ #region Constructors
public MediaTimeNode(String name, Time start, Time stop,string notes, uint fps,Pixbuf thumbnail):base (name,start,stop,thumbnail) {
this.notes = notes;
this.team = Team.NONE;
@@ -73,31 +72,63 @@ namespace LongoMatch.TimeNodes
}
#endregion
- #region Properties
-
+ #region Properties
+ /**
+ * Get/Set the notes of a play
+ *
+ * @returns Stop { Time}
+ */
public string Notes {
get{return notes;}
set{notes = value;}
}
-
+
+ /**
+ * Get/Set the { Team}
+ *
+ * @returns Stop { Time}
+ */
public Team Team{
get{return this.team;}
set{this.team = value;}
}
+ /**
+ * Get/Set the frames per second. This value is taken from the
+ * video file properties and used to translate from seconds
+ * to frames, for instance second 100 is equivalent to frame
+ * 100*fps
+ *
+ * @returns Stop { Time}
+ */
public uint Fps{
get{return this.fps;}
set{this.fps = value;}
}
+ /**
+ * Get the central frame (stop-start)/2
+ *
+ * @returns Stop { Time}
+ */
public uint CentralFrame{
get{ return this.StopFrame-((this.TotalFrames)/2);}
}
+ /**
+ * Get the numbers of frames between the start and stop time
+ *
+ * @returns Stop { Time}
+ */
public uint TotalFrames{
get{return this.StopFrame-this.StartFrame;}
}
+ /**
+ * Get/Set the start frame
+ *
+ * @returns Stop { Time}
+ */
public uint StartFrame {
get {return startFrame;}
set {
@@ -106,6 +137,11 @@ namespace LongoMatch.TimeNodes
}
}
+ /**
+ * Get/Set the stop frame
+ *
+ * @returns Stop { Time}
+ */
public uint StopFrame {
get {return stopFrame;}
set {
@@ -114,6 +150,11 @@ namespace LongoMatch.TimeNodes
}
}
+ /**
+ * Get the key frame number if this play as key frame drawing or 0
+ *
+ * @returns Stop { Time}
+ */
public uint KeyFrame{
get {
if (HasKeyFrame)
@@ -122,11 +163,21 @@ namespace LongoMatch.TimeNodes
}
}
+ /**
+ * Get/Set wheter a this play is actually loaded
+ *
+ * @returns Stop { Time}
+ */
public bool Selected {
get {return selected;}
set{this.selected = value;}
}
+ /**
+ * Get/Set
+ *
+ * @returns Stop { Time}
+ */
public List<int> LocalPlayers{
set {localPlayersList = value;}
get{return localPlayersList;}
@@ -144,34 +195,54 @@ namespace LongoMatch.TimeNodes
public bool HasKeyFrame{
get{return keyFrame != null;}
- }
-
-
-
+ }
#endregion
#region Public methods
-
+ /**
+ * Returns true is the frame number is in the play span
+ *
+ * @returns frame { boo}
+ */
public bool HasFrame(int frame){
return (frame>=startFrame && frame<stopFrame);
}
+ /**
+ * Adds a local player to the local team player's list
+ *
+ * @param index { Player} number
+ */
public void AddLocalPlayer(int index){
localPlayersList.Add(index);
}
+ /**
+ * Adds a visitor player to the visitor team player's list
+ *
+ * @param index { Player} number
+ */
public void AddVisitorPlayer(int index){
visitorPlayersList.Add(index);
}
+ /**
+ * Removes a local player from the local team player's list
+ *
+ * @param index { Player} number
+ */
public void RemoveLocalPlayer(int index){
localPlayersList.Remove(index);
}
+ /**
+ * Removes a visitor player from the visitor team player's list
+ *
+ * @param index { Player} number
+ */
public void RemoveVisitorPlayer(int index){
visitorPlayersList.Remove(index);
}
-
#endregion
}
}
diff --git a/LongoMatch/Time/PlayListTimeNode.cs b/LongoMatch/Time/PlayListTimeNode.cs
index b272b79..855ae7a 100644
--- a/LongoMatch/Time/PlayListTimeNode.cs
+++ b/LongoMatch/Time/PlayListTimeNode.cs
@@ -24,7 +24,8 @@ using LongoMatch.Video.Utils;
namespace LongoMatch.TimeNodes
{
-
+ /*Used in a { LongoMatch PlayList PlayList} to store a play or video segment
+ */
[Serializable]
public class PlayListTimeNode : TimeNode
{
@@ -42,8 +43,8 @@ namespace LongoMatch.TimeNodes
}
#endregion
- #region Properties
+ #region Properties
public MediaFile MediaFile{
set{
//PlayListTimeNode is serializable and only primary classes
@@ -51,8 +52,8 @@ namespace LongoMatch.TimeNodes
//a new MediaFile object.
if (value is PreviewMediaFile){
MediaFile mf = new MediaFile(value.FilePath,value.Length,value.Fps,
- value.HasAudio,value.HasVideo,value.VideoCodec,
- value.AudioCodec,value.VideoWidth,value.VideoHeight);
+ value.HasAudio,value.HasVideo,value.VideoCodec,
+ value.AudioCodec,value.VideoWidth,value.VideoHeight);
this.mediaFile= mf;
}
else this.mediaFile = value;
@@ -63,8 +64,7 @@ namespace LongoMatch.TimeNodes
public float Rate{
set{ this.rate = value;}
get{ return this.rate;}
- }
-
+ }
public bool Valid{
get{return this.valid;}
diff --git a/LongoMatch/Time/Player.cs b/LongoMatch/Time/Player.cs
index cc1f10e..ff86689 100644
--- a/LongoMatch/Time/Player.cs
+++ b/LongoMatch/Time/Player.cs
@@ -21,7 +21,8 @@ using Gdk;
namespace LongoMatch.TimeNodes
{
-
+ /* Represent a player in the database defined by its name, position in the field, number and photo
+ */
[Serializable]
public class Player
{
@@ -29,7 +30,8 @@ namespace LongoMatch.TimeNodes
private string position;
private int number;
private byte[] photo;
-
+
+ #region Constructors
public Player(string name, string position, int number, Pixbuf photo)
{
this.name = name;
@@ -37,7 +39,9 @@ namespace LongoMatch.TimeNodes
this.number = number;
Photo = photo;
}
-
+ #endregion
+
+ #region Properties
public string Name{
get{return name;}
set{name=value;}
@@ -67,5 +71,6 @@ namespace LongoMatch.TimeNodes
photo=null;
}
}
+ #endregion
}
}
diff --git a/LongoMatch/Time/Time.cs b/LongoMatch/Time/Time.cs
index 08a73a6..838dd65 100644
--- a/LongoMatch/Time/Time.cs
+++ b/LongoMatch/Time/Time.cs
@@ -23,7 +23,8 @@ using System;
namespace LongoMatch.TimeNodes
{
-
+ /* Represents a time instant. It's used to standarize the time units
+ */
public class Time : IComparable
{
private int time;
@@ -40,8 +41,8 @@ namespace LongoMatch.TimeNodes
this.time = time;
}
#endregion
- #region Properties
+ #region Properties
public int MSeconds {
get { return time;}
set { time = value;}
@@ -49,11 +50,10 @@ namespace LongoMatch.TimeNodes
public int Seconds {
get { return time/SECONDS_TO_TIME;}
- }
-
+ }
#endregion
- #region Public methods
+ #region Public methods
public string ToSecondsString ()
{
int _h, _m, _s;
@@ -96,39 +96,35 @@ namespace LongoMatch.TimeNodes
public override int GetHashCode ()
{
return base.GetHashCode ();
- }
-
-
+ }
public int CompareTo(object obj) {
if(obj is Time)
{
Time otherTime = (Time) obj;
return MSeconds.CompareTo(otherTime.MSeconds);
- }
-
- else
- {
- throw new ArgumentException("Object is not a Temperature");
- }
- }
-
+ }
+ else throw new ArgumentException("Object is not a Temperature");
+ }
#endregion
- #region Operators
-
+ #region Operators
public static bool operator < (Time t1,Time t2){
return t1.MSeconds < t2.MSeconds;
}
+
public static bool operator > (Time t1,Time t2){
return t1.MSeconds > t2.MSeconds;
}
+
public static bool operator <= (Time t1,Time t2){
return t1.MSeconds <= t2.MSeconds;
}
+
public static bool operator >= (Time t1,Time t2){
return t1.MSeconds >= t2.MSeconds;
}
+
public static Time operator +(Time t1,int t2){
return new Time(t1.MSeconds+t2);
}
@@ -143,9 +139,7 @@ namespace LongoMatch.TimeNodes
public static Time operator -(Time t1,int t2){
return new Time(t1.MSeconds-t2);
- }
-
+ }
#endregion
-
}
-}
+}
\ No newline at end of file
diff --git a/LongoMatch/Time/TimeNode.cs b/LongoMatch/Time/TimeNode.cs
index 3139d3f..ad89cce 100644
--- a/LongoMatch/Time/TimeNode.cs
+++ b/LongoMatch/Time/TimeNode.cs
@@ -28,7 +28,7 @@ namespace LongoMatch.TimeNodes
[Serializable]
public class TimeNode
{
- //Stores the name of the refenrence point
+ //Stores the name of the play
private string name;
//Stores the start time
@@ -37,7 +37,7 @@ namespace LongoMatch.TimeNodes
//Stores the stop time
private Time stop;
-
+ #region Constructors
public TimeNode(){
}
@@ -47,44 +47,33 @@ namespace LongoMatch.TimeNodes
this.start = start;
this.stop = stop;
}
+ #endregion
+ #region Properties
/**
- * Returns a String object that represents the name of the reference point
+ * Set/Get the name
*
* @returns name Name of the reference point
*/
public string Name {
- get{
- return this.name;
- }
- set{
- this.name=value;
-
- }
+ get{return this.name;}
+ set{this.name=value;}
}
-
-
/**
- * Returns a Time object representing the start time of the video sequence
+ * Set/Get the start { Time}
*
* @returns Start time
*/
public Time Start{
- get{
- return this.start;
- }
-
- set{
- this.start=value;
- }
-
+ get{return this.start;}
+ set{ this.start=value;}
}
/**
- * Returns a Time object representing the stop time of the video sequence
+ * Set/Get the stop
*
- * @returns Stop time
+ * @returns Stop { Time}
*/
public Time Stop {
get{
@@ -95,27 +84,26 @@ namespace LongoMatch.TimeNodes
}
}
+ /**
+ * Get the duration defined like start { Time} - stop { Time}
+ *
+ * @returns Stop { Time}
+ */
public Time Duration {
get {return Stop-Start;}
- }
-
-
+ }
+ #endregion
+ #region Public methods
/**
- * Returns a String object that represents the name of the reference point
+ * Change the Start and Stop { Time}
*
* @returns name Name of the reference point
- */
- public string toString() {
- return name;
- }
-
- public void changeStartStop(Time start, Time stop) {
+ */
+ public void ChangeStartStop(Time start, Time stop) {
this.start = start;
this.stop = stop;
}
-
-
-
+ #endregion
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]