List of usage examples for org.jfree.chart.plot XYPlot getSeriesCount
public int getSeriesCount()
From source file:net.sf.maltcms.common.charts.api.ChartCustomizer.java
/** * * @param plot// w w w. jav a 2 s . co m * @param s */ public static void setSeriesShapes(XYPlot plot, Shape s) { XYItemRenderer renderer = plot.getRenderer(); int series = plot.getSeriesCount(); for (int i = 0; i < series; i++) { renderer.setSeriesShape(i, s); } }
From source file:net.sf.maltcms.chromaui.charts.ChartCustomizer.java
/** * * @param plot//w ww . j a v a 2s . c o m * @param alpha */ public static void setSeriesColors(XYPlot plot, float alpha) { XYItemRenderer renderer = plot.getRenderer(); int series = plot.getSeriesCount(); for (int i = 0; i < series; i++) { renderer.setSeriesPaint(i, withAlpha(plotColors[i % plotColors.length], alpha)); } }
From source file:net.sf.maltcms.chromaui.charts.ChartCustomizer.java
/** * * @param plot/*from w ww . jav a 2s. co m*/ * @param width */ public static void setSeriesStrokes(XYPlot plot, float width) { XYItemRenderer renderer = plot.getRenderer(); int series = plot.getSeriesCount(); for (int i = 0; i < series; i++) { renderer.setSeriesStroke(i, new BasicStroke(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); } }
From source file:org.eobjects.datacleaner.util.ChartUtils.java
public static void applyStyles(JFreeChart chart) { TextTitle title = chart.getTitle();//from ww w. ja v a2 s . co m if (title != null) { title.setFont(WidgetUtils.FONT_HEADER1); title.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); } for (int i = 0; i < chart.getSubtitleCount(); i++) { Title subtitle = chart.getSubtitle(i); if (subtitle instanceof TextTitle) { ((TextTitle) subtitle).setFont(WidgetUtils.FONT_NORMAL); } } LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setItemFont(WidgetUtils.FONT_SMALL); } // transparent background chart.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); chart.setBorderVisible(false); final Plot plot = chart.getPlot(); plot.setInsets(new RectangleInsets(UnitType.ABSOLUTE, 0d, 0d, 0d, 0d)); plot.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); plot.setOutlinePaint(WidgetUtils.BG_COLOR_BRIGHTEST); plot.setOutlineVisible(true); if (plot instanceof PiePlot) { // tweaks for pie charts final PiePlot piePlot = (PiePlot) plot; piePlot.setBaseSectionOutlinePaint(WidgetUtils.BG_COLOR_DARK); piePlot.setBaseSectionOutlineStroke(normalStroke); piePlot.setLabelFont(WidgetUtils.FONT_SMALL); piePlot.setLabelBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHT); piePlot.setLabelOutlineStroke(normalStroke); piePlot.setLabelPaint(WidgetUtils.BG_COLOR_DARK); piePlot.setSectionOutlinesVisible(false); piePlot.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE); } else if (plot instanceof CategoryPlot) { // tweaks for bar charts final CategoryPlot categoryPlot = (CategoryPlot) plot; int columnCount = categoryPlot.getDataset().getColumnCount(); if (columnCount > 1) { categoryPlot.setDomainGridlinesVisible(true); } else { categoryPlot.setDomainGridlinesVisible(false); } categoryPlot.setDomainGridlinePaint(WidgetUtils.BG_COLOR_DARK); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.setDrawingSupplier(new DCDrawingSupplier()); final CategoryItemRenderer renderer = categoryPlot.getRenderer(); renderer.setBaseOutlinePaint(WidgetUtils.BG_COLOR_DARK); renderer.setBaseOutlineStroke(wideStroke); if (renderer instanceof BarRenderer) { BarRenderer barRenderer = (BarRenderer) renderer; barRenderer.setShadowPaint(WidgetUtils.BG_COLOR_BRIGHT); barRenderer.setBarPainter(new StandardBarPainter()); } } else if (plot instanceof XYPlot) { // tweaks for line charts final XYPlot xyPlot = (XYPlot) plot; xyPlot.setDrawingSupplier(new DCDrawingSupplier()); xyPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); final XYItemRenderer renderer = xyPlot.getRenderer(); final int seriesCount = xyPlot.getSeriesCount(); for (int i = 0; i < seriesCount; i++) { renderer.setSeriesStroke(i, wideStroke); } } }
From source file:org.datacleaner.util.ChartUtils.java
public static void applyStyles(JFreeChart chart) { TextTitle title = chart.getTitle();// w w w .j a v a 2s. com if (title != null) { title.setFont(WidgetUtils.FONT_HEADER1); title.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); } for (int i = 0; i < chart.getSubtitleCount(); i++) { Title subtitle = chart.getSubtitle(i); if (subtitle instanceof TextTitle) { ((TextTitle) subtitle).setFont(WidgetUtils.FONT_NORMAL); } } LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setItemFont(WidgetUtils.FONT_SMALL); } // transparent background chart.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); chart.setBorderVisible(false); final Plot plot = chart.getPlot(); plot.setInsets(new RectangleInsets(UnitType.ABSOLUTE, 0d, 0d, 0d, 0d)); plot.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); plot.setOutlinePaint(WidgetUtils.BG_COLOR_BRIGHTEST); plot.setOutlineVisible(true); if (plot instanceof PiePlot) { // tweaks for pie charts final PiePlot piePlot = (PiePlot) plot; piePlot.setBaseSectionOutlinePaint(WidgetUtils.BG_COLOR_DARK); piePlot.setBaseSectionOutlineStroke(STROKE_NORMAL); piePlot.setLabelFont(WidgetUtils.FONT_SMALL); piePlot.setLabelBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHT); piePlot.setLabelOutlineStroke(STROKE_NORMAL); piePlot.setLabelPaint(WidgetUtils.BG_COLOR_DARK); piePlot.setSectionOutlinesVisible(false); piePlot.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE); piePlot.setDrawingSupplier(new DCDrawingSupplier()); } else if (plot instanceof CategoryPlot) { // tweaks for bar charts final CategoryPlot categoryPlot = (CategoryPlot) plot; int columnCount = categoryPlot.getDataset().getColumnCount(); if (columnCount > 1) { categoryPlot.setDomainGridlinesVisible(true); } else { categoryPlot.setDomainGridlinesVisible(false); } categoryPlot.setDomainGridlinePaint(WidgetUtils.BG_COLOR_DARK); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.setDrawingSupplier(new DCDrawingSupplier()); final CategoryItemRenderer renderer = categoryPlot.getRenderer(); renderer.setBaseOutlinePaint(WidgetUtils.BG_COLOR_DARK); renderer.setBaseOutlineStroke(STROKE_WIDE); if (renderer instanceof BarRenderer) { BarRenderer barRenderer = (BarRenderer) renderer; barRenderer.setShadowPaint(WidgetUtils.BG_COLOR_BRIGHT); barRenderer.setBarPainter(new StandardBarPainter()); } } else if (plot instanceof XYPlot) { // tweaks for line charts final XYPlot xyPlot = (XYPlot) plot; xyPlot.setDrawingSupplier(new DCDrawingSupplier()); xyPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); final XYItemRenderer renderer = xyPlot.getRenderer(); final int seriesCount = xyPlot.getSeriesCount(); for (int i = 0; i < seriesCount; i++) { renderer.setSeriesStroke(i, STROKE_WIDE); } } }
From source file:ec.ui.chart.RevisionChartPanel.java
@Override protected void onColorSchemeChange() { refRenderer.setBasePaint(themeSupport.getLineColor(ColorScheme.KnownColor.RED)); seriesRenderer.setBasePaint(themeSupport.getLineColor(ColorScheme.KnownColor.BLUE)); XYPlot mainPlot = panel.getChart().getXYPlot(); for (int i = 0; i < mainPlot.getSeriesCount(); i++) { seriesRenderer.setSeriesPaint(i, themeSupport.getLineColor(ColorScheme.KnownColor.BLUE)); }/*from w w w . ja v a 2 s .com*/ mainPlot.setBackgroundPaint(themeSupport.getPlotColor()); mainPlot.setDomainGridlinePaint(themeSupport.getGridColor()); mainPlot.setRangeGridlinePaint(themeSupport.getGridColor()); panel.getChart().setBackgroundPaint(themeSupport.getBackColor()); }
From source file:org.jgrasstools.gears.utils.chart.Scatter.java
private void setShapeLinesVisibility(XYPlot plot) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); int seriesCount = plot.getSeriesCount(); for (int i = 0; i < seriesCount; i++) { renderer.setSeriesShapesVisible(i, showShapes); renderer.setSeriesLinesVisible(i, showLines); }//from w w w. j a v a 2 s . c o m }
From source file:org.xapagy.ui.tempdyn.GraphEvolution.java
/** * Creates a chart the style we like./* ww w .j a v a 2 s . co m*/ * * @param chart */ public static void setChartProperties(JFreeChart chart, List<SimpleEntry<Color, Stroke>> lineStyles) { // set the background and title font chart.setBackgroundPaint(Color.white); chart.getTitle().setFont(new Font("Tahoma", Font.BOLD, 14)); // set the background and the grid all white XYPlot plot = chart.getXYPlot(); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setBackgroundPaint(Color.white); // now plot.setOutlineStroke(null); XYItemRenderer rend = plot.getRenderer(); Stroke stroke = new BasicStroke(2.0f); rend.setBaseStroke(stroke); // rend.setDrawSeriesLineAsPath(true); // stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, // BasicStroke.JOIN_ROUND, 10, new float[] {10, 10}, 0); // strokes.add(stroke); // stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, // BasicStroke.JOIN_ROUND, 10, new float[] {2, 4}, 0); // strokes.add(stroke); int seriesCount = plot.getSeriesCount(); for (int i = 0; i != seriesCount; i++) { SimpleEntry<Color, Stroke> lineStyle = lineStyles.get(i % lineStyles.size()); rend.setSeriesStroke(i, lineStyle.getValue()); rend.setSeriesPaint(i, lineStyle.getKey()); } }
From source file:net.sf.maltcms.chromaui.charts.events.ChartPanelMouseListener.java
/** * * @param arg0/*from w ww . jav a2 s . com*/ */ @Override public void chartMouseClicked(final ChartMouseEvent arg0) { final ChartPanelMouseListener cpml = this; if (arg0.getEntity() != null) { if (arg0.getEntity() instanceof XYItemEntity) { XYItemEntity xyie = (XYItemEntity) arg0.getEntity(); if (arg0.getTrigger().getButton() == MouseEvent.BUTTON1) { // if (arg0.getTrigger().isAltDown() && arg0.getTrigger().isShiftDown()) { // System.out.println("Item removed"); fireEvent(new XYItemEntityRemovedEvent((XYItemEntity) arg0.getEntity(), cpml)); } else if (arg0.getTrigger().isAltDown()) { // System.out.println("Item added"); fireEvent(new XYItemEntityAddedEvent((XYItemEntity) arg0.getEntity(), cpml)); } else { setTarget(arg0); // System.out.println("Item clicked"); fireEvent(new XYItemEntityClickedEvent((XYItemEntity) arg0.getEntity(), cpml)); } } } else if (arg0.getEntity() instanceof LegendItemEntity) { JPopupMenu jpm = new JPopupMenu(); final LegendItemEntity lie = (LegendItemEntity) arg0.getEntity(); Dataset ds = lie.getDataset(); Comparable skey = lie.getSeriesKey(); Plot plot = arg0.getChart().getPlot(); if (plot instanceof XYPlot) { XYPlot xyplot = arg0.getChart().getXYPlot(); if (xyplot.getSeriesCount() > 1) { XYDataset xyds = (XYDataset) ds; XYItemRenderer xyir = xyplot.getRendererForDataset(xyds); xyir.setSeriesVisible(xyds.indexOf(skey), !xyir.isSeriesVisible(xyds.indexOf(skey))); xyir.setSeriesVisibleInLegend(xyds.indexOf(skey), Boolean.TRUE); } } else if (plot instanceof CategoryPlot) { CategoryPlot cplot = arg0.getChart().getCategoryPlot(); if (cplot.getDatasetCount() > 1) { CategoryDataset cds = (CategoryDataset) ds; CategoryItemRenderer xyir = cplot.getRendererForDataset(cds); int seriesIndex = cds.getColumnIndex(skey); if (seriesIndex == -1) { seriesIndex = cds.getRowIndex(skey); } xyir.setSeriesVisible(seriesIndex, !xyir.isSeriesVisible(seriesIndex)); xyir.setSeriesVisibleInLegend(seriesIndex, Boolean.TRUE); } } // AbstractAction hse = new AbstractAction("Hide") { // // @Override // public void actionPerformed(ActionEvent ae) { // // } // }; // AbstractAction hse = new AbstractAction("Show") { // // @Override // public void actionPerformed(ActionEvent ae) { // // } // }; // AbstractAction hse = new AbstractAction("Remove") { // // @Override // public void actionPerformed(ActionEvent ae) { // // } // }; } } }
From source file:com.itemanalysis.jmetrik.swing.GraphPanel.java
/** * This method should be called after a chart dataset is updated. It * will iterate over all XYDatasets and provide the line color and lineStyle. * If it is called before a chart has a dataset, it will not have an effect. * * @param plot/*from w w w . j av a 2 s. c o m*/ */ public void setXYPlotRenderer(XYPlot plot) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); int n = plot.getSeriesCount(); for (int i = 0; i < n; i++) { Stroke stroke = new BasicStroke(lineWidth, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, getLineStyle(i), 0.0f); renderer.setSeriesStroke(i, stroke); renderer.setSeriesPaint(i, getPaintColor(i)); } renderer.setLegendLine(new Line2D.Double(0, 5, 40, 5)); renderer.setBaseShapesFilled(false); renderer.setBaseShapesVisible(showMarkers); renderer.setDrawSeriesLineAsPath(true); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRenderer(renderer); }