@@ -6,16 +6,7 @@ use axis;
66use svg_render;
77use text_render;
88use representation:: Representation ;
9-
10- /**
11- The marker that should be used for the points of the scatter plot
12- */
13- #[ derive( Debug , Clone ) ]
14- pub enum Marker {
15- Circle ,
16- Square ,
17- Cross ,
18- }
9+ use style;
1910
2011/// `Style` follows the 'optional builder' pattern
2112/// Each field is a `Option` which start as `None`
@@ -24,7 +15,7 @@ pub enum Marker {
2415/// Settings will be cloned in and out of it.
2516#[ derive( Debug , Default ) ]
2617pub struct Style {
27- marker : Option < Marker > ,
18+ marker : Option < style :: Marker > ,
2819 colour : Option < String > ,
2920}
3021
@@ -36,45 +27,41 @@ impl Style {
3627 }
3728 }
3829
39- pub fn overlay ( & mut self , other : Self ) {
30+ pub fn overlay ( & mut self , other : & Self ) {
4031 match other. marker {
41- Some ( v) => self . marker = Some ( v) ,
32+ Some ( ref v) => self . marker = Some ( v. clone ( ) ) ,
4233 None => { }
4334 }
4435 match other. colour {
45- Some ( v) => self . colour = Some ( v) ,
36+ Some ( ref v) => self . colour = Some ( v. clone ( ) ) ,
4637 None => { }
4738 }
4839 }
40+ }
4941
50- pub fn marker < T > ( mut self , value : T ) -> Self
42+ impl style:: Point for Style {
43+ fn marker < T > ( & mut self , value : T ) -> & mut Self
5144 where
52- T : Into < Marker > ,
45+ T : Into < style :: Marker > ,
5346 {
5447 self . marker = Some ( value. into ( ) ) ;
5548 self
5649 }
5750
58- pub fn get_marker ( & self ) -> Marker {
59- match self . marker . clone ( ) {
60- Some ( v) => v,
61- None => Marker :: Circle ,
62- }
51+ fn get_marker ( & self ) -> & Option < style:: Marker > {
52+ & self . marker
6353 }
6454
65- pub fn colour < T > ( mut self , value : T ) -> Self
55+ fn colour < T > ( & mut self , value : T ) -> & mut Self
6656 where
6757 T : Into < String > ,
6858 {
6959 self . colour = Some ( value. into ( ) ) ;
7060 self
7161 }
7262
73- pub fn get_colour ( & self ) -> String {
74- match self . colour . clone ( ) {
75- Some ( v) => v,
76- None => "" . into ( ) ,
77- }
63+ fn get_colour ( & self ) -> & Option < String > {
64+ & self . colour
7865 }
7966}
8067
@@ -99,8 +86,8 @@ impl Scatter {
9986 }
10087 }
10188
102- pub fn style ( mut self , style : Style ) -> Self {
103- self . style . overlay ( style) ;
89+ pub fn style ( mut self , style : & Style ) -> Self {
90+ self . style . overlay ( & style) ;
10491 self
10592 }
10693
0 commit comments