You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: SelectPolyline.m
    path of file: ./repos/ImageM/ImageM/+imagem/+tools
    
    the code of the file until where you have to start completion: classdef SelectPolyline < imagem.gui.Tool
% Select a polyline, right-click to end.
%
%   Class SelectPolylineTool
%
%   Example
%   SelectPolylineTool
%
%   See also
%

% ------
% Author: David Legland
% e-mail: david.legland@inra.fr
% Created: 2012-03-14,    using Matlab 7.9.0
    
function deselect(obj)
        removeLineHandle(obj);
    end
    
    function removeLineHandle(obj)
        if ~ishandle(obj.LineHandle)
            return;
        end
        
        ax = obj.Viewer.Handles.ImageAxis;
        if isempty(ax)
            return;
        end
       
        delete(obj.LineHandle);
        
    end
    
    function onMouseButtonPressed(obj, hObject, eventdata) %#ok<INUSD>
        ax = obj.Viewer.Handles.ImageAxis;
        pos = get(ax, 'CurrentPoint');
        
        % check if right-clicked or double-clicked
        type = get(obj.Viewer.Handles.Figure, 'SelectionType');
        if ~strcmp(type, 'normal')
            % update viewer's current selection
            shape = struct('Type', 'Polyline', 'Data', obj.Positions);
            obj.Viewer.Selection = shape;
            
            obj.Positions = zeros(0, 2);
            return;
        end