本文整理汇总了Java中org.jfree.chart.plot.XYPlot.setRenderer方法的典型用法代码示例。如果您正苦于以下问题:Java XYPlot.setRenderer方法的具体用法?Java XYPlot.setRenderer怎么用?Java XYPlot.setRenderer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.plot.XYPlot
的用法示例。
在下文中一共展示了XYPlot.setRenderer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCandlestickChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Creates and returns a default instance of a candlesticks chart.
*
* @param title the chart title (<code>null</code> permitted).
* @param timeAxisLabel a label for the time axis (<code>null</code>
* permitted).
* @param valueAxisLabel a label for the value axis (<code>null</code>
* permitted).
* @param dataset the dataset for the chart (<code>null</code> permitted).
* @param legend a flag specifying whether or not a legend is required.
*
* @return A candlestick chart.
*/
public static JFreeChart createCandlestickChart(String title,
String timeAxisLabel,
String valueAxisLabel,
OHLCDataset dataset,
boolean legend) {
ValueAxis timeAxis = new DateAxis(timeAxisLabel);
NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
plot.setRenderer(new CandlestickRenderer());
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
plot, legend);
return chart;
}
示例2: createSignalChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Creates and returns a default instance of a signal chart.
*
* @param title the chart title (<code>null</code> permitted).
* @param timeAxisLabel a label for the time axis (<code>null</code> permitted).
* @param valueAxisLabel a label for the value axis (<code>null</code> permitted).
* @param dataset the dataset for the chart (<code>null</code> permitted).
* @param legend a flag specifying whether or not a legend is required.
*
* @return a signal chart.
*/
public static JFreeChart createSignalChart(String title,
String timeAxisLabel,
String valueAxisLabel,
SignalsDataset dataset,
boolean legend) {
ValueAxis timeAxis = new DateAxis(timeAxisLabel);
NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);
plot.setRenderer(new SignalRenderer());
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
return chart;
}
示例3: testGetRendererForDataset
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Some checks for the getRendererForDataset() method.
*/
public void testGetRendererForDataset() {
XYDataset d0 = new XYSeriesCollection();
XYDataset d1 = new XYSeriesCollection();
XYDataset d2 = new XYSeriesCollection();
XYDataset d3 = new XYSeriesCollection(); // not used by plot
XYItemRenderer r0 = new XYLineAndShapeRenderer();
XYItemRenderer r2 = new XYLineAndShapeRenderer();
XYPlot plot = new XYPlot();
plot.setDataset(0, d0);
plot.setDataset(1, d1);
plot.setDataset(2, d2);
plot.setRenderer(0, r0);
// no renderer 1
plot.setRenderer(2, r2);
assertEquals(r0, plot.getRendererForDataset(d0));
assertEquals(r0, plot.getRendererForDataset(d1));
assertEquals(r2, plot.getRendererForDataset(d2));
assertEquals(null, plot.getRendererForDataset(d3));
assertEquals(null, plot.getRendererForDataset(null));
}
示例4: getChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
@Override
public JFreeChart getChart() throws IOException {
if (chart == null) {
final YIntervalSeriesCollection series_collection = getDataset();
chart = ChartFactory.createXYLineChart("Change of state over time", "Time through experiment (s)", "Number of instances", series_collection, PlotOrientation.VERTICAL, true, false, false);
final XYErrorRenderer error_renderer = new XYErrorRenderer();
error_renderer.setBaseShapesVisible(false);
error_renderer.setBaseLinesVisible(true);
error_renderer.setDrawYError(false);
final XYPlot plot = chart.getXYPlot();
plot.getRangeAxis().setLowerBound(0);
plot.setRenderer(error_renderer);
PlainChartTheme.applyTheme(chart);
}
return chart;
}
示例5: testDrawRangeGridlines
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* A test for drawing range grid lines when there is no primary renderer.
* In 1.0.4, this is throwing a NullPointerException.
*/
public void testDrawRangeGridlines() {
DefaultXYDataset dataset = new DefaultXYDataset();
JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
dataset, PlotOrientation.VERTICAL, true, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(null);
boolean success = false;
try {
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
g2.dispose();
success = true;
}
catch (Exception e) {
e.printStackTrace();
success = false;
}
assertTrue(success);
}
示例6: plotTradeBubblesOnChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private void plotTradeBubblesOnChart(ArrayList<Integer> toPlot, String p, int k, int j)
{
final Plot main_plot = (Plot)((CombinedDomainXYPlot)this.candlestickChart.getPlot()).getSubplots().get(0);
final XYPlot plot = (XYPlot) main_plot;
final TimeSeries series = new TimeSeries(p);
///*
for(Integer i: toPlot)
{
switch(j)
{
case 0:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getOpen());
break;
case 1:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getHigh());
break;
case 2:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getLow());
break;
case 3:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getClose());
break;
}
}
/*
for (int i = 0; i < defaultHighLowDataset.getSeriesCount(); i++)
{
series.add(new Minute(defaultHighLowDataset.getXDate(0, i)),plot[i]);
}
*/
XYDataset dataSet = new TimeSeriesCollection(series);
plot.setDataset(k, dataSet);
XYItemRenderer ir = new XYShapeRenderer();
//ir.s
plot.setRenderer(k, ir);
}
示例7: plotSeperate
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private void plotSeperate(XYDataset dataset, String p)
{
NumberAxis rangeAxis1 = new NumberAxis(p);
rangeAxis1.setAutoRangeIncludesZero(false); // override default
rangeAxis1.setLowerMargin(0.40); // to leave room for volume bars
DecimalFormat format = new DecimalFormat("0");
rangeAxis1.setNumberFormatOverride(format);
final ValueAxis timeAxis = new DateAxis("Date");
timeAxis.setLowerMargin(0.02); // reduce the default margins
timeAxis.setUpperMargin(0.02);
XYPlot plot = new XYPlot(dataset, timeAxis, rangeAxis1, null);
XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
renderer1.setBaseToolTipGenerator(
new StandardXYToolTipGenerator(
StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#")
)
);
plot.setRenderer(0, renderer1);
final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot)this.candlestickChart.getPlot();
if (plot != null) cplot1.add(plot, 1); // weight is 1.
}
示例8: test1654215
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* A test for bug 1654215 (where a renderer is added to the plot without
* a corresponding dataset and it throws an exception at drawing time).
*/
public void test1654215() {
DefaultXYDataset dataset = new DefaultXYDataset();
JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
dataset, PlotOrientation.VERTICAL, true, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(1, new XYLineAndShapeRenderer());
boolean success = false;
try {
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
g2.dispose();
success = true;
}
catch (Exception e) {
e.printStackTrace();
success = false;
}
assertTrue(success);
}
示例9: testFindDomainBounds
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Check that the renderer is calculating the domain bounds correctly.
*/
public void testFindDomainBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"Test Chart", "X", "Y", dataset,
PlotOrientation.VERTICAL, false, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StackedXYBarRenderer());
NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
domainAxis.setAutoRangeIncludesZero(false);
Range bounds = domainAxis.getRange();
assertFalse(bounds.contains(0.3));
assertTrue(bounds.contains(0.5));
assertTrue(bounds.contains(2.5));
assertFalse(bounds.contains(2.8));
}
示例10: testFindRangeBounds
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Check that the renderer is calculating the range bounds correctly.
*/
public void testFindRangeBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"Test Chart", "X", "Y", dataset,
PlotOrientation.VERTICAL, false, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StackedXYBarRenderer());
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
Range bounds = rangeAxis.getRange();
assertTrue(bounds.contains(6.0));
assertTrue(bounds.contains(8.0));
}
示例11: createNumericalChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private JFreeChart createNumericalChart() {
JFreeChart chart;
XYDataset dataset = createNumericalDataSet();
// create the chart...
String domainName = dataTable == null ? MODEL_DOMAIN_AXIS_NAME : dataTable.getColumnName(plotColumn);
chart = ChartFactory.createXYLineChart(null, // chart title
domainName, // x axis label
RANGE_AXIS_NAME, // y axis label
dataset, // data
PlotOrientation.VERTICAL, true, // include legend
true, // tooltips
false // urls
);
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 {
for (int i = 0; i < dataset.getSeriesCount(); i++) {
renderer.setSeriesStroke(i, stroke);
Color color = getColorProvider().getPointColor((double) i / (double) (dataset.getSeriesCount() - 1));
renderer.setSeriesPaint(i, color);
renderer.setSeriesFillPaint(i, color);
}
}
renderer.setAlpha(0.12f);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(renderer);
return chart;
}
示例12: pushDataAndRendererIntoPlot
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private void pushDataAndRendererIntoPlot(XYPlot plot, int rangeAxisIdx, XYItemRenderer renderer, XYDataset dataset)
throws ChartPlottimeException {
if (dataset != null && renderer != null) {
int datasetIdx = plot.getDatasetCount();
if (datasetIdx > 0 && plot.getDataset(datasetIdx - 1) == null) {
datasetIdx -= 1;
}
// push dataset and renderer into plot
try {
plot.setDataset(datasetIdx, dataset); // if Eclipse states that
// dataset might not be
// initialized, you did
// not consider all
// possibilities in the
// condition block above
} catch (RuntimeException e) {
// probably this is because the domain axis contains values less
// then zero and the scaling is logarithmic.
// The shitty JFreeChart implementation does not throw a proper
// exception stating what happened,
// but just a RuntimeException with a string, so this is our
// best guess:
if (isProbablyZeroValuesOnLogScaleException(e)) {
throw new ChartPlottimeException("gui.plotter.error.log_axis_contains_zero", "domain axis");
} else {
throw e;
}
}
plot.mapDatasetToRangeAxis(datasetIdx, rangeAxisIdx);
plot.setRenderer(datasetIdx, renderer);
} else {
ChartPlottimeException chartPlottimeException = new ChartPlottimeException(new PlotConfigurationError(
"generic_plotter_error"));
throw chartPlottimeException;
}
}
示例13: testSetRenderer
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* A test for a bug where setting the renderer doesn't register the plot
* as a RendererChangeListener.
*/
public void testSetRenderer() {
XYPlot plot = new XYPlot();
XYItemRenderer renderer = new XYLineAndShapeRenderer();
plot.setRenderer(renderer);
// now make a change to the renderer and see if it triggers a plot
// change event...
MyPlotChangeListener listener = new MyPlotChangeListener();
plot.addChangeListener(listener);
renderer.setSeriesPaint(0, Color.black);
assertTrue(listener.getEvent() != null);
}
示例14: plotIndicatorOnChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private void plotIndicatorOnChart(Double[] toPlot, String p, int k)
{
final Plot main_plot = (Plot)((CombinedDomainXYPlot)this.candlestickChart.getPlot()).getSubplots().get(0);
final XYPlot plot = (XYPlot) main_plot;
plot.setDataset(k, createIndicatorPlot(p,toPlot));
XYItemRenderer ir = new XYLineAndShapeRenderer(true,false);
plot.setRenderer(k, ir);
}
示例15: testSetNullRenderer
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Setting a null renderer should be allowed, but is generating a null
* pointer exception in 0.9.7.
*/
public void testSetNullRenderer() {
boolean failed = false;
try {
XYPlot plot = new XYPlot(null, new NumberAxis("X"),
new NumberAxis("Y"), null);
plot.setRenderer(null);
}
catch (Exception e) {
failed = true;
}
assertTrue(!failed);
}