package org.cipres.kepler.testcase; //Cipres package import javax.swing.JOptionPane; import org.cipres.CipresIDL.api1.DataMatrix; import org.cipres.CipresIDL.api1.Rid3TreeImprove; import org.cipres.CipresIDL.api1.Tree; import org.cipres.helpers.CipresServiceDialog; import org.cipres.helpers.RegistryEntryWrapper; import org.cipres.kepler.registry.Globals; public class TestRecIDCM3Actor { // the final tree data structure in CIPRes IDL format private Tree _finalTree = null; // the RecIDCM3 registry entry wrapper private RegistryEntryWrapper _rid3Wrapper = null; // the RecIDCM3 service Rid3TreeImprove _service = null; // initialize the RecIDCM3 public TestRecIDCM3Actor() { try { // get RecIDCM3 algorithm wrapper _rid3Wrapper = Globals.getInstance().getRegistry().getCipresService(Rid3TreeImprove.class); // get the RecIDCM3 algorithm wrapper _service = (Rid3TreeImprove)_rid3Wrapper.getService(); } catch (Exception ex) { ex.printStackTrace(); if (_rid3Wrapper!=null) _rid3Wrapper.releaseService(); } } // set the initial tree public void setTree(Tree tree) { if (_service!=null) _service.setTree(tree); } // set the data matrix public void setDataMatrix(DataMatrix dataMatrix) { try { if (_service!=null) _service.setMatrix(dataMatrix); } catch (Exception ex) { ex.printStackTrace(); if (_rid3Wrapper!=null) _rid3Wrapper.releaseService(); } } // get the final improved tree public Tree getFinalTree() { try { // use GuiGen to get users' settings CipresServiceDialog dialog = _rid3Wrapper.getServiceDialog(null); int status = dialog.showAndInitialize(); if (status == CipresServiceDialog.OK) { // infer the result tree _finalTree = _service.improveTree(null); } else if (status == CipresServiceDialog.ERROR) { JOptionPane.showMessageDialog(null, "error initializing service"); } return _finalTree; } catch (Exception ex) { ex.printStackTrace(); if (_rid3Wrapper!=null) _rid3Wrapper.releaseService(); } return null; } }