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

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

Introduction

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

Prototype

public void setSeriesShapesVisible(int series, Boolean flag) 

Source Link

Document

Sets the 'shapes visible' flag for a series and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:beadAnalyzer.DrawPoints.java

public static void setDisplayType(final JFreeChart chart, final int seriesIndex, final boolean line,
        final boolean shape) {
    final XYPlot plot = chart.getXYPlot();
    final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesLinesVisible(seriesIndex, line);
    renderer.setSeriesShapesVisible(seriesIndex, shape);
}

From source file:Methods.CalculusBisection.java

public static ChartPanel createChartBisection(XYDataset datasetFunction) {// Method that populates and returns a Chart Pannel object, uses an entering paramether for the equation dataset and a global variable for the iteration points data set 

    datasetPointsBisection();/*from   w w w .j  a  v a 2 s .  c o  m*/

    JFreeChart chart = ChartFactory.createXYLineChart("Equation Chart", "X Axys", "Y Axys", datasetFunction,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();//declaring a renderer used to plot more than one datatset on the table

    plot.setDataset(1, datasetPoints);
    renderer.setSeriesLinesVisible(1, false);
    renderer.setSeriesShapesVisible(1, false);
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);
    plot.setRenderer(1, renderer);

    return new ChartPanel(chart);

}

From source file:Methods.CalculusNewtonRaphson.java

public static ChartPanel createChartNewtonRapson(XYDataset datasetFunction) {// Method that populates and returns a Chart Pannel object, uses an entering paramether for the equation dataset and a global variable for the iteration points data set 

    datasetPointsNewtonRapson();//w w w  . ja  v a 2  s  .  c o m
    JFreeChart chart = ChartFactory.createXYLineChart("Equation Chart", "X Axys", "Y Axys", datasetFunction,
            PlotOrientation.VERTICAL, true, true, false);//creating a object table wich takes the methods arguments as a dataset

    XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();//declaring a renderer used to plot more than one datatset on the table

    plot.setDataset(1, datasetPoints);
    renderer.setSeriesLinesVisible(1, false);
    renderer.setSeriesShapesVisible(1, false);
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);
    plot.setRenderer(1, renderer);

    return new ChartPanel(chart);

}

From source file:projects.hip.exec.HrDiagram.java

/**
 * Plot the distribution of distance of all objects.
 * @param d_hist//from  w  w w.  j  a va2  s. co m
 *    The array containing the distance distribution histogram.
 * @return
 *    A {@link JFreeChart} containing the plot.
 */
private static JFreeChart getDistanceChart(double[] d_hist) {

    XYSeries series = new XYSeries("Distance distribution");

    for (int i = 0; i < d_hist.length; i++) {
        // Centre of this distance bin
        double d = d_min + i * d_step + d_step / 2.0;
        series.add(d, d_hist[i]);
    }
    XYSeriesCollection data = new XYSeriesCollection();
    data.addSeries(series);

    // Set up the renderer
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, false);

    // Configure axes
    NumberAxis xAxis = new NumberAxis("Distance [pc]");
    xAxis.setRange(d_min, d_max);

    NumberAxis yAxis = new NumberAxis("Number of objects");
    yAxis.setAutoRangeIncludesZero(true);

    // Configure plot
    XYPlot xyplot = new XYPlot(data, xAxis, yAxis, renderer);
    xyplot.setBackgroundPaint(Color.white);

    JFreeChart dChart = new JFreeChart("Distance distribution of Hipparcos stars", xyplot);
    dChart.removeLegend();
    dChart.setBackgroundPaint(Color.white);

    return dChart;
}

From source file:projects.hip.exec.HrDiagram.java

/**
 * Plot the HR diagram chart from the given data.
 * @param series/*from   w w  w  .j  a va 2 s  .  co  m*/
 *    A {@link XYSeries} containing the HR diagram data.
 * @return
 *    A {@link JFreeChart} containing the plot.
 */
private static JFreeChart getHrChart(XYSeries series) {

    XYSeriesCollection hrData = new XYSeriesCollection();
    hrData.addSeries(series);

    // Set up the renderer
    XYLineAndShapeRenderer hrRenderer = new XYLineAndShapeRenderer();

    hrRenderer.setSeriesLinesVisible(0, false);
    hrRenderer.setSeriesShapesVisible(0, true);
    hrRenderer.setSeriesShape(0, new Ellipse2D.Double(-0.5, -0.5, 1, 1));

    // Configure axes
    NumberAxis xAxis = new NumberAxis("B - V [mag]");
    xAxis.setRange(-0.5, 2.25);

    NumberAxis yAxis = new NumberAxis("H [mag]");
    yAxis.setInverted(true);
    yAxis.setRange(-5, 13);

    // Configure plot
    XYPlot xyplot = new XYPlot(hrData, xAxis, yAxis, hrRenderer);
    xyplot.setBackgroundPaint(Color.white);

    JFreeChart hrChart = new JFreeChart("HR diagram of Hipparcos stars", xyplot);
    hrChart.removeLegend();
    hrChart.setBackgroundPaint(Color.white);

    return hrChart;
}

From source file:com.che.software.testato.util.jfreechart.LineChartGraphistUtil.java

/**
 * Colorized and transforms a given JFreeChart.
 * // w  w  w.j  a  v a  2s.co  m
 * @author Clement HELIOU (clement.heliou@che-software.com).
 * @param lineChart the given chart.
 * @param maxAbscissaValue the max abscissa value of the chart.
 * @param xValues the x axis values list.
 * @param yValues the y axis values list.
 * @param xExcludedValues the x axis excluded values.
 * @param yExcludedValues the y axis excluded values.
 * @return the transformed chart.
 * @since August, 2011.
 */
public static JFreeChart getColorizedChartFromChart(JFreeChart lineChart, double maxAbscissaValue,
        List<MatrixResult> xValues, List<MatrixResult> yValues, List<MatrixResult> xExcludedValues,
        List<MatrixResult> yExcludedValues) {
    LOGGER.debug("getColorizedChartFromChart().");
    lineChart.setBackgroundPaint(Color.WHITE);
    XYPlot plot = (XYPlot) lineChart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesLinesVisible(1, false);
    renderer.setSeriesStroke(2, new BasicStroke(2));
    renderer.setSeriesStroke(3, new BasicStroke(2));
    renderer.setSeriesShapesVisible(2, false);
    renderer.setSeriesShapesVisible(3, false);
    renderer.setSeriesPaint(0,
            ColorUtil.getHSBColor(ColorUtil.BLUE_COLOR[0], ColorUtil.BLUE_COLOR[1], ColorUtil.BLUE_COLOR[2]));
    renderer.setSeriesPaint(1, ColorUtil.getHSBColor(ColorUtil.ORANGE_COLOR[0], ColorUtil.ORANGE_COLOR[1],
            ColorUtil.ORANGE_COLOR[2]));
    renderer.setSeriesPaint(2, ColorUtil.getHSBColor(ColorUtil.DARK_BLUE_COLOR[0], ColorUtil.DARK_BLUE_COLOR[1],
            ColorUtil.DARK_BLUE_COLOR[2]));
    renderer.setSeriesPaint(3, ColorUtil.getHSBColor(ColorUtil.DARK_BLUE_COLOR[0], ColorUtil.DARK_BLUE_COLOR[1],
            ColorUtil.DARK_BLUE_COLOR[2]));
    plot.setRenderer(renderer);
    XYTextAnnotation low = new XYTextAnnotation(
            LocaleUtil.getResourceBundleStringByName(LocaleUtil.AREA_LOW_NAME), (0.5 * maxAbscissaValue) - 1,
            maxAbscissaValue + 1),
            medium = new XYTextAnnotation(LocaleUtil.getResourceBundleStringByName(LocaleUtil.AREA_MEDIUM_NAME),
                    (1.5 * maxAbscissaValue) - 2, maxAbscissaValue + 1),
            high = new XYTextAnnotation(LocaleUtil.getResourceBundleStringByName(LocaleUtil.AREA_HIGH_NAME),
                    1.5 * maxAbscissaValue, maxAbscissaValue - 2);
    low.setFont(ColorUtil.TITLE_FONT);
    medium.setFont(ColorUtil.TITLE_FONT);
    high.setFont(ColorUtil.TITLE_FONT);
    low.setPaint(ColorUtil.getHSBColor(ColorUtil.DARK_BLUE_COLOR[0], ColorUtil.DARK_BLUE_COLOR[1],
            ColorUtil.DARK_BLUE_COLOR[2]));
    medium.setPaint(ColorUtil.getHSBColor(ColorUtil.DARK_BLUE_COLOR[0], ColorUtil.DARK_BLUE_COLOR[1],
            ColorUtil.DARK_BLUE_COLOR[2]));
    high.setPaint(ColorUtil.getHSBColor(ColorUtil.DARK_BLUE_COLOR[0], ColorUtil.DARK_BLUE_COLOR[1],
            ColorUtil.DARK_BLUE_COLOR[2]));
    plot.addAnnotation(low);
    plot.addAnnotation(medium);
    plot.addAnnotation(high);
    for (int i = 0; i < xValues.size(); i++) {
        XYTextAnnotation itemLabel = new XYTextAnnotation(xValues.get(i).getScriptLabel(),
                (yValues.get(i).getPercentage() * 100), (xValues.get(i).getPercentage() * 100) + 0.5);
        itemLabel.setFont(ColorUtil.DEFAULT_FONT);
        itemLabel.setPaint(ColorUtil.getHSBColor(ColorUtil.BLUE_COLOR[0], ColorUtil.BLUE_COLOR[1],
                ColorUtil.BLUE_COLOR[2]));
        plot.addAnnotation(itemLabel);
    }
    if (null != xExcludedValues) {
        for (int j = 0; j < xExcludedValues.size(); j++) {
            XYTextAnnotation itemLabel = new XYTextAnnotation(xExcludedValues.get(j).getScriptLabel(),
                    (yExcludedValues.get(j).getPercentage() * 100),
                    (xExcludedValues.get(j).getPercentage() * 100) + 0.5);
            itemLabel.setFont(ColorUtil.DEFAULT_FONT);
            itemLabel.setPaint(ColorUtil.getHSBColor(ColorUtil.ORANGE_COLOR[0], ColorUtil.ORANGE_COLOR[1],
                    ColorUtil.ORANGE_COLOR[2]));
            plot.addAnnotation(itemLabel);
        }
    }
    return lineChart;
}

From source file:Similaridade.GraficosSimilaridade.java

public static JFreeChart criaGrafico2LinhasComDeslocada(CapturaAtual onda1, CapturaAtual onda2,
        int deslocamento, double correlacao, Paint cor1, Paint cor2) {
    String eixoy = new String("Current ");
    // verifica se  fase ou fuga
    if (onda1.getCodEvento().getCodEvento() == 1) { // evento 1  de fuga
        eixoy = eixoy.concat("(mA)");
    } else {/*from  w  w  w  .ja v  a 2s. c o m*/
        eixoy = eixoy.concat("(A)");
    }
    XYDataset dataset = newDataset2OndasComDeslocada(onda1, onda2, deslocamento, correlacao);

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
            "Time (ms)", // x axis label
            eixoy, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            false, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();

    // Definindo valores no eixo y
    double min = (double) DatasetUtilities.findMinimumRangeValue(dataset);
    double max = (double) DatasetUtilities.findMaximumRangeValue(dataset);

    plot.getRangeAxis().setRange(min - min * 0.005, //min
            max + min * 0.005);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    renderer.setBaseStroke(new BasicStroke(1.0f));
    for (int i = 0; i < dataset.getSeriesCount(); i++) {
        renderer.setSeriesLinesVisible(i, true);
        renderer.setSeriesShapesVisible(i, false);
    }
    // Ajustar para todas as cores padro, pelo menos 10
    renderer.setSeriesPaint(0, cor1);
    renderer.setSeriesPaint(1, cor2);

    /* Cdigo para ter linhas tracejadas 
    renderer.setSeriesStroke(1, 
        new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.CAP_ROUND,
                        20.0f, new float[] {5.0f}, 0.0f) );
               
    renderer.setDrawSeriesLineAsPath(true); 
    /* Final do Codigo para tracejadas */

    plot.setRenderer(renderer);

    return chart;
}

From source file:dumbara.view.Chart1.java

public static void ViewLineChart(String[] agencyID, String[] sslesDate, ArrayList<String[]> arrayList)
        throws SQLException, ClassNotFoundException {
    XYSeries series1 = new XYSeries("Agency 1");
    XYSeries series2 = new XYSeries("Agency 2");
    XYSeries series3 = new XYSeries("Agency 3");
    XYSeries series4 = new XYSeries("Agency 4");

    for (String[] strings : arrayList) {

        for (int i = 0; i < sslesDate.length; i++) {
            System.out.println(sslesDate[i].split("-")[1] + "");
            series1.add(Double.parseDouble(sslesDate[i].split("-")[1] + ""),
                    Double.parseDouble(arrayList.get(0)[i]));
        }/*from  www .j  av a2  s. c  o  m*/

        for (int i = 0; i < sslesDate.length; i++) {
            series2.add(Double.parseDouble(sslesDate[i].split("-")[1] + ""),
                    Double.parseDouble(arrayList.get(1)[i]));
        }

        for (int i = 0; i < sslesDate.length; i++) {
            series3.add(Double.parseDouble(sslesDate[i].split("-")[1] + ""),
                    Double.parseDouble(arrayList.get(2)[i]));
        }

        for (int i = 0; i < sslesDate.length; i++) {
            series4.add(Double.parseDouble(sslesDate[i].split("-")[1] + ""),
                    Double.parseDouble(arrayList.get(3)[i]));

        }

    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series1);
    dataset.addSeries(series2);
    dataset.addSeries(series3);
    dataset.addSeries(series4);
    XYDataset dataset1 = dataset;
    JFreeChart chart = ChartFactory.createXYLineChart("", "Test Id", "Average Marks", dataset1,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesShapesVisible(1, true);
    renderer.setSeriesLinesVisible(2, true);
    renderer.setSeriesShapesVisible(2, true);
    renderer.setSeriesFillPaint(2, Color.MAGENTA);
    plot.setRenderer(renderer);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
    //(chartPanel);
    ChartFrame frame = new ChartFrame("Dumbara Water Management System", chart);
    frame.setLocationRelativeTo(null);
    frame.pack();
    frame.setVisible(true);

}

From source file:org.gephi.ui.utils.ChartsUtils.java

/**
 * Modify a scatter plot to show lines instead or shapes or not.
 * @param scatterPlot Scatter plot to modify
 * @param enabled Indicates if lines have to be shown
 */// ww  w .ja v a2s  .c o m
public static void setScatterPlotLinesEnabled(final JFreeChart scatterPlot, final boolean enabled) {
    XYPlot plot = (XYPlot) scatterPlot.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    if (enabled) {
        renderer.setSeriesLinesVisible(0, true);
        renderer.setSeriesShapesVisible(0, false);
    } else {
        renderer.setSeriesLinesVisible(0, false);
        renderer.setSeriesShapesVisible(0, true);
        renderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(0, 0, 1, 1));
    }
    renderer.setSeriesPaint(0, Color.RED);

    plot.setRenderer(0, renderer);
}

From source file:com.comcast.cmb.test.tools.QueueDepthSimulator.java

public static void plotLineChart(Map<String, List<Double>> series, String filename, String title, String labelX,
        String labelY) throws IOException {
    XYSeriesCollection dataset = new XYSeriesCollection();
    for (String label : series.keySet()) {
        XYSeries data = new XYSeries(label);
        int t = 0;
        for (Double d : series.get(label)) {
            data.add(t, d);/*from  ww w  .j av a  2 s . com*/
            t++;
        }
        dataset.addSeries(data);
    }
    JFreeChart chart = ChartFactory.createXYLineChart(title, labelX, labelY, dataset, PlotOrientation.VERTICAL,
            true, true, false);
    XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);
    plot.setRenderer(renderer);
    ChartUtilities.saveChartAsPNG(new File(filename), chart, 1024, 768);
}