use of net.sf.mzmine.parameters.parametertypes.ranges.MZRangeComponent in project mzmine2 by mzmine.
the class KovatsIndexExtractionDialog method addDialogComponents.
@Override
protected void addDialogComponents() {
super.addDialogComponents();
mainPanel.removeAll();
mainPanel.getParent().remove(mainPanel);
ddlKovats = new DelayedDocumentListener(e -> updateKovatsList());
DelayedDocumentListener ddlUpdateChart = new DelayedDocumentListener(e -> updateChart());
newMainPanel = new JPanel(new MigLayout("fill", "[right][grow,fill]", ""));
getContentPane().add(newMainPanel, BorderLayout.SOUTH);
JPanel pnCenter = new JPanel(new BorderLayout());
getContentPane().add(pnCenter, BorderLayout.CENTER);
pnChart = new JPanel(new BorderLayout());
pnCenter.add(pnChart, BorderLayout.CENTER);
Box sizedummy = new Box(BoxLayout.X_AXIS);
sizedummy.setMinimumSize(new Dimension(200, 450));
sizedummy.setPreferredSize(new Dimension(200, 450));
pnChart.add(sizedummy, BorderLayout.CENTER);
// left: Kovats: min max and list
JPanel west = new JPanel(new BorderLayout());
newMainPanel.add(west);
// add min max
JPanel pnKovatsParam = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5));
west.add(pnKovatsParam, BorderLayout.NORTH);
minc = (IntegerComponent) getComponentForParameter(KovatsIndexExtractionParameters.minKovats);
maxc = (IntegerComponent) getComponentForParameter(KovatsIndexExtractionParameters.maxKovats);
minc.addDocumentListener(ddlKovats);
maxc.addDocumentListener(ddlKovats);
pnKovatsParam.add(new JLabel("Min carbon:"));
pnKovatsParam.add(minc);
pnKovatsParam.add(new JLabel("Max carbon:"));
pnKovatsParam.add(maxc);
// kovats list
JPanel pnKovatsSelect = new JPanel(new BorderLayout());
west.add(pnKovatsSelect, BorderLayout.CENTER);
comboKovats = (MultiChoiceComponent) getComponentForParameter(KovatsIndexExtractionParameters.kovats);
comboKovats.addValueChangeListener(() -> handleKovatsSelectionChange());
pnKovatsSelect.add(comboKovats, BorderLayout.CENTER);
// center: Chart and parameters
JPanel center = new JPanel(new BorderLayout());
newMainPanel.add(center);
// all parameters on peak pick panel
JPanel pnSouth = new JPanel(new BorderLayout());
center.add(pnSouth, BorderLayout.SOUTH);
JPanel pnPeakPick = new JPanel(new MigLayout("", "[right][]", ""));
pnSouth.add(pnPeakPick, BorderLayout.CENTER);
valuesComponent = (StringComponent) getComponentForParameter(KovatsIndexExtractionParameters.pickedKovatsValues);
MZRangeComponent mzc = (MZRangeComponent) getComponentForParameter(KovatsIndexExtractionParameters.mzRange);
RTRangeComponent rtc = (RTRangeComponent) getComponentForParameter(KovatsIndexExtractionParameters.rtRange);
DoubleComponent noisec = (DoubleComponent) getComponentForParameter(KovatsIndexExtractionParameters.noiseLevel);
DoubleComponent edgeRatioC = (DoubleComponent) getComponentForParameter(KovatsIndexExtractionParameters.ratioTopEdge);
valuesComponent.addDocumentListener(new DelayedDocumentListener(e -> kovatsValuesChanged()));
valuesComponent.setLayout(new GridLayout(1, 1));
pnCenter.add(valuesComponent, BorderLayout.SOUTH);
JPanel pnButtonFlow = new JPanel();
pnPeakPick.add(pnButtonFlow, "cell 0 0 2 1");
JButton btnUpdateChart = new JButton("Update chart");
btnUpdateChart.addActionListener(e -> updateChart());
pnButtonFlow.add(btnUpdateChart);
JButton btnPickRT = new JButton("Pick peaks");
btnPickRT.addActionListener(e -> pickRetentionTimes());
pnButtonFlow.add(btnPickRT);
JButton btnSaveFile = new JButton("Save to file");
btnSaveFile.setToolTipText("Save Kovats index file");
btnSaveFile.addActionListener(e -> saveToFile());
pnButtonFlow.add(btnSaveFile);
JButton btnLoad = new JButton("Load");
btnLoad.setToolTipText("Load Kovats index file");
btnLoad.addActionListener(e -> loadFile());
pnButtonFlow.add(btnLoad);
JButton btnCombineFiles = new JButton("Combine files");
btnCombineFiles.setToolTipText("Select multiple Kovats index files to be combined into one");
btnCombineFiles.addActionListener(e -> combineFiles());
pnButtonFlow.add(btnCombineFiles);
// add combo for raw data file
dataFiles = MZmineCore.getProjectManager().getCurrentProject().getDataFiles();
comboDataFileName = new JComboBox<RawDataFile>(dataFiles);
comboDataFileName2 = new JComboBox<RawDataFile>(dataFiles);
cbSecondRaw = new JCheckBox();
initRawDataFileSelection();
pnPeakPick.add(new JLabel("Raw data file(s)"), "cell 0 1");
pnPeakPick.add(comboDataFileName);
cbSecondRaw.addItemListener(e -> useSecondDataFile(cbSecondRaw.isSelected()));
pnPeakPick.add(cbSecondRaw, "cell 0 2");
pnPeakPick.add(comboDataFileName2);
// direct alkane selection < CxH2x+1 >
JPanel pnAlkaneSelect = new JPanel();
Dimension dim = new Dimension(SIZE, SIZE);
JButton btnPrevAlkane = new JButton(iconPrev);
btnPrevAlkane.addActionListener(e -> setMzRangeByAlkane(-1));
btnPrevAlkane.setPreferredSize(dim);
btnPrevAlkane.setMaximumSize(dim);
JButton btnNextAlkane = new JButton(iconNext);
btnNextAlkane.addActionListener(e -> setMzRangeByAlkane(1));
btnNextAlkane.setPreferredSize(dim);
btnNextAlkane.setMaximumSize(dim);
lbCurrentAlkane = new JLabel("");
cbCurrentAlkaneSubH = new JCheckBox("-H");
cbCurrentAlkaneSubH.setSelected(true);
cbCurrentAlkaneSubH.addItemListener(e -> setMzRangeByAlkane(0));
pnAlkaneSelect.add(btnPrevAlkane);
pnAlkaneSelect.add(lbCurrentAlkane);
pnAlkaneSelect.add(btnNextAlkane);
pnAlkaneSelect.add(cbCurrentAlkaneSubH);
pnPeakPick.add(pnAlkaneSelect, "cell 1 3");
pnPeakPick.add(new JLabel("m/z range"), "cell 0 4");
pnPeakPick.add(mzc);
pnPeakPick.add(new JLabel(KovatsIndexExtractionParameters.rtRange.getName()), "cell 0 5");
pnPeakPick.add(rtc);
pnPeakPick.add(new JLabel(KovatsIndexExtractionParameters.noiseLevel.getName()), "cell 0 6");
pnPeakPick.add(noisec);
pnPeakPick.add(new JLabel(KovatsIndexExtractionParameters.ratioTopEdge.getName()), "cell 0 7");
pnPeakPick.add(edgeRatioC);
// add listeners
comboDataFileName.addItemListener(e -> updateChart());
mzc.addDocumentListener(ddlUpdateChart);
rtc.addDocumentListener(ddlUpdateChart);
// show
revalidate();
updateMinimumSize();
pack();
updateChart();
}
use of net.sf.mzmine.parameters.parametertypes.ranges.MZRangeComponent in project mzmine2 by mzmine.
the class KovatsIndexExtractionDialog method updateChart.
private void updateChart() {
updateParameterSetFromComponents();
if (selectedDataFile == null)
return;
try {
// old charts axes ranges
org.jfree.data.Range domainZoom = chart == null ? null : chart.getChart().getXYPlot().getDomainAxis().getRange();
org.jfree.data.Range rangeZoom = chart == null ? null : chart.getChart().getXYPlot().getRangeAxis().getRange();
Range<Double> rangeMZ = parameterSet.getParameter(KovatsIndexExtractionParameters.mzRange).getValue();
Range<Double> rangeRT = parameterSet.getParameter(KovatsIndexExtractionParameters.rtRange).getValue();
if (rangeMZ == null) {
// set range to specific alkane fragment
rangeMZ = Range.closed(56.6, 57.5);
((MZRangeComponent) getComponentForParameter(KovatsIndexExtractionParameters.mzRange)).setValue(rangeMZ);
}
if (rangeRT == null) {
rangeRT = selectedDataFile[0].getDataRTRange();
((RTRangeComponent) getComponentForParameter(KovatsIndexExtractionParameters.rtRange)).setValue(rangeRT);
}
// create dataset
TICSumDataSet data = new TICSumDataSet(selectedDataFile, rangeRT, rangeMZ, null, TICPlotType.BASEPEAK);
chart = new TICPlot(this);
chart.addTICDataset(data);
if (domainZoom != null)
chart.getChart().getXYPlot().getDomainAxis().setRange(domainZoom);
if (rangeZoom != null)
chart.getChart().getXYPlot().getRangeAxis().setRange(rangeZoom);
// add control for markers
chart.getGestureAdapter().addGestureHandler(new ChartGestureDragDiffHandler(Entity.PLOT, Button.BUTTON1, new Key[] { Key.NONE }, e -> handleMarkerDrag(e)));
chart.getGestureAdapter().addGestureHandler(new ChartGestureHandler(new ChartGesture(Entity.PLOT, Event.RELEASED), e -> {
if (chart != null)
chart.setMouseZoomable(true);
if (currentlyDraggedMarker != null) {
// set value of current marker
logger.info("Marker dragging ended at " + currentlyDraggedMarker.getValue());
int index = markers.indexOf(currentlyDraggedMarker);
double value = e.getCoordinates().getX();
setValue(index, value);
//
currentlyDraggedMarker = null;
}
}));
kovatsValuesChanged();
pnChart.removeAll();
pnChart.add(chart, BorderLayout.CENTER);
revalidate();
repaint();
} catch (Exception e) {
logger.log(Level.WARNING, "Peak picking parameters incorrect");
}
}
use of net.sf.mzmine.parameters.parametertypes.ranges.MZRangeComponent in project mzmine2 by mzmine.
the class KovatsIndexExtractionDialog method setMzRangeByAlkane.
private void setMzRangeByAlkane(int diff) {
if (currentAlkane == null) {
currentAlkane = KovatsIndex.C4;
} else {
int index = currentAlkane.ordinal() + diff;
index = Math.min(Math.max(index, 0), KovatsIndex.values().length);
currentAlkane = KovatsIndex.values()[index];
}
String formula = currentAlkane.getFormula(cbCurrentAlkaneSubH.isSelected());
lbCurrentAlkane.setText(formula);
// set mz
Range<Double> mzRange = MzRangeFormulaCalculatorModule.getMzRangeFromFormula(formula, IonizationType.POSITIVE, new MZTolerance(0.75, 0), 1);
((MZRangeComponent) getComponentForParameter(KovatsIndexExtractionParameters.mzRange)).setValue(mzRange);
}
Aggregations