List of usage examples for org.jfree.chart.plot CategoryPlot addDomainMarker
public void addDomainMarker(CategoryMarker marker, Layer layer)
From source file:org.jfree.chart.demo.CategoryMarkerDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createLineChart("Category Marker Demo 1", "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.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setBaseFillPaint(Color.white); CategoryMarker categorymarker = new CategoryMarker("Category 4", Color.blue, new BasicStroke(1.0F)); categorymarker.setDrawAsLine(true);/*from w w w .j a v a 2 s .c o m*/ categorymarker.setLabel("Marker Label"); categorymarker.setLabelFont(new Font("Dialog", 0, 11)); categorymarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); categorymarker.setLabelOffset(new RectangleInsets(2D, 5D, 2D, 5D)); categoryplot.addDomainMarker(categorymarker, Layer.BACKGROUND); return jfreechart; }
From source file:org.jfree.chart.demo.CategoryMarkerDemo2.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createLineChart("Category Marker Demo 2", "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.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setBaseFillPaint(Color.white); CategoryMarker categorymarker = new CategoryMarker("Category 4", new Color(0, 0, 255, 25), new BasicStroke(1.0F)); categorymarker.setDrawAsLine(false); categorymarker.setAlpha(1.0F);//from www . j ava 2s .co m categorymarker.setLabel("Marker Label"); categorymarker.setLabelFont(new Font("Dialog", 0, 11)); categorymarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); categorymarker.setLabelOffset(new RectangleInsets(2D, 5D, 2D, 5D)); categoryplot.addDomainMarker(categorymarker, Layer.BACKGROUND); return jfreechart; }
From source file:org.pau.assetmanager.viewmodel.chart.PrepareChart.java
public static void prepareJFreeBarChart(JFreeChart jfchart, List<PropertyBook> listOfPropertties, CategoryDataset categoryModel) { CategoryPlot categoryPlot = ((CategoryPlot) jfchart.getPlot()); categoryPlot.getRangeAxis().resizeRange(1.2); categoryPlot.setBackgroundPaint(Color.WHITE); categoryPlot.setDomainGridlinePaint(Color.WHITE); categoryPlot.setRangeMinorGridlinePaint(Color.WHITE); categoryPlot.setRangeGridlinePaint(Color.BLACK); BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer(); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setBaseItemLabelsVisible(false); for (int i = 0; i < listOfPropertties.size(); i++) { renderer.setSeriesStroke(i, new BasicStroke(1)); }//from w w w. j av a 2 s .c om for (int i = 0; i < categoryModel.getColumnKeys().size(); i++) { String label = (String) categoryModel.getColumnKey(i); CategoryMarker marker = new CategoryMarker(label); marker.setLabel(""); marker.setPaint(Color.cyan); marker.setOutlinePaint(Color.cyan); marker.setAlpha(0.1f); marker.setLabelAnchor(RectangleAnchor.TOP); marker.setLabelTextAnchor(TextAnchor.TOP_CENTER); marker.setLabelOffsetType(LengthAdjustmentType.CONTRACT); categoryPlot.addDomainMarker(marker, Layer.BACKGROUND); } renderer.setDrawBarOutline(false); renderer.setShadowVisible(false); renderer.setItemMargin(.1); renderer.setBarPainter(new StandardBarPainter()); }
From source file:org.openfaces.component.chart.impl.configuration.charts.GridChartConfigurator.java
protected void initMarkers(Chart chart, CategoryPlot categoryPlot) { final GridChartView chartView = (GridChartView) chart.getChartView(); final List<Marker> domainMarkers = collectMarkers(chartView, DomainMarkers.class); final List<Marker> rangeMarkers = collectMarkers(chartView, RangeMarkers.class); for (Marker marker : domainMarkers) { org.jfree.chart.plot.Marker domainMarker = initCategoryMarker(marker); if (domainMarker != null) { categoryPlot.addDomainMarker((CategoryMarker) domainMarker, getMarkerLayer(marker)); }//from www . ja v a 2 s . c o m } for (Marker marker : rangeMarkers) { org.jfree.chart.plot.Marker rangeMarker = initMarker(marker); if (rangeMarker != null) { categoryPlot.addRangeMarker(rangeMarker, getMarkerLayer(marker)); } } }
From source file:edu.ucla.stat.SOCR.chart.demo.BarChartDemo3.java
/** * Creates a sample chart./*ww w . j ava 2 s. c o m*/ * * @param dataset the dataset. * * @return a sample chart. */ protected JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation !legendPanelOn, // include legend true, false); chart.setBackgroundPaint(Color.lightGray); // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setNoDataMessage("NO DATA!"); CategoryItemRenderer renderer = new CustomBarRenderer(new Paint[] { Color.red, Color.blue, Color.green, Color.yellow, Color.orange, Color.cyan, Color.magenta, Color.blue }); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setBaseItemLabelsVisible(true); ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, 45.0); renderer.setBasePositiveItemLabelPosition(p); plot.setRenderer(renderer); CategoryMarker marker = new CategoryMarker("Category 3"); marker.setLabel("Special"); marker.setPaint(new Color(0xDD, 0xFF, 0xDD, 0x80)); marker.setAlpha(0.5f); marker.setLabelAnchor(RectangleAnchor.TOP_LEFT); marker.setLabelTextAnchor(TextAnchor.TOP_LEFT); marker.setLabelOffsetType(LengthAdjustmentType.CONTRACT); plot.addDomainMarker(marker, Layer.BACKGROUND); // change the margin at the top of the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLowerMargin(0.15); rangeAxis.setUpperMargin(0.15); BarRenderer seriesRenderer = (BarRenderer) plot.getRenderer(); seriesRenderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); setCategorySummary(dataset); return chart; }
From source file:org.pau.assetmanager.viewmodel.chart.PrepareChart.java
public static void preparePropertiesVsOwnAllPropertiesJFreeChart(JFreeChart jfchart, CategoryDataset categoryModel) { CategoryPlot categoryPlot = ((CategoryPlot) jfchart.getPlot()); categoryPlot.getRangeAxis().resizeRange(1.2); categoryPlot.setBackgroundPaint(Color.WHITE); categoryPlot.setDomainGridlinePaint(Color.WHITE); categoryPlot.setRangeMinorGridlinePaint(Color.WHITE); categoryPlot.setRangeGridlinePaint(Color.BLACK); BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer(); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelFont(new Font("Serif", Font.PLAIN, 10)); renderer.setItemLabelAnchorOffset(15); 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.setSeriesPaint(0, new Color(0x77, 0x77, 0xFF)); renderer.setSeriesPaint(1, new Color(0xCC, 0xCC, 0xFF)); renderer.setSeriesPaint(2, new Color(0x00, 0x00, 0xFF)); renderer.setSeriesPaint(3, new Color(0xFF, 0x77, 0x77)); renderer.setSeriesPaint(4, new Color(0xFF, 0xCC, 0xCC)); renderer.setSeriesPaint(5, new Color(0xFF, 0x00, 0x00)); for (int i = 0; i < categoryModel.getColumnKeys().size(); i++) { String label = (String) categoryModel.getColumnKey(i); CategoryMarker marker = new CategoryMarker(label); marker.setLabel(""); marker.setPaint(Color.cyan); marker.setOutlinePaint(Color.cyan); marker.setAlpha(0.1f);//from w ww . j av a 2s . c o m marker.setLabelAnchor(RectangleAnchor.TOP); marker.setLabelTextAnchor(TextAnchor.TOP_CENTER); marker.setLabelOffsetType(LengthAdjustmentType.CONTRACT); categoryPlot.addDomainMarker(marker, Layer.BACKGROUND); } renderer.setDrawBarOutline(false); renderer.setShadowVisible(false); renderer.setItemMargin(.1); renderer.setBarPainter(new StandardBarPainter()); renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_RIGHT)); renderer.setBaseNegativeItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.BOTTOM_RIGHT)); }
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
public void addDomainMarker(CategoryPlot plot, cfCHARTDOMAINMARKERData dmData) throws cfmRunTimeException { CategoryMarker domainMarker = new CategoryMarker(dmData.getValue()); boolean drawAsLine = false; if (dmData.getShape().equals("line")) drawAsLine = true;//from w ww . j av a 2 s . com domainMarker.setDrawAsLine(drawAsLine); domainMarker.setPaint(convertStringToColor(dmData.getColor())); if (dmData.getLabel() != null) { domainMarker.setLabel(dmData.getLabel()); domainMarker.setLabelPaint(convertStringToColor(dmData.getLabelColor())); String labelPos = dmData.getLabelPosition(); if (labelPos.equals("top_left")) { domainMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); if (drawAsLine) domainMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); else domainMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT); } else if (labelPos.equals("top")) { domainMarker.setLabelAnchor(RectangleAnchor.TOP); domainMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER); } else if (labelPos.equals("top_right")) { domainMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); if (drawAsLine) domainMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT); else domainMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); } else if (labelPos.equals("left")) { domainMarker.setLabelAnchor(RectangleAnchor.LEFT); if (drawAsLine) domainMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT); else domainMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT); } else if (labelPos.equals("center")) { domainMarker.setLabelAnchor(RectangleAnchor.CENTER); domainMarker.setLabelTextAnchor(TextAnchor.CENTER); } else if (labelPos.equals("right")) { domainMarker.setLabelAnchor(RectangleAnchor.RIGHT); if (drawAsLine) domainMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT); else domainMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT); } else if (labelPos.equals("bottom_left")) { domainMarker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT); if (drawAsLine) domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); else domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); } else if (labelPos.equals("bottom")) { domainMarker.setLabelAnchor(RectangleAnchor.BOTTOM); domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER); } else if (labelPos.equals("bottom_right")) { domainMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); if (drawAsLine) domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); else domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); } domainMarker.setLabelOffsetType(LengthAdjustmentType.NO_CHANGE); domainMarker.setLabelFont( getFont(dmData.getFont(), dmData.getFontBold(), dmData.getFontItalic(), dmData.getFontSize())); } plot.addDomainMarker(domainMarker, Layer.BACKGROUND); }