Example usage for org.jfree.chart.plot XYPlot getRangeAxis

List of usage examples for org.jfree.chart.plot XYPlot getRangeAxis

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot getRangeAxis.

Prototype

public ValueAxis getRangeAxis() 

Source Link

Document

Returns the range axis for the plot.

Usage

From source file:eu.stratosphere.addons.visualization.swt.SWTVertexToolTip.java

private ChartComposite createThreadChart(VertexVisualizationData visualizationData, Color backgroundColor) {

    final JFreeChart chart = ChartFactory.createStackedXYAreaChart(null, "Time [sec.]",
            "Thread Utilization [%]", visualizationData.getThreadDataSet(), PlotOrientation.VERTICAL, true,
            true, false);//w w  w.  j av  a2  s .  com

    chart.setBackgroundPaint(new java.awt.Color(backgroundColor.getRed(), backgroundColor.getGreen(),
            backgroundColor.getBlue()));

    // Set axis properly
    final XYPlot xyPlot = chart.getXYPlot();
    xyPlot.getDomainAxis().setAutoRange(true);
    xyPlot.getDomainAxis().setAutoRangeMinimumSize(60);

    // xyPlot.getRangeAxis().setAutoRange(true);
    xyPlot.getRangeAxis().setRange(0, 100);

    return new ChartComposite(getShell(), SWT.NONE, chart, true);
}

From source file:com.github.dougkelly88.FLIMPlateReaderGUI.FLIMClasses.Classes.FindMaxpoint.java

/**
 * Creates a chart./*from  www.ja v a 2  s . c o  m*/
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
public JFreeChart createChart() {

    //http://www.java2s.com/Code/Java/Chart/JFreeChartDualAxisDemo2.htm
    String xlabel = "Delay (ps)";
    String ylabel = "Signal (DN)";

    // create the chart with findmaxpoint results
    final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
            xlabel, // x axis label
            ylabel, // y axis label
            findMaxpointData_, // data
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            false // urls
    );

    final XYPlot plot = chart.getXYPlot();
    // deal with axes and add second dataset
    final NumberAxis yaxis1 = (NumberAxis) plot.getRangeAxis();
    yaxis1.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10));
    yaxis1.setLabelFont(new Font("Dialog", Font.PLAIN, 10));
    final NumberAxis yaxis2 = new NumberAxis(null);
    final NumberAxis xaxis = (NumberAxis) plot.getDomainAxis();
    xaxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 10));
    xaxis.setLabelFont(new Font("Dialog", Font.PLAIN, 10));
    plot.setRangeAxis(1, yaxis2);
    plot.setDataset(1, gatePositionData_);
    plot.mapDatasetToRangeAxis(1, 1);
    yaxis1.setRange(0, 5000);
    yaxis2.setRange(-1, 1);
    yaxis2.setTickLabelsVisible(false);
    xaxis.setRange(0, 16666);

    // deal with visuals

    final XYLineAndShapeRenderer renderer1 = new XYLineAndShapeRenderer(true, true);
    renderer1.setSeriesPaint(0, Color.RED);
    renderer1.setSeriesStroke(0, new BasicStroke(3));

    //        renderer1.setBaseShapesVisible(true);
    //        renderer1.setSeriesShape(0, ShapeUtilities.createDiagonalCross(4,1));

    plot.setRenderer(0, renderer1);

    //        final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer();
    final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(false, true);
    renderer2.setSeriesPaint(0, Color.CYAN);
    renderer2.setSeriesShapesFilled(0, Boolean.TRUE);
    renderer2.setBaseShapesVisible(true);
    renderer2.setShape(new Rectangle(-2, -100, 4, 200));
    renderer2.setOutlineStroke(new BasicStroke(1));
    renderer2.setOutlinePaint(Color.GRAY);
    renderer2.setUseOutlinePaint(true);
    plot.setRenderer(1, renderer2);

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    //                
    return chart;

}

From source file:gui.DendrogramChart.java

ChartPanel getChartPanel(Dendrogram d, boolean log) {
    JFreeChart chart = ChartFactory.createXYLineChart(null, "Similarity", "No. of Groups", null,
            PlotOrientation.VERTICAL, true, true, false);

    setChartData(chart, log);//from  ww  w .j av a2s. co m

    RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    chart.setRenderingHints(rh);
    chart.removeLegend();

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(new Color(255, 255, 220));
    plot.setDomainGridlinePaint(new Color(128, 128, 128));
    plot.setRangeGridlinePaint(new Color(128, 128, 128));
    if (log == false) {
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        rangeAxis.setLowerBound(0);
        rangeAxis.setNumberFormatOverride(new DecimalFormat("0"));
        rangeAxis.setLabelFont(Prefs.labelFont);
    } else {
        // LogarithmicAxis logXAxis = new LogarithmicAxis("Similarity");
        // logXAxis.setAllowNegativesFlag(true);
        LogarithmicAxis logYAxis = new LogarithmicAxis("No. Of Groups");
        logYAxis.setAllowNegativesFlag(false);

        // plot.setDomainAxis(logXAxis);
        plot.setRangeAxis(logYAxis);
    }

    ChartPanel chartPanel = new ChartPanel(chart);
    // chartPanel.setPopupMenu(null);
    return chartPanel;
}

From source file:mil.tatrc.physiology.biogears.verification.ScenarioPlotTool.java

public void formatXYPlot(JFreeChart chart, Paint bgColor) {
    XYPlot plot = (XYPlot) chart.getPlot();

    //For Scientific notation
    NumberFormat formatter = new DecimalFormat("0.######E0");
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setNumberFormatOverride(formatter);

    //White background outside of plottable area
    chart.setBackgroundPaint(bgColor);/*from  ww w . j  a  v a2 s  .com*/

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

    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    //Changing font sizes so they are readable. 
    plot.getDomainAxis().setLabelFont(largeFont);
    plot.getRangeAxis().setLabelFont(largeFont);
    plot.getDomainAxis().setTickLabelFont(smallFont);
    plot.getRangeAxis().setTickLabelFont(smallFont);

    plot.getDomainAxis().setLabelPaint(bgColor == Color.red ? Color.white : Color.black);
    plot.getRangeAxis().setLabelPaint(bgColor == Color.red ? Color.white : Color.black);
    plot.getDomainAxis().setTickLabelPaint(bgColor == Color.red ? Color.white : Color.black);
    plot.getRangeAxis().setTickLabelPaint(bgColor == Color.red ? Color.white : Color.black);

    chart.getLegend().setItemFont(smallFont);
    chart.getTitle().setFont(largeFont);
    chart.getTitle().setPaint(bgColor == Color.red ? Color.white : Color.black);
}

From source file:de.suse.swamp.modules.scheduledjobs.Statistics.java

/**
 * Generating the graphs that show the amount of running finished wfs over the time.
 *///  w w  w .  j  ava 2  s .co m
protected void generateWorkflowGraph(String templateName, Date startDate, Date endDate) throws Exception {
    List stats = StatisticStorage.loadStats(templateName, startDate, endDate);
    // only generate if we have stats: 
    if (stats != null && stats.size() > 0) {
        TimeSeriesCollection dataset = new TimeSeriesCollection();
        TimeSeriesCollection avgdataset = new TimeSeriesCollection();
        TimeSeries serie = new TimeSeries("running workflows", Day.class);
        TimeSeries avgserie = new TimeSeries("average age", Day.class);
        for (Iterator datait = stats.iterator(); datait.hasNext();) {
            Dbstatistics statisticItem = (Dbstatistics) datait.next();
            serie.addOrUpdate(new Day(statisticItem.getDate()), statisticItem.getRunningcount());
            avgserie.addOrUpdate(new Day(statisticItem.getDate()), statisticItem.getAvgage() / (3600 * 24));
        }
        dataset.addSeries(serie);
        avgdataset.addSeries(avgserie);

        JFreeChart chart = ChartFactory.createTimeSeriesChart("Running " + templateName + " workflows", "Date",
                "running workflows", dataset, false, false, false);

        // modify chart appearance
        chart.setBackgroundImageAlpha(0.5f);
        XYPlot plot = chart.getXYPlot();
        plot.setBackgroundPaint(Color.lightGray);
        plot.setDomainGridlinePaint(Color.white);
        plot.setRangeGridlinePaint(Color.white);
        plot.getRangeAxis().setLabelPaint(Color.blue);

        // add the second line: 
        final NumberAxis axis2 = new NumberAxis("Avg. age in days");
        axis2.setLabelPaint(Color.red);
        plot.setRangeAxis(1, axis2);
        plot.setDataset(1, avgdataset);
        plot.mapDatasetToRangeAxis(1, 1);

        final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
        renderer2.setDrawOutlines(false);
        renderer2.setDrawSeriesLineAsPath(true);
        renderer2.setBaseShapesVisible(false);
        plot.setRenderer(1, renderer2);

        File image = new File(statPath + fs + templateName + ".png");
        if (image.exists())
            image.delete();
        try {
            ChartUtilities.saveChartAsPNG(image, chart, 750, 200);
        } catch (Exception e) {
            Logger.ERROR("Error generating graph for " + templateName + ", e: " + e.getMessage());
            e.printStackTrace();
            throw e;
        }
    }
}

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

public static JFreeChart createHistogramChart(String xAxisLabel, String yAxisLabel, IntervalXYDataset dataset) {
    JFreeChart jfreechart = ChartFactory.createHistogram(null, xAxisLabel, yAxisLabel, dataset,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setBackgroundPaint(null);//w ww  . j  a  v a  2s  .c om
    xyplot.setOutlinePaint(null);
    xyplot.setRangeGridlinePaint(UIConstants.INTEL_DARK_GRAY);
    NumberAxis yAxis = (NumberAxis) xyplot.getRangeAxis();
    yAxis.setRangeType(RangeType.POSITIVE);
    yAxis.setLabelFont(UIConstants.H5_FONT);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xyplot.getDomainAxis().setLabelFont(UIConstants.H5_FONT);
    xyplot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBarRenderer renderer = (XYBarRenderer) xyplot.getRenderer();
    renderer.setShadowVisible(false);
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelFont(UIConstants.H5_FONT);
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setSeriesPaint(0, UIConstants.INTEL_BLUE);
    return jfreechart;
}

From source file:gov.sandia.umf.platform.ui.jobs.Plot.java

public JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
            null, // x axis label
            null, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );/*from w  ww  .ja v a2 s. c  om*/

    chart.setBackgroundPaint(Color.white);

    LegendTitle legend = chart.getLegend();
    legend.setVisible(dataset.getSeriesCount() <= 5);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    ValueAxis axis = plot.getRangeAxis();
    if (axis instanceof NumberAxis)
        ((NumberAxis) axis).setAutoRangeIncludesZero(false);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    for (int i = 0; i < dataset.getSeriesCount(); i++)
        renderer.setSeriesShapesVisible(i, false);
    plot.setRenderer(renderer);

    return chart;
}

From source file:cgpanalyser.gui.chart.ChartCreator.java

private void setBothAxisProperties(XYPlot plot, XYDataset dataset) {
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); //set x axis tick
    xAxis.setVerticalTickLabels(true); //set x axis text rotation
    //xAxis.setTickUnit(new NumberTickUnit(100));
    //xAxis.setLowerBound(1); 
    //xAxis.setUpperBound(1000);

    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    //yAxis.setTickUnit(new NumberTickUnit(100));
}

From source file:visualizer.datamining.dataanalysis.NeighborhoodPreservation.java

private JFreeChart createChart(XYDataset xydataset) {
    JFreeChart chart = ChartFactory.createXYLineChart("Neighborhood Preservation", "Number Neighbors",
            "Precision", xydataset, PlotOrientation.VERTICAL, true, true, false);

    chart.setBackgroundPaint(Color.WHITE);

    XYPlot xyplot = (XYPlot) chart.getPlot();
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);

    xyplot.setDomainGridlinePaint(Color.BLACK);
    xyplot.setRangeGridlinePaint(Color.BLACK);

    xyplot.setOutlinePaint(Color.BLACK);
    xyplot.setOutlineStroke(new BasicStroke(1.0f));
    xyplot.setBackgroundPaint(Color.white);
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);

    xyplot.setDrawingSupplier(new DefaultDrawingSupplier(
            new Paint[] { Color.RED, Color.BLUE, Color.GREEN, Color.MAGENTA, Color.CYAN, Color.ORANGE,
                    Color.BLACK, Color.DARK_GRAY, Color.GRAY, Color.LIGHT_GRAY, Color.YELLOW },
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));

    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setBaseShapesFilled(true);
    xylineandshaperenderer.setDrawOutlines(true);

    return chart;
}

From source file:eu.stratosphere.addons.visualization.swt.SWTJobTabItem.java

private ChartComposite initializeNetworkChart(Composite parentComposite, TableXYDataset dataset) {

    final JFreeChart chart = ChartFactory.createStackedXYAreaChart("Network", "Time [sec.]",
            "Average throughput [MBit/s]", dataset, PlotOrientation.VERTICAL, true, true, false);

    // Set axis properly
    final XYPlot xyPlot = chart.getXYPlot();
    xyPlot.getDomainAxis().setAutoRange(true);
    xyPlot.getDomainAxis().setAutoRangeMinimumSize(60);

    // TODO: Repair auto range for range axis
    xyPlot.getRangeAxis().setAutoRange(false);
    xyPlot.getRangeAxis().setRange(0, 4096);

    return new ChartComposite(parentComposite, SWT.NONE, chart, true);
}