File: setTitleLabelProperty.sci

package info (click to toggle)
scilab 5.3.3-10
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 330,656 kB
file content (239 lines) | stat: -rw-r--r-- 6,984 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2004-2006 - INRIA - Farid Belahcene
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution.  The terms
// are also available at    
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt

function [fail]=setTitleLabelProperty(PropertyName,PropertyValue,titlelabel,current_figure,cur_draw_mode)
// SETTITLELABELPROPERTY function
// is used by the functions title, xlabel, ylabel, zlabel
// This function sets the title (or x_, y_, z_label) properties 

fail=0;

//conversion to lower format
str = convstr(PropertyName);

//Property = ['foreground' 'clipping'];

[PName] = getTitleLabelPropertyNam(str,current_figure,cur_draw_mode)

if (PName==[])
  ResetFigureDDM(current_figure, cur_draw_mode);
  return;
end

select PName

  /////////////////////////
case 'font_size'       // <=> fontsize 
  /////////////////////////

if (type(PropertyValue)<>1 | size(PropertyValue,"*")<>1)
  warning("Color data  must be a scalar.");
  ResetFigureDDM(current_figure, cur_draw_mode);
  return;
end

titlelabel.font_size = PropertyValue
return
  

  /////////////////////////
case 'font_angle'  // <=> rotation
  /////////////////////////
if (type(PropertyValue)<>1 | size(PropertyValue,"*")<>1)
  warning("Color data  must be a scalar.");
  ResetFigureDDM(current_figure, cur_draw_mode);
  return;
end

titlelabel.auto_rotation = 'off'
newPropertyValue=modulo(PropertyValue,360)
titlelabel.font_angle = 360-newPropertyValue
return


  /////////////////////////
case 'font_foreground'         // <=> color or edgecolor
  /////////////////////////

  if (type(PropertyValue) == 10)
    index = getColorIndex(PropertyValue);
    
    ColorVal   = ['red' 'green' 'blue' 'cyan' 'magenta' 'yellow' 'black' 'black' 'white']

    if index < 10
      titlelabel.font_foreground = color(ColorVal(index));
    elseif index == 10  // 'none' selected
      titlelabel.color_mode = 0; // <=> - colormap(1) and not black at all!!
    else
      warning("Color value must be a 3 element vector or an index in the colormap.");
      ResetFigureDDM(current_figure, cur_draw_mode);
      return;
    end
  elseif (type(PropertyValue) == 1) // we entered plot(x,y,'Color',[R,G,B])
    
    if (size(PropertyValue,'*')==3)
      titlelabel.font_foreground = addcolor(PropertyValue);
    else
      warning("Incorrect input : Color vector should be a 3x1 or 1x3 vector");
      ResetFigureDDM(current_figure, cur_draw_mode);
      return;
    end

  else
    warning("Color value must be a 3 element vector or an index in the colormap.");
    ResetFigureDDM(current_figure, cur_draw_mode);
    return;
  end

  
   /////////////////////////
case 'foreground'        // <=> foregroundcolor
  /////////////////////////
  
if (type(PropertyValue) == 10)
    index = getColorIndex(PropertyValue);
    
    ColorVal   = ['red' 'green' 'blue' 'cyan' 'magenta' 'yellow' 'black' 'black' 'white']

   if index < 10
      titlelabel.fill_mode = 'on'
      titlelabel.foreground = color(ColorVal(index));
    elseif index == 10  // 'none' selected
      titlelabel.color_mode = 0; // <=> - colormap(1) and not black at all!!
    else
      warning("Color value must be a 3 elements vector or an index in the colormap.");
      ResetFigureDDM(current_figure, cur_draw_mode);
      return;
    end
elseif (type(PropertyValue) == 1) // we entered plot(x,y,'Color',[R,G,B])
    
    if (size(PropertyValue,'*')==3) 
      titlelabel.fill_mode = 'on'
      titlelabel.foreground = addcolor(PropertyValue);
    else
      warning("Incorrect input : Color vector should be a 3x1 or 1x3 vector");
      ResetFigureDDM(current_figure, cur_draw_mode);
      return;
    end
else
    warning("Color value must be a 3 elements vector or an index in the colormap.");
    ResetFigureDDM(current_figure, cur_draw_mode);
    return;
end
  
  
  /////////////////////////
case 'background'        // <=> backgroundcolor
  /////////////////////////

if (type(PropertyValue) == 10)
   
    index = getColorIndex(PropertyValue);
    
    ColorVal   = ['red' 'green' 'blue' 'cyan' 'magenta' 'yellow' 'black' 'black' 'white']

    if index < 10
      titlelabel.fill_mode = 'on'
      titlelabel.background = color(ColorVal(index));
    elseif index == 10  // 'none' selected
      titlelabel.color_mode = 0; // <=> - colormap(1) and not black at all!!
    else
      warning("Color value must be a 3 elements vector or an index in the colormap.");
      ResetFigureDDM(current_figure, cur_draw_mode);
      return;
    end
elseif (type(PropertyValue) == 1) // we entered plot(x,y,'Color',[R,G,B])
    
    if (size(PropertyValue,'*')==3) 
      titlelabel.fill_mode = 'on'
      titlelabel.background = addcolor(PropertyValue);
    else
      warning("Incorrect input : Color vector should be a 3x1 or 1x3 vector");
      ResetFigureDDM(current_figure, cur_draw_mode);
      return;
    end
else
    warning("Color value must be a 3 elements vector or an index in the colormap.");
    ResetFigureDDM(current_figure, cur_draw_mode);
    return;
end

  
  /////////////////////////
case 'text'        // <=> string
  /////////////////////////
  if (type(PropertyValue) == 10)   
     titlelabel.text = PropertyValue;
     return
  else
    warning("Incorrect input : ...");
    ResetFigureDDM(current_figure, cur_draw_mode);
    return;
  end
  

  /////////////////////////
case 'position'        // <=> position,  completer: la position par rapport  z n'est pas pris en compte, de plus le vecteur position doit contenir des coordonnes utilisateur (coordonnes selon l'axe)
  /////////////////////////

  if type(PropertyValue) == 1 & size(PropertyValue,"*")<=3    
    titlelabel.auto_position = 'off';
    titlelabel.position = PropertyValue ;
    return
  else
    warning("Incorrect input : ...");
    ResetFigureDDM(current_figure, cur_draw_mode);
    return;
  end

  
  /////////////////////////  
case 'visible'           // <=> visible
  /////////////////////////

  if type(PropertyValue) == 10
    newPropertyName = convstr(PropertyName);
    if or(PropertyValue == ['off' 'of'])
      titlelabel.visible = 'off';
      return
    elseif PropertyValue == 'on'
      titlelabel.visible = 'on'; 
        return
    else
      warning("Incorrect input : ...");
      ResetFigureDDM(current_figure, cur_draw_mode);
      return;
    end
  else
    warning("Incorrect input : ...");
    ResetFigureDDM(current_figure, cur_draw_mode);
    return;    
  end
  
 
  /////////////////////////  
case 'font_style'     // <=> fontangle
  /////////////////////////
 
    warning("unknown property value : ...");
    ResetFigureDDM(current_figure, cur_draw_mode);
    return;    
  
end

endfunction


function k=getIndexInStringTable(pattern,table)

str =  convstr(pattern);
k=find(part(table,1:length(str))==str);

endfunction