use of cbit.vcell.modelopt.gui.MultisourcePlotPane in project vcell by virtualcell.
the class ParameterEstimationRunTaskPanel method plot.
private void plot() {
try {
java.util.Vector<DataSource> dataSourceList = new java.util.Vector<DataSource>();
java.util.Vector<String> nameVector = new java.util.Vector<String>();
ModelOptimizationSpec modelOptimizationSpec = parameterEstimationTask.getModelOptimizationSpec();
final ReferenceDataMappingSpec[] mappingSpecs = modelOptimizationSpec.getReferenceDataMappingSpecs();
int timeIndex = modelOptimizationSpec.getReferenceDataTimeColumnIndex();
ReferenceData referenceData = modelOptimizationSpec.getReferenceData();
if (referenceData != null) {
dataSourceList.add(new DataSource.DataSourceReferenceData("EXPT", timeIndex, referenceData));
String[] refColumnNames = referenceData.getColumnNames();
for (int i = 0; i < refColumnNames.length; i++) {
if (i == timeIndex) {
continue;
}
nameVector.add(refColumnNames[i]);
break;
}
}
ParameterEstimationTaskSimulatorIDA parestSimulator = new ParameterEstimationTaskSimulatorIDA();
ODESolverResultSet odeSolverResultSet = parestSimulator.getOdeSolverResultSet(parameterEstimationTask);
if (odeSolverResultSet != null) {
dataSourceList.add(new DataSource.DataSourceRowColumnResultSet("EST", odeSolverResultSet));
if (mappingSpecs != null) {
for (int i = 0; i < mappingSpecs.length; i++) {
if (i == timeIndex) {
continue;
}
Variable var = parameterEstimationTask.getMathSymbolMapping().getVariable(mappingSpecs[i].getModelObject());
nameVector.add(var.getName());
break;
}
}
}
DataSource[] dataSources = (DataSource[]) BeanUtils.getArray(dataSourceList, DataSource.class);
MultisourcePlotPane multisourcePlotPane = new MultisourcePlotPane();
multisourcePlotPane.setGroupingListSorter(new Comparator<SortDataReferenceHelper>() {
@Override
public int compare(SortDataReferenceHelper o1, SortDataReferenceHelper o2) {
DataSource ds01 = o1.dataReference.getDataSource();
DataSource ds02 = o2.dataReference.getDataSource();
// System.out.println(ds01.getClass().getSimpleName()+" "+o1.dataReference.getIdentifier()+" "+ds02.getClass().getSimpleName()+" "+o2.dataReference.getIdentifier());
if (ds01 instanceof DataSource.DataSourceReferenceData) {
if (ds02 instanceof DataSource.DataSourceReferenceData) {
// both reference data, sort names
ReferenceDataMappingSpec mspec01 = null;
ReferenceDataMappingSpec mspec02 = null;
for (ReferenceDataMappingSpec rdMappingSpec : mappingSpecs) {
// Variable var = parameterEstimationTask.getMathSymbolMapping().getVariable(rdMappingSpec.getModelObject());
if (rdMappingSpec.getModelObject() instanceof ReservedSymbol) {
continue;
}
if (o1.dataReference.getIdentifier().equals(rdMappingSpec.getReferenceDataColumnName())) {
mspec01 = rdMappingSpec;
o1.setReferenceDataMappingSpec(rdMappingSpec);
} else if (o2.dataReference.getIdentifier().equals(rdMappingSpec.getReferenceDataColumnName())) {
mspec02 = rdMappingSpec;
o2.setReferenceDataMappingSpec(rdMappingSpec);
}
}
if (mspec01 == null && mspec02 == null) {
return o1.dataReference.getIdentifier().compareToIgnoreCase(o2.dataReference.getIdentifier());
} else if (mspec01 != null && mspec02 != null) {
return mspec01.getReferenceDataColumnName().compareToIgnoreCase(mspec02.getReferenceDataColumnName());
} else if (mspec01 != null && mspec02 == null) {
return -1;
} else {
return 1;
}
} else {
// compare ref to ode
ReferenceDataMappingSpec mspec01 = null;
ReferenceDataMappingSpec mspec02 = null;
for (ReferenceDataMappingSpec rdMappingSpec : mappingSpecs) {
Variable var = parameterEstimationTask.getMathSymbolMapping().getVariable(rdMappingSpec.getModelObject());
if (rdMappingSpec.getModelObject() instanceof ReservedSymbol) {
continue;
}
if (o1.dataReference.getIdentifier().equals(rdMappingSpec.getReferenceDataColumnName())) {
mspec01 = rdMappingSpec;
o1.setReferenceDataMappingSpec(rdMappingSpec);
} else if (o2.dataReference.getIdentifier().equals(var.getName())) {
mspec02 = rdMappingSpec;
o2.setReferenceDataMappingSpec(rdMappingSpec);
}
}
if (mspec01 == null && mspec02 == null) {
return -1;
} else if (mspec01 != null && mspec02 == null) {
return -1;
} else if (mspec02 != null && mspec01 == null) {
return 1;
} else {
// BeanUtils.forceStringSize(mspec02.getReferenceDataColumnName(), 25, " ", true));
return mspec01.getReferenceDataColumnName().compareToIgnoreCase(mspec02.getReferenceDataColumnName());
}
}
} else {
if (ds02 instanceof DataSource.DataSourceRowColumnResultSet) {
// both OdeSolverResultSet data, sort names
ReferenceDataMappingSpec mspec01 = null;
ReferenceDataMappingSpec mspec02 = null;
for (ReferenceDataMappingSpec rdMappingSpec : mappingSpecs) {
Variable var = parameterEstimationTask.getMathSymbolMapping().getVariable(rdMappingSpec.getModelObject());
if (rdMappingSpec.getModelObject() instanceof ReservedSymbol) {
continue;
}
if (o1.dataReference.getIdentifier().equals(var.getName())) {
mspec01 = rdMappingSpec;
o1.setReferenceDataMappingSpec(rdMappingSpec);
} else if (o2.dataReference.getIdentifier().equals(var.getName())) {
mspec02 = rdMappingSpec;
o2.setReferenceDataMappingSpec(rdMappingSpec);
}
}
if (mspec01 == null && mspec02 == null) {
return o1.dataReference.getIdentifier().compareToIgnoreCase(o2.dataReference.getIdentifier());
} else if (mspec01 != null && mspec02 != null) {
return mspec01.getReferenceDataColumnName().compareToIgnoreCase(mspec02.getReferenceDataColumnName());
} else if (mspec01 != null && mspec02 == null) {
return -1;
} else {
return 1;
}
} else {
// compare ode to ref
ReferenceDataMappingSpec mspec01 = null;
ReferenceDataMappingSpec mspec02 = null;
for (ReferenceDataMappingSpec rdMappingSpec : mappingSpecs) {
Variable var = parameterEstimationTask.getMathSymbolMapping().getVariable(rdMappingSpec.getModelObject());
if (rdMappingSpec.getModelObject() instanceof ReservedSymbol) {
continue;
}
if (o2.dataReference.getIdentifier().equals(rdMappingSpec.getReferenceDataColumnName())) {
mspec02 = rdMappingSpec;
o2.setReferenceDataMappingSpec(rdMappingSpec);
} else if (o1.dataReference.getIdentifier().equals(var.getName())) {
mspec01 = rdMappingSpec;
o1.setReferenceDataMappingSpec(rdMappingSpec);
}
}
if (mspec01 == null && mspec02 == null) {
return 1;
} else if (mspec01 != null && mspec02 == null) {
return -1;
} else if (mspec02 != null && mspec01 == null) {
return 1;
} else {
// BeanUtils.forceStringSize(mspec02.getReferenceDataColumnName(), 25, " ", true));
return mspec01.getReferenceDataColumnName().compareToIgnoreCase(mspec02.getReferenceDataColumnName());
}
}
}
}
});
multisourcePlotPane.setDataSources(dataSources);
String[] nameArray = new String[nameVector.size()];
nameArray = (String[]) BeanUtils.getArray(nameVector, String.class);
multisourcePlotPane.select(nameArray);
DialogUtils.showComponentCloseDialog(JOptionPane.getFrameForComponent(this), multisourcePlotPane, "Data Plot");
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
use of cbit.vcell.modelopt.gui.MultisourcePlotPane in project vcell by virtualcell.
the class ReferenceDataPanel method getmultisourcePlotPane.
/**
* Return the multisourcePlotPane property value.
* @return cbit.vcell.modelopt.gui.MultisourcePlotPane
*/
private MultisourcePlotPane getmultisourcePlotPane() {
if (ivjmultisourcePlotPane == null) {
try {
ivjmultisourcePlotPane = new MultisourcePlotPane();
ivjmultisourcePlotPane.setName("multisourcePlotPane");
ivjmultisourcePlotPane.setListVisible(false);
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
return ivjmultisourcePlotPane;
}
Aggregations