List of usage examples for org.jfree.chart.title LegendTitle getFrame
public BlockFrame getFrame()
From source file:com.mgmtp.perfload.perfalyzer.reportpreparation.PlotCreator.java
public JFreeChart createPlot(final AxisType xAxisType, final AxisType yAxisType, final RendererType rendererType, final DisplayData displayData, final DataRange dataRange, boolean showMarkers, final NumberDataSet... dataSets) { NumberAxis xAxis = createAxis(xAxisType, resourceBundle.getString(displayData.getUnitX())); XYPlot plot;//from w w w .j a v a 2s . c om if (dataSets.length == 1) { NumberAxis yAxis = createAxis(yAxisType, resourceBundle.getString(displayData.getUnitY())); plot = new XYPlot(dataSets[0], xAxis, yAxis, rendererType.createRenderer()); } else { CombinedDomainXYPlot combinedPlot = new CombinedDomainXYPlot(xAxis); for (int i = 0; i < dataSets.length; ++i) { NumberDataSet dataSet = dataSets[i]; // no range for y-axis! NumberAxis yAxis = createAxis(yAxisType, resourceBundle.getString(displayData.getUnitYList().get(i))); XYPlot subPlot = new XYPlot(dataSet, null, yAxis, rendererType.createRenderer()); combinedPlot.add(subPlot); formatPlot(subPlot); } plot = combinedPlot; } JFreeChart chart = new JFreeChart(plot); CHART_THEME.apply(chart); formatPlot(plot); if (showMarkers) { for (Marker marker : markers) { IntervalMarker im = new IntervalMarker(marker.getLeftMillis() / 1000L, marker.getRightMillis() / 1000L); im.setLabel(marker.getName()); im.setLabelFont(new Font("Sans Serif", Font.ITALIC | Font.BOLD, 14)); im.setLabelAnchor(RectangleAnchor.TOP); im.setLabelOffset(new RectangleInsets(8d, 0d, 0d, 0d)); im.setLabelPaint(Color.BLACK); im.setAlpha(.2f); im.setPaint(Color.WHITE); im.setOutlinePaint(Color.BLACK); im.setOutlineStroke(new BasicStroke(1.0f)); plot.addDomainMarker(im, Layer.BACKGROUND); } } LegendTitle legend = chart.getLegend(); legend.setBackgroundPaint(new Color(229, 229, 229)); legend.setFrame( new LineBorder(new Color(213, 213, 213), new BasicStroke(1.0f), legend.getFrame().getInsets())); // only for non-logarithmic axes // range must be set after plot is created, otherwise nothing is drawn if (dataRange != null && !xAxisType.equals(AxisType.LOGARITHMIC)) { xAxis.setRange(dataRange.getLowerSeconds(), dataRange.getUpperSeconds()); } return chart; }