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