List of usage examples for org.jfree.chart.plot DefaultDrawingSupplier DefaultDrawingSupplier
public DefaultDrawingSupplier(Paint[] paintSequence, Paint[] outlinePaintSequence, Stroke[] strokeSequence,
Stroke[] outlineStrokeSequence, Shape[] shapeSequence)
From source file:com.pureinfo.srm.reports.impl.PieChartBuilder.java
/** * @throws PureException//from w w w. j av a 2 s. co m * @see com.pureinfo.srm.reports.IChartBuilder#draw(java.util.List, int) */ public JFreeChart buildChart() { Iterator result = m_datas.iterator(); DefaultPieDataset ds = getDataset(result); JFreeChart jfreechart = ChartFactory.createPieChart3D(null, ds, false, false, false); jfreechart.setBackgroundPaint(Color.WHITE); PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot(); pieplot3d.setOutlinePaint(Color.GRAY); pieplot3d.setOutlineStroke(new BasicStroke(1)); pieplot3d.setStartAngle(30D); pieplot3d.setDepthFactor(0.04); pieplot3d.setDrawingSupplier(new DefaultDrawingSupplier(MyPaintMgr.getPaints(), DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); pieplot3d.setCircular(false); pieplot3d.setDirection(Rotation.CLOCKWISE); pieplot3d.setOutlinePaint(Color.WHITE); pieplot3d.setInteriorGap(.15); Color color = new Color(0xaa, 0xaa, 0xaa, 255); pieplot3d.setBaseSectionOutlinePaint(color); pieplot3d.setBaseSectionOutlineStroke(new BasicStroke(0)); pieplot3d.setForegroundAlpha(0.6f); pieplot3d.setLabelLinkStroke(new BasicStroke(1)); pieplot3d.setLabelOutlinePaint(new Color(0x777777)); pieplot3d.setLabelBackgroundPaint(new Color(0xf1f1f7)); pieplot3d.setLabelLinkPaint(new Color(0xaa, 0xaa, 0xaa, 60)); pieplot3d.setNoDataMessage("No data to display"); pieplot3d.setLabelShadowPaint(new Color(0xdddddd)); pieplot3d.setLabelFont(new Font("", Font.PLAIN, 10)); if (m_nType == TYPE_PERCENT) { pieplot3d.setLabelGenerator(new StandardPieItemLabelGenerator("{0} = {2}", NumberFormat.getNumberInstance(), PERCENT_NUMBER_FORMAT)); } fillChartInfo(ds); return jfreechart; }
From source file:org.fhcrc.cpl.viewer.mrm.Utils.java
public static DrawingSupplier plainDrawingSupplier(Color c) { Paint black[] = new Paint[1]; black[0] = c;//from ww w .j a v a2 s. com return new DefaultDrawingSupplier(black, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE); }
From source file:org.xwiki.chart.internal.DrawingSupplierFactory.java
/** * @param parameters the user-defined parameters, containing {@link ChartGenerator#COLORS_PARAM} if the user * wants custom colors/*w w w . jav a 2s . c o m*/ * @return the Drawing Supplier to use */ public DrawingSupplier createDrawingSupplier(Map<String, String> parameters) { DrawingSupplier supplier; String colorParam = parameters.get(ChartGenerator.COLORS_PARAM); if (colorParam != null) { List<Color> colors = new ArrayList<Color>(); for (String colorAsString : colorParam.split(",")) { if (colorAsString.length() == 6) { int red = Integer.parseInt(colorAsString.substring(0, 2), 16); int green = Integer.parseInt(colorAsString.substring(2, 4), 16); int blue = Integer.parseInt(colorAsString.substring(4, 6), 16); colors.add(new Color(red, green, blue)); } } Paint[] paint = new Paint[colors.size()]; int i = 0; for (Color color : colors) { paint[i++] = color; } supplier = new DefaultDrawingSupplier(paint, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE); } else { supplier = new DefaultDrawingSupplier(); } return supplier; }
From source file:com.pureinfo.srm.reports.impl.CategoryChartBuilder.java
/** * @see com.pureinfo.srm.reports.IChartBuilder#buildChart(java.util.List, * int, java.lang.String)/*from www .ja v a 2s .com*/ */ public JFreeChart buildChart() { CategoryDataset dataset = createDataset(); JFreeChart jfreechart = MyChartFactory.createBarChart3D(null, m_sXAxisName, m_sYXxisName, dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot categoryplot = jfreechart.getCategoryPlot(); jfreechart.setBackgroundPaint(Color.white); categoryplot.setDomainGridlinesVisible(false); categoryplot.setRangeGridlinesVisible(true); categoryplot.setForegroundAlpha(0.8f); categoryplot.setDrawingSupplier(new DefaultDrawingSupplier(MyPaintMgr.getPaints(), DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); CategoryAxis categoryAxisX = categoryplot.getDomainAxis(); categoryAxisX.setTickLabelsVisible(true); categoryAxisX.setLabel(null); categoryAxisX.setMaximumCategoryLabelWidthRatio(.8f); ValueAxis categoryAxisY = categoryplot.getRangeAxis(); categoryAxisY.setVerticalTickLabels(false); // categoryplot.setDrawSharedDomainAxis(false); categoryAxisX.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(0.39269908169872414D)); BarRenderer3D barrenderer3d = (BarRenderer3D) categoryplot.getRenderer(); barrenderer3d.setDrawBarOutline(false); barrenderer3d.setItemLabelsVisible(true); barrenderer3d.setBaseItemLabelsVisible(false); barrenderer3d.setSeriesVisible(Boolean.FALSE); //CategoryPlot categoryPlot = jfreechart.getCategoryPlot(); // categoryPlot.setBackgroundPaint(Color.lightGray); // categoryPlot.setDomainGridlinePaint(Color.white); // categoryPlot.setRangeGridlinePaint(Color.white); // // BarRenderer barRenderer = (BarRenderer) categoryPlot.getRenderer(); // barRenderer.setDrawBarOutline(false); // barRenderer.setMaxBarWidth(0.03); // GradientPaint gradientPaint = new GradientPaint(0.0F, 0.0F, // Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); // barRenderer.setSeriesPaint(0, gradientPaint); DecimalFormat format = null; if (m_dblMaxData > 1) { format = new DecimalFormat("#,###"); } else { StringBuffer sb = new StringBuffer(); sb.append("0.00#"); for (double i = m_dblMaxData; i != 0 && i < 1; i *= 10f) { sb.append("#"); } format = new DecimalFormat(sb.toString()); } fillChartInfo(dataset, format); barrenderer3d.setMaxBarWidth(8.0 / m_ChartInfo.getChartSize().x); NumberAxis numberAxis = (NumberAxis) categoryplot.getRangeAxis(0); numberAxis.setUpperMargin(0.149999999999D); numberAxis.setNumberFormatOverride(format); categoryAxisX.setCategoryLabelPositions(CategoryLabelPositions.UP_45); NumberAxis dataNumberAxis = (NumberAxis) categoryplot.getRangeAxisForDataset(0); dataNumberAxis.setUpperMargin(0.149999999999D); dataNumberAxis.setNumberFormatOverride(format); // CategoryItemRenderer renderer = categoryPlot.getRenderer(); // CategoryItemLabelGenerator generator = new StandardCategoryItemLabelGenerator("{2}", format); // renderer.setItemLabelGenerator(generator); // renderer.setItemLabelFont(new Font("Serif", 0, 9)); // renderer.setItemLabelsVisible(true); return jfreechart; }
From source file:gavisualizer.LineChart.java
@Override public void generate() { // Creates Line Chart from variables JFreeChart chart = ChartFactory.createLineChart(_title, // chart title _axisLabelDomain, // domain axis label _axisLabelRange, // range axis label _dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend false, // tooltips false // urls );/*from w ww .java 2 s. c om*/ // Set the Plot to certain colors final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); plot.setOutlinePaint(Color.white); // Set Legend to the right of the chart final LegendTitle lt = (LegendTitle) chart.getLegend(); lt.setPosition(RectangleEdge.RIGHT); // Set paints for lines in the chart LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); DefaultDrawingSupplier dw = new DefaultDrawingSupplier(PAINTS, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE); plot.setDrawingSupplier(dw); // Customize stroke width of the series ((AbstractRenderer) renderer).setAutoPopulateSeriesStroke(false); renderer.setBaseStroke(STROKE_WIDTH); renderer.setBaseShapesVisible(false); // Include dashed lines if necessary List<String> rows = _dataset.getRowKeys(); // See if the title includes Downloads (Dashed lines are for Download lines) if (rows.get(rows.size() - 1).endsWith("Downloads")) { // Set the start to half the rows int start = _dataset.getRowCount() / 2; // Create an initial value int init = 0; // Iterate through the Download lines while (start < _dataset.getRowCount()) { // Make sure series and legend have dashes renderer.setSeriesStroke(start, DASHED_STROKE); LegendItemCollection legend = renderer.getLegendItems(); LegendItem li = legend.get(start - 1); li.setLineStroke(DASHED_STROKE); // Make sure the color matches the undashed year renderer.setSeriesPaint(start, renderer.getItemPaint(init, 0)); init++; start++; } } // Customise the range axis... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); _chart = chart; }
From source file:com.bitplan.vzjava.Plot.java
/** * Creates a chart./*from ww w. ja va 2 s. co m*/ * * @param dataset * a dataset. * * @return A chart. */ private JFreeChart createChart(final ColoredDataSet cdataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart(title, "Time", "Power", cdataset.dataSet, true, true, false); chart.setBackgroundPaint(Color.white); // final StandardLegend sl = (StandardLegend) chart.getLegend(); // sl.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); // plot.setOutlinePaint(null); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(false); final XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { renderer.setSeriesStroke(0, new BasicStroke(3.0f)); renderer.setSeriesStroke(1, new BasicStroke(3.0f)); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm")); // http://www.jfree.org/jfreechart/api/gjdoc/org/jfree/chart/plot/DefaultDrawingSupplier-source.html DrawingSupplier supplier = new DefaultDrawingSupplier(cdataset.paintSequence, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE); chart.getPlot().setDrawingSupplier(supplier); return chart; }
From source file:com.sun.japex.report.ChartGenerator.java
static protected void configureLineChart(JFreeChart chart) { CategoryPlot plot = chart.getCategoryPlot(); final DrawingSupplier supplier = new DefaultDrawingSupplier(DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, // Draw a small diamond new Shape[] { new Polygon(new int[] { 3, 0, -3, 0 }, new int[] { 0, 3, 0, -3 }, 4) }); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); plot.setDrawingSupplier(supplier);/*from w ww .j a va 2s .com*/ LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setStroke(new BasicStroke(2.0f)); CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); }
From source file:org.jfree.chart.demo.LineChartDemo5.java
/** * Creates a sample chart./*from ww w . j a va2s .co m*/ * * @param dataset the dataset. * * @return a chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createLineChart("Line Chart Demo 5", // chart title "Type", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); final Shape[] shapes = new Shape[3]; int[] xpoints; int[] ypoints; // right-pointing triangle xpoints = new int[] { -3, 3, -3 }; ypoints = new int[] { -3, 0, 3 }; shapes[0] = new Polygon(xpoints, ypoints, 3); // vertical rectangle shapes[1] = new Rectangle2D.Double(-2, -3, 3, 6); // left-pointing triangle xpoints = new int[] { -3, 3, 3 }; ypoints = new int[] { 0, -3, 3 }; shapes[2] = new Polygon(xpoints, ypoints, 3); final DrawingSupplier supplier = new DefaultDrawingSupplier(DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, shapes); final CategoryPlot plot = chart.getCategoryPlot(); plot.setDrawingSupplier(supplier); chart.setBackgroundPaint(Color.yellow); // set the stroke for each series... plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f)); plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 6.0f }, 0.0f)); plot.getRenderer().setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f)); // customise the renderer... final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); // renderer.setDrawShapes(true); renderer.setItemLabelsVisible(true); // renderer.setLabelGenerator(new StandardCategoryLabelGenerator()); // customise the range axis... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0.12); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.LineChartDemo5.java
/** * Creates a sample chart.// ww w .ja va2 s. c o m * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createLineChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation !legendPanelOn, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); Shape[] shapes = new Shape[3]; int[] xpoints; int[] ypoints; // right-pointing triangle xpoints = new int[] { -3, 3, -3 }; ypoints = new int[] { -3, 0, 3 }; shapes[0] = new Polygon(xpoints, ypoints, 3); // vertical rectangle shapes[1] = new Rectangle2D.Double(-2, -3, 3, 6); // left-pointing triangle xpoints = new int[] { -3, 3, 3 }; ypoints = new int[] { 0, -3, 3 }; shapes[2] = new Polygon(xpoints, ypoints, 3); DrawingSupplier supplier = new DefaultDrawingSupplier(DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, shapes); CategoryPlot plot = chart.getCategoryPlot(); plot.setOrientation(PlotOrientation.HORIZONTAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDrawingSupplier(supplier); // set the stroke for each series... plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f)); plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 6.0f }, 0.0f)); plot.getRenderer().setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f)); // customise the renderer... LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0.12); setCategorySummary(dataset); return chart; }
From source file:net.sf.mzmine.chartbasics.chartthemes.ChartThemeFactory.java
/** * Creates and returns a theme called "Darkness". In this theme, the charts have a black * background and white lines and labels * * @return The "Darkness" theme.//from w w w. ja v a2 s. c o m */ public static EStandardChartTheme createDarknessTheme() { EStandardChartTheme theme = new EStandardChartTheme(THEME.DARKNESS, "Darkness"); // Fonts theme.setExtraLargeFont(new Font("Arial", Font.BOLD, 20)); theme.setLargeFont(new Font("Arial", Font.BOLD, 11)); theme.setRegularFont(new Font("Arial", Font.PLAIN, 11)); theme.setSmallFont(new Font("Arial", Font.PLAIN, 11)); // theme.setTitlePaint(Color.white); theme.setSubtitlePaint(Color.white); theme.setLegendBackgroundPaint(Color.black); theme.setLegendItemPaint(Color.white); theme.setChartBackgroundPaint(Color.black); theme.setPlotBackgroundPaint(Color.black); theme.setPlotOutlinePaint(Color.yellow); theme.setBaselinePaint(Color.white); theme.setCrosshairPaint(Color.red); theme.setLabelLinkPaint(Color.lightGray); theme.setTickLabelPaint(Color.white); theme.setAxisLabelPaint(Color.white); theme.setShadowPaint(Color.darkGray); theme.setItemLabelPaint(Color.white); theme.setDrawingSupplier(new DefaultDrawingSupplier( new Paint[] { Color.WHITE, Color.decode("0xFFFF00"), Color.decode("0x0036CC"), Color.decode("0xFF0000"), Color.decode("0xFFFF7F"), Color.decode("0x6681CC"), Color.decode("0xFF7F7F"), Color.decode("0xFFFFBF"), Color.decode("0x99A6CC"), Color.decode("0xFFBFBF"), Color.decode("0xA9A938"), Color.decode("0x2D4587") }, new Paint[] { Color.decode("0xFFFF00"), Color.decode("0x0036CC") }, new Stroke[] { new BasicStroke(2.0f) }, new Stroke[] { new BasicStroke(0.5f) }, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); theme.setErrorIndicatorPaint(Color.lightGray); theme.setGridBandPaint(new Color(255, 255, 255, 20)); theme.setGridBandAlternatePaint(new Color(255, 255, 255, 40)); // axis Color transp = new Color(255, 255, 255, 200); theme.setRangeGridlinePaint(transp); theme.setDomainGridlinePaint(transp); theme.setAxisLinePaint(Color.white); theme.setMasterFontColor(Color.WHITE); // axis offset theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); return theme; }