-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAQTLabel.m
114 lines (99 loc) · 3.05 KB
/
AQTLabel.m
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
//
// AQTLabel.m
// AquaTerm
//
// Created by ppe on Wed May 16 2001.
// Copyright (c) 2001, 2002 Aquaterm. All rights reserved.
//
#import "AQTLabel.h"
@implementation AQTLabel
/**"
*** A leaf object class representing an actual item in the plot.
*** Since the app is a viewer we do three things with the object:
*** create (once), draw (any number of times) and (eventually) dispose of it.
"**/
-(id)initWithAttributedString:(NSAttributedString *)aString position:(NSPoint)aPoint angle:(float)textAngle shearAngle:(float)beta justification:(int32_t)justify
{
if (self=[super init])
{
string = [aString copy]; // [[NSAttributedString alloc] initWithAttributedString:aString];
fontName = @"Times-Roman";
fontSize = 14.0;
position=aPoint;
angle = textAngle;
shearAngle = beta;
justification = justify;
}
return self;
}
-(id)initWithString:(NSString *)aString position:(NSPoint)aPoint angle:(float)textAngle shearAngle:(float)beta justification:(int32_t)justify
{
/* return [self initWithAttributedString:[[[NSAttributedString alloc] initWithString:aString] autorelease]
position:aPoint
angle:textAngle
justification:justify];
*/
if (self=[super init])
{
string = [aString copy]; // [[NSAttributedString alloc] initWithAttributedString:aString];
fontName = @"Times-Roman";
fontSize = 14.0;
position=aPoint;
angle = textAngle;
shearAngle = beta;
justification = justify;
}
return self;
}
-(void)dealloc
{
[string release];
[fontName release];
[super dealloc];
}
- (void)setFontName:(NSString *)newFontName
{
if (fontName != newFontName)
{
NSString *oldValue = fontName;
fontName = [newFontName retain];
[oldValue release];
}
}
- (void)setFontSize:(float)newFontSize
{
fontSize = newFontSize;
}
-(NSString *)description
{
return [NSString stringWithFormat:@"%@\nwith string:\n%@", [super description], [string description]];
}
- (void)encodeWithCoder:(NSCoder *)coder
{
AQTPoint p;
[super encodeWithCoder:coder];
[coder encodeObject:string];
[coder encodeObject:fontName];
[coder encodeValueOfObjCType:@encode(float) at:&fontSize];
// 64bit safe
p.x = position.x; p.y = position.y;
[coder encodeValueOfObjCType:@encode(AQTPoint) at:&p];
[coder encodeValueOfObjCType:@encode(float) at:&angle];
[coder encodeValueOfObjCType:@encode(int32_t) at:&justification];
[coder encodeValueOfObjCType:@encode(float) at:&shearAngle];
}
-(id)initWithCoder:(NSCoder *)coder
{
AQTPoint p;
self = [super initWithCoder:coder];
string = [[coder decodeObject] retain];
fontName = [[coder decodeObject] retain];
[coder decodeValueOfObjCType:@encode(float) at:&fontSize];
[coder decodeValueOfObjCType:@encode(AQTPoint) at:&p];
position.x = p.x; position.y = p.y;
[coder decodeValueOfObjCType:@encode(float) at:&angle];
[coder decodeValueOfObjCType:@encode(int32_t) at:&justification];
[coder decodeValueOfObjCType:@encode(float) at:&shearAngle];
return self;
}
@end