本文整理汇总了Java中org.jfree.chart.renderer.xy.XYItemRenderer.setSeriesPaint方法的典型用法代码示例。如果您正苦于以下问题:Java XYItemRenderer.setSeriesPaint方法的具体用法?Java XYItemRenderer.setSeriesPaint怎么用?Java XYItemRenderer.setSeriesPaint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.renderer.xy.XYItemRenderer
的用法示例。
在下文中一共展示了XYItemRenderer.setSeriesPaint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPlot
import org.jfree.chart.renderer.xy.XYItemRenderer; //导入方法依赖的package包/类
private XYPlot createPlot( XYSeriesCollection dataset ) {
XYPlot plot = new XYPlot();
ValueAxis domainAxis = new NumberAxis( "Time" );
domainAxis.setTickLabelsVisible( false );
domainAxis.setRange( 0, RANGE );
plot.setDomainAxis( domainAxis );
ValueAxis rangeAxis = new NumberAxis( "Population" );
rangeAxis.setStandardTickUnits( NumberAxis.createIntegerTickUnits() );
plot.setRangeAxis( rangeAxis );
rangeAxis.setRange( 0, 50 );
plot.setRenderer( new StandardXYItemRenderer() );
final int seriesIndex = 0;
plot.setDataset( seriesIndex, dataset );
XYItemRenderer renderer = new StandardXYItemRenderer(); // TODO: maybe use XYLineAndShapeRenderer?
renderer.setStroke( new BasicStroke( 2f ) );
renderer.setSeriesPaint( TOTAL_INDEX, Color.BLACK );
renderer.setSeriesPaint( FUR_WHITE_INDEX, Color.RED );
plot.setRenderer( seriesIndex, renderer );
return plot;
}
示例2: applyColorSettings
import org.jfree.chart.renderer.xy.XYItemRenderer; //导入方法依赖的package包/类
/**
* Applies the color settings from the ontology model
*/
public void applyColorSettings(){
List colors = dataModel.getOntologyModel().getChartSettings().getYAxisColors();
XYItemRenderer renderer = this.chartPanel.getChart().getXYPlot().getRenderer();
for(int i=0; i < colors.size(); i++){
String colorString = (String) colors.get(i);
if (colorString!=null && colorString.equals("")==false) {
Color newColor = new Color(Integer.parseInt((String) colors.get(i)));
renderer.setSeriesPaint(i, newColor);
}
}
}
示例3: GenerateRTMapPNG
import org.jfree.chart.renderer.xy.XYItemRenderer; //导入方法依赖的package包/类
private void GenerateRTMapPNG(XYSeriesCollection xySeriesCollection, XYSeries series, float R2) throws IOException {
new File(Workfolder + "/RT_Mapping/").mkdir();
String pngfile = Workfolder + "/RT_Mapping/" + FilenameUtils.getBaseName(LCMSA.mzXMLFileName).substring(0, Math.min(120, FilenameUtils.getBaseName(LCMSA.mzXMLFileName).length() - 1)) + "_" + FilenameUtils.getBaseName(LCMSB.mzXMLFileName).substring(0, Math.min(120, FilenameUtils.getBaseName(LCMSB.mzXMLFileName).length() - 1)) + "_RT.png";
XYSeries smoothline = new XYSeries("RT fitting curve");
for (XYZData data : regression.PredictYList) {
smoothline.add(data.getX(), data.getY());
}
xySeriesCollection.addSeries(smoothline);
xySeriesCollection.addSeries(series);
JFreeChart chart = ChartFactory.createScatterPlot("Retention time mapping: R2=" + R2, "RT:" + FilenameUtils.getBaseName(LCMSA.mzXMLFileName), "RT:" + FilenameUtils.getBaseName(LCMSB.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);
}
示例4: setSeriesColor
import org.jfree.chart.renderer.xy.XYItemRenderer; //导入方法依赖的package包/类
public void setSeriesColor(int seriesIndex, Color color) throws NoSuchSeriesException{
if(seriesIndex < dataModel.getSeriesCount()){
XYItemRenderer renderer = this.chartPanel.getChart().getXYPlot().getRenderer();
renderer.setSeriesPaint(seriesIndex, color);
}else{
throw new NoSuchSeriesException();
}
}
示例5: updateChart
import org.jfree.chart.renderer.xy.XYItemRenderer; //导入方法依赖的package包/类
public void updateChart(double[] data) {
this.removeAll();
this.revalidate();
series = new XYSeries("XYGraph");
for(int i=0; i<data.length;i++){
if(data[i]>-1){
series.add(5*i , data[i]/255 );
}
}
dataset = new XYSeriesCollection();
dataset.addSeries(series);
chart = ChartFactory.createScatterPlot(
null, // Title
"ω [rad/s]", // x-axis Label
"Q / Qmax", // y-axis Label
dataset, // Dataset
PlotOrientation.VERTICAL,
false, // Show Legend
true, // Use tooltips
false // Configure chart to generate URLs?
);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint( Color.WHITE );
XYItemRenderer renderer = plot.getRenderer();
renderer.setSeriesPaint(0, Color.RED);
double delta = 2.0;
Shape shape1 = new Rectangle2D.Double(-delta, -delta, delta, delta);
renderer.setSeriesShape(0, shape1);
ValueAxis yAxis = plot.getRangeAxis();
yAxis.setRange(0, 1.1);
ValueAxis xAxis = plot.getDomainAxis();
xAxis.setRange(0, 2000);
ChartPanel cp = new ChartPanel(chart);
cp.setBackground(Color.WHITE);
this.setLayout(new BorderLayout());
this.add(cp, BorderLayout.CENTER);
this.repaint();
}
示例6: testSetRenderer
import org.jfree.chart.renderer.xy.XYItemRenderer; //导入方法依赖的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);
}
示例7: GenerateRTMapPNG
import org.jfree.chart.renderer.xy.XYItemRenderer; //导入方法依赖的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);
}
示例8: testSetRenderer
import org.jfree.chart.renderer.xy.XYItemRenderer; //导入方法依赖的package包/类
/**
* A test for a bug where setting the renderer doesn't register the plot
* as a RendererChangeListener.
*/
@Test
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);
}
示例9: testSetRenderer
import org.jfree.chart.renderer.xy.XYItemRenderer; //导入方法依赖的package包/类
/**
* A test for a bug where setting the renderer doesn't register the plot
* as a RendererChangeListener.
*/
@Test
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);
}
示例10: setChartProperties
import org.jfree.chart.renderer.xy.XYItemRenderer; //导入方法依赖的package包/类
/**
* Creates a chart the style we like.
*
* @param chart
*/
public static void setChartProperties(JFreeChart chart,
List<SimpleEntry<Color, Stroke>> lineStyles) {
// set the background and title font
chart.setBackgroundPaint(Color.white);
chart.getTitle().setFont(new Font("Tahoma", Font.BOLD, 14));
// set the background and the grid all white
XYPlot plot = chart.getXYPlot();
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setBackgroundPaint(Color.white);
// now
plot.setOutlineStroke(null);
XYItemRenderer rend = plot.getRenderer();
Stroke stroke = new BasicStroke(2.0f);
rend.setBaseStroke(stroke);
// rend.setDrawSeriesLineAsPath(true);
// stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND,
// BasicStroke.JOIN_ROUND, 10, new float[] {10, 10}, 0);
// strokes.add(stroke);
// stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND,
// BasicStroke.JOIN_ROUND, 10, new float[] {2, 4}, 0);
// strokes.add(stroke);
int seriesCount = plot.getSeriesCount();
for (int i = 0; i != seriesCount; i++) {
SimpleEntry<Color, Stroke> lineStyle =
lineStyles.get(i % lineStyles.size());
rend.setSeriesStroke(i, lineStyle.getValue());
rend.setSeriesPaint(i, lineStyle.getKey());
}
}
示例11: setAxisAndDataSet
import org.jfree.chart.renderer.xy.XYItemRenderer; //导入方法依赖的package包/类
private static XYItemRenderer setAxisAndDataSet(int i,XYPlot plot, ValueAxis axis,XYDataset dataset,Paint p,XYItemRenderer renderer){
plot.setRangeAxis(i, axis);
plot.setDataset(i, dataset);
plot.mapDatasetToRangeAxis(i, i);
renderer.setSeriesPaint(0,p);
axis.setLabelPaint(p);
axis.setTickLabelPaint(p);
return renderer;
}
示例12: ProbabilityDensityPlot
import org.jfree.chart.renderer.xy.XYItemRenderer; //导入方法依赖的package包/类
public ProbabilityDensityPlot( XYSeries probabilityDensitySeries ) {
super();
// Labels (localized)
String probabilityDensityLabel = QTResources.getString( "axis.probabilityDensity" );
// Dataset
XYSeriesCollection data = new XYSeriesCollection();
data.addSeries( probabilityDensitySeries );
// Renderer
XYItemRenderer renderer = new FastPathRenderer();
renderer.setSeriesPaint( 0, QTConstants.COLOR_SCHEME.getProbabilityDensityColor() );
renderer.setSeriesStroke( 0, QTConstants.PROBABILITY_DENSITY_STROKE );
// X axis
PositionAxis xAxis = new PositionAxis();
// Y axis
NumberAxis yAxis = new NumberAxis( probabilityDensityLabel );
yAxis.setLabelFont( QTConstants.AXIS_LABEL_FONT );
yAxis.setRange( QTConstants.DEFAULT_PROBABILITY_DENSITY_RANGE );
yAxis.setTickLabelPaint( QTConstants.COLOR_SCHEME.getTickColor() );
yAxis.setTickMarkPaint( QTConstants.COLOR_SCHEME.getTickColor() );
setRangeAxisLocation( AxisLocation.BOTTOM_OR_LEFT );
setBackgroundPaint( QTConstants.COLOR_SCHEME.getChartColor() );
setDomainGridlinesVisible( QTConstants.SHOW_VERTICAL_GRIDLINES );
setRangeGridlinesVisible( QTConstants.SHOW_HORIZONTAL_GRIDLINES );
setDomainGridlinePaint( QTConstants.COLOR_SCHEME.getGridlineColor() );
setRangeGridlinePaint( QTConstants.COLOR_SCHEME.getGridlineColor() );
setDataset( data );
setRenderer( renderer );
setDomainAxis( xAxis );
setRangeAxis( yAxis );
}
示例13: copyNumberCDF
import org.jfree.chart.renderer.xy.XYItemRenderer; //导入方法依赖的package包/类
@NotNull
static JFreeChart copyNumberCDF(@NotNull final List<PurpleCopyNumber> copyNumbers) {
final XYDataset dataset = CopyNumberCharts.createDataset(copyNumbers);
JFreeChart chart =
ChartFactory.createScatterPlot("Copy Number CDF", "BAF Weighting (CDF)", "Ploidy", dataset, PlotOrientation.VERTICAL, false,
false, false);
XYPlot xyPlot = (XYPlot) chart.getPlot();
XYItemRenderer renderer = ((XYPlot) chart.getPlot()).getRenderer();
Shape shape = new Ellipse2D.Double(0, 0, 4, 4);
renderer.setSeriesShape(0, shape);
renderer.setSeriesPaint(0, Color.blue);
xyPlot.getRangeAxis().setRange(0, 10);
return chart;
}
示例14: configureAxisSeriesColors
import org.jfree.chart.renderer.xy.XYItemRenderer; //导入方法依赖的package包/类
/**
* The series colors set in the main plot of a multiple axis chart are used for
* all the rendered charts in the plot. This is a problem with multiple line
* charts, using different scales and thus different axis. All the lines will
* be drawn using the first series color (since they are the first series for that
* rendered) and it will be impossible to tell them apart.
* <br>
* For this reason we interpret series colors for charts included in a multiple
* axis chart as specify absolute series colors for that renderer.
*
* @param renderer the renderer of the chart being created
* @param jrPlot the Jasper view of that plot
*/
private void configureAxisSeriesColors(XYItemRenderer renderer, JRChartPlot jrPlot)
{
SortedSet<JRSeriesColor> seriesColors = jrPlot.getSeriesColors();
if (seriesColors != null)
{
Iterator<JRSeriesColor> iter = seriesColors.iterator();
while (iter.hasNext())
{
JRSeriesColor seriesColor = iter.next();
renderer.setSeriesPaint(seriesColor.getSeriesOrder(), seriesColor.getColor());
}
}
}
示例15: createCombinedChart
import org.jfree.chart.renderer.xy.XYItemRenderer; //导入方法依赖的package包/类
/**
* Creates an overlaid chart.
*
* @return The chart.
*/
private static JFreeChart createCombinedChart() {
// create plot ...
IntervalXYDataset data1 = createDataset1();
XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
renderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
renderer1.setSeriesStroke(0, new BasicStroke(4.0f,
BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
renderer1.setSeriesPaint(0, Color.blue);
DateAxis domainAxis = new DateAxis("Year");
domainAxis.setLowerMargin(0.0);
domainAxis.setUpperMargin(0.02);
ValueAxis rangeAxis = new NumberAxis("$billion");
XYPlot plot1 = new XYPlot(data1, null, rangeAxis, renderer1);
plot1.setBackgroundPaint(Color.lightGray);
plot1.setDomainGridlinePaint(Color.white);
plot1.setRangeGridlinePaint(Color.white);
// add a second dataset and renderer...
IntervalXYDataset data2 = createDataset2();
XYBarRenderer renderer2 = new XYBarRenderer() {
public Paint getItemPaint(int series, int item) {
XYDataset dataset = getPlot().getDataset();
if (dataset.getYValue(series, item) >= 0.0) {
return Color.red;
}
else {
return Color.green;
}
}
};
renderer2.setSeriesPaint(0, Color.red);
renderer2.setDrawBarOutline(false);
renderer2.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
XYPlot plot2 = new XYPlot(data2, null, new NumberAxis("$billion"),
renderer2);
plot2.setBackgroundPaint(Color.lightGray);
plot2.setDomainGridlinePaint(Color.white);
plot2.setRangeGridlinePaint(Color.white);
CombinedXYPlot cplot = new CombinedXYPlot(domainAxis, rangeAxis);
cplot.add(plot1, 3);
cplot.add(plot2, 2);
cplot.setGap(8.0);
cplot.setDomainGridlinePaint(Color.white);
cplot.setDomainGridlinesVisible(true);
// return a new chart containing the overlaid plot...
JFreeChart chart = new JFreeChart("CombinedXYPlotDemo1",
JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
chart.setBackgroundPaint(Color.white);
LegendTitle legend = new LegendTitle(cplot);
chart.addSubtitle(legend);
return chart;
}