%
%  Abgel. Klasse für Strecken-Objekte
%
classdef ShLine < ShLines
  properties (Access = private)
    lenX = 0;
    lenY = 0;
  end  % properties
    
  methods
    function obj = ShLine( varargin )
      % Konstruktor
      obj@ShLines(0,0);
      obj.hnd = [];
      
      isCopyConstr = 0;
      posX = 0;
      posY = 0;
      % 1 Argument: Copy-Konstruktor
      if( nargin == 1 )
        obj1 = varargin{1}; 
        if( isa( obj1, 'ShLine' ) )
          isCopyConstr = 1;
        else     % Fehlerfall 
          obj = ShLine.empty;
          error( 'ShLine Kopierkonstruktor: falsches Argument' );
        end
      % mindestens 2 Argumente: lenX, lenY    
      elseif( nargin >= 2 )
        len_X = varargin{1};
        len_Y = varargin{2};
        % und noch posX und posX
        if( nargin == 4 )
          posX = varargin{3};
          posY = varargin{4};  
        end
      end
  
      if( isCopyConstr )    % Fall Copy Konstruktor 
        setData( obj, obj1 );
      else
        obj.x = posX;
        obj.y = posY;
        obj.lenX = len_X;
        obj.lenY = len_Y;
      end
    end
    
    function disp( obj )
      disp@Shape(obj);
      fprintf( 'lenX = %g, lenY = %g \n', obj.lenX, obj.lenY );
    end
  
    function draw( obj )      
      clear( obj );    % Methode von Shape
      % Koordinaten 
      x = [obj.x, obj.x + obj.lenX];
      y = [obj.y, obj.y + obj.lenY];
      % Plotten und MATLAB Handle merken 
      obj.hnd = plot( x,y );           
      % Lines-Eigenschaften setzen
      obj.setLnData();
    end
    
  end  % methods
      
  % private Funktionen
  methods ( Access = private )
    
    function setData( obj, obj1 )  
      obj.x = obj1.x;
      obj.y = obj1.y;
      obj.lenX = obj1.lenX;
      obj.lenY = obj1.lenY;
      setLnData( obj, obj1 );
    end
    
  end
end