0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % MPL2JPL converts a MATALB plist object into a java plist object.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % CALL: jpl = LTPDAworkbench.mpl2jpl(mpl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % M Hewitson 13-11-08
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % $Id: mpl2jpl.m,v 1.15 2011/04/18 16:57:17 ingo Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 function jpl = mpl2jpl(mpl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % build java plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 if isempty(mpl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 jpl = mpipeline.plisttable.JPlist('');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 jpl = mpipeline.plisttable.JPlist(mpl.name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 for aa=1:numel(mpl.params)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 pv = mpipeline.plisttable.JParamValue;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 if isa(mpl.params(aa).val, 'paramValue')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 options = mpl.params(aa).val.getOptions;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 for ll=1:numel(options)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 pval = convertVal(options{ll});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 type = class(pval);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 pv.addOption(pval, type);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 pv.setValIndex(mpl.params(aa).val.valIndex-1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 pv.setSelection(mpl.params(aa).val.selection);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 pval = convertVal(mpl.params(aa).val);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 pv.addOption(pval, class(pval));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 p = mpipeline.plisttable.JParam(mpl.params(aa).key, pv, mpl.params(aa).desc);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 jpl.add(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 function jval = convertVal(val)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 if ischar(val)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 jval = val;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 elseif isnumeric(val)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 if numel(val) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 jval = val;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 jval = utils.helper.mat2str(val);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 elseif iscell(val)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 jval = utils.prog.mcell2str(val);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 elseif islogical(val)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 if val
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 jval = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 jval = false;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 elseif isa(val, 'ltpda_nuo')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 jval = string(val);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 elseif isa(val, 'ltpda_uo')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 jval = string(val);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 % The 'string' method will fail when the object have more than one
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 % history step. In this case build we a PLIST which constructs the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 % object from the properties.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 pl = val.generateConstructorPlist();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 jval = string(pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 jval = char(val);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72
|