use of beast.app.draw.InputEditor in project beast2 by CompEvol.
the class GeneTreeForSpeciesTreeDistributionInputEditor method createPloidyEditor.
public InputEditor createPloidyEditor() {
InputEditor editor = new InputEditor.Base(doc) {
private static final long serialVersionUID = 1L;
@Override
public Class<?> type() {
return null;
}
@Override
public void init(Input<?> input, BEASTInterface beastObject, int itemNr, ExpandOption isExpandOption, boolean addButtons) {
m_beastObject = beastObject;
m_input = input;
m_bAddButtons = addButtons;
this.itemNr = itemNr;
addInputLabel();
m_selectBeastObjectBox = new JComboBox<>(valuesString);
setSelection();
String selectString = input.get().toString();
m_selectBeastObjectBox.setSelectedItem(selectString);
m_selectBeastObjectBox.addActionListener(e -> {
int i = m_selectBeastObjectBox.getSelectedIndex();
if (i == OTHER) {
setSelection();
return;
}
try {
setValue(_values[i]);
// lm_input.setValue(selected, m_beastObject);
} catch (Exception e1) {
e1.printStackTrace();
}
});
m_selectBeastObjectBox.setToolTipText(input.getHTMLTipText());
add(m_selectBeastObjectBox);
add(Box.createGlue());
}
private void setSelection() {
Double value = (Double) m_input.get();
m_selectBeastObjectBox.setSelectedIndex(OTHER);
for (int i = 0; i < _values.length; i++) {
if (value.equals(_values[i])) {
m_selectBeastObjectBox.setSelectedIndex(i);
}
}
}
};
editor.init(((GeneTreeForSpeciesTreeDistribution) m_beastObject).ploidyInput, m_beastObject, -1, ExpandOption.FALSE, true);
return editor;
}
use of beast.app.draw.InputEditor in project beast2 by CompEvol.
the class ConstantPopulationInputEditor method init.
@Override
public void init(Input<?> input, BEASTInterface beastObject, int itemNr, ExpandOption isExpandOption, boolean addButtons) {
ConstantPopulation population = (ConstantPopulation) input.get();
try {
InputEditor editor = doc.inputEditorFactory.createInputEditor(population.popSizeParameter, population, doc);
add(editor.getComponent());
} catch (NoSuchMethodException | SecurityException | ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// TODO Auto-generated method stub
// super.init(input, beastObject, itemNr, isExpandOption, addButtons);
}
use of beast.app.draw.InputEditor in project beast2 by CompEvol.
the class PriorListInputEditor method addPluginItem.
/**
* add components to box that are specific for the beastObject.
* By default, this just inserts a label with the beastObject ID
*
* @param itemBox box to add components to
* @param beastObject beastObject to add
*/
@Override
protected InputEditor addPluginItem(Box itemBox, BEASTInterface beastObject) {
try {
int listItemNr = ((List<?>) m_input.get()).indexOf(beastObject);
InputEditor editor = doc.getInputEditorFactory().createInputEditor(m_input, listItemNr, beastObject, false, ExpandOption.FALSE, ButtonStatus.NONE, null, doc);
itemBox.add((Component) editor);
return editor;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return this;
}
use of beast.app.draw.InputEditor in project beast2 by CompEvol.
the class BeautiPanel method refreshInputPanel.
void refreshInputPanel(BEASTInterface beastObject, Input<?> input, boolean addButtons, InputEditor.ExpandOption forceExpansion) throws NoSuchMethodException, SecurityException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
if (centralComponent != null) {
remove(centralComponent);
}
if (input != null && input.get() != null && input.getType() != null) {
InputEditor.ButtonStatus bs = config.buttonStatusInput.get();
InputEditor inputEditor = doc.getInputEditorFactory().createInputEditor(input, beastObject, addButtons, forceExpansion, bs, null, doc);
JPanel p = new JPanel();
p.setLayout(new BorderLayout());
if (isToClone()) {
ClonePartitionPanel clonePartitionPanel = new ClonePartitionPanel(this);
p.add(clonePartitionPanel, BorderLayout.NORTH);
} else {
p.add(inputEditor.getComponent(), BorderLayout.CENTER);
}
Rectangle bounds = new Rectangle(0, 0);
if (scroller != null) {
// get lastPaintPosition from viewport
// HACK access it through its string representation
JViewport v = scroller.getViewport();
String vs = v.toString();
int i = vs.indexOf("lastPaintPosition=java.awt.Point[x=");
if (i > -1) {
i = vs.indexOf("y=", i);
vs = vs.substring(i + 2, vs.indexOf("]", i));
i = Integer.parseInt(vs);
} else {
i = 0;
}
bounds.y = -i;
}
scroller = new JScrollPane(p);
scroller.getViewport().scrollRectToVisible(bounds);
centralComponent = scroller;
} else {
centralComponent = new JLabel("No input editors.");
}
if (splitPane != null) {
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(centralComponent, BorderLayout.NORTH);
splitPane.add(panel, JSplitPane.RIGHT);
} else {
add(centralComponent);
}
}
Aggregations