<s> from __future__ import absolute_import , division , print_function <EOL> from glue . config import settings <EOL> from glue . external . echo import callback_property <EOL> from glue . external import six <EOL> VALID_LINESTYLES = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:none>' ] <EOL> __all__ = [ '<STR_LIT>' ] <EOL> class VisualAttributes ( object ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , parent = None , washout = False , color = settings . DATA_COLOR ) : <EOL> self . parent = parent <EOL> self . _atts = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> self . color = color <EOL> self . alpha = <NUM_LIT:0.5> <EOL> self . linewidth = <NUM_LIT:1> <EOL> self . linestyle = '<STR_LIT>' <EOL> self . marker = '<STR_LIT:o>' <EOL> self . markersize = <NUM_LIT:3> <EOL> def __eq__ ( self , other ) : <EOL> if not isinstance ( other , VisualAttributes ) : <EOL> return False <EOL> elif self is other : <EOL> return True <EOL> else : <EOL> return all ( getattr ( self , a ) == getattr ( other , a ) for a in self . _atts ) <EOL> if six . PY3 : <EOL> __hash__ = object . __hash__ <EOL> def set ( self , other ) : <EOL> """<STR_LIT>""" <EOL> for att in self . _atts : <EOL> setattr ( self , att , getattr ( other , att ) ) <EOL> def copy ( self , new_parent = None ) : <EOL> """<STR_LIT>""" <EOL> result = VisualAttributes ( ) <EOL> result . set ( self ) <EOL> if new_parent is not None : <EOL> result . parent = new_parent <EOL> return result <EOL> @ callback_property <EOL> def color ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _color <EOL> @ color . setter <EOL> def color ( self , value ) : <EOL> if isinstance ( value , six . string_types ) : <EOL> self . _color = value . lower ( ) <EOL> else : <EOL> self . _color = value <EOL> @ callback_property <EOL> def alpha ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _alpha <EOL> @ alpha . setter <EOL> def alpha ( self , value ) : <EOL> self . _alpha = value <EOL> @ callback_property <EOL> def linestyle ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _linestyle <EOL> @ linestyle . setter <EOL> def linestyle ( self , value ) : <EOL> if value not in VALID_LINESTYLES : <EOL> raise Exception ( "<STR_LIT>" % <EOL> '<STR_LIT:/>' . join ( VALID_LINESTYLES ) ) <EOL> self . _linestyle = value <EOL> @ callback_property <EOL> def linewidth ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _linewidth <EOL> @ linewidth . setter <EOL> def linewidth ( self , value ) : <EOL> if type ( value ) not in [ float , int ] : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> if value < <NUM_LIT:0> : <EOL> raise Exception ( "<STR_LIT>" ) <EOL> self . _linewidth = value <EOL> @ callback_property <EOL> def marker ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _marker <EOL> @ marker . setter <EOL> def marker ( self , value ) : <EOL> self . _marker = value <EOL> @ callback_property <EOL> def markersize ( self ) : <EOL> return self . _markersize <EOL> @ markersize . setter <EOL> def markersize ( self , value ) : <EOL> self . _markersize = int ( value ) <EOL> def __setattr__ ( self , attribute , value ) : <EOL> allowed = set ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> if attribute not in allowed and not attribute . startswith ( '<STR_LIT:_>' ) : <EOL> raise Exception ( "<STR_LIT>" % attribute ) <EOL> changed = getattr ( self , attribute , None ) != value <EOL> super ( VisualAttributes , self ) . __setattr__ ( attribute , value ) <EOL> if ( changed and hasattr ( self , '<STR_LIT>' ) and <EOL> hasattr ( self . parent , '<STR_LIT>' ) and <EOL> attribute != '<STR_LIT>' and not attribute . startswith ( '<STR_LIT:_>' ) ) : <EOL> self . parent . broadcast ( '<STR_LIT>' ) </s>
