use of dr.app.beauti.components.linkedparameters.LinkedParameterComponentOptions in project beast-mcmc by beast-dev.
the class PriorsPanel method selectionChanged.
public void selectionChanged() {
LinkedParameterComponentOptions comp = (LinkedParameterComponentOptions) options.getComponentOptions(LinkedParameterComponentOptions.class);
int[] selRows = priorTable.getSelectedRows();
int jointPriorCount = 0;
for (int i = 0; i < selRows.length; ++i) {
Parameter parameter = parameters.get(selRows[i]);
if (parameter.isLinked || comp.getLinkedParameterForArgument(parameter) != null) {
jointPriorCount++;
}
}
linkButton.setEnabled(selRows.length > 1);
hpmButton.setEnabled(selRows.length > 1);
unlinkButton.setEnabled(jointPriorCount > 0);
}
use of dr.app.beauti.components.linkedparameters.LinkedParameterComponentOptions in project beast-mcmc by beast-dev.
the class PriorsPanel method removeFromJointPrior.
private void removeFromJointPrior(Parameter parameter) {
LinkedParameterComponentOptions comp = (LinkedParameterComponentOptions) options.getComponentOptions(LinkedParameterComponentOptions.class);
LinkedParameter linkedParameter = comp.getLinkedParameter(parameter);
if (linkedParameter != null) {
comp.removeDependentParameter(parameter);
}
// Possibly remove parameter from its HPM
HierarchicalModelComponentOptions hmco = (HierarchicalModelComponentOptions) options.getComponentOptions(HierarchicalModelComponentOptions.class);
if (hmco.isHierarchicalParameter(parameter)) {
if (hmco.removeParameter(this, parameter, true) == JOptionPane.NO_OPTION) {
// Bail out
System.err.println("Bailing out of modification");
return;
}
System.err.println("Parameter removed from an HPM");
}
}
use of dr.app.beauti.components.linkedparameters.LinkedParameterComponentOptions in project beast-mcmc by beast-dev.
the class PriorsPanel method priorButtonPressed.
private void priorButtonPressed(int row) {
Parameter parameter = parameters.get(row);
LinkedParameterComponentOptions lpco = (LinkedParameterComponentOptions) options.getComponentOptions(LinkedParameterComponentOptions.class);
HierarchicalModelComponentOptions hmco = (HierarchicalModelComponentOptions) options.getComponentOptions(HierarchicalModelComponentOptions.class);
if (lpco.isArgumentParameter(parameter)) {
LinkedParameter linkedParameter = lpco.getLinkedParameterForArgument(parameter);
editLinkedParameter(linkedParameter, linkedParameter.getDependentParameterList());
} else {
if (hmco.isHierarchicalParameter(parameter)) {
int option = JOptionPane.showConfirmDialog(this, "This parameter forms part of an Hierarchical Model.\n" + "Selecting a new prior will remove the parameter from\n" + "this HPM.\nContinue?", "Hierarchical parameter warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
if (option == JOptionPane.NO_OPTION) {
return;
}
}
if (parameter.isLinked) {
int option = JOptionPane.showConfirmDialog(this, "Parameter linked to other parameter. Selecting a\n" + "new prior will remove the link.\nContinue?", "Linked parameter warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
if (option == JOptionPane.NO_OPTION) {
return;
}
}
editPrior(parameter);
}
}
use of dr.app.beauti.components.linkedparameters.LinkedParameterComponentOptions in project beast-mcmc by beast-dev.
the class PriorsPanel method linkButtonPressed.
private void linkButtonPressed(int[] rows) {
Parameter firstParameter = parameters.get(rows[0]);
// gather the selected parameters...
List<Parameter> selectedParameters = new ArrayList<Parameter>();
boolean isLinked = false;
for (int i = 0; i < rows.length; ++i) {
Parameter parameter = parameters.get(rows[i]);
if (parameter.isStatistic) {
JOptionPane.showMessageDialog(frame, "Statistics cannot be linked together or\n" + "linked with parameter.", "Parameter linking error", JOptionPane.WARNING_MESSAGE);
// Bail out
return;
}
if (parameter.truncationLower != firstParameter.truncationLower || parameter.truncationUpper != firstParameter.truncationUpper || options.getOperator(parameter).getOperatorType() != options.getOperator(firstParameter).getOperatorType()) {
JOptionPane.showMessageDialog(frame, "Only parameters that share the same bounds\n" + "and have the same operator types can be linked.", "Parameter linking error", JOptionPane.WARNING_MESSAGE);
// Bail out
return;
}
if (parameter.isLinked) {
isLinked = true;
}
selectedParameters.add(parameters.get(rows[i]));
}
if (isLinked) {
int option = JOptionPane.showConfirmDialog(this, "One or more selected parameters are already linked or\n" + "part of a hierarchical model.\n\n" + "Constructing a new prior will remove these parameter\n" + "from the original model. Continue?", "Link warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
if (option == JOptionPane.NO_OPTION) {
return;
}
}
LinkedParameterComponentOptions comp = (LinkedParameterComponentOptions) options.getComponentOptions(LinkedParameterComponentOptions.class);
LinkedParameter linkedParameter = comp.createLinkedParameter(null, selectedParameters);
editLinkedParameter(linkedParameter, selectedParameters);
}
Aggregations