Example usage for org.jfree.data.general ValueDataset getValue

List of usage examples for org.jfree.data.general ValueDataset getValue

Introduction

In this page you can find the example usage for org.jfree.data.general ValueDataset getValue.

Prototype

public Number getValue();

Source Link

Document

Returns the value.

Usage

From source file:org.jfree.data.general.DefaultValueDataset.java

/**
 * Tests this dataset for equality with an arbitrary object.
 *
 * @param obj  the object (<code>null</code> permitted).
 *
 * @return A boolean./*from  w  w  w . jav a  2s  . c om*/
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (obj instanceof ValueDataset) {
        ValueDataset vd = (ValueDataset) obj;
        return ObjectUtils.equal(this.value, vd.getValue());
    }
    return false;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.BulletGraph.java

public JFreeChart createChart(DatasetMap datasets) {

    logger.debug("IN");
    Dataset dataset = (Dataset) datasets.getDatasets().get("1");
    ValueDataset valDataSet = (ValueDataset) dataset;

    Number value = valDataSet.getValue();

    DefaultCategoryDataset datasetC = new DefaultCategoryDataset();
    datasetC.addValue(value, "", "");

    // customize a bar chart 
    JFreeChart chart = ChartFactory.createBarChart(null, null, null, datasetC, PlotOrientation.HORIZONTAL,
            false, false, false);/*from   ww w  . j  a  v  a  2s .co m*/
    chart.setBorderVisible(false);

    chart.setBackgroundPaint(color);

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setOutlineVisible(true);
    plot.setOutlinePaint(Color.BLACK);
    plot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    plot.setBackgroundPaint(null);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setAnchorValue(value.doubleValue());

    // add the target marker 
    if (target != null) {
        ValueMarker marker = new ValueMarker(target.doubleValue(), Color.BLACK, new BasicStroke(2.0f));
        plot.addRangeMarker(marker, Layer.FOREGROUND);
    }

    //sets different marks
    for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
        KpiInterval interval = (KpiInterval) iterator.next();
        // add the marks 
        IntervalMarker marker = new IntervalMarker(interval.getMin(), interval.getMax(), interval.getColor());
        plot.addRangeMarker(marker, Layer.BACKGROUND);
        logger.debug("Added new interval to the plot");
    }

    // customize axes 
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setVisible(false);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setVisible(true);
    // calculate the upper limit 
    //double upperBound = target * upperFactor; 
    rangeAxis.setRange(new Range(lower, upper));
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    // customize renderer 
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setMaximumBarWidth(0.18);
    renderer.setSeriesPaint(0, Color.BLACK);

    return chart;
}

From source file:org.jfree.experimental.chart.plot.dial.DialPlot.java

/**
 * Returns the value from the specified dataset.
 * //from   w w  w .j  a v  a  2  s  . co m
 * @param datasetIndex  the dataset index.
 * 
 * @return The data value.
 */
public double getValue(int datasetIndex) {
    double result = Double.NaN;
    ValueDataset dataset = getDataset(datasetIndex);
    if (dataset != null) {
        Number n = dataset.getValue();
        if (n != null) {
            result = n.doubleValue();
        }
    }
    return result;
}