Search in sources :

Example 1 with DoubleRangeComponent

use of net.sf.mzmine.parameters.parametertypes.ranges.DoubleRangeComponent in project mzmine2 by mzmine.

the class XICManualPickerDialog method addDialogComponents.

@Override
protected void addDialogComponents() {
    super.addDialogComponents();
    Color l = new Color(50, 255, 50, 150), u = new Color(255, 50, 50, 150);
    Stroke stroke = new BasicStroke(1.0f);
    // make new panel, put tic into the middle of a border layout.
    remove(this.mainPanel);
    rtRangeComp = new DoubleRangeComponent(MZmineCore.getConfiguration().getRTFormat());
    mzRangeComp = new DoubleRangeComponent(MZmineCore.getConfiguration().getMZFormat());
    applyMassRange = new JButton("Set");
    applyMassRange.addActionListener(a -> setMassRange());
    addListenertoRTComp(rtRangeComp);
    JLabel rtLabel = new JLabel("Retention time range");
    JLabel mzLabel = new JLabel("m/z range");
    mainPanel.add(rtLabel, 0, getNumberOfParameters() + 1);
    mainPanel.add(rtRangeComp, 1, getNumberOfParameters() + 1);
    mainPanel.add(mzLabel, 0, getNumberOfParameters() + 2);
    mainPanel.add(mzRangeComp, 1, getNumberOfParameters() + 2);
    mainPanel.add(applyMassRange, 2, getNumberOfParameters() + 2);
    BorderLayout borderLayout = new BorderLayout();
    Panel pnlNewMain = new Panel(borderLayout);
    // put another border layout for south of the new main panel, so we can place controls and
    // integration specific stuff there
    Panel pnlControlsAndParameters = new Panel(new BorderLayout());
    pnlControlsAndParameters.add(this.mainPanel, BorderLayout.CENTER);
    pnlNewMain.add(pnlControlsAndParameters, BorderLayout.SOUTH);
    // now make another panel to put the integration specific stuff, like the buttons and the
    // current area
    Panel pnlIntegration = new Panel(new FlowLayout());
    setLower = GUIUtils.addButton(pnlIntegration, null, icoLower, this, "SETLOWER", "Set the lower integration boundary.");
    setUpper = GUIUtils.addButton(pnlIntegration, null, icoUpper, this, "SETUPPER", "Set the upper integration boundary.");
    GUIUtils.addSeparator(pnlIntegration);
    pnlIntegration.add(new Label("Area: "));
    txtArea = new JTextField(10);
    txtArea.setEditable(false);
    pnlIntegration.add(txtArea);
    pnlControlsAndParameters.add(pnlIntegration, BorderLayout.NORTH);
    ticPlot = new TICPlot(this);
    ticPlot.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
    ticPlot.setMinimumSize(new Dimension(400, 200));
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    ticPlot.setPreferredSize(new Dimension((int) (screenSize.getWidth() / 1.3d), (int) (screenSize.getHeight() / 1.8d)));
    pnlNewMain.add(ticPlot, BorderLayout.CENTER);
    // add a mouse listener to place the boundaries
    getTicPlot().addChartMouseListener(new ChartMouseListener() {

        // https://stackoverflow.com/questions/1512112/jfreechart-get-mouse-coordinates
        // draw a marker at the current position
        @Override
        public void chartMouseMoved(ChartMouseEvent event) {
            Point2D p = ticPlot.translateScreenToJava2D(event.getTrigger().getPoint());
            Rectangle2D plotArea = ticPlot.getScreenDataArea();
            XYPlot plot = ticPlot.getXYPlot();
            double rtValue = plot.getDomainAxis().java2DToValue(p.getX(), plotArea, plot.getDomainAxisEdge());
            Color clr = (nextBorder == NextBorder.LOWER) ? l : u;
            addMarkers();
            plot.addDomainMarker(new ValueMarker(rtValue, clr, stroke));
        }

        @Override
        public void chartMouseClicked(ChartMouseEvent event) {
            Point2D p = ticPlot.translateScreenToJava2D(event.getTrigger().getPoint());
            Rectangle2D plotArea = ticPlot.getScreenDataArea();
            XYPlot plot = ticPlot.getXYPlot();
            double rtValue = plot.getDomainAxis().java2DToValue(p.getX(), plotArea, plot.getDomainAxisEdge());
            inputSource = InputSource.GRAPH;
            setRTBoundary(rtValue);
            inputSource = InputSource.OTHER;
        }
    });
    add(pnlNewMain);
    pack();
}
Also used : BasicStroke(java.awt.BasicStroke) BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) FlowLayout(java.awt.FlowLayout) Color(java.awt.Color) JButton(javax.swing.JButton) Label(java.awt.Label) JLabel(javax.swing.JLabel) Rectangle2D(java.awt.geom.Rectangle2D) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) ChartMouseEvent(org.jfree.chart.ChartMouseEvent) ChartMouseListener(org.jfree.chart.ChartMouseListener) Panel(java.awt.Panel) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) XYPlot(org.jfree.chart.plot.XYPlot) Point2D(java.awt.geom.Point2D) TICPlot(net.sf.mzmine.modules.visualization.tic.TICPlot) ValueMarker(org.jfree.chart.plot.ValueMarker) DoubleRangeComponent(net.sf.mzmine.parameters.parametertypes.ranges.DoubleRangeComponent)

Example 2 with DoubleRangeComponent

use of net.sf.mzmine.parameters.parametertypes.ranges.DoubleRangeComponent in project mzmine2 by mzmine.

the class ParameterSetupDialogWithChromatogramPreview method addDialogComponents.

/**
 * This function add all the additional components for this dialog over the original
 * ParameterSetupDialog.
 */
@Override
protected void addDialogComponents() {
    super.addDialogComponents();
    dataFiles = MZmineCore.getProjectManager().getCurrentProject().getDataFiles();
    if (dataFiles.length == 0)
        return;
    RawDataFile[] selectedFiles = MZmineCore.getDesktop().getSelectedDataFiles();
    if (selectedFiles.length > 0)
        previewDataFile = selectedFiles[0];
    else
        previewDataFile = dataFiles[0];
    previewCheckBox = new JCheckBox("Show preview");
    previewCheckBox.addActionListener(this);
    previewCheckBox.setHorizontalAlignment(SwingConstants.CENTER);
    mainPanel.add(new JSeparator(), 0, getNumberOfParameters() + 1, 3, 1);
    mainPanel.add(previewCheckBox, 0, getNumberOfParameters() + 2, 3, 1);
    // Elements of pnlLab
    JPanel pnlLab = new JPanel();
    pnlLab.setLayout(new BoxLayout(pnlLab, BoxLayout.Y_AXIS));
    pnlLab.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    pnlLab.add(Box.createVerticalStrut(5));
    pnlLab.add(new JLabel("Data file "));
    pnlLab.add(Box.createVerticalStrut(20));
    pnlLab.add(new JLabel("Plot Type "));
    pnlLab.add(Box.createVerticalStrut(25));
    pnlLab.add(new JLabel("RT range "));
    pnlLab.add(Box.createVerticalStrut(15));
    pnlLab.add(new JLabel("m/z range "));
    // Elements of pnlFlds
    JPanel pnlFlds = new JPanel();
    pnlFlds.setLayout(new BoxLayout(pnlFlds, BoxLayout.Y_AXIS));
    pnlFlds.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    comboDataFileName = new JComboBox<RawDataFile>(dataFiles);
    comboDataFileName.setSelectedItem(previewDataFile);
    comboDataFileName.addActionListener(this);
    ticViewComboBox = new JComboBox<TICPlotType>(TICPlotType.values());
    ticViewComboBox.setSelectedItem(TICPlotType.TIC);
    ticViewComboBox.addActionListener(this);
    rtRangeBox = new DoubleRangeComponent(MZmineCore.getConfiguration().getRTFormat());
    rtRangeBox.setValue(previewDataFile.getDataRTRange(1));
    mzRangeBox = new DoubleRangeComponent(MZmineCore.getConfiguration().getMZFormat());
    mzRangeBox.setValue(previewDataFile.getDataMZRange(1));
    pnlFlds.add(comboDataFileName);
    pnlFlds.add(Box.createVerticalStrut(10));
    pnlFlds.add(ticViewComboBox);
    pnlFlds.add(Box.createVerticalStrut(20));
    pnlFlds.add(rtRangeBox);
    pnlFlds.add(Box.createVerticalStrut(5));
    pnlFlds.add(mzRangeBox);
    // Put all together
    pnlPreviewFields = new JPanel(new BorderLayout());
    pnlPreviewFields.add(pnlLab, BorderLayout.WEST);
    pnlPreviewFields.add(pnlFlds, BorderLayout.CENTER);
    pnlPreviewFields.setVisible(false);
    ticPlot = new TICPlot(this);
    ticPlot.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
    ticPlot.setMinimumSize(new Dimension(400, 300));
    mainPanel.add(pnlPreviewFields, 0, getNumberOfParameters() + 3, 3, 1, 0, 0);
    updateMinimumSize();
    pack();
}
Also used : JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JSeparator(javax.swing.JSeparator) JCheckBox(javax.swing.JCheckBox) TICPlotType(net.sf.mzmine.modules.visualization.tic.TICPlotType) BorderLayout(java.awt.BorderLayout) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) TICPlot(net.sf.mzmine.modules.visualization.tic.TICPlot) DoubleRangeComponent(net.sf.mzmine.parameters.parametertypes.ranges.DoubleRangeComponent)

Aggregations

BorderLayout (java.awt.BorderLayout)2 Dimension (java.awt.Dimension)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 TICPlot (net.sf.mzmine.modules.visualization.tic.TICPlot)2 DoubleRangeComponent (net.sf.mzmine.parameters.parametertypes.ranges.DoubleRangeComponent)2 BasicStroke (java.awt.BasicStroke)1 Color (java.awt.Color)1 FlowLayout (java.awt.FlowLayout)1 Label (java.awt.Label)1 Panel (java.awt.Panel)1 Stroke (java.awt.Stroke)1 Point2D (java.awt.geom.Point2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 BoxLayout (javax.swing.BoxLayout)1 JButton (javax.swing.JButton)1 JCheckBox (javax.swing.JCheckBox)1 JSeparator (javax.swing.JSeparator)1 JTextField (javax.swing.JTextField)1 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)1