本文整理匯總了Java中org.jfree.chart.JFreeChart.setBackgroundPaint方法的典型用法代碼示例。如果您正苦於以下問題:Java JFreeChart.setBackgroundPaint方法的具體用法?Java JFreeChart.setBackgroundPaint怎麽用?Java JFreeChart.setBackgroundPaint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jfree.chart.JFreeChart
的用法示例。
在下文中一共展示了JFreeChart.setBackgroundPaint方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createChartCategory
import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
/**
* Creates a sample chart for the given dataset.
*
* @param dataset
* the dataset.
*
* @return A sample chart.
*/
private JFreeChart createChartCategory(final CategoryDataset dataset) {
final JFreeChart chart = ChartFactory.createMultiplePieChart3D("Multiple Pie Chart Demo 4", dataset,
TableOrder.BY_COLUMN, false, true, false);
chart.setBackgroundPaint(new Color(216, 255, 216));
final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot();
final JFreeChart subchart = plot.getPieChart();
// final StandardLegend legend = new StandardLegend();
// legend.setItemFont(new Font("SansSerif", Font.PLAIN, 8));
// legend.setAnchor(Legend.SOUTH);
// subchart.setLegend(legend);
plot.setLimit(0.10);
final PiePlot p = (PiePlot) subchart.getPlot();
// p.setLabelGenerator(new StandardPieItemLabelGenerator("{0}"));
p.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
p.setInteriorGap(0.30);
return chart;
}
示例2: visualizarSeriesTiemposRescateVictPorRobots
import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
public void visualizarSeriesTiemposRescateVictPorRobots(CategoryDataset dataset) {
JFreeChart chart = ChartFactory.createBarChart(
"Tiempos de Rescate de Victimas por cada robot ", // chart title
"Robots en el entorno", // domain axis label
"Tiempo milisegundos", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips?
false // URLs?
);
ChartPanel chartPanel = new ChartPanel(chart);
chart.setBackgroundPaint(Color.white);
CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setUpperMargin(0.15);
CategoryItemRenderer renderer = plot.getRenderer();
renderer.setItemLabelGenerator(new LabelGenerator(50.0));
renderer.setItemLabelFont(new Font("Serif", Font.PLAIN, 8));
renderer.setItemLabelsVisible(true);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
this.visualizar(chartPanel);
}
示例3: createChart
import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
/**
* Creates a sample chart.
*
* @param dataset the dataset.
*
* @return A sample chart.
*/
private static JFreeChart createChart(VectorXYDataset dataset) {
NumberAxis xAxis = new NumberAxis("X");
xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
xAxis.setLowerMargin(0.01);
xAxis.setUpperMargin(0.01);
xAxis.setAutoRangeIncludesZero(false);
NumberAxis yAxis = new NumberAxis("Y");
yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
yAxis.setLowerMargin(0.01);
yAxis.setUpperMargin(0.01);
yAxis.setAutoRangeIncludesZero(false);
VectorRenderer renderer = new VectorRenderer();
renderer.setSeriesPaint(0, Color.blue);
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
plot.setOutlinePaint(Color.black);
JFreeChart chart = new JFreeChart("Vector Plot Demo 1", plot);
chart.setBackgroundPaint(Color.white);
return chart;
}
示例4: createChart
import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
protected JFreeChart createChart(XYDataset dataset) {
// create the chart...
final JFreeChart chart = ChartFactory.createXYLineChart("Quantidade de pixels", "Pixel", "Quantidade", dataset,
PlotOrientation.VERTICAL, true, // include legend
true, // tooltips
false // urls
);
chart.setBackgroundPaint(java.awt.Color.white);
// final StandardLegend legend = (StandardLegend) chart.getLegend();
// legend.setDisplaySeriesShapes(true);
// get a reference to the plot for further customisation...
final XYPlot plot = chart.getXYPlot();
plot.setBackgroundPaint(java.awt.Color.lightGray);
// plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
plot.setDomainGridlinePaint(java.awt.Color.white);
plot.setRangeGridlinePaint(java.awt.Color.white);
// change the auto tick unit selection to integer units only...
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// OPTIONAL CUSTOMISATION COMPLETED.
return chart;
}
示例5: crearBarChartCosteEnergiaRescateVictimas
import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
public void crearBarChartCosteEnergiaRescateVictimas(CategoryDataset dataset) {
JFreeChart chart = ChartFactory.createBarChart(
"Energ�a consumida para salvar las victimas ", // chart title
"Victimas ordenadas por tiempo de rescate", // domain axis label
"Energ�a consumida", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips?
false // URLs?
);
ChartPanel chartPanel = new ChartPanel(chart);
chart.setBackgroundPaint(Color.white);
CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setUpperMargin(0.15);
CategoryItemRenderer renderer = plot.getRenderer();
renderer.setItemLabelGenerator(new LabelGenerator(50.0));
renderer.setItemLabelFont(new Font("Serif", Font.PLAIN, 8));
renderer.setItemLabelsVisible(true);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
setContentPane(chartPanel);
this.pack();
RefineryUtilities.centerFrameOnScreen(this);
this.setVisible(true);
// return chart;
}
示例6: createChart
import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
/**
* Creates a chart.
*
* @param dataset a dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"Legal & General Unit Trust Prices", // title
"Date", // x-axis label
"Price Per Unit", // y-axis label
dataset, // data
true, // create legend?
true, // generate tooltips?
false // generate URLs?
);
chart.setBackgroundPaint(Color.white);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
XYItemRenderer r = plot.getRenderer();
if (r instanceof XYLineAndShapeRenderer) {
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
renderer.setBaseShapesVisible(true);
renderer.setBaseShapesFilled(true);
}
DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
return chart;
}
示例7: createHourlyBreakageDistributionChart
import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
public static void createHourlyBreakageDistributionChart(final SortedMap stats, final String categoryLabel, final OutputStream out) throws IOException {
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (final Iterator iter = stats.entrySet().iterator(); iter.hasNext();) {
final Map.Entry entry = (Map.Entry) iter.next();
final Integer hour = (Integer) entry.getKey();
final BuildStatistics bst = (BuildStatistics) entry.getValue();
dataset.addValue(new Integer(bst.getFailedBuilds()), "Failed builds", hour);
}
// create the chart object
// This generates a stacked bar - more suitable
final JFreeChart chart = ChartFactory.createStackedBarChart(null,
categoryLabel, "Builds", dataset,
PlotOrientation.VERTICAL,
true, false, false);
chart.setBackgroundPaint(Color.white);
// change the auto tick unit selection to integer units only
final CategoryPlot plot = chart.getCategoryPlot();
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// set bar colors
final BarRenderer bar = (BarRenderer) plot.getRenderer();
bar.setItemMargin(0); // reduce the width between the bars.
bar.setSeriesPaint(0, Color.RED); // first bar
// write to reposnce
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
ChartUtilities.writeChartAsPNG(out, chart, IMG_WIDTH, IMG_HEIGHT, info);
}
示例8: createChart
import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
/**
* Creates a chart for recent time to fix.
*
*/
public void createChart(final SortedMap time, final String valueKey, final Color lineColor, final OutputStream out) throws IOException {
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
addTimeToDataSet(dataset, time, valueKey);
// create the chart object
// This generates a stacked bar - more suitable
final JFreeChart chart = ChartFactory.createLineChart(null,
"Recent builds", "Time", dataset,
PlotOrientation.VERTICAL,
true, false, false);
chart.setBackgroundPaint(Color.white);
// change the auto tick unit selection to integer units only
final CategoryPlot plot = chart.getCategoryPlot();
final NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis();
rangeAxis.setStandardTickUnits(StatisticsUtils.createWordedTimeTickUnits());
// rotate X dates
final CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
// set bar colors
final LineAndShapeRenderer line = (LineAndShapeRenderer)plot.getRenderer();
line.setSeriesPaint(0, lineColor);
line.setStroke(StatisticsUtils.DEFAULT_LINE_STROKE);
// write to reposnce
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
ChartUtilities.writeChartAsPNG(out, chart, StatisticsUtils.IMG_WIDTH, StatisticsUtils.IMG_HEIGHT, info);
}
示例9: createDayOfWeekBreakageDistributionChart
import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
public static void createDayOfWeekBreakageDistributionChart(final SortedMap stats, final String categoryLabel, final OutputStream out) throws IOException {
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (final Iterator iter = stats.entrySet().iterator(); iter.hasNext();) {
final Map.Entry entry = (Map.Entry) iter.next();
final Integer dayOfWeek = (Integer) entry.getKey();
final BuildStatistics bst = (BuildStatistics) entry.getValue();
dataset.addValue(new Integer(bst.getFailedBuilds()), "Failed builds", new ComparableDayOfWeek(dayOfWeek));
}
// create the chart object
// This generates a stacked bar - more suitable
final JFreeChart chart = ChartFactory.createStackedBarChart(null,
categoryLabel, "Builds", dataset,
PlotOrientation.VERTICAL,
true, false, false);
chart.setBackgroundPaint(Color.white);
// change the auto tick unit selection to integer units only
final CategoryPlot plot = chart.getCategoryPlot();
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// set bar colors
final BarRenderer bar = (BarRenderer) plot.getRenderer();
bar.setItemMargin(0); // reduce the width between the bars.
bar.setSeriesPaint(0, Color.RED); // first bar
// write to reposnce
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
ChartUtilities.writeChartAsPNG(out, chart, IMG_WIDTH, IMG_HEIGHT, info);
}
示例10: updateChartProperties
import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
/**
* Updates the properties of a chart to match the properties defined on the
* panel.
*
* @param chart the chart.
*/
public void updateChartProperties(JFreeChart chart) {
this.titlePropertiesPanel.setTitleProperties(chart);
this.legendPropertiesPanel.setLegendProperties(chart);
this.plotPropertiesPanel.updatePlotProperties(chart.getPlot());
chart.setAntiAlias(getAntiAlias());
chart.setBackgroundPaint(getBackgroundPaint());
}
示例11: setChartBackgroundColor
import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
private void setChartBackgroundColor(Color backgroundColor) {
JFreeChart chart = getCurrentChart();
if (chart != null) {
chart.setBackgroundPaint(backgroundColor);
}
}
示例12: createChart
import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
private JFreeChart createChart(XYDataset dataset) {
// create the chart...
JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
null, // x axis label
null, // y axis label
dataset, // data
PlotOrientation.VERTICAL, true, // include legend
true, // tooltips
false // urls
);
chart.setBackgroundPaint(Color.white);
// get a reference to the plot for further customisation...
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.WHITE);
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
ValueAxis valueAxis = plot.getRangeAxis();
valueAxis.setLabelFont(PlotterAdapter.LABEL_FONT_BOLD);
valueAxis.setTickLabelFont(PlotterAdapter.LABEL_FONT);
ValueAxis domainAxis = plot.getDomainAxis();
domainAxis.setLabelFont(PlotterAdapter.LABEL_FONT_BOLD);
domainAxis.setTickLabelFont(PlotterAdapter.LABEL_FONT);
DeviationRenderer renderer = new DeviationRenderer(true, false);
Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
if (dataset.getSeriesCount() == 1) {
renderer.setSeriesStroke(0, stroke);
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesFillPaint(0, Color.RED);
} else if (dataset.getSeriesCount() == 2) {
renderer.setSeriesStroke(0, stroke);
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesFillPaint(0, Color.RED);
renderer.setSeriesStroke(1, stroke);
renderer.setSeriesPaint(1, Color.BLUE);
renderer.setSeriesFillPaint(1, Color.BLUE);
} else {
for (int i = 0; i < dataset.getSeriesCount(); i++) {
renderer.setSeriesStroke(i, stroke);
Color color = colorProvider.getPointColor((double) i / (double) (dataset.getSeriesCount() - 1));
renderer.setSeriesPaint(i, color);
renderer.setSeriesFillPaint(i, color);
}
}
renderer.setAlpha(0.12f);
plot.setRenderer(renderer);
// legend settings
LegendTitle legend = chart.getLegend();
if (legend != null) {
legend.setPosition(RectangleEdge.TOP);
legend.setFrame(BlockBorder.NONE);
legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
legend.setItemFont(PlotterAdapter.LABEL_FONT);
}
return chart;
}
示例13: createChangeListsBarChart
import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
/**
* Creates a distribution image for build results.
*
* @param stats SortedMap with dates as keys and
* BuildStatistics as value.
* @param categoryLabel - label to place on X axis.
* @param out OutputStream to write image to.
*/
public static void createChangeListsBarChart(final SortedMap stats, final String categoryLabel,
final String dateFormat, final OutputStream out) throws IOException {
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (final Iterator iter = stats.entrySet().iterator(); iter.hasNext();) {
final Map.Entry entry = (Map.Entry) iter.next();
final Date date = (Date) entry.getKey();
final BuildStatistics bst = (BuildStatistics) entry.getValue();
final String dateAsString = StringUtils.formatDate(date, dateFormat);
dataset.addValue(new Integer(bst.getChangeLists()), "Change lists", dateAsString);
}
// create the chart object
// This generates a stacked bar - more suitable
final JFreeChart chart = ChartFactory.createStackedBarChart(null,
categoryLabel, "Change lists", dataset,
PlotOrientation.VERTICAL,
true, false, false);
chart.setBackgroundPaint(Color.white);
// change the auto tick unit selection to integer units only
final CategoryPlot plot = chart.getCategoryPlot();
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// rotate X dates
final CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
// set bar colors
final BarRenderer bar = (BarRenderer) plot.getRenderer();
bar.setItemMargin(0); // reduce the width between the bars.
bar.setSeriesPaint(0, Color.BLUE); // first bar
//bar.setSeriesPaint(1, Color.GREEN); // second bar
// write to reposnce
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
ChartUtilities.writeChartAsPNG(out, chart, IMG_WIDTH, IMG_HEIGHT, info);
}
示例14: updateChartProperties
import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
/**
* Updates the chart.
*
* @param chart the chart.
*/
public void updateChartProperties(JFreeChart chart) {
chart.setAntiAlias(this.antialias.getSelection());
chart.setBackgroundPaint(SWTUtils.toAwtColor(
this.backgroundPaintCanvas.getColor()));
}
示例15: createChart
import org.jfree.chart.JFreeChart; //導入方法依賴的package包/類
private JFreeChart createChart(CategoryDataset dataset, HttpServletRequest request) {
JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false);
CategoryPlot plot = chart.getCategoryPlot();
Paint background = new GradientPaint(0, 0, Color.lightGray, 0, IMAGE_MIN_HEIGHT, Color.white);
plot.setBackgroundPaint(background);
plot.setDomainGridlinePaint(Color.white);
plot.setDomainGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.white);
plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
LogarithmicAxis rangeAxis = new LogarithmicAxis(null);
rangeAxis.setStrictValuesFlag(false);
rangeAxis.setAllowNegativesFlag(true);
plot.setRangeAxis(rangeAxis);
// Disable bar outlines.
BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
// Set up gradient paint for series.
GradientPaint gp0 = new GradientPaint(
0.0f, 0.0f, Color.blue,
0.0f, 0.0f, new Color(0, 0, 64)
);
renderer.setSeriesPaint(0, gp0);
// Rotate labels.
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
// Set theme-specific colors.
Color bgColor = getBackground(request);
Color fgColor = getForeground(request);
chart.setBackgroundPaint(bgColor);
domainAxis.setTickLabelPaint(fgColor);
domainAxis.setTickMarkPaint(fgColor);
domainAxis.setAxisLinePaint(fgColor);
rangeAxis.setTickLabelPaint(fgColor);
rangeAxis.setTickMarkPaint(fgColor);
rangeAxis.setAxisLinePaint(fgColor);
return chart;
}