%
%  Basisklasse für alle Text-Objekte
%
classdef ShText < Shape
  properties (Access = protected)
    String     = '';
    FontSize   = 10.0;
    Color      = LnColor.k;
    FontWeight = TxtWeight.normal;
    FntAngle   = FontAngle.normal;
    Rotation   = 0.0;   % in Grad  
  end
    
  methods
    function obj = ShText( str, posX, posY )
      obj@Shape(posX,posY); 
      obj.String     = str;
      obj.FontSize   = 10.0;
      obj.Color      = LnColor.k;
      obj.FontWeight = TxtWeight.normal;
      obj.FntAngle   = FontAngle.normal;
      obj.Rotation   = 0.0;   % in Grad
    end
    
    function draw( obj )      
      clear( obj );    % Methode von Shape
      % Plotten und MATLAB Handle merken 
      obj.hnd = text( obj.x,obj.y, obj.String ); 
      obj.setTxtData();   % Text-Eigenschaften setzen
    end    
    
    % Text-Eigenschaften setzen
    function setTxtData( obj )
      obj.setString    ( obj.String );
      obj.setColor     ( obj.Color );
      obj.setFontSize  ( obj.FontSize );
      obj.setFontWeight( obj.FontWeight );
      obj.setRotation  ( obj.Rotation );
      obj.setFontAngle ( obj.FntAngle );
    end    

    function setString( obj, str )
      if( ~isShTxtObj(obj) ) return; end
      obj.String = str;   % Daten merken für nächsten Plot 
      hnd = obj.hnd;
      if( ~isMatlabHandle(hnd) ) return; end
      set( hnd, 'String', str );
    end
    
    % FontSize für Graphic Handle hnd setzen
    function setFontSize( obj, sz )
      if( ~isShTxtObj(obj) ) return; end
      obj.FontSize = sz;      
      hnd = obj.hnd;
      if( ~isMatlabHandle(hnd) ) return; end
      set( hnd, 'FontSize', sz );
    end
    
    % Rotation (in Grad) für Graphic Handle hnd setzen
    function setRotation( obj, val )
      if( ~isShTxtObj(obj) ) return; end
      obj.Rotation = val;      
      hnd = obj.hnd;
      if( ~isMatlabHandle(hnd) ) return; end
      set( hnd, 'Rotation', val );
    end
    
    function setColor( obj, col )
      if( ~isShTxtObj(obj) ) return; end
      obj.Color = col;   % Daten merken für nächsten Plot 
      hnd = obj.hnd;
      LnColor.set( hnd, col );
    end

    % FontWeight für Graphic Handle hnd setzen
    function setFontWeight( obj, wgt )
      if( ~isShTxtObj(obj) ) return; end
      obj.FontWeight = wgt;      
      hnd = obj.hnd;
      TxtWeight.set( hnd, wgt );
    end
    
     % FontAngle für Graphic Handle hnd setzen
    function setFontAngle( obj, angle )
      if( ~isShTxtObj(obj) ) return; end
      obj.FntAngle = angle;      
      hnd = obj.hnd;
      FontAngle.set( hnd, angle );
    end    
    
  end  % methods 
  
end