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:inflor.core.plots.LogicleAxis.java

/**
 * Rescales the axis to ensure that all data is visible.
 */// w w w .  j a  v a 2s .c  o m
@Override
public void autoAdjustRange() {

    Plot plot = getPlot();
    if (plot == null) {
        return; // no plot, no data.
    }
    setRange(new Range(0, 262144), false, false);
}

From source file:org.shredzone.bullshitcharts.chart.BarChartGenerator.java

@Override
public Plot generate() {
    LineDatasetCreator dataset = new LineDatasetCreator();
    dataset.setTendency(getTendency());/*from   w  w w .j a  va2s  .  c  o m*/
    dataset.setNumberOfValues(getResolution());
    dataset.setAmplitude(getAmplitude());

    CategoryAxis catAxis = new CategoryAxis(getValue("x", "Time")); // TODO: i18n
    catAxis.setLowerMargin(0.0d);
    catAxis.setUpperMargin(0.0d);
    catAxis.setTickMarksVisible(false);
    catAxis.setTickLabelsVisible(false);

    ValueAxis valAxis = new NumberAxis(getValue("y", "Value"));
    valAxis.setRange(new Range(0.0d, 1.05d));
    valAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    valAxis.setTickMarksVisible(false);
    valAxis.setTickLabelsVisible(false);

    BarRenderer3D renderer = new BarRenderer3D();

    CategoryPlot plot = new CategoryPlot(dataset.generate(), catAxis, valAxis, renderer);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    return plot;
}

From source file:it.eng.spagobi.engines.kpi.bo.charttypes.dialcharts.Meter.java

/**
 * Creates the MeterChart .//from ww  w . ja va2s  .co  m
 * 
 * @return A MeterChart .
 */
public JFreeChart createChart() {
    logger.debug("IN");
    if (dataset == null) {
        logger.debug("The dataset to be represented is null");
        return null;
    }
    MeterPlot plot = new MeterPlot((ValueDataset) dataset);
    logger.debug("Created new plot");
    plot.setRange(new Range(lower, upper));
    logger.debug("Setted plot range");

    for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
        KpiInterval interval = (KpiInterval) iterator.next();
        plot.addInterval(new MeterInterval(interval.getLabel(), new Range(interval.getMin(), interval.getMax()),
                Color.lightGray, new BasicStroke(2.0f), interval.getColor()));
        logger.debug("Added new interval to the plot");
    }

    plot.setNeedlePaint(Color.darkGray);
    plot.setDialBackgroundPaint(Color.white);
    plot.setDialOutlinePaint(Color.gray);
    plot.setDialShape(DialShape.CHORD);
    plot.setMeterAngle(260);
    plot.setTickLabelsVisible(true);
    Font f = new Font("Arial", Font.PLAIN, 11);
    plot.setTickLabelFont(f);
    plot.setTickLabelPaint(Color.darkGray);
    plot.setTickSize(5.0);
    plot.setTickPaint(Color.lightGray);
    plot.setValuePaint(Color.black);
    plot.setValueFont(new Font("Arial", Font.PLAIN, 14));
    logger.debug("Setted all properties of the plot");

    JFreeChart chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    logger.debug("Created the chart");
    chart.setBackgroundPaint(color);
    logger.debug("Setted background color of the chart");

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    logger.debug("Setted the title of the chart");
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
        logger.debug("Setted the subtitle of the chart");
    }
    logger.debug("OUT");
    return chart;
}

From source file:org.fhcrc.cpl.viewer.mrm.utilities.CenterZoomNumberAxis.java

public void zoomRange(double lowerPercent, double upperPercent) {
    double start = this.getRange().getLowerBound() + this.getRange().getLength() * lowerPercent;
    double end = this.getRange().getLowerBound() + this.getRange().getLength() * upperPercent;
    Range adjusted = null;//from ww w  . jav  a2s.com
    if (isInverted()) {
        adjusted = new Range(1 - end, 1 - start);
    } else {
        adjusted = new Range(start, end);
    }
    setRange(adjusted);
    configure();
}

From source file:org.shredzone.bullshitcharts.chart.LineChartGenerator.java

@Override
public Plot generate() {
    LineDatasetCreator dataset = new LineDatasetCreator();
    dataset.setTendency(getTendency());//from   w  w  w  . j a v a  2s .c om
    dataset.setNumberOfValues(getResolution());
    dataset.setAmplitude(getAmplitude());

    CategoryAxis catAxis = new CategoryAxis(getValue("x", "Time")); // TODO: i18n
    catAxis.setLowerMargin(0.0d);
    catAxis.setUpperMargin(0.0d);
    catAxis.setTickMarksVisible(false);
    catAxis.setTickLabelsVisible(false);

    ValueAxis valAxis = new NumberAxis(getValue("y", "Value"));
    valAxis.setRange(new Range(0.0d, 1.05d));
    valAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    valAxis.setTickMarksVisible(false);
    valAxis.setTickLabelsVisible(false);

    LineAndShapeRenderer renderer = new LineRenderer3D();
    renderer.setBaseShapesVisible(false);
    //        renderer.setStroke(new BasicStroke(2.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER));

    CategoryPlot plot = new CategoryPlot(dataset.generate(), catAxis, valAxis, renderer);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    return plot;
}

From source file:net.atomique.ksar.xml.PlotStackConfig.java

public void setRange(String s) {
    String[] t = s.split(",");
    if (t.length == 2) {
        double min = Double.parseDouble(t[0]);
        double max = Double.parseDouble(t[1]);
        range = new Range(min, max);
    }//ww  w.j  a  v  a2s .c o m
}

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

@Override
protected void autoAdjustRange() {
    setRange(new Range(0.0, 3), true, true);
}

From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.link_and_brush.axis.CustomDateAxis.java

@Override
public void resizeRange2(double percent, double anchorValue) {
    if (percent > 0.0) {
        double left = anchorValue - getLowerBound();
        double right = getUpperBound() - anchorValue;
        Range adjusted = new Range(anchorValue - left * percent, anchorValue + right * percent);
        setRange(adjusted);//from ww w.  j a  v a2 s .c  o  m
    } else {
        restoreAutoRange(true);
    }
}

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

public SigmaProfileAreaPanel() {
    setLayout(new BorderLayout());

    sigmaProfileChart = ChartFactory.createStackedXYAreaChart(null, "sigma [e/]", "p(sigma)area []",
            dataset, PlotOrientation.VERTICAL, true, true, false);

    sigmaProfilePlot = sigmaProfileChart.getXYPlot();
    sigmaProfilePlot.getDomainAxis().setAutoRange(false);
    sigmaProfilePlot.getDomainAxis().setRange(new Range(-0.025, 0.025));
    sigmaProfilePlot.setBackgroundPaint(Color.WHITE);

    sigmaProfilePlot.setAxisOffset(new RectangleInsets(8, 0, 0, 16));
    sigmaProfilePlot.setDomainGridlinesVisible(false);
    sigmaProfilePlot.setRangeGridlinesVisible(false);

    Font font = new Font("DeJaVu Serif", Font.BOLD, 16);
    Font fontMini = new Font("DeJaVu Serif", 0, 12);

    sigmaProfileChart.getLegend().setItemFont(fontMini);
    sigmaProfilePlot.getDomainAxis().setLabelFont(font);
    sigmaProfilePlot.getRangeAxis().setLabelFont(font);
    sigmaProfilePlot.getDomainAxis().setTickLabelFont(fontMini);
    sigmaProfilePlot.getRangeAxis().setTickLabelFont(fontMini);

    sigmaProfilePlot.getDomainAxis().setAxisLinePaint(Color.BLACK);
    sigmaProfilePlot.getDomainAxis().setTickMarkPaint(Color.BLACK);
    sigmaProfilePlot.getDomainAxis().setTickMarkInsideLength(4);
    sigmaProfilePlot.getDomainAxis().setTickMarkOutsideLength(0);

    sigmaProfilePlot.getRangeAxis().setAxisLinePaint(Color.BLACK);
    sigmaProfilePlot.getRangeAxis().setTickMarkPaint(Color.BLACK);
    sigmaProfilePlot.getRangeAxis().setTickMarkInsideLength(4);
    sigmaProfilePlot.getRangeAxis().setTickMarkOutsideLength(0);

    add(new ChartPanel(sigmaProfileChart), BorderLayout.CENTER);
}

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

/**
 * Confirm that the constructor initializes all the required fields.
 */// www.j ava2 s.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
    }
}