diff options
author | Alex Merry <alex.merry@cs.ox.ac.uk> | 2012-04-18 13:45:43 +0100 |
---|---|---|
committer | Alex Merry <alex.merry@cs.ox.ac.uk> | 2012-04-18 13:45:43 +0100 |
commit | 2f6a98730f6af18a71b31c72468042f3b5b81915 (patch) | |
tree | 63dc3ece2a7ca80be03f5c32add0edc3d9693ce0 /tikzit/src/common/EdgeStyle.m | |
parent | b9c39efd55a5dd03a52e0ac3da191fed763f53db (diff) |
Add edge colours
Diffstat (limited to 'tikzit/src/common/EdgeStyle.m')
-rw-r--r-- | tikzit/src/common/EdgeStyle.m | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tikzit/src/common/EdgeStyle.m b/tikzit/src/common/EdgeStyle.m index da669e3..88b1f54 100644 --- a/tikzit/src/common/EdgeStyle.m +++ b/tikzit/src/common/EdgeStyle.m @@ -31,9 +31,16 @@ @"headStyle", @"decorationStyle", @"thickness", + @"colorRGB.red", + @"colorRGB.blue", + @"colorRGB.green", @"name", nil] triggerChangeNotificationsForDependentKey:@"tikz"]; + [self setKeys:[NSArray arrayWithObjects: + @"colorRGB.name", + nil] + triggerChangeNotificationsForDependentKey:@"colorIsKnown"]; } - (id)initWithName:(NSString*)nm { @@ -43,6 +50,7 @@ headStyle = AH_None; tailStyle = AH_None; decorationStyle = ED_None; + colorRGB = [[ColorRGB alloc] initWithRed:0 green:0 blue:0]; name = nm; category = nil; thickness = 1.0f; @@ -64,12 +72,14 @@ [style setTailStyle:[self tailStyle]]; [style setDecorationStyle:[self decorationStyle]]; [style setThickness:[self thickness]]; + [style setColorRGB:[self colorRGB]]; return style; } - (void)dealloc { [name release]; [category release]; + [colorRGB release]; [super dealloc]; } @@ -127,9 +137,26 @@ } } +- (ColorRGB*)colorRGB { + return colorRGB; +} + +- (void)setColorRGB:(ColorRGB*)c { + if (colorRGB != c) { + ColorRGB *oldValue = colorRGB; + colorRGB = [c copy]; + [self postPropertyChanged:@"colorRGB" oldValue:oldValue]; + [oldValue release]; + } +} + - (NSString*)tikz { NSMutableString *buf = [NSMutableString stringWithFormat:@"\\tikzstyle{%@}=[", name]; + NSString *colorName = [colorRGB name]; + if (colorName == nil) + colorName = [colorRGB hexName]; + if (tailStyle == AH_Plain) [buf appendString:@"<"]; else if (tailStyle == AH_Latex) @@ -142,6 +169,9 @@ else if (headStyle == AH_Latex) [buf appendString:@"latex"]; + [buf appendString:@",draw="]; + [buf appendString:colorName]; + if (decorationStyle != ED_None) { [buf appendString:@",postaction={decorate},decoration={markings,mark="]; if (decorationStyle == ED_Arrow) |