Example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setSeriesShape

List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setSeriesShape

Introduction

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

Prototype

public void setSeriesShape(int series, Shape shape) 

Source Link

Document

Sets the shape used for a series and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:org.gwaspi.reports.GenericReportGenerator.java

private static void appendToCombinedRangeManhattanPlot(CombinedRangeXYPlot combinedPlot, String chromosome,
        XYSeriesCollection currChrSC, boolean showlables, double threshold, Color background,
        Color backgroundAlternative, Color main) {

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);

    // Set dot shape of the currently appended Series
    renderer.setSeriesPaint(currChrSC.getSeriesCount() - 1, main);
    renderer.setSeriesVisibleInLegend(currChrSC.getSeriesCount() - 1, showlables);
    renderer.setSeriesShape(currChrSC.getSeriesCount() - 1, new Rectangle2D.Double(-1.0, -1.0, 2.0, 2.0));

    // Set range axis
    if (combinedPlot.getSubplots().isEmpty()) {
        LogAxis rangeAxis = new LogAxis("P value");
        rangeAxis.setBase(10);/* www  .j av  a  2 s  .  co  m*/
        rangeAxis.setInverted(true);
        rangeAxis.setNumberFormatOverride(FORMAT_P_VALUE);

        rangeAxis.setTickMarkOutsideLength(2.0f);
        rangeAxis.setMinorTickCount(2);
        rangeAxis.setMinorTickMarksVisible(true);
        rangeAxis.setAxisLineVisible(true);
        rangeAxis.setUpperMargin(0);

        TickUnitSource units = NumberAxis.createIntegerTickUnits();
        rangeAxis.setStandardTickUnits(units);

        combinedPlot.setRangeAxis(0, rangeAxis);
    }

    // Build subchart
    JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", currChrSC,
            PlotOrientation.VERTICAL, false, false, false);

    // Get subplot from subchart
    XYPlot subplot = (XYPlot) subchart.getPlot();
    subplot.setRenderer(renderer);
    subplot.setBackgroundPaint(null);

    // CHART BACKGROUD COLOR
    if (combinedPlot.getSubplots().size() % 2 == 0) {
        subplot.setBackgroundPaint(background); // Hue, saturation, brightness
    } else {
        subplot.setBackgroundPaint(backgroundAlternative); // Hue, saturation, brightness
    }

    // Add significance Threshold to subplot
    final Marker thresholdLine = new ValueMarker(threshold);
    thresholdLine.setPaint(Color.red);
    // Add legend to hetzyThreshold
    if (showlables) {
        thresholdLine.setLabel("P = " + FORMAT_P_VALUE.format(threshold));
    }
    thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    subplot.addRangeMarker(thresholdLine);

    // Chromosome Axis Labels
    NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis();
    chrAxis.setLabelAngle(1.0);
    chrAxis.setAutoRangeIncludesZero(false);
    chrAxis.setAxisLineVisible(true);

    chrAxis.setTickLabelsVisible(false);
    chrAxis.setTickMarksVisible(false);
    //      chrAxis.setNumberFormatOverride(Report_Analysis.FORMAT_SCIENTIFIC);
    //      TickUnitSource units = NumberAxis.createIntegerTickUnits();
    //      chrAxis.setStandardTickUnits(units);

    //combinedPlot.setGap(0);
    combinedPlot.add(subplot, 1);
}

From source file:lifnetwork.ChartSave.java

public ChartSave() {
    super(ChartFactory.createScatterPlot("Population Fire", "Time (s)", "Neuron #", (new XYSeriesCollection()),
            PlotOrientation.VERTICAL, false, false, false));
    fireChart = this.getChart();
    fireChart.setNotify(false);//  w  w  w .j av a  2  s .c om
    XYPlot plot = fireChart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesShape(0, new Rectangle2D.Double(0, 0, 1, 1));
    fireCollection = (XYSeriesCollection) plot.getDataset();
    fireSeries = new XYSeries("fires");
    fireCollection.addSeries(fireSeries);
}

From source file:org.gwaspi.reports.GenericReportGenerator.java

public static XYPlot buildQQPlot(OperationKey testOpKey, int df) throws IOException {

    if (df != 1 && df != 2) {
        throw new IllegalArgumentException("Only df = 1 or 2 is supported; it is " + df);
    }/*from ww  w  .ja  v a  2 s. c o m*/

    //<editor-fold defaultstate="expanded" desc="PLOT DEFAULTS">
    final Config config = Config.getSingleton();
    final Color background = config.getColor(PLOT_QQ_BACKGROUND_CONFIG, PLOT_QQ_BACKGROUND_DEFAULT);
    final Color actual = config.getColor(PLOT_QQ_ACTUAL_CONFIG, PLOT_QQ_ACTUAL_DEFAULT);
    final Color sigma = config.getColor(PLOT_QQ_SIGMA_CONFIG, PLOT_QQ_SIGMA_DEFAULT);
    final Color mu = config.getColor(PLOT_QQ_MU_CONFIG, PLOT_QQ_MU_DEFAULT);
    //</editor-fold>

    //<editor-fold defaultstate="expanded" desc="GET X^2">
    List<Double> obsChiSqrVals = assembleQQPlotData(testOpKey);

    int N = obsChiSqrVals.size();
    List<Double> expChiSqrDist;
    if (df == 1) {
        expChiSqrDist = Chisquare.getChiSquareDistributionDf1(N, 1.0f);
    } else { // df == 2
        expChiSqrDist = Chisquare.getChiSquareDistributionDf2(N, 1.0f);
    }
    Collections.sort(expChiSqrDist);
    //</editor-fold>

    //<editor-fold defaultstate="expanded" desc="GET CONFIDENCE BOUNDARY">
    InputStream boundaryStream = GenericReportGenerator.class
            .getResourceAsStream("/samples/chisqrboundary-df" + df + ".txt");
    InputStreamReader isr = new InputStreamReader(boundaryStream);
    BufferedReader inputBufferReader = new BufferedReader(isr);

    Double stopValue = expChiSqrDist.get(N - 1);
    Double currentValue = 0d;
    List<Double[]> boundary = new ArrayList<Double[]>();
    while (currentValue <= stopValue) {
        String l = inputBufferReader.readLine();
        if (l == null) {
            break;
        }
        String[] cVals = l.split(",");
        Double[] slice = new Double[3];
        slice[0] = Double.parseDouble(cVals[0]);
        slice[1] = Double.parseDouble(cVals[1]);
        slice[2] = Double.parseDouble(cVals[2]);
        currentValue = slice[1];
        boundary.add(slice);
    }
    inputBufferReader.close();
    //</editor-fold>

    XYSeriesCollection dataSeries = new XYSeriesCollection();
    XYSeries seriesData = new XYSeries("X");
    XYSeries seriesRef = new XYSeries("Expected");

    for (int i = 0; i < obsChiSqrVals.size(); i++) {
        double obsVal = obsChiSqrVals.get(i);
        double expVal = expChiSqrDist.get(i);

        seriesData.add(expVal, obsVal);
        seriesRef.add(expVal, expVal);
    }

    //constant chi-square boundaries
    XYSeries seriesLower = new XYSeries("2 boundary");
    XYSeries seriesUpper = new XYSeries("");
    for (Double[] slice : boundary) {
        seriesUpper.add(slice[1], slice[0]);
        seriesLower.add(slice[1], slice[2]);
    }

    dataSeries.addSeries(seriesData);
    dataSeries.addSeries(seriesRef);
    dataSeries.addSeries(seriesUpper);
    dataSeries.addSeries(seriesLower);
    final XYDataset data = dataSeries;

    //create QQ plot
    final boolean withLegend = true;
    JFreeChart chart = ChartFactory.createScatterPlot("QQ-plot", "Exp X", "Obs X", data,
            PlotOrientation.VERTICAL, withLegend, false, false);

    final XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);
    renderer.setSeriesPaint(0, actual);
    renderer.setSeriesPaint(1, mu);
    renderer.setSeriesPaint(2, sigma);
    renderer.setSeriesPaint(3, sigma);

    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setSeriesShape(0, new Rectangle2D.Double(-1.0, -1.0, 2.0, 2.0));
    renderer.setSeriesShape(1, new Rectangle2D.Double(-1.0, -1.0, 2.0, 2.0));
    renderer.setSeriesShape(2, new Rectangle2D.Double(-1.0, -1.0, 2.0, 2.0));
    renderer.setSeriesShape(3, new Rectangle2D.Double(-1.0, -1.0, 2.0, 2.0));

    plot.setRenderer(renderer);

    // PLOT BACKGROUND COLOR
    plot.setBackgroundPaint(background); // Hue, saturation, brightness

    return plot;
}

From source file:playground.anhorni.crossborder.verification.TGZMCompare.java

public JFreeChart createChart(String actType) {

    XYSeriesCollection dataset0 = new XYSeriesCollection();
    XYSeries series0 = new XYSeries(actType + " Trips MATSim");
    XYSeries series1 = new XYSeries(actType + " Trips TGZM");

    for (int i = 0; i < 24; i++) {
        double realVal = this.aggregatedVolumePerHour[i];
        int calcVal = this.xTripsPerHour[i];
        series0.add(i, calcVal);//from w ww .j  a v a 2  s .  c om
        series1.add(i, realVal);
    }
    dataset0.addSeries(series0);
    dataset0.addSeries(series1);

    String title = "Compare TGZM and MATSim volumes per hour";
    this.chart = ChartFactory.createXYLineChart(title, "hour", // x axis label
            "Trips", // y axis label
            dataset0, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    XYPlot plot = this.chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setLinesVisible(true);
    renderer.setSeriesPaint(0, Color.blue);
    renderer.setSeriesShape(0, new Rectangle2D.Double(-1.5, -1.5, 3.0, 3.0));
    renderer.setSeriesPaint(1, Color.black);
    renderer.setSeriesShape(1, new Rectangle2D.Double(-1.5, -1.5, 3.0, 3.0));

    plot.setRenderer(0, renderer);

    return this.chart;
}

From source file:org.apache.qpid.disttest.charting.chartbuilder.XYDataSetBasedChartBuilder.java

@Override
protected SeriesStrokeAndPaintApplier newStrokeAndPaintApplier() {
    return new SeriesStrokeAndPaintApplier() {
        @Override//from  w w w .  j  a va  2 s. co m
        public void setSeriesStroke(int seriesIndex, Stroke stroke, JFreeChart targetChart) {
            targetChart.getXYPlot().getRenderer().setSeriesStroke(seriesIndex, stroke);
        }

        @Override
        public void setSeriesPaint(int seriesIndex, Color colour, JFreeChart targetChart) {
            targetChart.getXYPlot().getRenderer().setSeriesPaint(seriesIndex, colour);
        }

        @Override
        public void setSeriesShape(final int seriesIndex, final Shape shape, final JFreeChart targetChart) {
            XYItemRenderer renderer = targetChart.getXYPlot().getRenderer();
            if (renderer instanceof XYLineAndShapeRenderer) {
                XYLineAndShapeRenderer lineAndShapeRenderer = (XYLineAndShapeRenderer) renderer;
                lineAndShapeRenderer.setSeriesShapesVisible(seriesIndex, true);
                lineAndShapeRenderer.setSeriesShape(seriesIndex, shape);
            }
        }
    };
}

From source file:cloud.requestengine.ResponseTimeService.java

public JFreeChart getChart() {
    JFreeChart chart = ChartFactory.createScatterPlot("Response Time", "Time (ms)", "ResponseTime (ms)",
            getDataset(), PlotOrientation.VERTICAL, true, true, false);
    final XYPlot plot = chart.getXYPlot();
    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);

    Shape shape = new Rectangle2D.Double(-1, -1, 2, 2);
    renderer.setSeriesShape(0, shape);

    plot.setRenderer(renderer);/* w  w w.jav a2 s  .c  o  m*/

    return chart;
}

From source file:org.ow2.clif.jenkins.chart.CallChart.java

@Override
protected JFreeChart createChart() {
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(this.eventSerie);

    JFreeChart chart;//w w w .  ja  v a  2 s . c  om
    if (this.scatterPlot) {
        chart = ChartFactory.createScatterPlot(getBasicTitle(),
                // chart title
                Messages.CallChart_Time(), // x axis label
                Messages.CallChart_ResponseTime(), // y axis label
                dataset, // data
                PlotOrientation.VERTICAL, true, // include legend
                true, // tooltips
                false // urls
        );
    } else {
        chart = ChartFactory.createXYLineChart(getBasicTitle(),
                // chart title
                Messages.CallChart_Time(), // x axis label
                this.chartId.getEvent(), // y axis label
                dataset, // data
                PlotOrientation.VERTICAL, false, // include legend
                true, // tooltips
                false // urls
        );
    }

    chart.setBackgroundPaint(Color.white);
    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    Shape cross = ShapeUtilities.createDiamond(3);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseShape(cross);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShape(0, cross);
    plot.setRenderer(renderer);

    // Force the 0 on vertical axis
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRangeIncludesZero(true);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // Force the 0 on horizontal axis
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(true);
    return chart;
}

From source file:sim.util.media.chart.ScatterPlotSeriesAttributes.java

/** Produces a ScatterPlotSeriesAttributes object with the given generator, series name, series index,
and desire to display margin options. */
public ScatterPlotSeriesAttributes(ChartGenerator generator, String name, int index, double[][] values,
        SeriesChangeListener stoppable) {
    super(generator, name, index, stoppable);

    setValues(values);/*w ww  .  j a va2  s  .c  o m*/
    super.setSeriesName(name); // just set the name, don't update.  Bypasses standard method below.

    // increment shape counter
    ((ScatterPlotGenerator) generator).shapeCounter++;
    if (((ScatterPlotGenerator) generator).shapeCounter >= shapes.length)
        ((ScatterPlotGenerator) generator).shapeCounter = 0;

    // set the shape
    shapeNum = ((ScatterPlotGenerator) generator).shapeCounter;
    shape = shapes[shapeNum];
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) (((XYPlot) getPlot()).getRenderer());
    renderer.setSeriesShape(getSeriesIndex(), shape);
    renderer.setAutoPopulateSeriesShape(false);
}

From source file:edu.gmu.cs.sim.util.media.chart.ScatterPlotSeriesAttributes.java

/** Produces a ScatterPlotSeriesAttributes object with the given generator, series name, series index,
 and desire to display margin options. */
public ScatterPlotSeriesAttributes(ChartGenerator generator, String name, int index, double[][] values,
        SeriesChangeListener stoppable) {
    super(generator, name, index, stoppable);

    setValues(values);//from   w  w  w .ja v  a2s.  c  o  m
    super.setSeriesName(name); // just set the name, don't update.  Bypasses standard method below.

    // increment shape counter
    ((ScatterPlotGenerator) generator).shapeCounter++;
    if (((ScatterPlotGenerator) generator).shapeCounter >= shapes.length) {
        ((ScatterPlotGenerator) generator).shapeCounter = 0;
    }

    // set the shape
    shapeNum = ((ScatterPlotGenerator) generator).shapeCounter;
    shape = shapes[shapeNum];
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) (((XYPlot) getPlot()).getRenderer());
    renderer.setSeriesShape(getSeriesIndex(), shape);
    renderer.setAutoPopulateSeriesShape(false);
}

From source file:regression.gui.RegressionChart.java

/**
 * Creates a chart./*from ww  w .j a va2  s  .  co  m*/
 *
 * @param dataset the data for the chart.
 *
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    final JFreeChart chart = ChartFactory.createScatterPlot("Wykres funkcji regresji", // chart title
            "X", // x axis label
            "Y", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesShape(0, ShapeUtilities.createRegularCross(3, 3));
    renderer.setSeriesShape(2, ShapeUtilities.createRegularCross(3, 3));
    renderer.setSeriesLinesVisible(0, false);

    renderer.setSeriesShapesVisible(1, false);
    renderer.setSeriesLinesVisible(2, false);
    plot.setRenderer(renderer);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return chart;

}