Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pb branch #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 28 additions & 24 deletions WordCloudCalculator/Contract/Range.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,29 @@

namespace WordCloudCalculator.Contract
{
/// <summary>
/// Defines Boundaries and provides some related calculation methods
/// </summary>
public struct Range
{
private double _min;
private double _max;
/// <summary>
/// Defines Boundaries and provides some related calculation methods
/// </summary>
public struct Range
{
private double _min;
private double _max;
//private double _step ;

public Range(double min, double max)
{
_max = max;
_min = min;
if(!IsValid) throw new Exception("Invalid Range!");
}

/// <summary>
/// Lower Bound
/// </summary>
public double Min
public Range(double min, double max /*, step = 1.0*/ )
{
//_step = 1.0;
//_max = Convert.ToInt32(max / _step) * _step;
//_min = Convert.ToInt32(min / _step) * _step;
_max = max;
_min = min;
if (min > max) throw new Exception("Invalid Range!");
}
//private double InStep(double x, double s) => { return Convert.ToInt32(x / s) * s };
/// <summary>
/// Lower Bound
/// </summary>
public double Min
{
get { return _min; }
set
Expand All @@ -38,7 +42,7 @@ public double Max
get { return _max; }
set
{
if (value < Min) throw new Exception("Maximum cannot be lesser than Minimum!");
if (!IsValid) throw new Exception("Maximum cannot be lesser than Minimum!");
_max = value;
}
}
Expand All @@ -52,10 +56,10 @@ public double Max
/// <returns></returns>
public bool Includes(double value) => Min <= value && value <= Max;

/// <summary>
/// Checks if bound relation is correct
/// </summary>
public bool IsValid => Max >= Min;
/// <summary>
/// Checks if bound relation is correct
/// </summary>
public bool IsValid => Max >= Min;

/// <summary>
/// Calculates the relative range value of a given value of an other Range
Expand All @@ -65,7 +69,7 @@ public double Max
/// <returns>Relative Range Value</returns>
public double CalculateRelativeValue(Range valueRange, double currentValue)
{
return Min + (currentValue - valueRange.Min)*Amplitude/valueRange.Amplitude;
return Min + (currentValue - valueRange.Min) * Amplitude / valueRange.Amplitude;
}
}
}
6 changes: 4 additions & 2 deletions WordCloudCalculator/Contract/Word/VisualizedWord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public VisualizedWord(IWord word)
/// Defines how strong the word should be displayed [0..1]
/// </summary>
public double Opacity { get; set; }
public override string ToString() => $"{Text}, Position({Position}), FontSize({FontSize}) Opacity = {Opacity:N1}";
}
public Size Size { get; set; }
public override string ToString() => $"{Text}, Position({Position}), Size({Size}), FontSize({FontSize}) Opacity = {Opacity:N1}";

}
}
Loading