function TextPropUDF (TextFont,TextCol,flxType,idxt,idyt,idwt,idht,k,flx,h1,Thresh)
% TextPropUDF
% Based on user defined properties of text properties, changes
% text color and font properties on map images.
%
% O. Jamialahmadi
% TMU, Chem. Eng. Dept., Biotech. Group 
% Apr. 2015

if isempty(TextCol) % Set default value
    TextCol=[1, 0.98,0.82];
end

switch flxType
    case 'One'
        
       if isempty(TextFont) % Set default properties
            TextFont.FontName = 'Arial';
            TextFont.FontWeight = 'normal';
            TextFont.FontAngle = 'normal';
            TextFont.FontUnits = 'points';
            TextFont.FontSize = 8;
        end
        
        for m1=1:size(flx,1)
            if abs(flx(m1,k)) > Thresh
				x = abs(flx(m1,k));
				n=0;
				while (floor(x*10^n)~=x*10^n)
					n=n+1;
				end
				if n || n<1
					txtstr = '%.2f';
				else
					txtstr = '%d';
				end
                text(idxt(m1),idyt(m1)+(idht(m1)./2)...
                    ,num2str(abs(flx(m1,k)),txtstr)...
                    ,'FontSize',TextFont.FontSize,'FontName',...
                    TextFont.FontName,'FontWeight',...
                    TextFont.FontWeight,'FontAngle',...
                    TextFont.FontAngle,'FontUnits',...
                    TextFont.FontUnits,'Parent',h1,'Color'...
                    ,TextCol)
			else
				text(idxt(m1),idyt(m1)+(idht(m1)./2)...
                    ,num2str(0)...
                    ,'FontSize',TextFont.FontSize,'FontName',...
                    TextFont.FontName,'FontWeight',...
                    TextFont.FontWeight,'FontAngle',...
                    TextFont.FontAngle,'FontUnits',...
                    TextFont.FontUnits,'Parent',h1,'Color'...
                    ,[1,0,0])
            end
        end

    case 'Two'
        
       if isempty(TextFont) % Set default properties
            TextFont.FontName = 'Arial';
            TextFont.FontWeight = 'normal';
            TextFont.FontAngle = 'normal';
            TextFont.FontUnits = 'points';
            TextFont.FontSize = 7;
       end
        for m1=1:size(flx,1)
            if abs(flx(m1,k)) > Thresh
				x = abs(flx(m1,k));
				n=0;
				while (floor(x*10^n)~=x*10^n)
					n=n+1;
				end
				if n || n<1
					txtstr = '%.2f';
				else
					txtstr = '%d';
				end
                text(idxt(m1)+idwt(m1)./6,idyt(m1)+5,...
                    num2str(abs(flx(m1,k)),txtstr),...
                    'FontSize',TextFont.FontSize,'FontName',...
                    TextFont.FontName,'FontWeight',...
                    TextFont.FontWeight,'FontAngle',...
                    TextFont.FontAngle,'FontUnits',...
                    TextFont.FontUnits,'Parent',h1,'Color'...
                    ,TextCol)
            else
                text(idxt(m1)+idwt(m1)./3,idyt(m1)+5,...
                    num2str(0),...
                    'FontSize',TextFont.FontSize,'FontName',...
                    TextFont.FontName,'FontWeight',...
                    TextFont.FontWeight,'FontAngle',...
                    TextFont.FontAngle,'FontUnits',...
                    TextFont.FontUnits,'Parent',h1,'Color'...
                    ,[1,0,0])
            end
                % For 2nd set (lower)
            if abs(flx(m1,k+1)) > Thresh
				x = abs(flx(m1,k));
				n=0;
				while (floor(x*10^n)~=x*10^n)
					n=n+1;
				end
				if n || n<1
					txtstr = '%.2f';
                else 
					txtstr = '%d';
				end
                text(idxt(m1)+idwt(m1)./6,idyt(m1)+idht(m1)-4,...
                    num2str(abs(flx(m1,k+1)),txtstr),'FontSize',...
                    TextFont.FontSize,'FontName',TextFont.FontName,...
                    'FontWeight',TextFont.FontWeight,...
                    'FontAngle',TextFont.FontAngle,'FontUnits',...
                    TextFont.FontUnits,'Parent',h1,'Color'...
                    ,TextCol)
            else
                text(idxt(m1)+idwt(m1)./3,idyt(m1)+idht(m1)-4,...
                    num2str(0),'FontSize',...
                    TextFont.FontSize,'FontName',TextFont.FontName,...
                    'FontWeight',TextFont.FontWeight,...
                    'FontAngle',TextFont.FontAngle,'FontUnits',...
                    TextFont.FontUnits,'Parent',h1,'Color'...
                    ,[1,0,0])
            end
        end
end