List of usage examples for org.jfree.chart.renderer.category LineAndShapeRenderer setSeriesStroke
public void setSeriesStroke(int series, Stroke stroke)
From source file:edu.coeia.charts.LineChartPanel.java
/** * Creates a sample chart.//w ww .j a v a2 s.com * * @param dataset a dataset. * * @return The chart. */ private static JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createLineChart("Frequency of Messages", // chart title "Time of Messages", // domain axis label "Number of Messages", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // customise the renderer... final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f)); renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 6.0f }, 0.0f)); renderer.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f)); return chart; }
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:grafici.StatisticheLineChart.java
/** * Creates a sample chart./*from ww w .j a v a 2 s . c o m*/ * * @param dataset * the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset, Table results, int variabile, int valore) { // create the chart... JFreeChart chart = ChartFactory.createLineChart(titolo, "", // domain axis label results.getColumn(valore).getText().toUpperCase(), // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // customise the renderer... final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); // renderer.setDrawShapes(true); renderer.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f)); renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 6.0f }, 0.0f)); renderer.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:sas.BarChart.java
public static JFreeChart createChart(CategoryDataset categorydataset, String name, String type, String t) { JFreeChart jfreechart = ChartFactory.createLineChart(name, null, type, categorydataset, PlotOrientation.VERTICAL, false, true, false); jfreechart.addSubtitle(new TextTitle(t)); TextTitle texttitle = new TextTitle(""); texttitle.setFont(new Font("SansSerif", 0, 10)); texttitle.setPosition(RectangleEdge.BOTTOM); texttitle.setHorizontalAlignment(HorizontalAlignment.CENTER); jfreechart.addSubtitle(texttitle);//from ww w . jav a 2 s . co m CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setRangePannable(true); categoryplot.setRangeGridlinesVisible(false); java.net.URL url = (BarChart.class).getClassLoader().getResource("line_Chart_example.png"); if (url != null) { ImageIcon imageicon = new ImageIcon(url); jfreechart.setBackgroundImage(imageicon.getImage()); categoryplot.setBackgroundPaint(null); } NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartUtilities.applyCurrentTheme(jfreechart); LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); lineandshaperenderer.setBaseShapesVisible(true); lineandshaperenderer.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setBaseFillPaint(Color.white); lineandshaperenderer.setSeriesStroke(0, new BasicStroke(3F)); lineandshaperenderer.setSeriesOutlineStroke(0, new BasicStroke(2.0F)); lineandshaperenderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D)); 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 ww . j a v a2 s . c o m * @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>/* w w w . j a va 2 s .c o m*/ * @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:playground.artemc.calibration.charts.AddSecondChart.java
public void addChart() { plot.setDataset(1, dataset);//from w w w .ja v a 2s .c o m plot.mapDatasetToRangeAxis(1, 0); final LineAndShapeRenderer renderer = new LineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.BLACK); renderer.setSeriesStroke(0, new BasicStroke(4.0f)); plot.setRenderer(1, renderer); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setDomainGridlinesVisible(true); }
From source file:playground.artemc.calibration.charts.AddSecondChart.java
public void addChartAndAxis() { //this.plot.setBackgroundPaint(new Color(0xEE, 0xEE, 0xFF)); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); //final CategoryAxis domainAxis = plot.getDomainAxis(); //domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); final ValueAxis axis2 = new NumberAxis(yAxisLabel); axis2.setRange(lowerLimit, upperLimit); plot.setRangeAxis(1, axis2);/*from ww w.j a va 2 s . c o m*/ plot.setDataset(1, dataset); plot.mapDatasetToRangeAxis(1, 1); final LineAndShapeRenderer renderer = new LineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.BLACK); renderer.setSeriesStroke(0, new BasicStroke(4.0f)); plot.setRenderer(1, renderer); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setDomainGridlinesVisible(true); }
From source file:org.jfree.chart.demo.LineChartDemo1.java
/** * Creates a sample chart./*from w w w. ja v a 2s . com*/ * * @param dataset a dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createLineChart("Line Chart Demo 1", // chart title "Type", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // legend.setShapeScaleX(1.5); // legend.setShapeScaleY(1.5); //legend.setDisplaySeriesLines(true); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // customise the renderer... final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); // renderer.setDrawShapes(true); renderer.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f)); renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 6.0f }, 0.0f)); renderer.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:smarthouse_server.LineChart.java
/** * Creates a sample chart./*ww w .ja v a 2s .c o m*/ * * @param dataset a dataset. * * @return The chart. */ private JFreeChart createChart(CategoryDataset dataset) { // create the chart... chart = ChartFactory.createLineChart("Room Monitor #", // chart title "Time", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // legend.setShapeScaleX(1.5); // legend.setShapeScaleY(1.5); //legend.setDisplaySeriesLines(true); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); plot.getDomainAxis().setVisible(false); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // customise the renderer... LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); // renderer.setDrawShapes(true); renderer.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f)); renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 6.0f }, 0.0f)); /* renderer.setSeriesStroke( 2, new BasicStroke( 2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] {2.0f, 6.0f}, 0.0f ) );*/ // OPTIONAL CUSTOMISATION COMPLETED. return chart; }