Example usage for org.jfree.data Range getUpperBound

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

Introduction

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

Prototype

public double getUpperBound() 

Source Link

Document

Returns the upper bound for the range.

Usage

From source file:org.jfree.data.xy.junit.DefaultOHLCDatasetTest.java

/**
 * A small test for the data range calculated on this dataset.
 *//* www.j  a va  2  s. c  o m*/
public void testDataRange() {
    OHLCDataItem[] data = new OHLCDataItem[3];
    data[0] = new OHLCDataItem(new Date(11L), 2.0, 4.0, 1.0, 3.0, 100.0);
    data[1] = new OHLCDataItem(new Date(22L), 4.0, 9.0, 2.0, 5.0, 120.0);
    data[2] = new OHLCDataItem(new Date(33L), 3.0, 7.0, 3.0, 6.0, 140.0);
    DefaultOHLCDataset d = new DefaultOHLCDataset("S1", data);
    Range r = DatasetUtilities.findRangeBounds(d, true);
    assertEquals(1.0, r.getLowerBound(), EPSILON);
    assertEquals(9.0, r.getUpperBound(), EPSILON);
}

From source file:inflor.core.plots.FCSChartPanel.java

private double[] estimateGateLabelPosition(XYGateAnnotation annotation) {
    Range xRange = annotation.getXRange();
    Range yRange = annotation.getYRange();
    double x = xRange.getLowerBound();
    double y = yRange.getUpperBound() + yHandleSize / 10;
    return new double[] { x, y };
}

From source file:ec.ui.chart.RevisionChartPanel.java

private void setRange(TimeSeriesCollection ref, TimeSeriesCollection series) {
    double min, max;
    Range c = ref.getRangeBounds(true);

    min = c.getLowerBound();//from w w w  . j  a v a 2 s.c o  m
    max = c.getUpperBound();

    if (series != null && series.getSeriesCount() != 0) {
        Range s = series.getRangeBounds(true);
        if (min > s.getLowerBound()) {
            min = s.getLowerBound();
        }

        if (max < s.getUpperBound()) {
            max = s.getUpperBound();
        }
    }

    min -= (Math.abs(min) * .03);
    max += (Math.abs(max) * .03);

    panel.getChart().getXYPlot().getRangeAxis().setRange(new Range(min, max));
}

From source file:inflor.core.plots.FCSChartPanel.java

public FCSChartPanel(JFreeChart chart, ChartSpec spec, FCSFrame data, TransformSet transforms) {
    super(chart);
    this.data = data;
    this.spec = spec;
    this.transformSet = transforms;

    getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("DELETE"),
            DELETE_ANNOTATIONS_KEY);/*  w  ww  . ja va 2  s  . c o m*/
    getActionMap().put(DELETE_ANNOTATIONS_KEY, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            deleteSelectedAnnotations();
        }
    });
    Range xRange = this.getChart().getXYPlot().getDomainAxis().getRange();
    xHandleSize = (xRange.getUpperBound() - xRange.getLowerBound()) / 100;
    Range yRange = this.getChart().getXYPlot().getDomainAxis().getRange();
    yHandleSize = (yRange.getUpperBound() - yRange.getLowerBound()) / 100;
}

From source file:org.kalypso.ogc.sensor.diagview.jfreechart.NumberAxisDefault.java

/**
 * Rescales the axis to ensure that all data is visible.
 *//*from w ww  . jav a  2s .  com*/
@Override
protected void autoAdjustRange() {
    final Plot plot = getPlot();
    if (plot == null) {
        return; // no plot, no data
    }

    if (plot instanceof ValueAxisPlot) {
        final ValueAxisPlot vap = (ValueAxisPlot) plot;

        Range r = vap.getDataRange(this);
        if (r == null) {
            r = new Range(DEFAULT_LOWER_BOUND, DEFAULT_UPPER_BOUND);
        }

        double upper = r.getUpperBound();
        double lower = r.getLowerBound();
        if (autoRangeIncludesZero()) {
            lower = Math.min(lower, 0.0);
            upper = Math.max(upper, 0.0);
        }
        final double range = upper - lower;

        // if fixed auto range, then derive lower bound...
        final double fixedAutoRange = getFixedAutoRange();
        if (fixedAutoRange > 0.0) {
            lower = upper - fixedAutoRange;
        } else {
            // ensure the autorange is at least <minRange> in size...
            final double minRange = getAutoRangeMinimumSize();
            if (range < minRange) {
                // double expand = ( minRange - range ) / 2;
                upper = minRange; // upper + expand;
                lower = 0; // getlower - expand;
            }

            if (autoRangeStickyZero()) {
                if (upper <= 0.0) {
                    upper = Math.min(0.0, upper + getUpperMargin() * range);
                } else {
                    upper = upper + getUpperMargin() * range;
                }
                if (lower >= 0.0) {
                    lower = Math.max(0.0, lower - getLowerMargin() * range);
                } else {
                    lower = lower - getLowerMargin() * range;
                }
            } else {
                upper = upper + getUpperMargin() * range;
                lower = lower - getLowerMargin() * range;
            }
        }

        if (m_min != null && lower > m_min.doubleValue())
            lower = m_min.doubleValue();

        if (m_max != null && upper < m_max.doubleValue())
            upper = m_max.doubleValue();

        setRange(new Range(lower, upper), false, false);
    }
}

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

/**
 * A test for bug 3072674./* w  w  w. j  av a2  s  .co  m*/
 */
@Test
public void test3072674() {
    DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset();
    dataset.add(1.0, Double.NaN, "R1", "C1");
    assertEquals(1.0, dataset.getRangeLowerBound(true), EPSILON);
    assertEquals(1.0, dataset.getRangeUpperBound(true), EPSILON);

    Range r = dataset.getRangeBounds(true);
    assertEquals(1.0, r.getLowerBound(), EPSILON);
    assertEquals(1.0, r.getUpperBound(), EPSILON);
}

From source file:com.bdb.weather.display.day.DayTemperaturePane.java

@Override
public void finishLoadData() {
    if (recordHigh == null || recordLow == null)
        return;//from w w  w  .  ja v  a 2s  .  c  om

    ValueAxis axis = getPlot().getRangeAxis();

    Range range = axis.getRange();

    double lowRange = recordLow.get() < range.getLowerBound() ? recordLow.get() : range.getLowerBound();
    double highRange = recordHigh.get() > range.getUpperBound() ? recordHigh.get() : range.getUpperBound();

    axis.setAutoRange(false);
    axis.setRange(lowRange - 10.0, highRange + 10.0);
}

From source file:edu.scripps.fl.curves.plot.CurvePlot.java

public void addLineAt(double response, Paint paint, BasicStroke stroke) {
    Range range = plot.getDomainAxis().getRange();
    double lower = range.getLowerBound();
    double upper = range.getUpperBound();
    YIntervalSeries series = new YIntervalSeries("");
    series.add(lower, response, response, response);
    series.add(upper, response, response, response);
    addSeries(series, paint, false, false);
    MyXYErrorRenderer renderer = (MyXYErrorRenderer) plot.getRenderer();
    int idx = dataset.getSeriesCount() - 1;
    renderer.setSeriesStroke(idx, stroke);
}

From source file:com.epiq.bitshark.ui.TimeDomainPanel.java

public TimeDomainPanel() {
    initComponents();/*from w w  w . ja  va 2  s . c om*/

    initGraph();

    JPanel holderPanel = new JPanel() {
        @Override
        public void paint(Graphics g) {

            if (plot.getDomainAxis().isAutoRange()) {
                plot.getDomainAxis().setAutoRange(false);
                Range newDomain = new Range(0, FMCUartClient.BLOCK_SIZE - 1);
                plot.getDomainAxis().setRange(newDomain, true, false);
            }

            if (plot.getRangeAxis().isAutoRange()) {
                plot.getRangeAxis().setAutoRange(false);
            }

            // ensureAxisMargin( ) ?

            Range newRange = null;
            Range currentRangeRange = plot.getRangeAxis().getRange();
            double extent = currentRangeRange.getUpperBound() - currentRangeRange.getLowerBound();
            newRange = new Range(-(extent) / 2, (extent) / 2);
            plot.getRangeAxis().setRange(newRange, true, false);

            super.paint(g);
        }
    };
    holderPanel.setLayout(new BorderLayout());
    holderPanel.add(chartPanel, BorderLayout.CENTER);
    mainPanel.add(holderPanel, BorderLayout.CENTER);

    headerPanel.setBackgroundPainter(Common.getHeaderPainter());

    titleLabel.setUI(new BasicLabelUI());

    showICheckBox.setFocusPainted(false);
    showQCheckBox.setFocusPainted(false);
}

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

/**
 * Confirm that the constructor initializes all the required fields.
 *///w  ww  .  j a v a  2s . c om
@Test
public void testConstructor() {
    Range r1 = new Range(0.1, 1000.0);
    assertEquals(r1.getLowerBound(), 0.1, 0.0d);
    assertEquals(r1.getUpperBound(), 1000.0, 0.0d);

    try {
        /*Range r2 =*/ new Range(10.0, 0.0);
        fail("Lower bound cannot be greater than the upper");
    } catch (Exception e) {
        // expected
    }
}