0001 function drawText(x,y, drawString, fontSize, fontStyle, color, font, fontWeight, flagCenter)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 global CB_MAP_OUTPUT
0020 global mapHandle
0021
0022 if nargin < 4
0023 fontSize = 12;
0024 end
0025 if nargin < 5
0026 fontStyle = 'normal';
0027 end
0028 if nargin < 6
0029 color = [0 0 0];
0030 end
0031 if nargin < 7
0032 font = 'sans-serif';
0033 end
0034 if nargin <8
0035 fontWeight = 'normal';
0036 end
0037 if nargin < 9
0038 flagCenter = false;
0039 end
0040
0041
0042
0043 if iscell(drawString)
0044 display ('whoops - this shouldnt happen. drawText.m')
0045
0046
0047 drawString = drawString{1};
0048 end
0049 if isnan(x) | isnan(y) | isnan(fontSize)
0050
0051 return;
0052 end
0053 if strcmp(CB_MAP_OUTPUT, 'matlab')
0054 if find(color>1)
0055 color = color/255;
0056 end
0057 if flagCenter
0058 text(x,-y,drawString, 'FontSize', fontSize/2, 'color', color,'HorizontalAlignment','center');
0059 else
0060 text(x,-y,drawString, 'FontSize', fontSize/2, 'color', color);
0061 end
0062 elseif strcmp(CB_MAP_OUTPUT, 'java')
0063
0064 elseif strcmp(CB_MAP_OUTPUT, 'svg')
0065
0066 if ischar(color)
0067 if color=='k'
0068 colorStroke = 'rgb(0,0,0)';
0069 else
0070 colorStroke = color;
0071 end
0072 else if isvector(color)
0073 colorStroke = strcat('rgb(',num2str(color(1)),',',num2str(color(2)),',',num2str(color(3)),')');
0074 end
0075 end
0076 drawString = regexprep(drawString,'&','&');
0077 fprintf(mapHandle, '<g style="font-family: %s; font-style: %s; font-weight: %s; stroke: none;">\n',font,fontStyle, fontWeight);
0078 if flagCenter
0079 fprintf(mapHandle,'<text style="fill: %s; text-rendering: optimizeLegibility;" x="%.2f" y="%.2f" font-size="%dpx">%s</text>\n</g>\n',colorStroke,x-(length(drawString)*fontSize*1.25),y+(5*fontSize),5*fontSize,drawString);
0080 else
0081 fprintf(mapHandle,'<text style="fill: %s; text-rendering: optimizeLegibility;" x="%.2f" y="%.2f" font-size="%dpx">%s</text>\n</g>\n',colorStroke,x,y,5*fontSize,drawString);
0082 end
0083
0084 else
0085 display('error CB_MAP_OUTPUT in drawText');
0086 end