%
%  Basisklasse für alle Text-Objekte
%
classdef ShText < Shape
  properties (Access = protected)
    String   = '';
    FontSize = 10.0;
  end
    
  methods
    function obj = ShText( str, posX, posY )
      obj@Shape(posX,posY); 
      obj.String     = str;
      obj.FontSize   = 10.0;
    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    
    
    % Lines-Eigenschaften setzen
    function setTxtData( obj )
      obj.setString  ( obj.String );
      obj.setFontSize( obj.FontSize );
    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
    
  end  % methods 
  
end