本文整理汇总了Java中org.jfree.chart.renderer.xy.XYLineAndShapeRenderer.setSeriesStroke方法的典型用法代码示例。如果您正苦于以下问题:Java XYLineAndShapeRenderer.setSeriesStroke方法的具体用法?Java XYLineAndShapeRenderer.setSeriesStroke怎么用?Java XYLineAndShapeRenderer.setSeriesStroke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.renderer.xy.XYLineAndShapeRenderer
的用法示例。
在下文中一共展示了XYLineAndShapeRenderer.setSeriesStroke方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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 );
}
示例2: editRenderer
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入方法依赖的package包/类
/**
* Edit the parameters in the renderer
* @param i
* @param dotSize
* @param p
*/
public void editRenderer(int i, int dotSize, Paint p, boolean drawLines, boolean drawShapes){
XYLineAndShapeRenderer rend = renderers.get(i);
rend.setSeriesPaint(0, p);
rend.setSeriesShape(0, new Ellipse2D.Double(0, 0, dotSize, dotSize));
rend.setSeriesStroke(0, new BasicStroke(2));
rend.setSeriesLinesVisible(0, drawLines);
rend.setSeriesShapesVisible(0, drawShapes);
}
示例3: TimeSeriesViewObserver
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入方法依赖的package包/类
/**
* 构造分时图的全部元素
*/
public TimeSeriesViewObserver() {
timeSeriesPrice = new TimeSeries("分时图", Hour.class);
timeSeriesPrice.add(new Hour(count++, day), StockSubject.OPENING_PRICE);
timeSeriesPrice.setMaximumItemAge(MAXIMUM_ITEM_AGE);
TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
timeseriescollection.addSeries(timeSeriesPrice);
DateAxis dateaxis = new DateAxis("时间");
NumberAxis numberaxis = new NumberAxis("股票价格");
dateaxis.setTickLabelFont(new Font("微软雅黑", 0, 12));
numberaxis.setTickLabelFont(new Font("微软雅黑", 0, 12));
dateaxis.setLabelFont(new Font("微软雅黑", 0, 12));
numberaxis.setLabelFont(new Font("微软雅黑", 0, 12));
XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
xylineandshaperenderer.setSeriesPaint(0, Color.red);
xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(1F, 0, 1));
XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer);
xyplot.setAxisOffset(new RectangleInsets(0D, 0D, 0D, 0D));
dateaxis.setAutoRange(true);
dateaxis.setLowerMargin(0.0D);
dateaxis.setUpperMargin(0.0D);
dateaxis.setTickLabelsVisible(true);
numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
JFreeChart chart = new JFreeChart("中国铁通股票", new Font("微软雅黑", 1, 12), xyplot, true);
chartPanel = new ChartPanel(chart);
}
示例4: addDatasetToPlot
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入方法依赖的package包/类
private void addDatasetToPlot(XYPlot xyPlot, XYDataset xyDataset) {
int index = xyPlot.getDatasetCount();
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
for (int i = 0, size = xyDataset.getSeriesCount(); i < size; ++i) {
renderer.setSeriesShapesVisible(i, false);
renderer.setSeriesStroke(i, new BasicStroke(1.5f));
}
xyPlot.setRenderer(index, renderer);
xyPlot.setDataset(index, xyDataset);
xyPlot.mapDatasetToRangeAxis(index, 0);
xyPlot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
}
示例5: setLineStyle
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入方法依赖的package包/类
/**
* This method specifies shape of markers and line width.
* It is intended for advanced users, who are familiar with Java2D API.
*
* @param lineIndex index specifying the line. Indices are assigned to
* lines in the same order as they were added to chart. Use jPlot.LAST_IDX
* to refer to the last line added.
* @param marker shape drawn at point positions, for example new
* Rectangle2D.Double(-4, -4, 8, 8). May also be null, to keep
* the existing shape.
* @param lineWidth line width
* @param style specifies lenghts of dashes and spaces, for example new
* float[]{1, 10, 5, 5}
*/
public void setLineStyle(int lineIndex,
Shape marker,
int lineWidth,
float[] style) {
XYPlot plot = m_chart.getXYPlot();
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
lineIndex = getLastIndex(lineIndex);
if (marker != null) {
renderer.setSeriesShape(lineIndex, marker);
if (style == null) { // no line, draw only markers
/* float dashPhase = 0;
Stroke stroke = new BasicStroke(lineWidth,
BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND,
2,
null,
dashPhase);
renderer.setSeriesStroke(lineIndex, stroke);
*/
setLineVisibility(lineIndex, false, true);
} else {
setLineVisibility(lineIndex, true, true); // show line and markers
}
}
if (style != null) {
float dashPhase = 0;
Stroke stroke = new BasicStroke(lineWidth,
BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND,
2,
style,
dashPhase);
renderer.setSeriesStroke(lineIndex, stroke);
}
}
示例6: configureXYLineAndShapeRenderer
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入方法依赖的package包/类
private static void configureXYLineAndShapeRenderer(XYLineAndShapeRenderer renderer, ValueSource valueSource,
PlotInstance plotInstance) {
renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
SeriesFormat seriesFormat = valueSource.getSeriesFormat();
DimensionConfig domainConfig = valueSource.getDomainConfig();
DimensionConfig colorDimensionConfig = plotInstance.getCurrentPlotConfigurationClone().getDimensionConfig(
PlotDimension.COLOR);
DimensionConfig shapeDimensionConfig = plotInstance.getCurrentPlotConfigurationClone().getDimensionConfig(
PlotDimension.SHAPE);
ValueSourceData valueSourceData = plotInstance.getPlotData().getValueSourceData(valueSource);
int seriesCount = valueSourceData.getSeriesDataForAllGroupCells().groupCellCount();
// Loop all series and set series format.
// Format based on dimension configs will be set later on in initFormatDelegate().
for (int seriesIdx = 0; seriesIdx < seriesCount; ++seriesIdx) {
// configure linestyle
if (seriesFormat.getLineStyle() == LineStyle.NONE) {
renderer.setSeriesLinesVisible(seriesIdx, false);
} else {
renderer.setSeriesLinesVisible(seriesIdx, true);
renderer.setSeriesStroke(seriesIdx, seriesFormat.getStroke(), false);
}
// configure series shape if necessary
if (!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, shapeDimensionConfig)) {
if (seriesFormat.getItemShape() != ItemShape.NONE) {
renderer.setSeriesShapesVisible(seriesIdx, true);
renderer.setSeriesShape(seriesIdx, seriesFormat.getItemShape().getShape());
} else {
renderer.setSeriesShapesVisible(seriesIdx, false);
}
}
// configure series color if necessary
if (!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, colorDimensionConfig)) {
Color itemColor = seriesFormat.getItemColor();
renderer.setSeriesPaint(seriesIdx, itemColor);
renderer.setSeriesFillPaint(seriesIdx, itemColor);
}
renderer.setSeriesOutlinePaint(seriesIdx, PlotConfiguration.DEFAULT_SERIES_OUTLINE_PAINT);
renderer.setUseOutlinePaint(true);
}
}
示例7: BetaChart
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入方法依赖的package包/类
public BetaChart( int maxItemCount ) {
this.maxItemCount = maxItemCount;
meanSeries = new XYSeries( "Raw Data" );
lineSeries = new XYSeries( "Mean Values" );
bestFitSeries = new XYSeries( "Best Fit" );
xySeriesCollection = new XYSeriesCollection( meanSeries );
xySeriesCollection.addSeries( lineSeries );
xySeriesCollection.addSeries( bestFitSeries );
domainAxis = new NumberAxis( "ln[(c-r)/c]" );
rangeAxis = new NumberAxis( "ln(Order Parameter)" );
renderer = new XYLineAndShapeRenderer();
int RAW_DATA_SERIES = 0;
int LINE_SERIES = 1;
int BEST_FIT_SERIES = 2;
renderer.setSeriesShape( RAW_DATA_SERIES, new Ellipse2D.Double( -3, -3, 6, 6 ) );
renderer.setSeriesShape( LINE_SERIES, new Rectangle( -4, -4, 8, 8 ) );
renderer.setSeriesLinesVisible( RAW_DATA_SERIES, false );
renderer.setSeriesShapesVisible( RAW_DATA_SERIES, true );
Color blue = new Color( 0, 0, 255, 14 );
renderer.setSeriesPaint( RAW_DATA_SERIES, blue );
renderer.setSeriesItemLabelPaint( RAW_DATA_SERIES, blue );
renderer.setSeriesOutlinePaint( RAW_DATA_SERIES, blue );
renderer.setSeriesLinesVisible( LINE_SERIES, true );
renderer.setSeriesLinesVisible( BEST_FIT_SERIES, true );
renderer.setSeriesShapesVisible( BEST_FIT_SERIES, false );
renderer.setSeriesStroke( BEST_FIT_SERIES, new BasicStroke( 2 ) );
renderer.setSeriesPaint( BEST_FIT_SERIES, Color.green );
xyPlot = new XYPlot( xySeriesCollection,
domainAxis,
rangeAxis, renderer );
chart = new JFreeChart( "Critical Exponent Log Plot", xyPlot );
rangeAxis.setAutoRange( true );
rangeAxis.setAutoRangeIncludesZero( false );
domainAxis.setAutoRange( true );
domainAxis.setAutoRangeIncludesZero( false );
}
示例8: createSubplot
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入方法依赖的package包/类
public XYPlot createSubplot(int numOfPlot) {
ArrayList<XYSeries> serie = new ArrayList<>(4);
serie.add(new XYSeries("Worst of generation"));
serie.add(new XYSeries("Best of generation"));
serie.add(new XYSeries("Generation average"));
serie.add(new XYSeries("Absolute best"));
this.series.add(serie);
XYSeriesCollection dataset1 = new XYSeriesCollection();
XYSeriesCollection dataset2 = new XYSeriesCollection();
ArrayList<XYSeriesCollection> datasetCol = new ArrayList<>(2);
datasetCol.add(dataset1);
datasetCol.add(dataset2);
this.datasets.add(datasetCol);
XYPlot plot = new XYPlot();
plot.setDataset(0, dataset2);
XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false);
lineRenderer.setSeriesPaint(0, blue1);
lineRenderer.setSeriesStroke(0, stroke1);
lineRenderer.setSeriesPaint(1, blue2);
lineRenderer.setSeriesStroke(1, stroke2);
if(numOfPlot == 0) {
lineRenderer.setSeriesVisibleInLegend(0, true);
lineRenderer.setSeriesVisibleInLegend(1, true);
}
else {
lineRenderer.setSeriesVisibleInLegend(0, false);
lineRenderer.setSeriesVisibleInLegend(1, false);
}
plot.setRenderer(0, lineRenderer);
plot.setDataset(1, dataset1);
XYDifferenceRenderer diffRenderer = new XYDifferenceRenderer(
blue, blue, false
);
diffRenderer.setSeriesPaint(0, transparent);
diffRenderer.setSeriesPaint(1, transparent);
diffRenderer.setSeriesVisibleInLegend(0, false);
diffRenderer.setSeriesVisibleInLegend(1, false);
plot.setRenderer(1, diffRenderer);
plot.setOutlinePaint(null);
plot.setBackgroundPaint(Color.white);
plot.setForegroundAlpha(1);
plot.setDomainGridlinePaint(lighterGray);
plot.setRangeGridlinePaint(lighterGray);
NumberAxis domainAxis = new NumberAxis("");
plot.setDomainAxis(domainAxis);
domainAxis.setTickMarkPaint(Color.black);
domainAxis.setLowerMargin(0.0);
domainAxis.setUpperMargin(0.0);
domainAxis.setAutoRangeIncludesZero(false);
NumberAxis rangeAxis = new NumberAxis(this.gCtrl.getFitnessName(numOfPlot));
plot.setRangeAxis(rangeAxis);
rangeAxis.setTickMarkPaint(Color.black);
rangeAxis.setLowerMargin(0.01);
rangeAxis.setUpperMargin(0.01);
rangeAxis.setAutoRangeIncludesZero(false);
return plot;
}
示例9: createGraph
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; //导入方法依赖的package包/类
public static void createGraph(String toDir, Paint bgColor, String title, String XAxisLabel, String YAxisLabel, List<Double> xData ,List<Double> yData)
{
JFreeChart chart;
ScenarioPlotTool plotter = new ScenarioPlotTool();
try
{
XYSeriesCollection dataSet = new XYSeriesCollection();
chart = ChartFactory.createXYLineChart(
title , // chart title
XAxisLabel, // x axis label
YAxisLabel, // y axis label
dataSet, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips
false // urls
);
XYPlot plot = (XYPlot) chart.getPlot();
XYLineAndShapeRenderer r = new XYLineAndShapeRenderer();
plot.setRenderer(r);
plotter.formatXYPlot(chart, Color.white);
// Set up the line to plot
BasicStroke wideLine = new BasicStroke( ScenarioPlotTool.lineWidth );
r.setSeriesStroke(0, wideLine);
r.setSeriesLinesVisible(0, true);
r.setSeriesShapesVisible(0, false);
dataSet.addSeries(plotter.createTruncatedXYSeries(title,xData,yData));
// Pull out our max and mins
List<Double> xMin = new ArrayList<Double>();
List<Double> yMin = new ArrayList<Double>();
List<Double> xMax = new ArrayList<Double>();
List<Double> yMax = new ArrayList<Double>();
WaveformUtils.getPeriodBounds(xData, yData, xMin, yMin, xMax, yMax);
// Let's put some shapes over the max's and min's
XYSeries seriesMaxes = new XYSeries("Max");
r.setSeriesLinesVisible(1, false);
r.setSeriesShapesVisible(1, true);
r.setSeriesPaint(1, Color.green);
Shape maxShape = ShapeUtilities.createUpTriangle(10);
r.setSeriesShape(1, maxShape);
for(int i=0; i<xMax.size(); i++)
seriesMaxes.add(xMax.get(i),yMax.get(i));
dataSet.addSeries(seriesMaxes);
XYSeries seriesMins = new XYSeries("Min");
r.setSeriesLinesVisible(2, false);
r.setSeriesShapesVisible(2, true);
r.setSeriesPaint(2, Color.red);
Shape minShape = ShapeUtilities.createDownTriangle(10);
r.setSeriesShape(2, minShape);
for(int i=0; i<xMin.size(); i++)
seriesMins.add(xMin.get(i),yMin.get(i));
dataSet.addSeries(seriesMins);
}
catch(Exception ex)
{
Log.error("Unable to make base chart");
return;
}
// Now let's mark all the max and min values
try
{
if(toDir==null||toDir.isEmpty())
toDir=".";
File JPGFile = new File(toDir+"/"+StringUtils.removeParens(title)+".jpg");
ChartUtilities.saveChartAsJPEG(JPGFile, chart, 3200, 1600);
}
catch (IOException e)
{
Log.error(e.getMessage());
}
}