External/OxyPlot/OxyPlot/Series/BarSeries/TornadoBarItem.cs
author moel.mich
Sat, 08 Jun 2013 16:53:22 +0000
changeset 391 5be8f2773237
permissions -rw-r--r--
Added the source code of OxyPlot as of commit d190d7748a73 (6.5.2013).
moel@391
     1
// --------------------------------------------------------------------------------------------------------------------
moel@391
     2
// <copyright file="TornadoBarItem.cs" company="OxyPlot">
moel@391
     3
//   The MIT License (MIT)
moel@391
     4
//
moel@391
     5
//   Copyright (c) 2012 Oystein Bjorke
moel@391
     6
//
moel@391
     7
//   Permission is hereby granted, free of charge, to any person obtaining a
moel@391
     8
//   copy of this software and associated documentation files (the
moel@391
     9
//   "Software"), to deal in the Software without restriction, including
moel@391
    10
//   without limitation the rights to use, copy, modify, merge, publish,
moel@391
    11
//   distribute, sublicense, and/or sell copies of the Software, and to
moel@391
    12
//   permit persons to whom the Software is furnished to do so, subject to
moel@391
    13
//   the following conditions:
moel@391
    14
//
moel@391
    15
//   The above copyright notice and this permission notice shall be included
moel@391
    16
//   in all copies or substantial portions of the Software.
moel@391
    17
//
moel@391
    18
//   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
moel@391
    19
//   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
moel@391
    20
//   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
moel@391
    21
//   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
moel@391
    22
//   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
moel@391
    23
//   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
moel@391
    24
//   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
moel@391
    25
// </copyright>
moel@391
    26
// <summary>
moel@391
    27
//   Represents an item for the TornadoBarSeries.
moel@391
    28
// </summary>
moel@391
    29
// --------------------------------------------------------------------------------------------------------------------
moel@391
    30
namespace OxyPlot.Series
moel@391
    31
{
moel@391
    32
    /// <summary>
moel@391
    33
    /// Represents an item for the TornadoBarSeries.
moel@391
    34
    /// </summary>
moel@391
    35
    public class TornadoBarItem : CategorizedItem, ICodeGenerating
moel@391
    36
    {
moel@391
    37
        /// <summary>
moel@391
    38
        /// Initializes a new instance of the <see cref="TornadoBarItem"/> class.
moel@391
    39
        /// </summary>
moel@391
    40
        public TornadoBarItem()
moel@391
    41
        {
moel@391
    42
            this.Minimum = double.NaN;
moel@391
    43
            this.Maximum = double.NaN;
moel@391
    44
            this.BaseValue = double.NaN;
moel@391
    45
            this.MinimumColor = null;
moel@391
    46
            this.MaximumColor = null;
moel@391
    47
        }
moel@391
    48
moel@391
    49
        /// <summary>
moel@391
    50
        /// Initializes a new instance of the <see cref="TornadoBarItem"/> class.
moel@391
    51
        /// </summary>
moel@391
    52
        /// <param name="minimum">
moel@391
    53
        /// The minimum.
moel@391
    54
        /// </param>
moel@391
    55
        /// <param name="maximum">
moel@391
    56
        /// The maximum.
moel@391
    57
        /// </param>
moel@391
    58
        /// <param name="baseValue">
moel@391
    59
        /// The base value.
moel@391
    60
        /// </param>
moel@391
    61
        /// <param name="minimumColor">
moel@391
    62
        /// The minimum color.
moel@391
    63
        /// </param>
moel@391
    64
        /// <param name="maximumColor">
moel@391
    65
        /// The maximum color.
moel@391
    66
        /// </param>
moel@391
    67
        public TornadoBarItem(
moel@391
    68
            double minimum,
moel@391
    69
            double maximum,
moel@391
    70
            double baseValue = double.NaN,
moel@391
    71
            OxyColor minimumColor = null,
moel@391
    72
            OxyColor maximumColor = null)
moel@391
    73
        {
moel@391
    74
            this.Minimum = minimum;
moel@391
    75
            this.Maximum = maximum;
moel@391
    76
            this.BaseValue = baseValue;
moel@391
    77
            this.MinimumColor = minimumColor;
moel@391
    78
            this.MaximumColor = maximumColor;
moel@391
    79
        }
moel@391
    80
moel@391
    81
        /// <summary>
moel@391
    82
        /// Gets or sets the base value.
moel@391
    83
        /// </summary>
moel@391
    84
        public double BaseValue { get; set; }
moel@391
    85
moel@391
    86
        /// <summary>
moel@391
    87
        /// Gets or sets the maximum.
moel@391
    88
        /// </summary>
moel@391
    89
        public double Maximum { get; set; }
moel@391
    90
moel@391
    91
        /// <summary>
moel@391
    92
        /// Gets or sets the color for the maximum bar.
moel@391
    93
        /// </summary>
moel@391
    94
        public OxyColor MaximumColor { get; set; }
moel@391
    95
moel@391
    96
        /// <summary>
moel@391
    97
        /// Gets or sets the minimum value.
moel@391
    98
        /// </summary>
moel@391
    99
        public double Minimum { get; set; }
moel@391
   100
moel@391
   101
        /// <summary>
moel@391
   102
        /// Gets or sets the color for the minimum bar.
moel@391
   103
        /// </summary>
moel@391
   104
        public OxyColor MinimumColor { get; set; }
moel@391
   105
moel@391
   106
        /// <summary>
moel@391
   107
        /// Returns c# code that generates this instance.
moel@391
   108
        /// </summary>
moel@391
   109
        /// <returns>
moel@391
   110
        /// C# code.
moel@391
   111
        /// </returns>
moel@391
   112
        public string ToCode()
moel@391
   113
        {
moel@391
   114
            if (this.MaximumColor != null)
moel@391
   115
            {
moel@391
   116
                return CodeGenerator.FormatConstructor(
moel@391
   117
                    this.GetType(),
moel@391
   118
                    "{0},{1},{2},{3},{4}",
moel@391
   119
                    this.Minimum,
moel@391
   120
                    this.Maximum,
moel@391
   121
                    this.BaseValue,
moel@391
   122
                    this.MinimumColor.ToCode(),
moel@391
   123
                    this.MaximumColor.ToCode());
moel@391
   124
            }
moel@391
   125
moel@391
   126
            if (this.MinimumColor != null)
moel@391
   127
            {
moel@391
   128
                return CodeGenerator.FormatConstructor(
moel@391
   129
                    this.GetType(),
moel@391
   130
                    "{0},{1},{2},{3}",
moel@391
   131
                    this.Minimum,
moel@391
   132
                    this.Maximum,
moel@391
   133
                    this.BaseValue,
moel@391
   134
                    this.MinimumColor.ToCode());
moel@391
   135
            }
moel@391
   136
moel@391
   137
            if (!double.IsNaN(this.BaseValue))
moel@391
   138
            {
moel@391
   139
                return CodeGenerator.FormatConstructor(
moel@391
   140
                    this.GetType(), "{0},{1},{2}", this.Minimum, this.Maximum, this.BaseValue);
moel@391
   141
            }
moel@391
   142
moel@391
   143
            return CodeGenerator.FormatConstructor(this.GetType(), "{0},{1}", this.Minimum, this.Maximum);
moel@391
   144
        }
moel@391
   145
moel@391
   146
    }
moel@391
   147
}