本文整理汇总了Java中org.jfree.chart.renderer.xy.XYSplineRenderer类的典型用法代码示例。如果您正苦于以下问题:Java XYSplineRenderer类的具体用法?Java XYSplineRenderer怎么用?Java XYSplineRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XYSplineRenderer类属于org.jfree.chart.renderer.xy包,在下文中一共展示了XYSplineRenderer类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawChart
import org.jfree.chart.renderer.xy.XYSplineRenderer; //导入依赖的package包/类
public void drawChart(String filename, int width, int height) throws IOException {
// Create plot
NumberAxis xAxis = new NumberAxis(xAxisLabel);
NumberAxis yAxis = new NumberAxis(yAxisLabel);
XYSplineRenderer renderer = new XYSplineRenderer();
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4));
// Create chart
JFreeChart chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
ChartUtilities.applyCurrentTheme(chart);
ChartPanel chartPanel = new ChartPanel(chart, false);
// Draw png
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
Graphics graphics = bi.getGraphics();
chartPanel.setBounds(0, 0, width, height);
chartPanel.paint(graphics);
ImageIO.write(bi, "png", new File(filename));
}
示例2: createLineChart
import org.jfree.chart.renderer.xy.XYSplineRenderer; //导入依赖的package包/类
private JFreeChart createLineChart(String title, XYSeriesCollection data) {
// plot
final NumberAxis xAxis = new NumberAxis("X");
xAxis.setAutoRangeIncludesZero(false);
final NumberAxis yAxis = new NumberAxis("Y");
yAxis.setAutoRangeIncludesZero(false);
final XYSplineRenderer renderer = new XYSplineRenderer();
final XYPlot plot = new XYPlot(data, xAxis, yAxis, renderer);
{
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4));
}
// chart
return new JFreeChart(title, plot);
}
示例3: run
import org.jfree.chart.renderer.xy.XYSplineRenderer; //导入依赖的package包/类
@Override
public void run(final String arg0) {
// http://www.math.hu-berlin.de/~ccafm/lehre_BZQ_Numerik/allg/JAVA_Pakete/JFreeChart/JFreeChart-Tutorial.html
final String title = "Contrast Transfer Function";
final XYSplineRenderer spline = new XYSplineRenderer();
spline.setSeriesPaint(0, Color.RED);
spline.setSeriesPaint(1, Color.BLUE);
spline.setSeriesShapesVisible(0, false);
spline.setSeriesShapesVisible(1, false);
final NumberAxis xax = new NumberAxis("q in 1/nm");
final NumberAxis yax = new NumberAxis("CTF");
final XYPlot plot = new XYPlot(createDataset(), xax, yax, spline);
final JFreeChart chart = new JFreeChart(plot);
final ChartPanel chartPanel = new ChartPanel(chart);
final ApplicationFrame chartFrame = new ApplicationFrame(title);
chartFrame.setContentPane(chartPanel);
chartFrame.pack();
RefineryUtilities.centerFrameOnScreen(chartFrame);
chartFrame.setVisible(true);
}
示例4: customize
import org.jfree.chart.renderer.xy.XYSplineRenderer; //导入依赖的package包/类
@Override
public void customize(JFreeChart jfc, JRChart jrc)
{
Plot plot = jfc.getPlot();
if (plot instanceof XYPlot)
{
((XYPlot)plot).setRenderer( new XYSplineRenderer());
}
}
示例5: createChartImage
import org.jfree.chart.renderer.xy.XYSplineRenderer; //导入依赖的package包/类
public BufferedImage createChartImage(MediaMatrix mat, Color bgColor, int width, int height) {
final XYSplineRenderer renderer = new XYSplineRenderer();
final NumberAxis xAxis = new NumberAxis("Time");
final NumberAxis yAxis = new NumberAxis("Score");
final XYPlot plot = new XYPlot(new MediaMatrixXYDataSetAdapter(mat), xAxis, yAxis, renderer);
plot.setBackgroundPaint(bgColor);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4));
final JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
chart.setBackgroundPaint(Color.white);
final LegendTitle legendTitle = chart.getLegend();
legendTitle.setItemFont(new Font("SanSerif", Font.PLAIN, 14));
return chart.createBufferedImage(width, height);
}
示例6: testEquals
import org.jfree.chart.renderer.xy.XYSplineRenderer; //导入依赖的package包/类
/**
* Test that the equals() method distinguishes all fields.
*/
public void testEquals() {
XYSplineRenderer r1 = new XYSplineRenderer();
XYSplineRenderer r2 = new XYSplineRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
r1.setPrecision(9);
assertFalse(r1.equals(r2));
r2.setPrecision(9);
assertTrue(r1.equals(r2));
}
示例7: testHashcode
import org.jfree.chart.renderer.xy.XYSplineRenderer; //导入依赖的package包/类
/**
* Two objects that are equal are required to return the same hashCode.
*/
public void testHashcode() {
XYSplineRenderer r1 = new XYSplineRenderer();
XYSplineRenderer r2 = new XYSplineRenderer();
assertTrue(r1.equals(r2));
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
示例8: LineChart
import org.jfree.chart.renderer.xy.XYSplineRenderer; //导入依赖的package包/类
public LineChart(List<Fetch> fetches) {
final XYDataset dataset = updateDataset(fetches);
final JFreeChart chart = ChartFactory.createXYLineChart(
fetches.get(0).getBrand(), // chart title
"Time", // domain axis label
"Number", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips?
false // URLs?
);
XYPlot plot = (XYPlot) chart.getPlot();
DateAxis range = new DateAxis("Date");
range.setDateFormatOverride(new SimpleDateFormat("dd/MM/yyyy"));
plot.setDomainAxis(range);
chart.getXYPlot().setRenderer(new XYSplineRenderer());
chart.setBackgroundPaint(Color.WHITE);
lineChartPanel = new ChartPanel(chart);
lineChartPanel.setPreferredSize(new Dimension(930, 700));
}
示例9: testPublicCloneable
import org.jfree.chart.renderer.xy.XYSplineRenderer; //导入依赖的package包/类
/**
* Verify that this class implements {@link PublicCloneable}.
*/
public void testPublicCloneable() {
XYSplineRenderer r1 = new XYSplineRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
示例10: createGraghPanel
import org.jfree.chart.renderer.xy.XYSplineRenderer; //导入依赖的package包/类
private void createGraghPanel(JPanel dataPanel) {
JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, null, PlotOrientation.VERTICAL, false, true, false);
chart.setBorderVisible(true);
mafChartPanel = new MafChartPanel(chart, this);
GridBagConstraints gbl_chartPanel = new GridBagConstraints();
gbl_chartPanel.anchor = GridBagConstraints.PAGE_START;
gbl_chartPanel.insets = insets0;
gbl_chartPanel.fill = GridBagConstraints.BOTH;
gbl_chartPanel.weightx = 1.0;
gbl_chartPanel.weighty = 1.0;
gbl_chartPanel.gridx = 0;
gbl_chartPanel.gridy = 2;
dataPanel.add(mafChartPanel.getChartPanel(), gbl_chartPanel);
XYSplineRenderer lineRenderer = new XYSplineRenderer(3);
lineRenderer.setUseFillPaint(true);
lineRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
new DecimalFormat("0.00"), new DecimalFormat("0.00")));
Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f);
lineRenderer.setSeriesStroke(0, stroke);
lineRenderer.setSeriesStroke(1, stroke);
lineRenderer.setSeriesPaint(0, new Color(201, 0, 0));
lineRenderer.setSeriesPaint(1, new Color(0, 0, 255));
lineRenderer.setSeriesShape(0, ShapeUtilities.createDiamond((float) 2.5));
lineRenderer.setSeriesShape(1, ShapeUtilities.createUpTriangle((float) 2.5));
ValueAxis mafvDomain = new NumberAxis(XAxisName);
ValueAxis mafgsRange = new NumberAxis(YAxisName);
XYSeriesCollection lineDataset = new XYSeriesCollection();
lineDataset.addSeries(currMafData);
lineDataset.addSeries(corrMafData);
XYPlot plot = chart.getXYPlot();
plot.setRangePannable(true);
plot.setDomainPannable(true);
plot.setDomainGridlinePaint(Color.DARK_GRAY);
plot.setRangeGridlinePaint(Color.DARK_GRAY);
plot.setBackgroundPaint(new Color(224, 224, 224));
plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
plot.setDataset(0, lineDataset);
plot.setRenderer(0, lineRenderer);
plot.setDomainAxis(0, mafvDomain);
plot.setRangeAxis(0, mafgsRange);
plot.mapDatasetToDomainAxis(0, 0);
plot.mapDatasetToRangeAxis(0, 0);
LegendTitle legend = new LegendTitle(plot.getRenderer());
legend.setItemFont(new Font("Arial", 0, 10));
legend.setPosition(RectangleEdge.TOP);
chart.addLegend(legend);
}