2525import beast .base .evolution .tree .TraitSet ;
2626import beast .base .evolution .tree .Tree ;
2727import beast .base .inference .parameter .RealParameter ;
28+ import beast .base .spec .domain .Real ;
29+ import beast .base .spec .inference .parameter .RealVectorParam ;
2830import beastfx .app .inputeditor .BeautiDoc ;
2931import beastfx .app .inputeditor .InputEditor ;
3032import beastfx .app .util .FXUtils ;
@@ -109,13 +111,13 @@ public void init(Input<?> input, BEASTInterface beastObject, int itemNr,
109111 mainInputBox .getChildren ().add (changeTimesBox );
110112
111113 if (nChanges > 0 ) {
112- updateChangeTimesUI ((RealParameter ) skylineParameter .changeTimesInput .get (),
114+ updateChangeTimesUI ((RealVectorParam <? extends Real > ) skylineParameter .changeTimesInput .get (),
113115 changeTimesEntryRow );
114116 timesAreAgesCheckBox .setSelected (skylineParameter .timesAreAgesInput .get ());
115117 timesAreRelativeCheckBox .setSelected (skylineParameter .timesAreRelativeInput .get ());
116118
117119 estimateTimesCheckBox .setSelected (
118- ((RealParameter ) skylineParameter .changeTimesInput .get ())
120+ ((RealVectorParam <? extends Real > ) skylineParameter .changeTimesInput .get ())
119121 .isEstimatedInput .get ());
120122 } else {
121123 changeTimesBox .setVisible (false );
@@ -124,7 +126,8 @@ public void init(Input<?> input, BEASTInterface beastObject, int itemNr,
124126
125127 // Add elements specific to values
126128
127- RealParameter valuesParameter = (RealParameter ) skylineParameter .skylineValuesInput .get ();
129+ RealVectorParam <? extends Real > valuesParameter =
130+ (RealVectorParam <? extends Real >) skylineParameter .skylineValuesInput .get ();
128131
129132 boxHoriz = FXUtils .newHBox ();
130133 boxHoriz .getChildren ().add (new Label ("Values:" ));
@@ -163,7 +166,7 @@ public void init(Input<?> input, BEASTInterface beastObject, int itemNr,
163166 mainInputBox .getChildren ().add (epochVisualizer );
164167
165168 int nTypes = skylineParameter .getNTypes ();
166- if (valuesParameter .getDimension () == (nChanges + 1 )) {
169+ if (valuesParameter .size () == (nChanges + 1 )) {
167170 if (nTypes > 1 ) {
168171 scalarRatesCheckBox .setSelected (true );
169172 scalarRatesCheckBox .disableProperty ().set (false );
@@ -186,13 +189,14 @@ public void init(Input<?> input, BEASTInterface beastObject, int itemNr,
186189 System .out .println (oldValue + " -> " + newValue );
187190
188191 if (newValue > 0 ) {
189- RealParameter param = (RealParameter ) skylineParameter .changeTimesInput .get ();
192+ RealVectorParam <? extends Real > param =
193+ (RealVectorParam <? extends Real >) skylineParameter .changeTimesInput .get ();
190194 if (param == null ) {
191195 if (!doc .pluginmap .containsKey (getChangeTimesParameterID ())) {
192- param = new RealParameter ( " 0.0" );
196+ param = new RealVectorParam <>( new double [] { 0.0 }, Real . INSTANCE );
193197 param .setID (getChangeTimesParameterID ());
194198 } else {
195- param = (RealParameter ) doc .pluginmap .get (getChangeTimesParameterID ());
199+ param = (RealVectorParam <? extends Real > ) doc .pluginmap .get (getChangeTimesParameterID ());
196200 }
197201 skylineParameter .changeTimesInput .setValue (param , skylineParameter );
198202 }
@@ -205,7 +209,7 @@ public void init(Input<?> input, BEASTInterface beastObject, int itemNr,
205209 ensureValuesConsistency ();
206210
207211 if (newValue > 0 ) {
208- updateChangeTimesUI ((RealParameter ) skylineParameter .changeTimesInput .get (),
212+ updateChangeTimesUI ((RealVectorParam <? extends Real > ) skylineParameter .changeTimesInput .get (),
209213 changeTimesEntryRow );
210214 timesAreAgesCheckBox .setSelected (skylineParameter .timesAreAgesInput .get ());
211215
@@ -248,17 +252,18 @@ public void init(Input<?> input, BEASTInterface beastObject, int itemNr,
248252
249253 distributeChangeTimesButton .setOnAction (e -> {
250254
251- RealParameter changeTimesParam = (RealParameter ) skylineParameter .changeTimesInput .get ();
252- int nTimes = changeTimesParam .getDimension ();
253- double processLength = skylineParameter .processLengthInput .get ().getArrayValue ();
255+ RealVectorParam <? extends Real > changeTimesParam =
256+ (RealVectorParam <? extends Real >) skylineParameter .changeTimesInput .get ();
257+ int nTimes = changeTimesParam .size ();
258+ double processLength = skylineParameter .processLengthInput .get ().get ();
254259
255260 if (skylineParameter .timesAreRelativeInput .get ()) {
256261 for (int i = 0 ; i < nTimes ; i ++) {
257- changeTimesParam .setValue (i , ((double ) (i + 1 )) / (nTimes + 1 ));
262+ changeTimesParam .set (i , ((double ) (i + 1 )) / (nTimes + 1 ));
258263 }
259264 } else {
260265 for (int i = 0 ; i < nTimes ; i ++) {
261- changeTimesParam .setValue (i , processLength *(i +1 ) / (nTimes + 1 ));
266+ changeTimesParam .set (i , processLength *(i +1 ) / (nTimes + 1 ));
262267 }
263268 }
264269
@@ -301,21 +306,21 @@ public void init(Input<?> input, BEASTInterface beastObject, int itemNr,
301306 * @param parameter change times parameter
302307 * @param changeTimesEntryRow HBox containing time inputs
303308 */
304- void updateChangeTimesUI (RealParameter parameter ,
309+ void updateChangeTimesUI (RealVectorParam <? extends Real > parameter ,
305310 HBox changeTimesEntryRow ) {
306311 changeTimesEntryRow .getChildren ().clear ();
307312 changeTimesEntryRow .getChildren ().add (new Label ("Change times:" ));
308- for (int i =0 ; i <parameter .getDimension (); i ++) {
313+ for (int i =0 ; i <parameter .size (); i ++) {
309314 changeTimesEntryRow .getChildren ().add (new Label ("Epoch " + (i +1 ) + "->" + (i +2 ) + ": " ));
310- TextField textField = new TextField (parameter .getValue (i ). toString ( ));
315+ TextField textField = new TextField (String . valueOf ( parameter .get (i )));
311316
312317 textField .setPrefWidth (50 );
313318 textField .setPadding (new Insets (0 ));
314319 HBox .setMargin (textField , new Insets (0 , 10 , 0 , 0 ));
315320
316321 int index = i ;
317322 textField .textProperty ().addListener ((observable , oldValue , newValue ) -> {
318- parameter .setValue (index , Double .valueOf (newValue ));
323+ parameter .set (index , Double .parseDouble (newValue ));
319324 sanitiseRealParameter (parameter );
320325 skylineParameter .initAndValidate ();
321326 System .out .println (skylineParameter );
@@ -326,10 +331,10 @@ void updateChangeTimesUI(RealParameter parameter,
326331 }
327332 }
328333
329- void sanitiseRealParameter (RealParameter parameter ) {
334+ void sanitiseRealParameter (RealVectorParam <? extends Real > parameter ) {
330335 parameter .valuesInput .setValue (
331- Arrays . stream ( parameter .getDoubleValues () )
332- .mapToObj ( String :: valueOf )
336+ parameter .getElements (). stream ( )
337+ .map ( Object :: toString )
333338 .collect (Collectors .joining (" " )),
334339 parameter );
335340 parameter .initAndValidate ();
0 commit comments