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:org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDatasetTest.java

/**
 * Some checks for the getRangeBounds() method.
 *///from  ww w . ja v a 2 s.  c  o m
@Test
public void testGetRangeBounds() {
    DefaultBoxAndWhiskerCategoryDataset d1 = new DefaultBoxAndWhiskerCategoryDataset();
    d1.add(new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList()), "R1", "C1");
    assertEquals(new Range(7.0, 8.0), d1.getRangeBounds(false));
    assertEquals(new Range(7.0, 8.0), d1.getRangeBounds(true));

    d1.add(new BoxAndWhiskerItem(1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, new ArrayList()), "R1", "C1");
    assertEquals(new Range(7.5, 8.5), d1.getRangeBounds(false));
    assertEquals(new Range(7.5, 8.5), d1.getRangeBounds(true));

    d1.add(new BoxAndWhiskerItem(2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, new ArrayList()), "R2", "C1");
    assertEquals(new Range(7.5, 9.5), d1.getRangeBounds(false));
    assertEquals(new Range(7.5, 9.5), d1.getRangeBounds(true));

    // this replaces the entry with the current minimum value, but the new
    // minimum value is now in a different item
    d1.add(new BoxAndWhiskerItem(1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 8.6, 9.6, new ArrayList()), "R1", "C1");
    assertEquals(new Range(8.5, 9.6), d1.getRangeBounds(false));
    assertEquals(new Range(8.5, 9.6), d1.getRangeBounds(true));
}

From source file:com.idealista.solrmeter.view.statistic.CacheHistoryPanel.java

/**
 * Invoke this method when the selection of what to show changes
 * @param b//from w w w .ja  v  a2s  .com
 */
private void setShowingSpecificData(boolean b) {
    showingSpecificCacheData = b;
    comboBoxCache.setEnabled(showingSpecificCacheData);
    cumulativeDataPanel.setVisible(showingSpecificCacheData);
    if (b) {
        plot.getRangeAxis().setAutoRange(true);
        changeChartTitle("title" + comboBoxCache.getSelectedItem().toString());
    } else {
        plot.getRangeAxis().setRange(new Range(0, 1));
        plot.getRangeAxis().setAutoRange(false);
        changeChartTitle("titleHitRatio");
    }
    clearChart();

}

From source file:com.compomics.cell_coord.gui.controller.summary.VisualizeTracksController.java

/**
 * Scale the axes to the experiment coordinates ranges.
 *
 * @param chart//from w w  w  . ja  va  2 s. c  om
 */
private void scaleAxes(JFreeChart chart, boolean useRawData) {
    XYPlot xYPlot = chart.getXYPlot();
    Double[][] coordinatesRanges;
    if (useRawData) {
        coordinatesRanges = coordRanges;
    } else {
        coordinatesRanges = shiftedCoordRange;
    }
    Double[] xCoords = coordinatesRanges[0];
    Double[] yCoords = coordinatesRanges[1];
    xYPlot.getDomainAxis().setRange(new Range(yCoords[0], yCoords[1]));
    xYPlot.getRangeAxis().setRange(new Range(xCoords[0], xCoords[1]));
}

From source file:org.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset.java

/**
 * Adds an item to the dataset and sends a {@link DatasetChangeEvent} to
 * all registered listeners.//  w w w .jav a2  s.c o m
 *
 * @param date  the date (<code>null</code> not permitted).
 * @param item  the item (<code>null</code> not permitted).
 */
public void add(Date date, BoxAndWhiskerItem item) {
    this.dates.add(date);
    this.items.add(item);
    if (this.minimumRangeValue == null) {
        this.minimumRangeValue = item.getMinRegularValue();
    } else {
        if (item.getMinRegularValue().doubleValue() < this.minimumRangeValue.doubleValue()) {
            this.minimumRangeValue = item.getMinRegularValue();
        }
    }
    if (this.maximumRangeValue == null) {
        this.maximumRangeValue = item.getMaxRegularValue();
    } else {
        if (item.getMaxRegularValue().doubleValue() > this.maximumRangeValue.doubleValue()) {
            this.maximumRangeValue = item.getMaxRegularValue();
        }
    }
    this.rangeBounds = new Range(this.minimumRangeValue.doubleValue(), this.maximumRangeValue.doubleValue());
    fireDatasetChanged();
}

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

public COSMOSACDialog() {
    super("JCOSMO Simple");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setLayout(new BorderLayout());

    db = COSMOSACDataBase.getInstance();

    COSMOSAC models[] = new COSMOSAC[5];
    models[0] = new COSMOSAC();
    models[1] = new COSMOPAC();
    models[2] = new COSMOSAC_SVP();
    models[3] = new COSMOSAC_G();
    models[4] = new PCMSAC();
    modelBox = new JComboBox(models);
    modelBox.addActionListener(this);

    JPanel north = new JPanel(new GridLayout(0, 2));
    add(north, BorderLayout.NORTH);
    JPanel northAba1 = new JPanel(new GridLayout(0, 4));
    JPanel northAba2 = new JPanel(new GridLayout(0, 2));

    //Where the GUI is created:
    JMenuBar menuBar;//  w  w  w  .j av  a 2s  .co  m
    JMenu file, help;
    JMenuItem menuItem;

    //Create the menu bar.
    menuBar = new JMenuBar();

    // the file menu
    file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);
    menuBar.add(file);
    menuItem = new JMenuItem("Quit", KeyEvent.VK_Q);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK));
    menuItem.setActionCommand(QUIT);
    menuItem.addActionListener(this);
    file.add(menuItem);

    // the help menu
    help = new JMenu("Help");
    file.setMnemonic(KeyEvent.VK_H);
    menuBar.add(help);
    menuItem = new JMenuItem("About", KeyEvent.VK_A);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
    menuItem.setActionCommand(ABOUT);
    menuItem.addActionListener(this);
    help.add(menuItem);

    setJMenuBar(menuBar);

    listModel = new DefaultListModel();
    list = new JList(listModel);
    list.setBorder(BorderFactory.createTitledBorder("compounds"));
    list.setVisibleRowCount(2);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane listScrollPane = new JScrollPane(list);

    JButton addButton = new JButton("Add");
    addButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new AddCompoundDialog(COSMOSACDialog.this);
        }
    });

    removeButton = new JButton("Remove");
    removeButton.addActionListener(this);
    visibRemove(false);

    JButton calcButton = new JButton("Calculate");
    calcButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            rebuildChart();
            rebuildSigmaProfiles();
        }
    });

    JButton refreshButton = new JButton("Refresh");
    refreshButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            rebuildSigmaProfiles();
        }
    });

    ignoreSGButton = new JCheckBox("Ignore SG");
    ignoreSGButton.setToolTipText("Toogles the ignore flag for the Staverman-Guggenheim term");
    ignoreSGButton.addActionListener(this);

    JPanel but = new JPanel(new GridLayout(0, 1));
    but.add(addButton, BorderLayout.EAST);
    but.add(removeButton, BorderLayout.EAST);
    but.add(modelBox);
    north.add(listScrollPane);
    north.add(but);

    northAba1.add(new JLabel("Temperature [K]"));
    northAba1.add(temperature = new JTextField(10));
    temperature.setText("298");

    northAba1.add(new JLabel("Sigma HB"));
    northAba1.add(sigmaHB = new JTextField(10));
    northAba1.add(new JLabel("Sigma HB2"));
    northAba1.add(sigmaHB2 = new JTextField(10));
    northAba1.add(new JLabel("Sigma HB3"));
    northAba1.add(sigmaHB3 = new JTextField(10));

    northAba1.add(new JLabel("Charge HB"));
    northAba1.add(chargeHB = new JTextField(10));

    northAba1.add(new JLabel("Sigma Disp"));
    northAba1.add(sigmaDisp = new JTextField(10));
    northAba1.add(new JLabel("Charge Disp"));
    northAba1.add(chargeDisp = new JTextField(10));

    northAba1.add(new JLabel("Beta"));
    northAba1.add(beta = new JTextField(10));
    northAba1.add(new JLabel("fpol"));
    northAba1.add(fpol = new JTextField(10));
    northAba1.add(new JLabel("Anorm"));
    northAba1.add(anorm = new JTextField(10));

    northAba1.add(ignoreSGButton);
    northAba1.add(calcButton);
    northAba2.add(new JLabel(""));
    northAba2.add(refreshButton);

    //      chart = new JLineChart();
    //      add(chart, BorderLayout.CENTER);
    //      chart.setTitle("Gamma Plot");
    //      chart.setSubtitle("");
    //      chart.setXAxisLabel("Mole Fraction, x_1");
    //      chart.setYAxisLabel("ln gamma, gE/RT");
    //      chart.setSource(getTitle());
    //      chart.setLegendPosition(LegendPosition.BOTTOM);
    //      chart.setShapesVisible(true);

    JFreeChart chart = ChartFactory.createXYLineChart(null, "Mole Fraction, x_1", "ln gamma, gE/RT", null,
            PlotOrientation.VERTICAL, true, true, false);
    plot = (XYPlot) chart.getPlot();
    plot.getDomainAxis().setAutoRange(false);
    plot.getDomainAxis().setRange(new Range(0.0, 1.0));

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer();
    r.setUseFillPaint(true);
    r.setBaseFillPaint(Color.white);
    r.setBaseShapesVisible(true);

    JFreeChart sigmaProfileChart = ChartFactory.createXYLineChart(null, "sigma", "P^x", null,
            PlotOrientation.VERTICAL, true, true, false);
    sigmaProfilePlot = sigmaProfileChart.getXYPlot();
    sigmaProfilePlot.getDomainAxis().setAutoRange(false);
    sigmaProfilePlot.getDomainAxis().setRange(new Range(-0.025, 0.025));

    //      sigmaProfilePlot.setBackgroundPaint(Color.lightGray);
    //      sigmaProfilePlot.setDomainGridlinePaint(Color.white);
    //      sigmaProfilePlot.setRangeGridlinePaint(Color.white);

    JFreeChart chartSegGamma = ChartFactory.createXYLineChart(null, "sigma", "Segment Gamma", null,
            PlotOrientation.VERTICAL, true, true, false);
    plotSegGamma = (XYPlot) chartSegGamma.getPlot();

    JPanel south = new JPanel();
    south.setLayout(new FlowLayout());
    south.add(new JLabel("<html>ln &gamma;<sup>&infin;</sup><sub>1</sub>:</html>"));
    south.add(lnGammaInf1Label = new JLabel());
    south.add(new JLabel("<html>ln &gamma;<sup>&infin;</sup><sub>2</sub>:</html>"));
    south.add(lnGammaInf2Label = new JLabel());
    south.add(Box.createHorizontalStrut(20));
    south.add(new JLabel("<html>&gamma;<sup>&infin;</sup><sub>1</sub>:</html>"));
    south.add(gammaInf1Label = new JLabel());
    south.add(new JLabel("<html>&gamma;<sup>&infin;</sup><sub>2</sub>:</html>"));
    south.add(gammaInf2Label = new JLabel());

    JPanel aba1 = new JPanel(new BorderLayout());
    aba1.add(northAba1, BorderLayout.NORTH);
    JPanel chartsPanel = new JPanel(new GridLayout(0, 2));
    aba1.add(chartsPanel, BorderLayout.CENTER);
    chartsPanel.add(new ChartPanel(chart));
    chartsPanel.add(new ChartPanel(chartSegGamma));
    aba1.add(south, BorderLayout.SOUTH);

    JPanel aba2 = new JPanel(new BorderLayout());
    aba2.add(northAba2, BorderLayout.NORTH);
    aba2.add(chartPanel = new ChartPanel(sigmaProfileChart), BorderLayout.CENTER);

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("gamma", aba1);
    tabbedPane.addTab("sigma", aba2);
    add(tabbedPane, BorderLayout.CENTER);

    //      cosmosac.setAEffPrime(6.596176570595075);
    //      cosmosac.setCoord(11.614599507917934);
    //      cosmosac.setVnorm(56.36966406129967);
    //      cosmosac.setAnorm(41.56058649432742);
    //      cosmosac.setCHB(65330.19484947528);
    //      cosmosac.setSigmaHB(0.008292411048046008);

    //Display the window.
    setSize(800, 600);
    setLocationRelativeTo(null);
    modelBox.setSelectedIndex(0);
    setVisible(true);

    // test for a mixture
    //      addList("WATER");
    //      addList("H3O+1");
    //      addList("OH-1");
    //      addList("CL-1");
    //      addList("OXYGEN");
    //      addList("sec-butylamine");
    //      addList("hydrogen-fluoride");
    //      addList("ACETONE");
    //      addList("METHANOL");
    //      addList("ACETONE.opt");
    //      addList("METHANOL.opt");
    //      addList("METHYL-ETHYL-KETONE");
    //      addList("ETHANOL");
    //      addList("N-HEPTANE");
    //      addList("PROPIONIC-ACID");
    //      addList("EMIM");
    //      addList("NTF2");
    //      addList("DCA");
    //      addList("N-OCTANE");
    addList("ETHYLENE CARBONATE");
    addList("BENZENE");
    addList("TOLUENE");
    removeButton.setEnabled(true);
}

From source file:org.jfree.data.RangeTest.java

/**
 * Some checks for the combine method.//from ww  w.  j  ava 2s  .  c o m
 */
@Test
public void testCombine() {
    Range r1 = new Range(1.0, 2.0);
    Range r2 = new Range(1.5, 2.5);

    assertNull(Range.combine(null, null));
    assertEquals(r1, Range.combine(r1, null));
    assertEquals(r2, Range.combine(null, r2));
    assertEquals(new Range(1.0, 2.5), Range.combine(r1, r2));

    Range r3 = new Range(Double.NaN, 1.3);
    Range rr = Range.combine(r1, r3);
    assertTrue(Double.isNaN(rr.getLowerBound()));
    assertEquals(2.0, rr.getUpperBound(), EPSILON);

    Range r4 = new Range(1.7, Double.NaN);
    rr = Range.combine(r4, r1);
    assertEquals(1.0, rr.getLowerBound(), EPSILON);
    assertTrue(Double.isNaN(rr.getUpperBound()));
}

From source file:forms.frDados.java

/**
 * Inicializa o grfico de intensidade de sinal dos satlites.
 *///  ww w .j  a v  a 2  s . c  o  m
private void initSatGrafico() {
    dadosGraficoSats.clear();
    plot = ChartFactory.createBarChart("Intensidade do sinal", "PRN", "SNR", dadosGraficoSats,
            PlotOrientation.VERTICAL, false, true, true);

    plot.getTitle().setFont(Font.decode("arial-16"));
    plot.getTitle().setPadding(5, 20, 5, 20);
    plot.setPadding(new RectangleInsets(10, 10, 0, 10));
    //plot.setBackgroundPaint(new Color(255,255,255,0));

    BarRenderer br = (BarRenderer) plot.getCategoryPlot().getRenderer();
    br.setSeriesPaint(0, Color.BLUE);
    br.setMaximumBarWidth(0.05);

    plot.getCategoryPlot().getRangeAxis().setRange(new Range(0, 50), true, true);
    br.setBaseItemLabelsVisible(true);
    br.setSeriesItemLabelFont(0, Font.decode("arial-12"));
    br.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    br.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));

    SpringLayout lm = new SpringLayout();
    ChartPanel cp = new ChartPanel(plot);
    cp.setBorder(LineBorder.createGrayLineBorder());

    lm.putConstraint(SpringLayout.EAST, pnlSatPlot, 10, SpringLayout.EAST, cp);
    lm.putConstraint(SpringLayout.WEST, cp, 10, SpringLayout.WEST, pnlSatPlot);
    lm.putConstraint(SpringLayout.SOUTH, pnlSatPlot, 10, SpringLayout.SOUTH, cp);
    lm.putConstraint(SpringLayout.NORTH, cp, 10, SpringLayout.NORTH, pnlSatPlot);

    pnlSatPlot.setLayout(lm);
    pnlSatPlot.add(cp);
}

From source file:anl.verdi.plot.jfree.XYBlockRenderer.java

/**
 * Returns the lower and upper bounds (range) of the x-values in the
 * specified dataset.//from   w ww .j  a  v  a2s  .c om
 *
 * @param dataset the dataset (<code>null</code> permitted).
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 */
public Range findDomainBounds(XYDataset dataset) {
    if (dataset != null) {
        Range r = DatasetUtilities.findDomainBounds(dataset, false);
        return new Range(r.getLowerBound() + xOffset, r.getUpperBound() + blockWidth + xOffset);
    } else {
        return null;
    }
}

From source file:nl.vu.nat.jfreechartcustom.XYBlockRenderer.java

/**
 * Returns the lower and upper bounds (range) of the x-values in the
 * specified dataset./*  w w  w  .  j  a v  a  2s  .c o  m*/
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return The range (<code>null</code> if the dataset is <code>null</code>
 *         or empty).
 *
 * @see #findRangeBounds(XYDataset)
 */
@Override
public Range findDomainBounds(XYDataset dataset) {
    if (dataset != null) {
        Range r = DatasetUtilities.findDomainBounds(dataset, false);
        if (r == null) {
            return null;
        } else {
            return new Range(r.getLowerBound() + this.xOffset,
                    r.getUpperBound() + this.blockWidth + this.xOffset);
        }
    } else {
        return null;
    }
}

From source file:org.jfree.data.contour.DefaultContourDataset.java

/**
 * Returns the maximum z-value within visible region of plot.
 *
 * @param x  the x range.//from  w  w w  .  j  a  v  a 2s. c o  m
 * @param y  the y range.
 *
 * @return The z range.
 */
@Override
public Range getZValueRange(Range x, Range y) {

    double minX = x.getLowerBound();
    double minY = y.getLowerBound();
    double maxX = x.getUpperBound();
    double maxY = y.getUpperBound();

    double zMin = 1.e20;
    double zMax = -1.e20;
    for (int k = 0; k < this.zValues.length; k++) {
        if (this.xValues[k].doubleValue() >= minX && this.xValues[k].doubleValue() <= maxX
                && this.yValues[k].doubleValue() >= minY && this.yValues[k].doubleValue() <= maxY) {
            if (this.zValues[k] != null) {
                zMin = Math.min(zMin, this.zValues[k].doubleValue());
                zMax = Math.max(zMax, this.zValues[k].doubleValue());
            }
        }
    }

    return new Range(zMin, zMax);
}