Example usage for org.jfree.chart.renderer.category LineAndShapeRenderer setSeriesLinesVisible

List of usage examples for org.jfree.chart.renderer.category LineAndShapeRenderer setSeriesLinesVisible

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.category LineAndShapeRenderer setSeriesLinesVisible.

Prototype

public void setSeriesLinesVisible(int series, boolean visible) 

Source Link

Document

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

Usage

From source file:org.jfree.chart.demo.LineChartDemo7.java

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createLineChart("Line Chart Demo 7", "Category", "Count",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setSeriesShapesVisible(0, true);
    lineandshaperenderer.setSeriesShapesVisible(1, false);
    lineandshaperenderer.setSeriesShapesVisible(2, true);
    lineandshaperenderer.setSeriesLinesVisible(2, false);
    lineandshaperenderer.setSeriesShape(2, ShapeUtilities.createDiamond(4F));
    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setBaseFillPaint(Color.white);
    return jfreechart;
}

From source file:org.jfree.chart.demo.LineChartDemo8.java

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createLineChart("Line Chart Demo 8", "Category", "Count",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    SymbolAxis symbolaxis = new SymbolAxis("Group", new String[] { "A", "B", "C", "D", "E", "F" });
    categoryplot.setRangeAxis(symbolaxis);
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setSeriesShapesVisible(0, true);
    lineandshaperenderer.setSeriesShapesVisible(1, false);
    lineandshaperenderer.setSeriesShapesVisible(2, true);
    lineandshaperenderer.setSeriesLinesVisible(2, false);
    lineandshaperenderer.setSeriesShape(2, ShapeUtilities.createDiamond(4F));
    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setBaseFillPaint(Color.white);
    return jfreechart;
}

From source file:org.pentaho.chart.plugin.jfreechart.chart.line.JFreeLineChartGenerator.java

/**
 * Sets the line width for each of the series that is defined as a lineRenderer
 * </p>// w  w w .  j a va  2 s.c om
 * @param categoryPlot   -- The category plot from the current chart object. Category plot will be updated.
 * @param seriesElements -- Series elements from the current chart definition.
 */
public static void setSeriesLineStyles(final CategoryPlot categoryPlot, final ChartElement[] seriesElements) {
    final int length = seriesElements.length;
    final StrokeFactory strokeFacObj = StrokeFactory.getInstance();
    for (int i = 0; i < length; i++) {
        final ChartElement currElement = seriesElements[i];

        if (categoryPlot.getRenderer() instanceof LineAndShapeRenderer) {
            final LineAndShapeRenderer lineAndShapeRenderer = (LineAndShapeRenderer) categoryPlot.getRenderer();
            final CSSValue visibleStr = currElement.getLayoutStyle().getValue(ChartStyleKeys.LINE_VISIBLE);
            lineAndShapeRenderer.setSeriesLinesVisible(i, !ChartLineVisibleType.HIDDEN.equals(visibleStr));
            final BasicStroke lineStyleStroke = strokeFacObj.getLineStroke(currElement);
            if (lineStyleStroke != null) {
                lineAndShapeRenderer.setSeriesStroke(i, lineStyleStroke);
            }
        }
    }
}

From source file:org.pentaho.chart.plugin.jfreechart.chart.multi.JFreeMultiChartGenerator.java

/**
 * Sets the line width for each of the series that is defined as a lineRenderer
 * </p>/*from   w ww . jav a2  s . com*/
 * @param categoryPlot   -- The category plot from the current chart object. Category plot will be updated.
 * @param seriesElements -- Series elements from the current chart definition.
 */
public static void setSeriesLineStyles(final CategoryPlot categoryPlot, final ChartElement[] seriesElements) {
    final int length = seriesElements.length;
    final StrokeFactory strokeFacObj = StrokeFactory.getInstance();
    for (int i = 0; i < length; i++) {
        final ChartElement currElement = seriesElements[i];

        if (categoryPlot.getRenderer() instanceof LineAndShapeRenderer) {
            final LineAndShapeRenderer lineAndShapeRenderer = (LineAndShapeRenderer) categoryPlot.getRenderer();
            final CSSValue visibleStr = currElement.getLayoutStyle().getValue(ChartStyleKeys.LINE_VISIBLE);
            lineAndShapeRenderer.setSeriesLinesVisible(i, ChartLineVisibleType.VISIBLE.equals(visibleStr));
            final BasicStroke lineStyleStroke = strokeFacObj.getLineStroke(currElement);
            if (lineStyleStroke != null) {
                lineAndShapeRenderer.setSeriesStroke(i, lineStyleStroke);
            }
        }
    }
}

From source file:org.pau.assetmanager.viewmodel.chart.PrepareChart.java

public static void commonPrepareJFreeChart(LineAndShapeRenderer renderer) {
    renderer.setSeriesStroke(0, new BasicStroke(1));
    renderer.setSeriesStroke(1, new BasicStroke(1));
    renderer.setSeriesStroke(2, new BasicStroke(1));
    renderer.setSeriesStroke(3, new BasicStroke(1));
    renderer.setSeriesStroke(4, new BasicStroke(1));
    renderer.setSeriesStroke(5, new BasicStroke(1));
    renderer.setSeriesStroke(6, new BasicStroke(1));

    renderer.setSeriesItemLabelsVisible(0, true);
    renderer.setSeriesItemLabelsVisible(1, true);
    renderer.setSeriesItemLabelsVisible(2, true);
    renderer.setSeriesItemLabelsVisible(3, true);
    renderer.setSeriesItemLabelsVisible(4, true);
    renderer.setSeriesItemLabelsVisible(5, true);
    renderer.setSeriesItemLabelsVisible(6, true);

    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesLinesVisible(2, true);
    renderer.setSeriesLinesVisible(3, true);
    renderer.setSeriesLinesVisible(4, true);
    renderer.setSeriesLinesVisible(5, true);
    renderer.setSeriesLinesVisible(6, true);

    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesShapesVisible(1, true);
    renderer.setSeriesShapesVisible(2, true);
    renderer.setSeriesShapesVisible(3, true);
    renderer.setSeriesShapesVisible(4, true);
    renderer.setSeriesShapesVisible(5, true);
    renderer.setSeriesShapesVisible(6, true);
}

From source file:guineu.modules.filter.report.RTShift.ReportTask.java

/**
 * Create the chart and save it into a png file.
 * @param dataset/* w w w . j av  a 2  s.  co m*/
 * @param lipidName
 */
private void createChart(CategoryDataset dataset, String lipidName) {
    try {

        JFreeChart chart = ChartFactory.createLineChart("RT shift", "Samples", "RT", dataset,
                PlotOrientation.VERTICAL, false, false, false);

        // Chart characteristics
        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        final NumberAxis axis = (NumberAxis) plot.getRangeAxis();
        axis.setAutoRangeIncludesZero(false);
        axis.setAutoRangeMinimumSize(1.0);
        LineAndShapeRenderer categoryRenderer = new LineAndShapeRenderer();
        categoryRenderer.setSeriesLinesVisible(0, false);
        categoryRenderer.setSeriesShapesVisible(0, true);
        plot.setRenderer(categoryRenderer);

        // Save all the charts in the folder choosen by the user
        ChartUtilities.saveChartAsPNG(new File(this.reportFileName + "/RT Shift:" + lipidName + ".png"), chart,
                1000, (500));
    } catch (IOException ex) {
        Logger.getLogger(ReportTask.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:guineu.modules.filter.report.areaVSheight.ReportTask.java

/**
 * Create the chart and save it into a png file.
 * @param dataset/*  w  ww  .ja  v a 2  s.  c  o  m*/
 * @param lipidName
 */
private void createChart(CategoryDataset dataset, String lipidName) {
    try {

        JFreeChart chart = ChartFactory.createLineChart("Height/Area", "Samples", "Height/Area", dataset,
                PlotOrientation.VERTICAL, false, false, false);

        // Chart characteristics
        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        final NumberAxis axis = (NumberAxis) plot.getRangeAxis();
        axis.setAutoRangeIncludesZero(false);
        LineAndShapeRenderer categoryRenderer = new LineAndShapeRenderer();
        categoryRenderer.setSeriesLinesVisible(0, false);
        categoryRenderer.setSeriesShapesVisible(0, true);
        plot.setRenderer(categoryRenderer);

        // Save all the charts in the folder choosen by the user
        ChartUtilities.saveChartAsPNG(new File(this.reportFileName + "/HeightvsArea:" + lipidName + ".png"),
                chart, 1000, 500);
    } catch (IOException ex) {
        Logger.getLogger(ReportTask.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:guineu.modules.filter.report.intensitiesReport.ReportTask.java

/**
 * Create the chart and save it into a png file.
 * @param dataset/*from   w w w .  jav a 2  s  .  co m*/
 * @param lipidName
 */
private void createChart(CategoryDataset dataset, String lipidName) {
    try {
        String fieldY;
        if (this.useArea) {
            fieldY = "Area";
        } else {
            fieldY = "Heights";
        }

        JFreeChart chart = ChartFactory.createLineChart("Intensities", "Samples", fieldY, dataset,
                PlotOrientation.VERTICAL, false, false, false);

        // Chart characteristics
        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        final NumberAxis axis = (NumberAxis) plot.getRangeAxis();
        axis.setAutoRangeIncludesZero(false);
        LineAndShapeRenderer categoryRenderer = new LineAndShapeRenderer();
        categoryRenderer.setSeriesLinesVisible(0, false);
        categoryRenderer.setSeriesShapesVisible(0, true);
        plot.setRenderer(categoryRenderer);

        // Save all the charts in the folder choosen by the user
        ChartUtilities.saveChartAsPNG(new File(this.reportFileName + "/" + fieldY + ":" + lipidName + ".png"),
                chart, 1000, 500);
    } catch (IOException ex) {
        Logger.getLogger(ReportTask.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:org.operamasks.faces.render.graph.LineChartRenderer.java

private void setSeriesLineStyles(LineAndShapeRenderer renderer, UIChart comp, int index, UIDataItem item) {
    Boolean drawLines = item.getDrawLines();
    if (drawLines != null) {
        renderer.setSeriesLinesVisible(index, drawLines);
    }//from w w w  .j  a va2  s.co m

    Float lineWidth = item.getLineWidth();
    LineStyleType lineStyle = item.getLineStyle();
    if (lineWidth == null)
        lineWidth = comp.getLineWidth();
    if (lineStyle == null)
        lineStyle = comp.getLineStyle();
    if (lineWidth != null || lineStyle != null) {
        if (lineWidth == null)
            lineWidth = 1.0f;
        renderer.setSeriesStroke(index, createLineStroke(lineWidth, lineStyle));
    }

    Boolean drawMarkers = item.getDrawMarkers();
    if (drawMarkers != null) {
        renderer.setSeriesShapesVisible(index, drawMarkers);
    }

    Boolean fillMarkers = item.getFillMarkers();
    if (fillMarkers != null) {
        renderer.setSeriesShapesFilled(index, fillMarkers);
    }

    Paint markerFillColor = item.getMarkerFillColor();
    if (markerFillColor == null) {
        markerFillColor = comp.getMarkerFillColor();
        if (markerFillColor == null)
            markerFillColor = renderer.getSeriesPaint(index);
    }
    renderer.setSeriesFillPaint(index, markerFillColor);
}

From source file:org.cerberus.refactor.LineChart.java

public BufferedImage bi(CategoryDataset categorydataset, String name, int count) {

    BufferedImage bi = null;/*www .  j av a  2s.co  m*/

    JFreeChart jfreechart = ChartFactory.createLineChart(name, "Category", "Count", categorydataset,
            PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    Shape point = ShapeUtilities.createDiagonalCross(1, 1);
    //TODO check this - seriesColors never used
    //        String[] seriesColors = {"#FF0000", "#D7D6F6", "#0F07F3", "#EEFFBD", "#75C53E", "#FED7BA", "#FE6F01"};
    //        String[] seriesColors2 = {"#D7D6F6", "#0F07F3", "#EEFFBD", "#75C53E", "#FED7BA", "#FE6F01"};

    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setBaseShapesVisible(true);
    lineandshaperenderer.setBaseShapesFilled(true);
    for (int a = 0; a < count; a++) {
        lineandshaperenderer.setSeriesShapesVisible(a, true);
        lineandshaperenderer.setSeriesLinesVisible(a, true);
        lineandshaperenderer.setSeriesStroke(a, new BasicStroke(1.0F));
        lineandshaperenderer.setSeriesShape(a, point);
    }

    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setBaseFillPaint(Color.white);

    //DateAxis dateaxis = (DateAxis)xyplot.getDomainAxis();
    //dateaxis.setDateFormatOverride(new SimpleDateFormat("hh:mm"));

    bi = jfreechart.createBufferedImage(500, 270);

    return bi;

}