forked from core-plot/core-plot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPTLimitBand.m
More file actions
114 lines (90 loc) · 2.65 KB
/
CPTLimitBand.m
File metadata and controls
114 lines (90 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#import "CPTLimitBand.h"
#import "CPTFill.h"
#import "CPTPlotRange.h"
/**
* @brief Defines a range and fill used to highlight a band of data.
**/
@implementation CPTLimitBand
/** @property CPTPlotRange *range
* @brief The data range for the band.
**/
@synthesize range;
/** @property CPTFill *fill
* @brief The fill used to draw the band.
**/
@synthesize fill;
#pragma mark -
#pragma mark Init/Dealloc
/** @brief Creates and returns a new CPTLimitBand instance initialized with the provided range and fill.
* @param newRange The range of the band.
* @param newFill The fill used to draw the interior of the band.
* @return A new CPTLimitBand instance initialized with the provided range and fill.
**/
+(instancetype)limitBandWithRange:(CPTPlotRange *)newRange fill:(CPTFill *)newFill
{
return [[CPTLimitBand alloc] initWithRange:newRange fill:newFill];
}
/** @brief Initializes a newly allocated CPTLimitBand object with the provided range and fill.
* @param newRange The range of the band.
* @param newFill The fill used to draw the interior of the band.
* @return The initialized CPTLimitBand object.
**/
-(instancetype)initWithRange:(CPTPlotRange *)newRange fill:(CPTFill *)newFill
{
if ( (self = [super init]) ) {
range = newRange;
fill = newFill;
}
return self;
}
#pragma mark -
#pragma mark NSCopying Methods
/// @cond
-(id)copyWithZone:(NSZone *)zone
{
CPTLimitBand *newBand = [[CPTLimitBand allocWithZone:zone] init];
if ( newBand ) {
newBand.range = self.range;
newBand.fill = self.fill;
}
return newBand;
}
/// @endcond
#pragma mark -
#pragma mark NSCoding Methods
/// @cond
-(void)encodeWithCoder:(NSCoder *)encoder
{
if ( [encoder allowsKeyedCoding] ) {
[encoder encodeObject:self.range forKey:@"CPTLimitBand.range"];
[encoder encodeObject:self.fill forKey:@"CPTLimitBand.fill"];
}
else {
[encoder encodeObject:self.range];
[encoder encodeObject:self.fill];
}
}
-(instancetype)initWithCoder:(NSCoder *)decoder
{
CPTPlotRange *newRange;
CPTFill *newFill;
if ( [decoder allowsKeyedCoding] ) {
newRange = [decoder decodeObjectForKey:@"CPTLimitBand.range"];
newFill = [decoder decodeObjectForKey:@"CPTLimitBand.fill"];
}
else {
newRange = [decoder decodeObject];
newFill = [decoder decodeObject];
}
return [self initWithRange:newRange fill:newFill];
}
/// @endcond
#pragma mark -
#pragma mark Description
/// @cond
-(NSString *)description
{
return [NSString stringWithFormat:@"<%@ with range: %@ and fill: %@>", [super description], self.range, self.fill];
}
/// @endcond
@end