Example usage for org.jfree.data Range Range

List of usage examples for org.jfree.data Range Range

Introduction

In this page you can find the example usage for org.jfree.data Range Range.

Prototype

public Range(double lower, double upper) 

Source Link

Document

Creates a new range.

Usage

From source file:net.sf.mzmine.chartbasics.ChartLogicsFX.java

/**
 * /*  www  .  ja  va2 s  . co  m*/
 * @param myChart
 * @return Range the domainAxis zoom (X-axis)
 */
public static Range getZoomDomainAxis(ChartViewer myChart) {
    XYPlot plot = (XYPlot) myChart.getChart().getPlot();
    ValueAxis domainAxis = plot.getDomainAxis();

    return new Range(domainAxis.getLowerBound(), domainAxis.getUpperBound());
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.SpectraPanel.java

public void updateMZAxis() {
    if (theDocument.getNoScans() > 0)
        thePlot.getDomainAxis().setRange(theDocument.getPeakDataAt(current_ind).getMZRange());
    else//from w  ww.j a  va 2  s.  c o m
        thePlot.getDomainAxis().setRange(new Range(0., 1.));
}

From source file:br.ufrgs.enq.jcosmo.ui.COSMOSACDialog.java

private void rebuildChart() {
    if (listModel.getSize() < 2) {
        JOptionPane.showMessageDialog(this, "Select 2 compounds.", "Error", JOptionPane.OK_OPTION);
        err = true;/* w ww  . j av a2s  .  c o m*/
        return;
    }
    if (listModel.getSize() > 2) {
        JOptionPane.showMessageDialog(this, "Select only 2 compounds.", "Error", JOptionPane.OK_OPTION);
        return;
    }
    double T = Double.parseDouble(temperature.getText());
    if (T <= 0) {
        JOptionPane.showMessageDialog(this, "Invalid Temperature.", "Error", JOptionPane.OK_OPTION);
        return;
    }

    COSMOSAC cosmosac = (COSMOSAC) modelBox.getSelectedItem();
    COSMOSACCompound comps[] = new COSMOSACCompound[2];
    try {
        comps[0] = db.getComp((String) listModel.getElementAt(0));
        comps[1] = db.getComp((String) listModel.getElementAt(1));
        cosmosac.setComponents(comps);
    } catch (Exception e1) {
        e1.printStackTrace();
        return;
    }
    if (comps[0] == null || comps[1] == null)
        return;

    cosmosac.setSigmaHB(Double.parseDouble(sigmaHB.getText()));
    cosmosac.setSigmaHB2(Double.parseDouble(sigmaHB2.getText()));
    cosmosac.setSigmaHB3(Double.parseDouble(sigmaHB3.getText()));
    //      cosmosac.setSigmaHBUpper(Double.parseDouble(sigmaHBUpper.getText()));
    cosmosac.setCHB(Double.parseDouble(chargeHB.getText()));
    cosmosac.setSigmaDisp(Double.parseDouble(sigmaDisp.getText()));
    cosmosac.setCDisp(Double.parseDouble(chargeDisp.getText()));
    cosmosac.setBeta(Double.parseDouble(beta.getText()));
    cosmosac.setFpol(Double.parseDouble(fpol.getText()));
    cosmosac.setAnorm(Double.parseDouble(anorm.getText()));
    cosmosac.parametersChanged();

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    //      cosmosac.setParameters(cavityVolume, c1.charge, sigma);

    cosmosac.setTemperature(T);

    // testing several compositions
    XYSeriesCollection dataset = new XYSeriesCollection();
    int n = 20;
    XYSeries lnGamma1 = new XYSeries(comps[0].name);
    XYSeries lnGamma2 = new XYSeries(comps[1].name);
    XYSeries ge_RT = new XYSeries("gE/RT");

    for (int i = 0; i <= n; ++i) {
        z[0] = (double) i / n;
        z[1] = 1 - z[0];
        cosmosac.setComposition(z);
        cosmosac.activityCoefficient(lnGamma);

        lnGamma1.add(z[0], lnGamma[0]);
        lnGamma2.add(z[0], lnGamma[1]);
        ge_RT.add(z[0], z[0] * lnGamma[0] + z[1] * lnGamma[1]);

        if (z[0] == 0) {
            lnGammaInf1Label.setText(String.format("%6.3g", lnGamma[0]));
            gammaInf1Label.setText(String.format("%6.3g", Math.exp(lnGamma[0])));
        }
        if (z[1] == 0) {
            lnGammaInf2Label.setText(String.format("%6.3g", lnGamma[1]));
            gammaInf2Label.setText(String.format("%6.3g", Math.exp(lnGamma[1])));
        }
    }
    dataset.addSeries(lnGamma1);
    dataset.addSeries(lnGamma2);
    dataset.addSeries(ge_RT);

    plot.setDataset(dataset);

    // now the segment gamma
    dataset = new XYSeriesCollection();
    double[][] seggamma = cosmosac.getPureSegmentGamma();

    n = comps[0].charge.length;
    XYSeries g1 = new XYSeries(comps[0].name);
    XYSeries g2 = new XYSeries(comps[1].name);
    XYSeries g1s = new XYSeries(comps[0].name + " * sigma");
    XYSeries g2s = new XYSeries(comps[1].name + " * sigma");

    for (int j = 0; j < n; ++j) {
        g1.add(comps[0].charge[j], Math.log(seggamma[0][j]));
        g2.add(comps[1].charge[j], Math.log(seggamma[1][j]));
        g1s.add(comps[0].charge[j], comps[0].area[j] * (Math.log(seggamma[1][j]) - Math.log(seggamma[0][j])));
        g2s.add(comps[1].charge[j], comps[1].area[j] * (Math.log(seggamma[0][j]) - Math.log(seggamma[1][j])));
    }
    dataset.addSeries(g1);
    dataset.addSeries(g2);
    dataset.addSeries(g1s);
    dataset.addSeries(g2s);
    plotSegGamma.setDataset(dataset);

    // adjust the plot properties
    plotSegGamma.getDomainAxis().setAutoRange(false);
    plotSegGamma.getDomainAxis().setRange(new Range(-0.025, 0.025));
    XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plotSegGamma.getRenderer();
    r.setSeriesStroke(0, new BasicStroke(2.5f));
    r.setSeriesStroke(1, new BasicStroke(2.5f));
    BasicStroke dashed = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 6.0f, 6.0f }, 0.0f);

    r.setSeriesStroke(2, dashed);
    r.setSeriesStroke(3, dashed);
    r.setSeriesPaint(0, Color.RED);
    r.setSeriesPaint(1, Color.BLUE);
    r.setSeriesPaint(2, Color.RED);
    r.setSeriesPaint(3, Color.BLUE);
    //      plotSegGamma.setRenderer(stepRenderer);
    //      plotSegGamma.setRenderer(3, stepRenderer);

    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:org.logisticPlanning.utils.graphics.chart.impl.jfree._JFCLineChart2D.java

/**
 * paint a legend//from w  w w  .ja  v  a 2s . c o m
 *
 * @param legend
 *          the legend
 * @param graphics
 *          the graphics
 * @param bounds
 *          the bounds
 */
private static final void __paintLegend(final LegendTitle legend, final Graphics2D graphics,
        final Rectangle2D bounds) {
    final Rectangle2D titleArea;
    final BlockParams p;
    final double ww, hh;
    final RectangleConstraint constraint;
    final Size2D size;

    p = new BlockParams();
    p.setGenerateEntities(false);

    ww = bounds.getWidth();
    if (ww <= 0.0d) {
        return;
    }
    hh = bounds.getHeight();
    if (hh <= 0.0d) {
        return;
    }

    constraint = new RectangleConstraint(ww, new Range(0.0, ww), LengthConstraintType.RANGE, hh,
            new Range(0.0, hh), LengthConstraintType.RANGE);

    size = legend.arrange(graphics, constraint);
    titleArea = _JFCLineChart2D.__createAlignedRectangle2D(size, bounds, legend.getHorizontalAlignment(),
            VerticalAlignment.TOP);
    legend.setMargin(_JFCLineChart2D.LEGEND_MARGIN);
    legend.setPadding(_JFCLineChart2D.CHART_INSETS);
    legend.draw(graphics, titleArea, p);
}

From source file:projects.wdlf47tuc.ProcessAllSwathcal.java

/**
 * Get an appropriate range for the Y axis based on the particular filter chosen.
 * //w  w  w  . j a  v a  2s . c o m
 * @return
 *    A range suitable for plotting the data
 */
private Range getYRange() {
    switch (magFilter) {
    case F110W_WFC3_IR:
        return new Range(13.0, 29.0);
    case F160W_WFC3_IR:
        return new Range(13.0, 29.0);
    case F390W_WFC3_UVIS:
        return new Range(16.0, 30.0);
    case F606W_WFC3_UVIS:
        return new Range(15.0, 30.0);
    default:
        throw new RuntimeException("Unrecognized Filter: " + magFilter);
    }
}

From source file:com.rapidminer.gui.new_plotter.gui.dialog.ManageZoomDialog.java

/**
 * Setup the GUI.// w ww . ja va2 s .  co  m
 */
private void setupGUI() {
    JPanel mainPanel = new JPanel();
    this.setContentPane(mainPanel);

    // start layout
    mainPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 0;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 2, 5);
    JPanel radioPanel = new JPanel();
    radioPanel.setLayout(new BorderLayout());
    zoomRadiobutton = new JRadioButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.zoom.label"));
    zoomRadiobutton.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.zoom.tip"));
    zoomRadiobutton.setSelected(true);
    radioPanel.add(zoomRadiobutton, BorderLayout.LINE_START);

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weightx = 1;
    selectionRadiobutton = new JRadioButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.selection.label"));
    selectionRadiobutton
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.selection.tip"));
    selectionRadiobutton.setHorizontalAlignment(SwingConstants.CENTER);
    radioPanel.add(selectionRadiobutton, BorderLayout.LINE_END);

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 3;
    this.add(radioPanel, gbc);

    ButtonGroup group = new ButtonGroup();
    group.add(zoomRadiobutton);
    group.add(selectionRadiobutton);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.CENTER;
    rangeAxisSelectionCombobox = new JComboBox();
    rangeAxisSelectionCombobox.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.range_axis_combobox.tip"));
    rangeAxisSelectionCombobox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateValueRange();
        }
    });
    this.add(rangeAxisSelectionCombobox, gbc);

    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 1;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 2, 5);
    JLabel domainRangeLowerBoundLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.domain_lower_bound.label"));
    this.add(domainRangeLowerBoundLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.insets = new Insets(2, 5, 2, 5);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    domainRangeLowerBoundField = new JTextField();
    domainRangeLowerBoundField.setText(String.valueOf(domainRangeLowerBound));
    domainRangeLowerBoundField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyDomainRangeLowerBoundInput(input);
        }
    });
    domainRangeLowerBoundField.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.domain_lower_bound.tip"));
    this.add(domainRangeLowerBoundField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.NONE;
    JLabel domainRangeUpperBoundLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.domain_upper_bound.label"));
    this.add(domainRangeUpperBoundLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    domainRangeUpperBoundField = new JTextField();
    domainRangeUpperBoundField.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.domain_upper_bound.tip"));
    domainRangeUpperBoundField.setText(String.valueOf(domainRangeUpperBound));
    domainRangeUpperBoundField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyDomainRangeUpperBoundInput(input);
        }
    });
    this.add(domainRangeUpperBoundField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.fill = GridBagConstraints.NONE;
    JLabel valueRangeLowerBoundLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.value_lower_bound.label"));
    this.add(valueRangeLowerBoundLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 4;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    valueRangeLowerBoundField = new JTextField();
    valueRangeLowerBoundField.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.value_lower_bound.tip"));
    valueRangeLowerBoundField.setText(String.valueOf(valueRangeLowerBound));
    valueRangeLowerBoundField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyValueRangeLowerBoundInput(input);
        }
    });
    this.add(valueRangeLowerBoundField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.fill = GridBagConstraints.NONE;
    JLabel valueRangeUpperBoundLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.value_upper_bound.label"));
    this.add(valueRangeUpperBoundLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    valueRangeUpperBoundField = new JTextField();
    valueRangeUpperBoundField.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.value_upper_bound.tip"));
    valueRangeUpperBoundField.setText(String.valueOf(valueRangeUpperBound));
    valueRangeUpperBoundField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyValueRangeUpperBoundInput(input);
        }
    });
    this.add(valueRangeUpperBoundField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 6;
    gbc.gridwidth = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    this.add(new JSeparator(), gbc);

    gbc.gridx = 0;
    gbc.gridy = 7;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    JLabel colorMinValueLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.color_min_value.label"));
    this.add(colorMinValueLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 7;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    colorMinValueField = new JTextField();
    colorMinValueField
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.color_min_value.tip"));
    colorMinValueField.setText(String.valueOf(colorMinValue));
    colorMinValueField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyColorInput(input);
        }
    });
    colorMinValueField.setEnabled(false);
    this.add(colorMinValueField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 8;
    gbc.fill = GridBagConstraints.NONE;
    JLabel colorMaxValueLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.color_max_value.label"));
    this.add(colorMaxValueLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 8;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    colorMaxValueField = new JTextField();
    colorMaxValueField
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.color_max_value.tip"));
    colorMaxValueField.setText(String.valueOf(colorMaxValue));
    colorMaxValueField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyColorInput(input);
        }
    });
    colorMaxValueField.setEnabled(false);
    this.add(colorMaxValueField, gbc);

    gbc.gridx = 1;
    gbc.gridy = 9;
    gbc.fill = GridBagConstraints.NONE;
    restoreColorButton = new JButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.restore_color.label"));
    restoreColorButton
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.restore_color.tip"));
    restoreColorButton.setIcon(SwingTools.createIcon(
            "16/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.restore_color.icon")));
    restoreColorButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            LinkAndBrushSelection linkAndBrushSelection = new LinkAndBrushSelection(SelectionType.RESTORE_COLOR,
                    new LinkedList<Pair<Integer, Range>>(), new LinkedList<Pair<Integer, Range>>(), null, null,
                    engine.getPlotInstance());
            engine.getChartPanel().informLinkAndBrushSelectionListeners(linkAndBrushSelection);
            updateColorValues();
        }
    });
    restoreColorButton.setEnabled(false);
    this.add(restoreColorButton, gbc);

    gbc.gridx = 0;
    gbc.gridy = 10;
    gbc.gridwidth = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(2, 5, 5, 5);
    this.add(new JSeparator(), gbc);

    gbc.gridx = 0;
    gbc.gridy = 11;
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 5, 5);
    okButton = new JButton(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.ok.label"));
    okButton.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.ok.tip"));
    okButton.setIcon(SwingTools
            .createIcon("24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.ok.icon")));
    okButton.setMnemonic(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.ok.mne").toCharArray()[0]);
    okButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // make sure fields have correct values
            boolean fieldsPassedChecks = checkFields();
            if (!fieldsPassedChecks) {
                return;
            }

            Object selectedItem = rangeAxisSelectionCombobox.getSelectedItem();
            if (selectedItem != null && selectedItem instanceof RangeAxisConfig) {
                RangeAxisConfig config = (RangeAxisConfig) selectedItem;
                boolean zoomOnLinkAndBrushSelection = engine.getChartPanel().getZoomOnLinkAndBrushSelection();
                Range domainRange = new Range(Double.parseDouble(domainRangeLowerBoundField.getText()),
                        Double.parseDouble(domainRangeUpperBoundField.getText()));
                Range valueRange = new Range(Double.parseDouble(valueRangeLowerBoundField.getText()),
                        Double.parseDouble(valueRangeUpperBoundField.getText()));
                LinkedList<Pair<Integer, Range>> domainRangeList = new LinkedList<Pair<Integer, Range>>();
                // only add domain zoom if != 0
                if (domainRange.getUpperBound() != 0) {
                    domainRangeList.add(new Pair<Integer, Range>(0, domainRange));
                }
                LinkedList<Pair<Integer, Range>> valueRangeList = new LinkedList<Pair<Integer, Range>>();
                // only add range zoom if at least one RangeAxisConfig exists
                if (engine.getPlotInstance().getMasterPlotConfiguration().getRangeAxisConfigs().size() > 0) {
                    if (valueRange.getUpperBound() != 0) {
                        // only add value zoom if != 0
                        valueRangeList.add(
                                new Pair<Integer, Range>(engine.getPlotInstance().getMasterPlotConfiguration()
                                        .getIndexOfRangeAxisConfigById(config.getId()), valueRange));
                    }
                }

                // zoom or select or color
                LinkAndBrushSelection linkAndBrushSelection = null;
                if (zoomRadiobutton.isSelected()) {
                    linkAndBrushSelection = new LinkAndBrushSelection(SelectionType.ZOOM_IN, domainRangeList,
                            valueRangeList);
                    if (isColorChanged(Double.parseDouble(colorMinValueField.getText()),
                            Double.parseDouble(colorMaxValueField.getText()))) {
                        linkAndBrushSelection = new LinkAndBrushSelection(SelectionType.COLOR_ZOOM,
                                domainRangeList, valueRangeList,
                                Double.parseDouble(colorMinValueField.getText()),
                                Double.parseDouble(colorMaxValueField.getText()), engine.getPlotInstance());
                    }
                } else if (selectionRadiobutton.isSelected()) {
                    linkAndBrushSelection = new LinkAndBrushSelection(SelectionType.SELECTION, domainRangeList,
                            valueRangeList);
                    if (isColorChanged(Double.parseDouble(colorMinValueField.getText()),
                            Double.parseDouble(colorMaxValueField.getText()))) {
                        linkAndBrushSelection = new LinkAndBrushSelection(SelectionType.COLOR_SELECTION,
                                domainRangeList, valueRangeList,
                                Double.parseDouble(colorMinValueField.getText()),
                                Double.parseDouble(colorMaxValueField.getText()), engine.getPlotInstance());
                    }
                }
                engine.getChartPanel().informLinkAndBrushSelectionListeners(linkAndBrushSelection);
                engine.getChartPanel().setZoomOnLinkAndBrushSelection(zoomOnLinkAndBrushSelection);
            } else {
                return;
            }

            ManageZoomDialog.this.dispose();
        }
    });
    okButton.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                okButton.doClick();
            }
        }
    });
    this.add(okButton, gbc);

    gbc.gridx = 2;
    gbc.gridy = 11;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    cancelButton = new JButton(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.cancel.label"));
    cancelButton.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.cancel.tip"));
    cancelButton.setIcon(SwingTools
            .createIcon("24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.cancel.icon")));
    cancelButton.setMnemonic(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.cancel.mne").toCharArray()[0]);
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // cancel requested, close dialog
            ManageZoomDialog.this.dispose();
        }
    });
    this.add(cancelButton, gbc);

    // misc settings
    this.setMinimumSize(new Dimension(375, 360));
    // center dialog
    this.setLocationRelativeTo(null);
    this.setTitle(I18N.getMessage(I18N.getGUIBundle(), "gui.action.manage_zoom.title.label"));
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.setModal(true);

    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowActivated(WindowEvent e) {
            okButton.requestFocusInWindow();
        }
    });
}

From source file:dk.netarkivet.harvester.harvesting.monitor.StartedJobHistoryChartGen.java

/**
 * Set the axis range.//  w w  w  .  j  a v a  2 s.c  o m
 * @param axis a numberAxis
 * @param range a range
 */
private void setAxisRange(NumberAxis axis, double[] range) {
    if (range == null || range.length != 2) {
        axis.setAutoRange(true);
    } else {
        double lower = range[0];
        double upper = range[1];
        ArgumentNotValid.checkTrue(lower < upper, "Incorrect range");
        axis.setAutoRange(false);
        axis.setRange(new Range(lower, upper));
    }
}

From source file:projects.wdlf47tuc.ProcessAllSwathcal.java

/**
 * Get an appropriate range for the X axis based on the particular combination of
 * filters chosen./* ww  w  . j a  v  a  2 s  .co  m*/
 * 
 * @return
 *    A range suitable for plotting the data
 */
private Range getXRange() {

    if (col1Filter == Filter.F110W_WFC3_IR) {
        switch (col2Filter) {
        case F110W_WFC3_IR:
            return new Range(0, 0);
        case F160W_WFC3_IR:
            return new Range(-0.25, 1.25);
        case F390W_WFC3_UVIS:
            return new Range(-7.5, 2.5);
        case F606W_WFC3_UVIS:
            return new Range(-4.0, 1.0);
        default:
            throw new RuntimeException("Unrecognized Filter: " + col2Filter);
        }
    } else if (col1Filter == Filter.F160W_WFC3_IR) {
        switch (col2Filter) {
        case F110W_WFC3_IR:
            return new Range(-1.25, 0.25);
        case F160W_WFC3_IR:
            return new Range(0, 0);
        case F390W_WFC3_UVIS:
            return new Range(-8, 2);
        case F606W_WFC3_UVIS:
            return new Range(-7, 2);
        default:
            throw new RuntimeException("Unrecognized Filter: " + col2Filter);
        }
    } else if (col1Filter == Filter.F390W_WFC3_UVIS) {
        switch (col2Filter) {
        case F110W_WFC3_IR:
            return new Range(-2.5, 7.5);
        case F160W_WFC3_IR:
            return new Range(-2, 8);
        case F390W_WFC3_UVIS:
            return new Range(0, 0);
        case F606W_WFC3_UVIS:
            return new Range(-2, 4);
        default:
            throw new RuntimeException("Unrecognized Filter: " + col2Filter);
        }
    } else if (col1Filter == Filter.F606W_WFC3_UVIS) {
        switch (col2Filter) {
        case F110W_WFC3_IR:
            return new Range(-1.0, 4.0);
        case F160W_WFC3_IR:
            return new Range(-2, 7);
        case F390W_WFC3_UVIS:
            return new Range(-4, 2);
        case F606W_WFC3_UVIS:
            return new Range(0, 0);
        default:
            throw new RuntimeException("Unrecognized Filter: " + col2Filter);
        }
    }
    return null;
}

From source file:org.jfree.data.jdbc.JDBCXYDataset.java

/**
 * Returns the range of the values in this dataset's range.
 *
 * @param includeInterval  a flag that determines whether or not the
 *                         y-interval is taken into account.
 *
 * @return The range.//from w  ww. j  a  va  2s .c o m
 */
public Range getRangeBounds(boolean includeInterval) {
    return new Range(this.minValue, this.maxValue);
}