<s> import ginga . canvas . types . all <EOL> class RenderContext ( object ) : <EOL> def __init__ ( self , viewer ) : <EOL> self . viewer = viewer <EOL> self . cr = None <EOL> def __get_color ( self , color , alpha ) : <EOL> clr = None <EOL> return clr <EOL> def set_line_from_shape ( self , shape ) : <EOL> pass <EOL> def set_fill_from_shape ( self , shape ) : <EOL> pass <EOL> def set_font_from_shape ( self , shape ) : <EOL> pass <EOL> def initialize_from_shape ( self , shape , line = True , fill = True , font = True ) : <EOL> if line : <EOL> self . set_line_from_shape ( shape ) <EOL> if fill : <EOL> self . set_fill_from_shape ( shape ) <EOL> if font : <EOL> self . set_font_from_shape ( shape ) <EOL> def set_line ( self , color , alpha = <NUM_LIT:1.0> , linewidth = <NUM_LIT:1> , style = '<STR_LIT>' ) : <EOL> pass <EOL> def set_fill ( self , color , alpha = <NUM_LIT:1.0> ) : <EOL> pass <EOL> def set_font ( self , fontname , fontsize , color = '<STR_LIT>' , alpha = <NUM_LIT:1.0> ) : <EOL> pass <EOL> def text_extents ( self , text ) : <EOL> width = <NUM_LIT:200> <EOL> height = <NUM_LIT:15> <EOL> return width , height <EOL> def draw_text ( self , cx , cy , text , rot_deg = <NUM_LIT:0.0> ) : <EOL> pass <EOL> def draw_polygon ( self , cpoints ) : <EOL> pass <EOL> def draw_circle ( self , cx , cy , cradius ) : <EOL> cradius = float ( cradius ) <EOL> self . draw_ellipse ( cx , cy , cradius , cradius , <NUM_LIT:0.0> ) <EOL> def draw_ellipse ( self , cx , cy , cradius , cyradius , theta ) : <EOL> pass <EOL> def draw_line ( self , cx1 , cy1 , cx2 , cy2 ) : <EOL> pass <EOL> def draw_path ( self , cpoints ) : <EOL> for i in range ( len ( cpoints ) - <NUM_LIT:1> ) : <EOL> cx1 , cy1 = cpoints [ i ] <EOL> cx2 , cy2 = cpoints [ i + <NUM_LIT:1> ] <EOL> def draw_bezier_curve ( self , cp ) : <EOL> pass <EOL> class CanvasRenderer ( object ) : <EOL> def __init__ ( self , viewer ) : <EOL> self . viewer = viewer <EOL> def setup_cr ( self , shape ) : <EOL> cr = RenderContext ( self . viewer ) <EOL> cr . initialize_from_shape ( shape , font = False ) <EOL> return cr <EOL> def get_dimensions ( self , shape ) : <EOL> cr = self . setup_cr ( shape ) <EOL> cr . set_font_from_shape ( shape ) <EOL> return cr . text_extents ( shape . text ) </s>
