function initialize(Constr,iConstr)
%INITIALIZE   Initializes rectangular constraint objects

%   Author(s): N. Hickey, A. Stothert
%   Copyright 1986-2004 The MathWorks, Inc. 
%   $Revision: 1.1.6.1 $  $Date: 2004/12/10 19:32:12 $

if nargin<2, iConstr = 1:numel(Constr); end

for idx = iConstr
   % Add generic listeners and mouse event callbacks
   Constr(idx).addlisteners;

   % Add @rectelement-specific listeners
   p = [...
      Constr(idx).findprop('xCoords') ; ...
      Constr(idx).findprop('yCoords')];
   Listener = handle.listener(Constr(idx),p,'PropertyPostSet',{@localUpdate Constr(idx)});
   Listener.CallbackTarget = Constr(idx);
   Listener = [Listener; ...
      handle.listener(Constr(idx),Constr(idx).findprop('SelectedEdge'),...
      'PropertyPostSet', {@localUpdateEdge Constr(idx)})];
   Constr(idx).addlisteners(Listener);
end

%--------------------------------------------------------------------------
function localUpdate(hSrc,hData,Constr)

%Call method to update coordinates
Constr.updateCoords;

%Call the superclass update method to re-render the constraint
Constr.update

%--------------------------------------------------------------------------
function localUpdateEdge(hSrc,hData,Constr)

Constr.update