using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Microsoft.Research.DynamicDataDisplay.Common.Auxiliary;
namespace Microsoft.Research.DynamicDataDisplay.Charts
{
///
/// Contains information about one minor tick - its value (relative size) and its tick.
///
///
[DebuggerDisplay("{Value} @ {Tick}")]
public struct MinorTickInfo
{
internal MinorTickInfo(double value, T tick)
{
this.value = value;
this.tick = tick;
}
private readonly double value;
private readonly T tick;
public double Value { get { return value; } }
public T Tick { get { return tick; } }
public override string ToString()
{
return String.Format("{0} @ {1}", value, tick);
}
}
///
/// Contains data for all generated ticks.
/// Used by TicksLabelProvider.
///
/// Type of axis tick.
public interface ITicksInfo
{
///
/// Gets the array of axis ticks.
///
/// The ticks.
T[] Ticks { get; }
///
/// Gets the tick sizes.
///
/// The tick sizes.
double[] TickSizes { get; }
///
/// Gets the additional information, added to ticks info and specifying range's features.
///
/// The info.
object Info { get; }
}
internal class TicksInfo : ITicksInfo
{
private T[] ticks = { };
///
/// Gets the array of axis ticks.
///
/// The ticks.
public T[] Ticks
{
get { return ticks; }
internal set { ticks = value; }
}
private double[] tickSizes = { };
///
/// Gets the tick sizes.
///
/// The tick sizes.
public double[] TickSizes
{
get
{
if (tickSizes.Length != ticks.Length)
tickSizes = ArrayExtensions.CreateArray(ticks.Length, 1.0);
return tickSizes;
}
internal set { tickSizes = value; }
}
private object info = null;
///
/// Gets the additional information, added to ticks info and specifying range's features.
///
/// The info.
public object Info
{
get { return info; }
internal set { info = value; }
}
private static readonly TicksInfo empty = new TicksInfo { info = null, ticks = new T[0], tickSizes = new double[0] };
internal static TicksInfo Empty
{
get { return empty; }
}
}
///
/// Base interface for ticks generator.
///
///
public interface ITicksProvider
{
///
/// Generates ticks for given range and preferred ticks count.
///
/// The range.
/// The ticks count.
///
ITicksInfo GetTicks(Range range, int ticksCount);
///
/// Decreases the tick count.
/// Returned value should be later passed as ticksCount parameter to GetTicks method.
///
/// The ticks count.
/// Decreased ticks count.
int DecreaseTickCount(int ticksCount);
///
/// Increases the tick count.
/// Returned value should be later passed as ticksCount parameter to GetTicks method.
///
/// The ticks count.
/// Increased ticks count.
int IncreaseTickCount(int ticksCount);
///
/// Gets the minor ticks provider, used to generate ticks between each two adjacent ticks.
///
/// The minor provider. If there is no minor provider available, returns null.
ITicksProvider MinorProvider { get; }
///
/// Gets the major provider, used to generate major ticks - for example, years for common ticks as months.
///
/// The major provider. If there is no major provider available, returns null.
ITicksProvider MajorProvider { get; }
///
/// Occurs when properties of ticks provider changeds.
/// Notifies axis to rebuild its view.
///
event EventHandler Changed;
}
}