Java Code Examples for org.jfree.chart.plot.CategoryPlot#getRenderer()
The following examples show how to use
org.jfree.chart.plot.CategoryPlot#getRenderer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScheduleReport.java From ezScrum with GNU General Public License v2.0 | 6 votes |
private void setAttribute(JFreeChart chart) { // 圖案與文字的間隔 LegendTitle legend = chart.getLegend(); legend.setBorder(1, 1, 1, 1); CategoryPlot plot = chart.getCategoryPlot(); // 設定WorkItem的屬性 CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); // 字體角度 domainAxis.setTickLabelFont(new Font("新細明體", Font.TRUETYPE_FONT, 12)); // 字體 // 設定Date的屬性 DateAxis da = (DateAxis) plot.getRangeAxis(0); setDateAxis(da); // 設定實體的顯示名稱 CategoryItemRenderer render = plot.getRenderer(0); DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); CategoryItemLabelGenerator generator = new IntervalCategoryItemLabelGenerator( "{3} ~ {4}", format); render.setBaseItemLabelGenerator(generator); render.setBaseItemLabelPaint(Color.BLUE); render.setBaseItemLabelsVisible(true); render.setBaseItemLabelFont(new Font("黑體", Font.TRUETYPE_FONT, 8)); render.setSeriesPaint(0, Color.RED); }
Example 2
Source File: AegeanChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected JFreeChart createBar3DChart() throws JRException { JFreeChart jfreeChart = super.createBar3DChart(); CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot(); BarRenderer3D barRenderer3D = (BarRenderer3D)categoryPlot.getRenderer(); barRenderer3D.setItemMargin(0); barRenderer3D.setWallPaint(ChartThemesConstants.TRANSPARENT_PAINT); //categoryPlot.setOrientation(PlotOrientation.HORIZONTAL); CategoryDataset categoryDataset = categoryPlot.getDataset(); if(categoryDataset != null) { for(int i = 0; i < categoryDataset.getRowCount(); i++) { barRenderer3D.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT); } } return jfreeChart; }
Example 3
Source File: BarChartTest.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Check that setting a tool tip generator for a series does override the * default generator. */ @Test public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); }
Example 4
Source File: BarChart3DTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Check that setting a URL generator for a series does override the * default generator. */ public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getURLGenerator(0, 0); assertTrue(url2 == url1); }
Example 5
Source File: BarChart3DTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0, false); assertTrue(tt2 == tt); }
Example 6
Source File: LineChartTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Check that setting a tool tip generator for a series does override the * default generator. */ public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0, false); assertTrue(tt2 == tt); }
Example 7
Source File: LineChartTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Check that setting a tool tip generator for a series does override the * default generator. */ @Test public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertSame(tt2, tt); }
Example 8
Source File: BarChartTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Check that setting a URL generator for a series does override the * default generator. */ public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getURLGenerator(0, 0, false); assertTrue(url2 == url1); }
Example 9
Source File: LineChartTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Check that setting a URL generator for a series does override the * default generator. */ public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getURLGenerator(0, 0); assertTrue(url2 == url1); }
Example 10
Source File: StackedBarChart3DTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Check that setting a URL generator for a series does override the * default generator. */ @Test public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesItemURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); assertTrue(url2 == url1); }
Example 11
Source File: StackedBarChartTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Check that setting a tool tip generator for a series does override the * default generator. */ @Test public void testSetSeriesToolTipGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator(); renderer.setSeriesToolTipGenerator(0, tt); CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); assertTrue(tt2 == tt); }
Example 12
Source File: LineChart3DTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Check that setting a URL generator for a series does override the * default generator. */ public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getURLGenerator(0, 0, false); assertTrue(url2 == url1); }
Example 13
Source File: StackedBarChart3DTest.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Check that setting a URL generator for a series does override the * default generator. */ @Test public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesItemURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); assertTrue(url2 == url1); }
Example 14
Source File: BarChartBuilder.java From nmonvisualizer with Apache License 2.0 | 5 votes |
@Override protected void formatChart() { super.formatChart(); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.getDomainAxis().setLabel(definition.getCategoryAxisLabel()); plot.getRangeAxis().setLabel(definition.getYAxisLabel()); if (definition.hasSecondaryYAxis()) { plot.getRangeAxis(1).setLabel(definition.getSecondaryYAxisLabel()); } if (definition.usePercentYAxis()) { setPercentYAxis(); } for (int i = 0; i < plot.getRendererCount(); i++) { BarRenderer renderer = (BarRenderer) plot.getRenderer(i); formatter.formatRenderer(renderer); renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("{1} {0} - {2} ({3})", Styles.NUMBER_FORMAT)); } plot.getDomainAxis().setCategoryMargin(0.15d); plot.getDomainAxis().setTickMarksVisible(false); // position of first bar start and last bar end // 1.5% of the chart area within the axis will be blank space on each end plot.getDomainAxis().setLowerMargin(.015); plot.getDomainAxis().setUpperMargin(.015); }
Example 15
Source File: LineChartTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Check that setting a URL generator for a series does override the * default generator. */ public void testSetSeriesURLGenerator() { CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator(); renderer.setSeriesURLGenerator(0, url1); CategoryURLGenerator url2 = renderer.getURLGenerator(0, 0, false); assertTrue(url2 == url1); }
Example 16
Source File: ChartJFreeChartOutputHistogram.java From gama with GNU General Public License v3.0 | 4 votes |
protected void resetRenderer(final IScope scope, final String serieid) { // AbstractCategoryItemRenderer // newr=(AbstractCategoryItemRenderer)this.getOrCreateRenderer(scope, // serieid); final CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); final AbstractCategoryItemRenderer newr = (AbstractCategoryItemRenderer) plot.getRenderer(); // if // (serieid!=this.getChartdataset().series.keySet().iterator().next()) // newr=(AbstractCategoryItemRenderer)this.getOrCreateRenderer(scope, // serieid); final ChartDataSeries myserie = this.getChartdataset().getDataSeries(scope, serieid); if (!IdPosition.containsKey(serieid)) { // DEBUG.LOG("pb!!!"); } else { final int myrow = IdPosition.get(serieid); if (myserie.getMycolor() != null) { newr.setSeriesPaint(myrow, myserie.getMycolor()); } if (this.series_label_position.equals("onchart")) { // ((BarRenderer)newr).setBaseItemLabelGenerator(new // LabelGenerator()); newr.setDefaultItemLabelGenerator(new LabelGenerator()); final ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); newr.setDefaultPositiveItemLabelPosition(itemlabelposition); newr.setDefaultNegativeItemLabelPosition(itemlabelposition); newr.setDefaultItemLabelsVisible(true); } if (newr instanceof BarRenderer) { if (gap >= 0) { ((BarRenderer) newr).setMaximumBarWidth(1 - gap); } } } }
Example 17
Source File: CategoryAxis3D.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (<code>null</code> not permitted). * @param cursor the cursor location. * @param plotArea the area within which the axis should be drawn * (<code>null</code> not permitted). * @param dataArea the area within which the plot is being drawn * (<code>null</code> not permitted). * @param edge the location of the axis (<code>null</code> not permitted). * @param plotState collects information about the plot (<code>null</code> * permitted). * * @return The axis state (never <code>null</code>). */ @Override public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { // if the axis is not visible, don't draw it... if (!isVisible()) { return new AxisState(cursor); } // calculate the adjusted data area taking into account the 3D effect... // this assumes that there is a 3D renderer, all this 3D effect is a // bit of an ugly hack... CategoryPlot plot = (CategoryPlot) getPlot(); Rectangle2D adjustedDataArea = new Rectangle2D.Double(); if (plot.getRenderer() instanceof Effect3D) { Effect3D e3D = (Effect3D) plot.getRenderer(); double adjustedX = dataArea.getMinX(); double adjustedY = dataArea.getMinY(); double adjustedW = dataArea.getWidth() - e3D.getXOffset(); double adjustedH = dataArea.getHeight() - e3D.getYOffset(); if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) { adjustedY += e3D.getYOffset(); } else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) { adjustedX += e3D.getXOffset(); } adjustedDataArea.setRect(adjustedX, adjustedY, adjustedW, adjustedH); } else { adjustedDataArea.setRect(dataArea); } if (isAxisLineVisible()) { drawAxisLine(g2, cursor, adjustedDataArea, edge); } // draw the category labels and axis label AxisState state = new AxisState(cursor); if (isTickMarksVisible()) { drawTickMarks(g2, cursor, adjustedDataArea, edge, state); } state = drawCategoryLabels(g2, plotArea, adjustedDataArea, edge, state, plotState); if (getAttributedLabel() != null) { state = drawAttributedLabel(getAttributedLabel(), g2, plotArea, dataArea, edge, state); } else { state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); } return state; }
Example 18
Source File: CategoryAxis3D.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * Returns the Java 2D coordinate for a category. * * @param anchor the anchor point. * @param category the category index. * @param categoryCount the category count. * @param area the data area. * @param edge the location of the axis. * * @return The coordinate. */ @Override public double getCategoryJava2DCoordinate(CategoryAnchor anchor, int category, int categoryCount, Rectangle2D area, RectangleEdge edge) { double result = 0.0; Rectangle2D adjustedArea = area; CategoryPlot plot = (CategoryPlot) getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); if (renderer instanceof Effect3D) { Effect3D e3D = (Effect3D) renderer; double adjustedX = area.getMinX(); double adjustedY = area.getMinY(); double adjustedW = area.getWidth() - e3D.getXOffset(); double adjustedH = area.getHeight() - e3D.getYOffset(); if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) { adjustedY += e3D.getYOffset(); } else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) { adjustedX += e3D.getXOffset(); } adjustedArea = new Rectangle2D.Double(adjustedX, adjustedY, adjustedW, adjustedH); } if (anchor == CategoryAnchor.START) { result = getCategoryStart(category, categoryCount, adjustedArea, edge); } else if (anchor == CategoryAnchor.MIDDLE) { result = getCategoryMiddle(category, categoryCount, adjustedArea, edge); } else if (anchor == CategoryAnchor.END) { result = getCategoryEnd(category, categoryCount, adjustedArea, edge); } return result; }
Example 19
Source File: ParetoChartPlotter.java From rapidminer-studio with GNU Affero General Public License v3.0 | 4 votes |
public void paintParetoChart(Graphics graphics) { prepareData(); JFreeChart chart = createChart(); if (chart != null) { // set the background color for the chart... chart.setBackgroundPaint(Color.white); chart.getPlot().setBackgroundPaint(Color.WHITE); // bar renderer --> own 3D effect CategoryPlot plot = chart.getCategoryPlot(); BarRenderer renderer = (BarRenderer) plot.getRenderer(); // renderer.setBarPainter(new StandardBarPainter()); renderer.setBarPainter(new RapidBarPainter()); renderer.setSeriesPaint(0, getColorProvider(true).getPointColor(1)); // labels on top of bars Map<String, String> barItemLabels = new HashMap<>(); Map<String, String> cumulativeItemLabels = new HashMap<>(); int groupSum = 0; int totalSum = 0; for (Object key : totalData.getKeys()) { String k = (String) key; try { Number groupValue = data.getValue(k); Number totalValue = totalData.getValue(k); groupSum += groupValue.intValue(); totalSum += totalValue.intValue(); barItemLabels.put( k, Tools.formatIntegerIfPossible(groupValue.doubleValue()) + " / " + Tools.formatIntegerIfPossible(totalValue.doubleValue())); cumulativeItemLabels.put(k, groupSum + " / " + totalSum); } catch (UnknownKeyException e) { // do nothing } } renderer.setSeriesItemLabelFont(0, LABEL_FONT); if (showBarLabelsFlag) { renderer.setSeriesItemLabelsVisible(0, true); renderer.setSeriesItemLabelGenerator(0, new ParetoChartItemLabelGenerator(barItemLabels)); if (isLabelRotating()) { renderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, -Math.PI / 2.0d)); renderer.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, -Math.PI / 2.0d)); } } LineAndShapeRenderer renderer2 = (LineAndShapeRenderer) chart.getCategoryPlot().getRenderer(1); renderer2.setSeriesPaint(0, Color.GRAY.darker().darker()); renderer2.setSeriesItemLabelFont(0, LABEL_FONT); renderer2.setSeriesItemLabelPaint(0, Color.BLACK); if (isLabelRotating()) { renderer2.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, -Math.PI / 2.0d)); renderer2.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, -Math.PI / 2.0d)); } else { renderer2.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE10, TextAnchor.BOTTOM_RIGHT)); renderer2.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.OUTSIDE10, TextAnchor.BOTTOM_RIGHT)); } if (showCumulativeLabelsFlag) { renderer2.setSeriesItemLabelsVisible(0, true); renderer2.setSeriesItemLabelGenerator(0, new ParetoChartItemLabelGenerator(cumulativeItemLabels)); } // draw outlines renderer.setDrawBarOutline(true); // gridline colors plot.setRangeGridlinePaint(Color.BLACK); // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); legend.setItemFont(LABEL_FONT); } Rectangle2D drawRect = new Rectangle2D.Double(0, 0, getWidth(), getHeight()); chart.draw((Graphics2D) graphics, drawRect); } }
Example 20
Source File: NumberAxisTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * A check for the interaction between the 'autoRangeIncludesZero' flag * and the base setting in the BarRenderer. */ public void testAutoRange4() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createBarChart("Test", "Categories", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); BarRenderer br = (BarRenderer) plot.getRenderer(); br.setIncludeBaseInRange(false); assertEquals(95.0, axis.getLowerBound(), EPSILON); assertEquals(205.0, axis.getUpperBound(), EPSILON); br.setIncludeBaseInRange(true); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(210.0, axis.getUpperBound(), EPSILON); axis.setAutoRangeIncludesZero(true); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(210.0, axis.getUpperBound(), EPSILON); br.setIncludeBaseInRange(true); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(210.0, axis.getUpperBound(), EPSILON); // now replacing the dataset should update the axis range... DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(900.0, "Row 1", "Column 1"); dataset2.setValue(1000.0, "Row 1", "Column 2"); plot.setDataset(dataset2); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(1050.0, axis.getUpperBound(), EPSILON); br.setIncludeBaseInRange(false); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(1050.0, axis.getUpperBound(), EPSILON); axis.setAutoRangeIncludesZero(false); assertEquals(895.0, axis.getLowerBound(), EPSILON); assertEquals(1005.0, axis.getUpperBound(), EPSILON); }