use of net.sf.mzmine.parameters.UserParameter in project mzmine2 by mzmine.
the class RowsFilterParameters method showSetupDialog.
@Override
public ExitCode showSetupDialog(Window parent, boolean valueCheckRequired) {
// Update the parameter choices
UserParameter<?, ?>[] newChoices = MZmineCore.getProjectManager().getCurrentProject().getParameters();
String[] choices;
if (newChoices == null || newChoices.length == 0) {
choices = new String[1];
choices[0] = "No parameters defined";
} else {
choices = new String[newChoices.length + 1];
choices[0] = "Ignore groups";
for (int i = 0; i < newChoices.length; i++) {
choices[i + 1] = "Filtering by " + newChoices[i].getName();
}
}
getParameter(RowsFilterParameters.GROUPSPARAMETER).setChoices(choices);
ParameterSetupDialog dialog = new ParameterSetupDialog(parent, valueCheckRequired, this);
dialog.setVisible(true);
return dialog.getExitCode();
}
use of net.sf.mzmine.parameters.UserParameter in project mzmine2 by mzmine.
the class SignificanceTask method calculateSignificance.
private void calculateSignificance() throws IllegalStateException {
if (peakListRows.length == 0) {
return;
}
List<Set<RawDataFile>> groups = getGroups(userParameter);
finishedPercentage = 0.0;
final double finishedStep = 1.0 / peakListRows.length;
for (PeakListRow row : peakListRows) {
if (isCanceled()) {
break;
}
finishedPercentage += finishedStep;
double[][] intensityGroups = new double[groups.size()][];
for (int i = 0; i < groups.size(); ++i) {
Set<RawDataFile> groupFiles = groups.get(i);
intensityGroups[i] = Arrays.stream(row.getPeaks()).filter(peak -> groupFiles.contains(peak.getDataFile())).mapToDouble(Feature::getHeight).toArray();
}
Double pValue = oneWayAnova(intensityGroups);
// Save results
PeakInformation peakInformation = row.getPeakInformation();
if (peakInformation == null) {
peakInformation = new SimplePeakInformation();
}
peakInformation.getAllProperties().put(P_VALUE_KEY, pValue == null ? EMPTY_STRING : pValue.toString());
row.setPeakInformation(peakInformation);
}
}
use of net.sf.mzmine.parameters.UserParameter in project mzmine2 by mzmine.
the class ParameterSetupDialog method addDialogComponents.
/**
* Constructs all components of the dialog
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void addDialogComponents() {
// Main panel which holds all the components in a grid
mainPanel = new GridBagPanel();
int rowCounter = 0;
int vertWeightSum = 0;
// Create labels and components for each parameter
for (Parameter p : parameterSet.getParameters()) {
if (!(p instanceof UserParameter))
continue;
UserParameter up = (UserParameter) p;
JComponent comp = up.createEditingComponent();
comp.setToolTipText(up.getDescription());
// Set the initial value
Object value = up.getValue();
if (value != null)
up.setValueToComponent(comp, value);
// Add listeners so we are notified about any change in the values
addListenersToComponent(comp);
// By calling this we make sure the components will never be resized
// smaller than their optimal size
comp.setMinimumSize(comp.getPreferredSize());
comp.setToolTipText(up.getDescription());
JLabel label = new JLabel(p.getName());
mainPanel.add(label, 0, rowCounter);
label.setLabelFor(comp);
parametersAndComponents.put(p.getName(), comp);
JComboBox t = new JComboBox();
int comboh = t.getPreferredSize().height;
int comph = comp.getPreferredSize().height;
// Multiple selection will be expandable, other components not
int verticalWeight = comph > 2 * comboh ? 1 : 0;
vertWeightSum += verticalWeight;
mainPanel.add(comp, 1, rowCounter, 1, 1, 1, verticalWeight, GridBagConstraints.VERTICAL);
rowCounter++;
}
// Add a single empty cell to the 99th row. This cell is expandable
// (weightY is 1), therefore the other components will be
// aligned to the top, which is what we want
// JComponent emptySpace = (JComponent) Box.createVerticalStrut(1);
// mainPanel.add(emptySpace, 0, 99, 3, 1, 0, 1);
// Create a separate panel for the buttons
pnlButtons = new JPanel();
btnOK = GUIUtils.addButton(pnlButtons, "OK", null, this);
btnCancel = GUIUtils.addButton(pnlButtons, "Cancel", null, this);
if (helpURL != null) {
btnHelp = GUIUtils.addButton(pnlButtons, "Help", null, this);
}
/*
* Last row in the table will be occupied by the buttons. We set the row number to 100 and width
* to 3, spanning the 3 component columns defined above.
*/
if (vertWeightSum == 0) {
mainPanel.add(Box.createGlue(), 0, 99, 3, 1, 1, 1);
}
if (footerMessage == null) {
mainPanel.addCenter(pnlButtons, 0, 100, 3, 1);
} else {
// Footer
JEditorPane editorPane = GUIUtils.addEditorPane(footerMessage);
editorPane.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
try {
Desktop.getDesktop().browse(e.getURL().toURI());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
});
// This line is important on Windows, where resizing the dialog has unexpected consequences on
// some components
editorPane.setMinimumSize(editorPane.getPreferredSize());
mainPanel.add(editorPane, 0, 98, 3, 1);
mainPanel.addCenter(pnlButtons, 0, 100, 3, 1);
}
// Add some space around the widgets
GUIUtils.addMargin(mainPanel, 10);
// Add the main panel as the only component of this dialog
add(mainPanel);
pack();
}
use of net.sf.mzmine.parameters.UserParameter in project mzmine2 by mzmine.
the class HeatMapParameters method showSetupDialog.
@Override
public ExitCode showSetupDialog(Window parent, boolean valueCheckRequired) {
// Update the parameter choices
MZmineProject project = MZmineCore.getProjectManager().getCurrentProject();
UserParameter<?, ?>[] newChoices = project.getParameters();
getParameter(HeatMapParameters.selectionData).setChoices(newChoices);
if (newChoices.length > 0) {
ArrayList<Object> values = new ArrayList<Object>();
for (RawDataFile dataFile : project.getDataFiles()) {
Object paramValue = project.getParameterValue(newChoices[0], dataFile);
if (paramValue == null) {
continue;
}
if (!values.contains(paramValue)) {
values.add(paramValue);
}
}
Object[] newValues = values.toArray();
getParameter(HeatMapParameters.referenceGroup).setChoices(newValues);
}
HeatmapSetupDialog dialog = new HeatmapSetupDialog(parent, valueCheckRequired, this);
dialog.setVisible(true);
return dialog.getExitCode();
}
use of net.sf.mzmine.parameters.UserParameter in project mzmine2 by mzmine.
the class GraphicsExportDialog method updateParameterSetFromComponents.
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void updateParameterSetFromComponents() {
for (Parameter<?> p : parameters.getParameters()) {
if (!(p instanceof UserParameter))
continue;
UserParameter up = (UserParameter) p;
JComponent component = parametersAndComponents.get(p.getName());
up.setValueFromComponent(component);
}
for (Parameter<?> p : chartParam.getParameters()) {
if (!(p instanceof UserParameter))
continue;
UserParameter up = (UserParameter) p;
JComponent component = parametersAndComponents.get(p.getName());
up.setValueFromComponent(component);
}
}
Aggregations