Example usage for org.jfree.chart.renderer.xy StandardXYItemRenderer setBaseShapesVisible

List of usage examples for org.jfree.chart.renderer.xy StandardXYItemRenderer setBaseShapesVisible

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy StandardXYItemRenderer setBaseShapesVisible.

Prototype

public void setBaseShapesVisible(boolean flag) 

Source Link

Document

Sets the flag that controls whether or not a shape is plotted at each data point.

Usage

From source file:sim.app.sugarscape.util.ResultsGrapher.java

JFreeChart createChart1(XYSeries[] series) {
    JFreeChart chart3 = ChartFactory.createXYLineChart("Results", x_axis_fieldname, y_axis_fieldname, null, //new XYSeriesCollection(series[2]),
            PlotOrientation.VERTICAL, true, true, false);
    //System.out.println("Series count = " +series[0].getItemCount());
    XYPlot plot = chart3.getXYPlot();/*w ww.j a  v  a2  s  .  c  o m*/

    ValueAxis yAxis = plot.getRangeAxis();
    //xAxis.setFixedDimension(100);
    //yAxis.setFixedDimension(1.0);
    //yAxis.setRange(0,1);
    ValueAxis xAxis = plot.getDomainAxis();
    //xAxis.setFixedDimension(50);

    StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, Color.black);
    renderer.setStroke(new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));

    renderer.setItemLabelFont(new Font("Serif", Font.PLAIN, 20));
    renderer.setItemLabelsVisible(true);

    renderer.setSeriesItemLabelsVisible(1, true);
    renderer.setBaseShapesVisible(true);
    //XYLabelGenerator generator = new StandardXYLabelGenerator();

    //"{2}", new DecimalFormat("0.00") );
    //renderer.setLabelGenerator(generator);
    //NumberAxis axis2 = new NumberAxis("Average Agent Vision");
    //renderer.setItemLabelsVisible(true);
    //axis2.setAutoRangeIncludesZero(false);
    //axis2.setRange(0,12);
    //plot.setRangeAxis(1, axis2);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);
    //XYSeriesCollection vision = new XYSeriesCollection(lorenz_agent_vision);
    //plot.setDataset(1, vision);
    //String first_letter = x_param_fieldname.substring(0,1)+"=";
    XYSeriesCollection xys = new XYSeriesCollection();
    for (int a = 0; a < series.length; a++) {
        xys.addSeries(series[a]);
        //xys.
        //xys.getSeriesName(4);
        System.out.println(xys.getSeries(a).getDescription());
    }
    plot.setDataset(0, xys);
    return chart3;

}

From source file:mil.tatrc.physiology.utilities.csv.plots.MultiPlotter.java

protected void formatMultiPlot(PlotJob job, JFreeChart chart, XYSeriesCollection dataSet1,
        XYSeriesCollection dataSet2) {/*from  www  .jav  a  2 s  .  c  om*/
    Color[] blueColors = { Color.blue, Color.cyan, new Color(0, 160, 255), new Color(0, 100, 255),
            new Color(0, 160, 255), new Color(14, 0, 145), new Color(70, 105, 150) };
    Color[] redColors = { Color.red, Color.magenta, new Color(255, 0, 100), new Color(255, 0, 160), Color.pink,
            new Color(145, 0, 0), new Color(132, 58, 58) };
    Color[] variedColors = { Color.red, Color.blue, Color.green, Color.orange, Color.magenta, Color.cyan,
            Color.gray, new Color(255, 165, 0), new Color(42, 183, 136), new Color(87, 158, 186) };
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer1 = (XYLineAndShapeRenderer) plot.getRenderer();
    BasicStroke wideLine = new BasicStroke(2.0f);

    //For Scientific notation
    NumberFormat formatter = new DecimalFormat("0.######E0");

    for (int i = 0; i < plot.getDomainAxisCount(); i++) {
        plot.getDomainAxis(i).setLabelFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
        plot.getDomainAxis(i).setTickLabelFont(new Font("SansSerif", Font.PLAIN, 15));
        plot.getDomainAxis(i).setLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        plot.getDomainAxis(i).setTickLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
    }
    for (int i = 0; i < plot.getRangeAxisCount(); i++) {
        plot.getRangeAxis(i).setLabelFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
        plot.getRangeAxis(i).setTickLabelFont(new Font("SansSerif", Font.PLAIN, 15));
        plot.getRangeAxis(i).setLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        plot.getRangeAxis(i).setTickLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(i);
        rangeAxis.setNumberFormatOverride(formatter);
    }

    //White background outside of plottable area
    chart.setBackgroundPaint(job.bgColor);

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

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

    chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 15));
    chart.getTitle().setFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
    chart.getTitle().setPaint(job.bgColor == Color.red ? Color.white : Color.black);

    //If there is only one Y axis, we just need to color the data series differently
    if (job.Y2headers == null || job.Y2headers.isEmpty()) {
        for (int i = 0, cIndex = 0; i < dataSet1.getSeriesCount(); i++, cIndex++) {
            renderer1.setSeriesStroke(i, wideLine);
            renderer1.setBaseShapesVisible(false);
            if (cIndex > 9)
                cIndex = 0;
            renderer1.setSeriesFillPaint(i, variedColors[cIndex]);
            renderer1.setSeriesPaint(i, variedColors[cIndex]);
        }
    }
    //If there are 2 Y axes, we should color the axes to correspond with the data so it isn't (as) confusing
    else {
        StandardXYItemRenderer renderer2 = new StandardXYItemRenderer();
        plot.setRenderer(1, renderer2);

        for (int i = 0, cIndex = 0; i < dataSet1.getSeriesCount(); i++, cIndex++) {
            renderer1.setSeriesStroke(i, wideLine);
            renderer1.setBaseShapesVisible(false);
            if (cIndex > 6)
                cIndex = 0;
            renderer1.setSeriesFillPaint(i, redColors[cIndex]);
            renderer1.setSeriesPaint(i, redColors[cIndex]);
        }
        for (int i = 0, cIndex = 0; i < dataSet2.getSeriesCount(); i++, cIndex++) {
            renderer2.setSeriesStroke(i, wideLine);
            renderer2.setBaseShapesVisible(false);
            if (cIndex > 6)
                cIndex = 0;
            renderer2.setSeriesFillPaint(i, blueColors[cIndex]);
            renderer2.setSeriesPaint(i, blueColors[cIndex]);
        }
        plot.getRangeAxis(0).setLabelPaint(redColors[0]);
        plot.getRangeAxis(0).setTickLabelPaint(redColors[0]);
        plot.getRangeAxis(1).setLabelPaint(blueColors[0]);
        plot.getRangeAxis(1).setTickLabelPaint(blueColors[0]);
    }
}

From source file:mil.tatrc.physiology.utilities.csv.plots.ConvexHullPlotter.java

protected void formatConvexHullPlot(PlotJob job, JFreeChart chart, XYSeriesCollection dataSet1,
        XYSeriesCollection dataSet2) {//w ww . j a  va 2 s  .co  m
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer1 = (XYLineAndShapeRenderer) plot.getRenderer();
    BasicStroke wideLine = new BasicStroke(2.0f);

    //For Scientific notation
    NumberFormat formatter = new DecimalFormat("0.######E0");

    for (int i = 0; i < plot.getDomainAxisCount(); i++) {
        plot.getDomainAxis(i).setLabelFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
        plot.getDomainAxis(i).setTickLabelFont(new Font("SansSerif", Font.PLAIN, 15));
        plot.getDomainAxis(i).setLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        plot.getDomainAxis(i).setTickLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
    }
    for (int i = 0; i < plot.getRangeAxisCount(); i++) {
        plot.getRangeAxis(i).setLabelFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
        plot.getRangeAxis(i).setTickLabelFont(new Font("SansSerif", Font.PLAIN, 15));
        plot.getRangeAxis(i).setLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        plot.getRangeAxis(i).setTickLabelPaint(job.bgColor == Color.red ? Color.white : Color.black);
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(i);
        rangeAxis.setNumberFormatOverride(formatter);
    }

    //White background outside of plottable area
    chart.setBackgroundPaint(job.bgColor);

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

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

    chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 15));
    chart.getTitle().setFont(new Font("SansSerif", Font.PLAIN, job.fontSize));
    chart.getTitle().setPaint(job.bgColor == Color.red ? Color.white : Color.black);

    //If there is only one Y axis, color all datasets red (so top, bottom, left, and right will be the same)
    if (job.Y2headers == null || job.Y2headers.isEmpty()) {
        for (int i = 0; i < dataSet1.getSeriesCount(); i++) {
            renderer1.setSeriesStroke(i, wideLine);
            renderer1.setBaseShapesVisible(false);
            renderer1.setSeriesFillPaint(i, Color.red);
            renderer1.setSeriesPaint(i, Color.red);
            if (dataSet1.getSeries(i).getKey() != null
                    && dataSet1.getSeries(i).getKey().toString().equalsIgnoreCase("REMOVE"))
                renderer1.setSeriesVisibleInLegend(i, false);
        }
    }
    //If there are 2 Y axes, we should color the axes to correspond with the data so it isn't (as) confusing
    else {
        StandardXYItemRenderer renderer2 = new StandardXYItemRenderer();
        plot.setRenderer(1, renderer2);

        for (int i = 0; i < dataSet1.getSeriesCount(); i++) {
            renderer1.setSeriesStroke(i, wideLine);
            renderer1.setBaseShapesVisible(false);
            renderer1.setSeriesFillPaint(i, Color.red);
            renderer1.setSeriesPaint(i, Color.red);
            if (dataSet1.getSeries(i).getKey() != null
                    && dataSet1.getSeries(i).getKey().toString().equalsIgnoreCase("REMOVE"))
                renderer1.setSeriesVisibleInLegend(i, false);
        }
        for (int i = 0; i < dataSet2.getSeriesCount(); i++) {
            renderer2.setSeriesStroke(i, wideLine);
            renderer2.setBaseShapesVisible(false);
            renderer2.setSeriesFillPaint(i, Color.blue);
            renderer2.setSeriesPaint(i, Color.blue);
            if (dataSet2.getSeries(i).getKey() != null
                    && dataSet2.getSeries(i).getKey().toString().equalsIgnoreCase("REMOVE"))
                renderer2.setSeriesVisibleInLegend(i, false);
        }
        plot.getRangeAxis(0).setLabelPaint(Color.red);
        plot.getRangeAxis(0).setTickLabelPaint(Color.red);
        plot.getRangeAxis(1).setLabelPaint(Color.blue);
        plot.getRangeAxis(1).setTickLabelPaint(Color.blue);
    }
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.reporting.AnnotationReportCanvas.java

private void updateChart() {
    String x_label = "m/z ratio";
    String y_label = (theDocument.isShowRelativeIntensities()) ? "Intensity %" : "Intensity";
    theDataset = new DefaultXYDataset();

    if (theDocument.getPeakData() != null) {
        theChart = org.jfree.chart.ChartFactory.createScatterPlot(null, x_label, y_label, theDataset,
                org.jfree.chart.plot.PlotOrientation.VERTICAL, false, false, false);
        thePlot = (XYPlot) theChart.getPlot();
        thePlot.setRenderer(new StandardXYItemRenderer(StandardXYItemRenderer.LINES));
    } else {/*  w  w  w  .jav a  2 s  .c om*/
        theChart = org.jfree.chart.ChartFactory.createScatterPlot(null, x_label, y_label,
                new XYBarDataset(theDataset, 0.001), org.jfree.chart.plot.PlotOrientation.VERTICAL, false,
                false, false);
        thePlot = (XYPlot) theChart.getPlot();
        thePlot.setRenderer(new XYBarRenderer());
    }

    if (theDocument.isShowRelativeIntensities() && theOptions.SHOW_MAX_INTENSITY) {
        // set second axis
        ValueAxis second_axis = new NumberAxis("");
        thePlot.setRangeAxis(1, second_axis);

        // set dataset
        maxIntensityDataset = new DefaultXYDataset();
        thePlot.setDataset(1, maxIntensityDataset);
        thePlot.mapDatasetToRangeAxis(1, 1);

        // set invisible renderer
        StandardXYItemRenderer r = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES);
        r.setBaseShapesVisible(false);
        thePlot.setRenderer(1, r);
    }

    theChart.setBackgroundPaint(Color.white);
    theChart.setBorderVisible(false);
    thePlot.getRenderer().setPaint(theOptions.SPECTRUM_COLOR);
    thePlot.setOutlinePaint(null);
    thePlot.setDomainGridlinesVisible(false);
    thePlot.setRangeGridlinesVisible(false);
}