Example usage for org.jfree.chart.axis ValueAxis setUpperBound

List of usage examples for org.jfree.chart.axis ValueAxis setUpperBound

Introduction

In this page you can find the example usage for org.jfree.chart.axis ValueAxis setUpperBound.

Prototype

public void setUpperBound(double max) 

Source Link

Document

Sets the upper bound for the axis range, and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:org.codehaus.mojo.chronos.chart.ChartUtil.java

public static XYPlot setUpperBound(JFreeChart chart, double max) {
    XYPlot plot = chart.getXYPlot();//w  w  w. jav  a2  s  . co m

    ValueAxis axis = (ValueAxis) plot.getDomainAxis();
    axis.setUpperBound(max);
    return plot;
}

From source file:net.commerce.zocalo.freechart.ChartGenerator.java

private static ValueAxis setBoundsForPercent(JFreeChart chart) {
    ValueAxis rangeAxis = setLowerBoundsZero(chart);
    rangeAxis.setUpperBound(100);
    return rangeAxis;
}

From source file:net.commerce.zocalo.freechart.ChartGenerator.java

private static ValueAxis setBoundsForPrice(JFreeChart chart) {
    ValueAxis rangeAxis = setLowerBoundsZero(chart);
    rangeAxis.setUpperBound(1);
    return rangeAxis;
}

From source file:com.orange.atk.results.logger.documentGenerator.GraphGenerator.java

/**
 * This function creates the measurement graph by using the JFreeChart
 * library. The X axis of the graph is in minutes.
 * // w  w  w  . j a v a2 s .  c  om
 * @param plotList
 *            plotlist to save. Xvalues must be stored in milliseconds.
 * @param associatedName
 *            Name of the list
 * @param folderWhereResultsAreSaved
 *            folder where results are saved
 * @param yLabel
 *            Name of the y label
 * @param pictureFile
 *            name of the file
 * @param yDivisor
 *            use to divide measurements stored in the plotlist by yDivisor
 */
public static void generateGraphWithJFreeChart(PlotList plotList, String associatedName,
        String folderWhereResultsAreSaved, String yLabel, String pictureFile, float yDivisor) {

    // Create a new XYSeries
    // XYSeries are used to represent couples of (x,y) values.
    XYSeries data = new XYSeries(associatedName);

    int size = plotList.getSize();
    if (size == 0) {
        // no element in graphics, exit
        //Logger.getLogger(this.getClass() ).warn("Nothing in graph");
        return;
    }

    // Find the initial value of the time
    // Due to the fact that getX(i) <= getX(i+1),
    // min({0<=i<size / getX(i)}) = getX(0)
    long initialValue = plotList.getX(0);

    XYSeriesCollection series = new XYSeriesCollection(data);
    if (!plotList.getunit().equals(""))
        yLabel += " (" + plotList.getunit() + ")";
    // Create a new XY graph.
    //JFreeChart chart = ChartFactory.createXYLineChart("", "Time", yLabel, series, PlotOrientation.VERTICAL, true, true, false);
    JFreeChart chart = ChartFactory.createTimeSeriesChart("", "Time (min:sec)", yLabel, series, true, true,
            false);
    // Set the graph format
    XYPlot plot = chart.getXYPlot();
    plot.setOrientation(PlotOrientation.VERTICAL);
    DateAxis axis = (DateAxis) plot.getDomainAxis();
    //axis.setTickUnit(new DateTickUnit(DateTickUnit.SECOND, 10));
    RelativeDateFormat rdf = new RelativeDateFormat(initialValue);
    rdf.setSecondFormatter(new DecimalFormat("00"));
    axis.setDateFormatOverride(rdf);

    // Fill the JFreeChart object which will be used to create the Graph
    for (int i = 0; i < size; i++) {
        // xvalue must be in
        double xval = ((Long) plotList.getX(i)).doubleValue();
        float yval = plotList.getY(i).floatValue() / yDivisor;
        // Logger.getLogger(this.getClass() ).debug(associatedName + " [" + (((Long)
        // plotList.getX(i)).floatValue() - initialValue)
        // / XDIVISOR +"] "+ yval);
        data.add(xval, yval);
    }

    ValueAxis rangeAxis = plot.getRangeAxis();
    Long min = plotList.getMin();
    Long max = plotList.getMax();
    double diff = (max - min) * 0.02;
    if (diff == 0)
        diff = max * 0.0001;

    rangeAxis.setLowerBound((min - diff) / yDivisor);
    rangeAxis.setUpperBound((max + diff) / yDivisor);
    //      Logger.getLogger(this.getClass() ).debug("(" + (min / yDivisor) * 0.98 + " - "
    //            + (min / yDivisor) * 0.98 + ")");
    //      Logger.getLogger(this.getClass() ).debug("Bound = " + rangeAxis.getLowerBound() + " - "
    //            + rangeAxis.getUpperBound());
    //      Logger.getLogger(this.getClass() ).debug("Margin = " + rangeAxis.getLowerMargin() + " - "
    //            + rangeAxis.getUpperMargin());
    //      Logger.getLogger(this.getClass() ).debug("NB AXIS = " + plot.getRangeAxisCount());

    // save the chart in a picture file.
    BufferedImage bufImage = chart.createBufferedImage(640, 480);
    File fichier = new File(pictureFile);
    try {
        if (!ImageIO.write(bufImage, "png", fichier)) {
            return;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:net.commerce.zocalo.freechart.ChartGenerator.java

private static ValueAxis setBoundsLoosely(JFreeChart chart) {
    ValueAxis rangeAxis = setLowerBoundsZero(chart);
    double highY = rangeAxis.getRange().getUpperBound();
    double top = Math.min((Math.ceil(highY / 10) + 1) * 10, 100);
    rangeAxis.setUpperBound(top);
    return rangeAxis;
}

From source file:ch.zhaw.ias.dito.ui.util.BlockPlotPanel.java

public BlockPlotPanel(Matrix m, double lowerBound, double upperBound) {
    super(new BorderLayout());
    NumberAxis xAxis = new NumberAxis();
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xAxis.setLowerMargin(1.0);/*from ww w. j av  a 2  s . c  o m*/
    xAxis.setUpperMargin(0.0);
    NumberAxis yAxis = new NumberAxis();
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setLowerMargin(1.0);
    yAxis.setUpperMargin(0.0);
    XYBlockRenderer renderer = new XYBlockRenderer();
    renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
        @Override
        public String generateToolTip(XYDataset dataset, int series, int item) {
            XYZDataset xyzDataset = (XYZDataset) dataset;
            double x = xyzDataset.getXValue(series, item);
            double y = xyzDataset.getYValue(series, item);
            double z = xyzDataset.getZValue(series, item);
            return ("X=" + x + ", Y=" + y + ", Z=" + z);
        }
    });
    PaintScale scale = new ColorPaintScale(lowerBound, upperBound);
    renderer.setPaintScale(scale);
    ValueAxis axis = new NumberAxis();
    axis.setLowerBound(scale.getLowerBound());
    axis.setUpperBound(scale.getUpperBound());
    PaintScaleLegend legend = new PaintScaleLegend(scale, axis);
    legend.setMargin(new RectangleInsets(10, 10, 10, 10));
    legend.setPosition(RectangleEdge.RIGHT);

    MatrixXYDataset dataset = new MatrixXYDataset(m);
    plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    chart = new JFreeChart(plot);
    chart.removeLegend();
    chart.addSubtitle(legend);
    chart.setBackgroundPaint(Color.white);

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setDisplayToolTips(true);
    this.add(chartPanel, BorderLayout.CENTER);
}

From source file:playground.dgrether.signalsystems.utils.DgSignalPlanChart.java

public JFreeChart createSignalPlanChart(String title, String xAxisTitle, String yAxisTitle) {
    JFreeChart chart = ChartFactory.createStackedBarChart(title, xAxisTitle, yAxisTitle, this.dataset,
            PlotOrientation.HORIZONTAL, false, false, false);
    DgDefaultAxisBuilder axis = new DgDefaultAxisBuilder();
    CategoryPlot plot = chart.getCategoryPlot();

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.black);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    CategoryAxis xAxis = axis.createCategoryAxis(xAxisTitle);
    plot.setDomainAxis(xAxis);//ww  w  .  j a va 2 s.c  om
    ValueAxis yAxis = axis.createValueAxis(yAxisTitle);
    yAxis.setUpperBound(this.tMax);
    yAxis.setLowerBound(this.tMin);
    plot.setRangeAxis(yAxis);

    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.findRangeBounds(dataset);
    renderer.setShadowVisible(false);
    //      renderer.setItemMargin(10.005);
    renderer.setMaximumBarWidth(0.2);
    for (Entry<Integer, Color> ee : seriesColor.entrySet()) {
        renderer.setSeriesPaint(ee.getKey(), ee.getValue());
        //         renderer.setSeriesStroke(ee.getKey(), new BasicStroke(50));
    }
    plot.setRenderer(renderer);
    //      chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    //      chart.setBackgroundPaint(ChartColor.WHITE);
    //      chart.removeLegend();
    return chart;
}

From source file:com.xilinx.ultrascale.gui.DMABarChart.java

private void makeChart() {
    dataset = new DefaultCategoryDataset();
    chart = ChartFactory.createBarChart("", "Time Interval", "Throughput (Gbps)", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(bg);/*  w ww. j  a v a  2  s  .  co m*/
    TextTitle ttitle = new TextTitle(title, new Font(title, Font.BOLD, 15));
    ttitle.setPaint(Color.WHITE);
    chart.setTitle(ttitle);

    CategoryPlot plot = chart.getCategoryPlot();
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    ValueAxis axis = plot.getRangeAxis();
    axis.setUpperBound(64.0);
    axis.setLowerBound(0.0);
    axis.setTickLabelPaint(new Color(185, 185, 185));
    axis.setLabelPaint(new Color(185, 185, 185));

    CategoryAxis caxis = plot.getDomainAxis();
    caxis.setTickLabelPaint(new Color(185, 185, 185));
    caxis.setLabelPaint(new Color(185, 185, 185));

    renderer.setItemMargin(0);
    renderer.setSeriesPaint(0, new Color(0x2e, 0x90, 0x18));//(0x17, 0x7b, 0x7c));
    renderer.setSeriesPaint(1, new Color(0x12, 0x45, 0x73));//(0xa2, 0x45, 0x73)
    renderer.setSeriesPaint(3, new Color(0xff, 0x80, 0x40));
    renderer.setSeriesPaint(2, new Color(0x6f, 0x2c, 0x85));
    renderer.setSeriesPaint(4, new Color(0xa1, 0x60, 0x98));
    renderer.setBaseToolTipGenerator(
            new StandardCategoryToolTipGenerator("{0}:{2}", new DecimalFormat("0.000")));
    //renderer.setMaximumBarWidth(0.05);
    //        addDummy();
}

From source file:com.xilinx.kintex7.DMABarChart.java

private void makeChart() {
    dataset = new DefaultCategoryDataset();
    chart = ChartFactory.createBarChart("", "Time Interval", "Throughput (Gbps)", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(bg);/*from ww w. jav  a 2 s  . c  o m*/
    TextTitle ttitle = new TextTitle(title, new Font(title, Font.BOLD, 15));
    ttitle.setPaint(Color.WHITE);
    chart.setTitle(ttitle);

    CategoryPlot plot = chart.getCategoryPlot();
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    ValueAxis axis = plot.getRangeAxis();
    axis.setUpperBound(30.0);
    axis.setLowerBound(0.0);
    axis.setTickLabelPaint(new Color(185, 185, 185));
    axis.setLabelPaint(new Color(185, 185, 185));

    CategoryAxis caxis = plot.getDomainAxis();
    caxis.setTickLabelPaint(new Color(185, 185, 185));
    caxis.setLabelPaint(new Color(185, 185, 185));

    renderer.setItemMargin(0);
    renderer.setSeriesPaint(0, new Color(0, 0, 0x80));
    renderer.setSeriesPaint(1, new Color(0, 0x80, 0xff));
    renderer.setSeriesPaint(2, new Color(0xa2, 0x45, 0x73));
    renderer.setBaseToolTipGenerator(
            new StandardCategoryToolTipGenerator("{0}:{2}", new DecimalFormat("0.000")));
    //renderer.setMaximumBarWidth(0.05);
    addDummy();
}

From source file:com.xilinx.ultrascale.gui.BarChartsEth.java

License:asdf

public void upperBounds(int topVal) {
    CategoryPlot plot = chart.getCategoryPlot();
    //        BarRenderer renderer = (BarRenderer)plot.getRenderer();
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);/* www.j  av a2 s. co  m*/
    ValueAxis axis = plot.getRangeAxis();
    axis.setUpperBound(topVal);
    axis.setLowerBound(0.0);
    //        axis.setAutoRangeMinimumSize(1.0);
    //        axis.setAutoRange(true);
    ////        axis.setLowerMargin(0);
    //        axis.setLowerMargin(0);
    //        axis.setUpperMargin(0.40);
    //        axis.setAutoRangeMinimumSize(1.0);
    //        axis.setDefaultAutoRange(new Range(0, 1000));
}