本文整理汇总了Java中org.jfree.chart.renderer.xy.XYLineAndShapeRenderer类的典型用法代码示例。如果您正苦于以下问题:Java XYLineAndShapeRenderer类的具体用法?Java XYLineAndShapeRenderer怎么用?Java XYLineAndShapeRenderer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XYLineAndShapeRenderer类属于org.jfree.chart.renderer.xy包,在下文中一共展示了XYLineAndShapeRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scatterGridPlot
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入依赖的package包/类
public JFreeChart scatterGridPlot(String xLabel, String yLabel){
int numDatasets = dataset.size();
JFreeChart result = ChartFactory.createScatterPlot(chartTitle
, xLabel
, yLabel
, dataset.get(0));
XYPlot plot = result.getXYPlot();
plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
plot.getRenderer().setSeriesPaint(0, seriesColor.get(0));
for(int i=1;i<numDatasets;i++){
plot.setDataset(i,dataset.get(i));
//XYItemRenderer renderer = plot.getRenderer(i-0);
plot.setRenderer(i, new XYLineAndShapeRenderer(true, true));
plot.getRenderer(i).setSeriesStroke(0, new BasicStroke(1.0f));
plot.getRenderer(i).setSeriesPaint(0,seriesColor.get(i));
}
return result;
}
开发者ID:PacktPublishing,项目名称:Neural-Network-Programming-with-Java-SecondEdition,代码行数:20,代码来源:Chart.java
示例2: createChart
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入依赖的package包/类
private JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createScatterPlot(this.title,
this.xAxisLabel, this.yAxisLable, dataset, PlotOrientation.VERTICAL, true, true, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setNoDataMessage("NO DATA");
XYLineAndShapeRenderer renderer
= (XYLineAndShapeRenderer) plot.getRenderer();
renderer.setSeriesOutlinePaint(0, Color.black);
renderer.setUseOutlinePaint(true);
NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
domainAxis.setAutoRangeIncludesZero(false);
return chart;
}
示例3: plotSeperate
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入依赖的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.
}
示例4: createChart
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入依赖的package包/类
private JFreeChart createChart(XYSeriesCollection xySeriesCollection) {
JFreeChart chart = ChartFactory.createXYLineChart(
"PlotDemo",
"X",
"Y",
xySeriesCollection,
PlotOrientation.VERTICAL,
true,
true,
false);
chart.setBackgroundPaint(Color.white);
//...Устанавливаем правила для серий
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
renderer.setSeriesLinesVisible(2, false);
renderer.setSeriesShapesVisible(1, false);
renderer.setSeriesPaint(0, Color.orange);
renderer.setSeriesPaint(1, Color.red);
renderer.setSeriesPaint(2, Color.blue);
XYPlot plot = chart.getXYPlot();
plot.setOutlinePaint(Color.cyan);
plot.setRenderer(renderer);
return chart;
}
示例5: testGetRendererForDataset
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入依赖的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));
}
示例6: test1654215
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入依赖的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);
}
示例7: testGetRendererForDataset
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入依赖的package包/类
/**
* Some checks for the getRendererForDataset() method.
*/
@Test
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));
}
示例8: test1654215
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入依赖的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).
*/
@Test
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());
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();
}
catch (Exception e) {
fail("No exception should be thrown.");
}
}
示例9: testRendererIndices
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入依赖的package包/类
@Test
public void testRendererIndices() {
XYDataset dataset = new XYSeriesCollection();
NumberAxis xAxis = new NumberAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
XYItemRenderer renderer = new DefaultXYItemRenderer();
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
assertEquals(renderer, plot.getRenderer(0));
// we should be able to give a renderer an arbitrary index
XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
plot.setRenderer(20, renderer2);
assertEquals(2, plot.getRendererCount());
assertEquals(renderer2, plot.getRenderer(20));
assertEquals(20, plot.getIndexOf(renderer2));
}
示例10: testGetRendererForDataset2
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入依赖的package包/类
@Test
public void testGetRendererForDataset2() {
XYDataset dataset = new XYSeriesCollection();
NumberAxis xAxis = new NumberAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
XYItemRenderer renderer = new DefaultXYItemRenderer();
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
// add a second dataset
XYSeriesCollection dataset2 = new XYSeriesCollection();
dataset2.addSeries(new XYSeries("Series in dataset 2"));
plot.setDataset(99, dataset2);
// by default, the renderer with index 0 is used
assertEquals(renderer, plot.getRendererForDataset(dataset2));
// add a second renderer with the same index as dataset2, now it will
// be used
XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
plot.setRenderer(99, renderer);
assertEquals(renderer2, plot.getRendererForDataset(dataset2));
}
示例11: testDomainMarkerIndices
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入依赖的package包/类
@Test
public void testDomainMarkerIndices() {
XYDataset dataset = new XYSeriesCollection();
NumberAxis xAxis = new NumberAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
XYItemRenderer renderer = new DefaultXYItemRenderer();
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
// add a second dataset, plotted against a second x axis
XYSeriesCollection dataset2 = new XYSeriesCollection();
dataset2.addSeries(new XYSeries("Series in dataset 2"));
plot.setDataset(99, dataset);
NumberAxis xAxis2 = new NumberAxis("X2");
plot.setDomainAxis(1, xAxis2);
XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
plot.setRenderer(99, renderer2);
plot.mapDatasetToDomainAxis(99, 1);
ValueMarker xMarker1 = new ValueMarker(123);
plot.addDomainMarker(99, xMarker1, Layer.FOREGROUND);
assertTrue(plot.getDomainMarkers(99, Layer.FOREGROUND).contains(
xMarker1));
}
示例12: testRangeMarkerIndices
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入依赖的package包/类
@Test
public void testRangeMarkerIndices() {
XYDataset dataset = new XYSeriesCollection();
NumberAxis xAxis = new NumberAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
XYItemRenderer renderer = new DefaultXYItemRenderer();
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
// add a second dataset, plotted against a second axis
XYSeriesCollection dataset2 = new XYSeriesCollection();
dataset2.addSeries(new XYSeries("Series in dataset 2"));
plot.setDataset(99, dataset);
NumberAxis yAxis2 = new NumberAxis("Y2");
plot.setRangeAxis(1, yAxis2);
XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
plot.setRenderer(99, renderer2);
plot.mapDatasetToRangeAxis(99, 1);
ValueMarker yMarker1 = new ValueMarker(123);
plot.addRangeMarker(99, yMarker1, Layer.FOREGROUND);
assertTrue(plot.getRangeMarkers(99, Layer.FOREGROUND).contains(yMarker1));
}
示例13: createXYLineChart
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入依赖的package包/类
/**
* Creates a line chart (based on an {@link XYDataset}) with default
* settings.
*
* @param title the chart title (<code>null</code> permitted).
* @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
* @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
* @param dataset the dataset for the chart (<code>null</code> permitted).
* @param orientation the plot orientation (horizontal or vertical)
* (<code>null</code> NOT permitted).
* @param legend a flag specifying whether or not a legend is required.
* @param tooltips configure chart to generate tool tips?
* @param urls configure chart to generate URLs?
*
* @return The chart.
*/
public static JFreeChart createXYLineChart(String title, String xAxisLabel,
String yAxisLabel, XYDataset dataset, PlotOrientation orientation,
boolean legend, boolean tooltips, boolean urls) {
ParamChecks.nullNotPermitted(orientation, "orientation");
NumberAxis xAxis = new NumberAxis(xAxisLabel);
xAxis.setAutoRangeIncludesZero(false);
NumberAxis yAxis = new NumberAxis(yAxisLabel);
XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
plot.setOrientation(orientation);
if (tooltips) {
renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
}
if (urls) {
renderer.setURLGenerator(new StandardXYURLGenerator());
}
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
plot, legend);
currentTheme.apply(chart);
return chart;
}
示例14: createXYLineChart
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入依赖的package包/类
/**
* Creates a line chart (based on an {@link XYDataset}) with default
* settings.
*
* @param title the chart title ({@code null} permitted).
* @param xAxisLabel a label for the X-axis ({@code null} permitted).
* @param yAxisLabel a label for the Y-axis ({@code null} permitted).
* @param dataset the dataset for the chart ({@code null} permitted).
* @param orientation the plot orientation (horizontal or vertical)
* ({@code null} NOT permitted).
* @param legend a flag specifying whether or not a legend is required.
* @param tooltips configure chart to generate tool tips?
* @param urls configure chart to generate URLs?
*
* @return The chart.
*/
public static JFreeChart createXYLineChart(String title, String xAxisLabel,
String yAxisLabel, XYDataset dataset, PlotOrientation orientation,
boolean legend, boolean tooltips, boolean urls) {
Args.nullNotPermitted(orientation, "orientation");
NumberAxis xAxis = new NumberAxis(xAxisLabel);
xAxis.setAutoRangeIncludesZero(false);
NumberAxis yAxis = new NumberAxis(yAxisLabel);
XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
plot.setOrientation(orientation);
if (tooltips) {
renderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator());
}
if (urls) {
renderer.setURLGenerator(new StandardXYURLGenerator());
}
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
plot, legend);
currentTheme.apply(chart);
return chart;
}
示例15: OrderParameterVsTimeChart
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入依赖的package包/类
public OrderParameterVsTimeChart( int maxItemCount ) {
this.maxItemCount = maxItemCount;
meanSeries = new XYSeries( "Order Parameter vs Time" );
xySeriesCollection = new XYSeriesCollection( meanSeries );
domainAxis = new NumberAxis( "Time" );
rangeAxis = new NumberAxis( "Order Parameter" );
renderer = new XYLineAndShapeRenderer();
int MEAN_SERIES = 0;
renderer.setSeriesStroke( MEAN_SERIES, new BasicStroke( 2 ) );
renderer.setSeriesLinesVisible( MEAN_SERIES, true );
renderer.setSeriesShapesVisible( MEAN_SERIES, false );
xyPlot = new XYPlot( xySeriesCollection,
domainAxis,
rangeAxis, renderer );
chart = new JFreeChart( "Order Parameter vs. Time", xyPlot );
rangeAxis.setRange( -0.01, 1.01 );
domainAxis.setAutoRange( false );
domainAxis.setRange( 0, maxItemCount * PlotOrderParameterVsTime.MOD );
}