本文整理汇总了Java中org.jfree.chart.plot.XYPlot.getRenderer方法的典型用法代码示例。如果您正苦于以下问题:Java XYPlot.getRenderer方法的具体用法?Java XYPlot.getRenderer怎么用?Java XYPlot.getRenderer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.plot.XYPlot
的用法示例。
在下文中一共展示了XYPlot.getRenderer方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的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;
}
示例2: createHistogramChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Creates the histogram chart.
*
* @param exampleSet
* @return
*/
private JFreeChart createHistogramChart(ExampleSet exampleSet) {
JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(exampleSet),
PlotOrientation.VERTICAL, false, false, false);
AbstractAttributeStatisticsModel.setDefaultChartFonts(chart);
chart.setBackgroundPaint(null);
chart.setBackgroundImageAlpha(0.0f);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRangeGridlinesVisible(false);
plot.setDomainGridlinesVisible(false);
plot.setOutlineVisible(false);
plot.setRangeZeroBaselineVisible(false);
plot.setDomainZeroBaselineVisible(false);
plot.setBackgroundPaint(COLOR_INVISIBLE);
plot.setBackgroundImageAlpha(0.0f);
XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.NUMERICAL));
renderer.setBarPainter(new StandardXYBarPainter());
renderer.setDrawBarOutline(true);
renderer.setShadowVisible(false);
return chart;
}
示例3: addChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* It creates a chart for the given dataset and adds the chart to the panel.
*
* @param dataset The dataset that will provide the values for the chart.
*/
private void addChart() {
JFreeChart chart = ChartFactory.createXYBarChart(getTitle(),
"Elapsed Time (sec)", false, "Time" + unitSuffix(),
dataset, PlotOrientation.VERTICAL, true, true, false);
chart.addProgressListener(locker);
XYPlot plot = (XYPlot) chart.getPlot();
XYItemRenderer renderer = plot.getRenderer();
renderer.setToolTipGenerator(dataset);
groupActivatingTable = new GroupActivatingPanel(dataset, locker);
org.jfree.chart.ChartPanel chartPanel =
new org.jfree.chart.ChartPanel(chart);
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
groupActivatingTable, chartPanel);
splitPane.setDividerLocation(200);
mainPanel().add(BorderLayout.CENTER, splitPane);
}
示例4: setTimeSeriesRender
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public static void setTimeSeriesRender(Plot plot, boolean isShowData, boolean isShapesVisible) {
XYPlot xyplot = (XYPlot) plot;
xyplot.setNoDataMessage(NO_DATA_MSG);
xyplot.setInsets(new RectangleInsets(10, 10, 5, 10));
XYLineAndShapeRenderer xyRenderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
xyRenderer.setBaseShapesVisible(false);
if (isShowData) {
xyRenderer.setBaseItemLabelsVisible(true);
xyRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
xyRenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE1, TextAnchor.BOTTOM_CENTER));
}
xyRenderer.setBaseShapesVisible(isShapesVisible);
DateAxis domainAxis = (DateAxis) xyplot.getDomainAxis();
domainAxis.setAutoTickUnitSelection(false);
DateTickUnit dateTickUnit = new DateTickUnit(DateTickUnitType.YEAR, 1, new SimpleDateFormat("yyyy-MM"));
domainAxis.setTickUnit(dateTickUnit);
StandardXYToolTipGenerator xyTooltipGenerator = new StandardXYToolTipGenerator("{1}:{2}", new SimpleDateFormat("yyyy-MM-dd"), new DecimalFormat("0"));
xyRenderer.setBaseToolTipGenerator(xyTooltipGenerator);
setXY_XAixs(xyplot);
setXY_YAixs(xyplot);
}
示例5: actionPerformed
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent ae) {
// Visibility checkbox - show or hide a series
if(ae.getSource() instanceof JCheckBox){
// Determine which series to hide
JCheckBox source = (JCheckBox) ae.getSource();
String seriesLabel = source.getText();
// Find the series
XYPlot plot = this.getChart().getXYPlot();
for(int i=0; i<plot.getSeriesCount(); i++){
// Toggle visibility
if(plot.getDataset().getSeriesKey(i).equals(seriesLabel)){
XYItemRenderer renderer = plot.getRenderer();
boolean currentlyVisible = renderer.getItemVisible(i, 0);
renderer.setSeriesVisible(i, new Boolean(!currentlyVisible));
}
}
// Update the tooltip text to reflect the new state
source.setToolTipText(this.generateToolTipTextForVisibilityCheckBox(source));
}
}
示例6: testSetSeriesToolTipGenerator
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Check that setting a tool tip generator for a series does override the
* default generator.
*/
public void testSetSeriesToolTipGenerator() {
XYPlot plot = (XYPlot) this.chart.getPlot();
XYItemRenderer renderer = plot.getRenderer();
StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator();
renderer.setSeriesToolTipGenerator(0, tt);
XYToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
assertTrue(tt2 == tt);
}
示例7: createChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private static JFreeChart createChart(XYDataset dataset, String chartName) {
// create the chart...
if(chartName == null)
chartName = FunctionToPlot;
JFreeChart chart = ChartFactory.createXYLineChart(
chartName,
Var,
Value,
dataset,
PlotOrientation.VERTICAL,
true,
true,
false
);
chart.setBackgroundPaint(Color.white);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
XYLineAndShapeRenderer renderer
= (XYLineAndShapeRenderer) plot.getRenderer();
//renderer.setShapesVisible(true);
//renderer.setShapesFilled(true);
// change the auto tick unit selection to integer units only...
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setLabelAngle(Math.PI/2.0);
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED.
return chart;
}
示例8: createChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的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;
}
示例9: GenerateRTMapPNG
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private void GenerateRTMapPNG(XYSeriesCollection xySeriesCollection, XYSeries series, float R2) throws IOException {
String pngfile = FilenameUtils.getFullPath(TargetLCMS.mzXMLFileName) + "/" + FilenameUtils.getBaseName(TargetLCMS.mzXMLFileName) + "_" + libManager.LibID + "_RTMap.png";
FileWriter writer = new FileWriter(FilenameUtils.getFullPath(TargetLCMS.mzXMLFileName) + "/" + FilenameUtils.getBaseName(TargetLCMS.mzXMLFileName) + "_" + libManager.LibID + "_RTMap.txt");
XYSeries smoothline = new XYSeries("RT fitting curve");
for (XYZData data : regression.PredictYList) {
smoothline.add(data.getX(), data.getY());
writer.write(data.getX() + "\t" + data.getY() + "\n");
}
writer.close();
xySeriesCollection.addSeries(smoothline);
xySeriesCollection.addSeries(series);
JFreeChart chart = ChartFactory.createScatterPlot("Retention time mapping: R2=" + R2, "Normalized RT (" + libManager.LibID + ")", "RT:" + FilenameUtils.getBaseName(TargetLCMS.mzXMLFileName), xySeriesCollection,
PlotOrientation.VERTICAL, true, true, false);
XYPlot xyPlot = (XYPlot) chart.getPlot();
xyPlot.setDomainCrosshairVisible(true);
xyPlot.setRangeCrosshairVisible(true);
XYItemRenderer renderer = xyPlot.getRenderer();
renderer.setSeriesPaint(1, Color.blue);
renderer.setSeriesPaint(0, Color.BLACK);
renderer.setSeriesShape(1, new Ellipse2D.Double(0, 0, 3, 3));
renderer.setSeriesStroke(1, new BasicStroke(3.0f));
renderer.setSeriesStroke(0, new BasicStroke(3.0f));
xyPlot.setBackgroundPaint(Color.white);
ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
}
示例10: createChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的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);
renderer.setDrawSeriesLineAsPath(true);
}
DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
return chart;
}
示例11: createChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Creates a chart.
*
* @param dataset a dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"International Coffee Organisation : Coffee Prices", // title
null, // x-axis label
"US cents/lb", // y-axis label
dataset);
String fontName = "Palatino";
chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));
chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf", new Font(fontName, Font.PLAIN, 14)));
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainPannable(true);
plot.setRangePannable(false);
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
plot.getDomainAxis().setLowerMargin(0.0);
plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
chart.getLegend().setFrame(BlockBorder.NONE);
chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER);
XYItemRenderer r = plot.getRenderer();
if (r instanceof XYLineAndShapeRenderer) {
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
renderer.setDefaultShapesVisible(false);
renderer.setDrawSeriesLineAsPath(true);
// set the default stroke for all series
renderer.setAutoPopulateSeriesStroke(false);
renderer.setDefaultStroke(new BasicStroke(3.0f,
BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false);
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesPaint(1, new Color(24, 123, 58));
renderer.setSeriesPaint(2, new Color(149, 201, 136));
renderer.setSeriesPaint(3, new Color(1, 62, 29));
renderer.setSeriesPaint(4, new Color(81, 176, 86));
renderer.setSeriesPaint(5, new Color(0, 55, 122));
renderer.setSeriesPaint(6, new Color(0, 92, 165));
renderer.setDefaultLegendTextFont(new Font(fontName, Font.PLAIN, 14));
}
return chart;
}
示例12: createChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Creates a chart.
*
* @param dataset a dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"International Coffee Organisation : Coffee Prices", // title
null, // x-axis label
"US cents/lb", // y-axis label
dataset);
String fontName = "Palatino";
chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));
chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf",
new Font(fontName, Font.PLAIN, 14)));
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainPannable(true);
plot.setRangePannable(true);
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
plot.getDomainAxis().setLowerMargin(0.0);
plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
chart.getLegend().setFrame(BlockBorder.NONE);
chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER);
XYItemRenderer r = plot.getRenderer();
if (r instanceof XYLineAndShapeRenderer) {
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
renderer.setDefaultShapesVisible(false);
renderer.setDrawSeriesLineAsPath(true);
// set the default stroke for all series
renderer.setAutoPopulateSeriesStroke(false);
renderer.setDefaultStroke(new BasicStroke(3.0f));
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesPaint(1, new Color(24, 123, 58));
renderer.setSeriesPaint(2, new Color(149, 201, 136));
renderer.setSeriesPaint(3, new Color(1, 62, 29));
renderer.setSeriesPaint(4, new Color(81, 176, 86));
renderer.setSeriesPaint(5, new Color(0, 55, 122));
renderer.setSeriesPaint(6, new Color(0, 92, 165));
}
return chart;
}
示例13: createChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public static JFreeChart createChart(XYDataset xydataset, String shou, String shu) {
JFreeChart jfreechart = ChartFactory.createScatterPlot("Rating and Rating People Distribution", shou, shu,
xydataset, PlotOrientation.VERTICAL, true, false, false);
jfreechart.setBackgroundPaint(Color.white);
jfreechart.setBorderPaint(Color.GREEN);
XYPlot xyplot = (XYPlot) jfreechart.getPlot();
xyplot.setNoDataMessage("no data");
xyplot.setNoDataMessageFont(new Font("微软雅黑", Font.BOLD, 14));
xyplot.setNoDataMessagePaint(Color.blue);
xyplot.setBackgroundPaint(Color.lightGray);
TextTitle textTitle = jfreechart.getTitle();
textTitle.setFont(new Font("宋体", Font.BOLD, 20));
LegendTitle legend = jfreechart.getLegend();
if (legend != null) {
legend.setItemFont(new Font("宋体", Font.BOLD, 20));
}
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
renderer.setBaseShapesVisible(true);
renderer.setDrawOutlines(true);
renderer.setSeriesOutlinePaint(0, Color.WHITE);
renderer.setUseOutlinePaint(true);
renderer.setSeriesOutlineStroke(1, new BasicStroke(0.5F));
xyplot.setRenderer(renderer);
NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis();
numberaxis.setTickMarkInsideLength(3.0F);
numberaxis.setTickMarkOutsideLength(0.0F);
numberaxis.setUpperBound(280000);
numberaxis.setLowerBound(50000);
numberaxis.setAxisLineStroke(new BasicStroke(1.5f));
NumberAxis numberaxis1 = (NumberAxis) xyplot.getRangeAxis();
numberaxis1.setUpperBound(10.0);
numberaxis1.setLowerBound(5.0);
NumberTickUnit ntu1 = new NumberTickUnit(0.5);
numberaxis1.setTickUnit(ntu1);
return jfreechart;
}
示例14: createChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的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
false, // 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);
LegendTitle lt = new LegendTitle(plot);
lt.setItemFont(new Font("Dialog", Font.PLAIN, 9));
lt.setBackgroundPaint(new Color(200, 200, 255, 100));
lt.setBorder(new BlockBorder(Color.white));
lt.setPosition(RectangleEdge.BOTTOM);
XYTitleAnnotation ta = new XYTitleAnnotation(0.98, 0.02, lt,
RectangleAnchor.BOTTOM_RIGHT);
ta.setMaxWidth(0.48);
plot.addAnnotation(ta);
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"));
ValueAxis yAxis = plot.getRangeAxis();
yAxis.setLowerMargin(0.35);
return chart;
}