本文整理汇总了Java中org.jfree.chart.plot.DatasetRenderingOrder类的典型用法代码示例。如果您正苦于以下问题:Java DatasetRenderingOrder类的具体用法?Java DatasetRenderingOrder怎么用?Java DatasetRenderingOrder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DatasetRenderingOrder类属于org.jfree.chart.plot包,在下文中一共展示了DatasetRenderingOrder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ScatterPlot
import org.jfree.chart.plot.DatasetRenderingOrder; //导入依赖的package包/类
/**
* Constructor: initialize the plot & chart
* @param title
*/
public ScatterPlot (String title) {
data = new ScatterData();
chart = ChartFactory.createScatterPlot(title,
"X",
"Y",
new DefaultXYDataset(), PlotOrientation.VERTICAL,
false,false,false);
chart.setBackgroundPaint(Color.white);
chart.setBorderVisible(false);
plot = chart.getXYPlot();
plot.setBackgroundPaint(Color.white);
plot.setOutlineVisible(false);
plot.setDomainGridlinesVisible(false);
plot.setRangeGridlinesVisible(false);
plot.setDomainZeroBaselineVisible(true);
plot.setRangeZeroBaselineVisible(true);
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
this.configAxes();
}
示例2: lineGraph
import org.jfree.chart.plot.DatasetRenderingOrder; //导入依赖的package包/类
public void lineGraph() {
final LengthDataset dataset = new LengthDataset(this.eventBus);
final JFreeChart chart = ChartFactory.createXYLineChart("", "Iteration", "Length", dataset, PlotOrientation.VERTICAL, true, false, true);
final XYPlot plot = chart.getXYPlot();
plot.setDataset(1, new FittnessDataset(this.eventBus));
plot.mapDatasetToRangeAxis(1, 1);
final XYItemRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
plot.setRenderer(1, renderer2);
plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);
final ValueAxis axis2 = new NumberAxis("Fittness");
plot.setRangeAxis(1, axis2);
final ChartPanel panel = new ChartPanel(chart);
final JFrame jFrame = new JFrame();
jFrame.setContentPane(panel);
jFrame.pack();
jFrame.setVisible(true);
}
示例3: paint
import org.jfree.chart.plot.DatasetRenderingOrder; //导入依赖的package包/类
protected void paint( PPaintContext paintContext ) {
Graphics2D g2 = paintContext.getGraphics();
if ( _renderingHints != null ) {
g2.setRenderingHints( _renderingHints );
}
// Clip to the data area.
// Do NOT call g2.setClip, or really bad things happen
// with drawing order on Macintosh (and possibly other platforms).
paintContext.pushClip( _dataArea );
// Render each of the plot's datasets, in the proper order...
int numberOfDatasets = _plot.getDatasetCount();
DatasetRenderingOrder renderingOrder = _plot.getDatasetRenderingOrder();
if ( renderingOrder == DatasetRenderingOrder.FORWARD ) {
for ( int i = 0; i < numberOfDatasets; i++ ) {
_plot.render( g2, _dataArea, i, null, null );
}
}
else { /* DatasetRenderingOrder.REVERSE */
for ( int i = numberOfDatasets - 1; i >= 0; i-- ) {
_plot.render( g2, _dataArea, i, null, null );
}
}
// restore the clip
paintContext.popClip( null );
// optionally stroke the data area -- do this after restoring the clip
if ( _dataAreaStroked ) {
g2.setStroke( _plot.getOutlineStroke() );
g2.setPaint( _plot.getOutlinePaint() );
g2.draw( _dataArea );
}
}
示例4: addDatasetToPlot
import org.jfree.chart.plot.DatasetRenderingOrder; //导入依赖的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: getCategoryPlot
import org.jfree.chart.plot.DatasetRenderingOrder; //导入依赖的package包/类
/**
* Returns a CategoryPlot.
*/
private CategoryPlot getCategoryPlot( CategoryDataset dataSet, CategoryItemRenderer renderer,
PlotOrientation orientation, CategoryLabelPositions labelPositions )
{
CategoryPlot plot = new CategoryPlot( dataSet, new CategoryAxis(), new NumberAxis(), renderer );
plot.setDatasetRenderingOrder( DatasetRenderingOrder.FORWARD );
plot.setOrientation( orientation );
CategoryAxis xAxis = plot.getDomainAxis();
xAxis.setCategoryLabelPositions( labelPositions );
return plot;
}
示例6: createChart
import org.jfree.chart.plot.DatasetRenderingOrder; //导入依赖的package包/类
private JFreeChart createChart() {
if (data.getItemCount() > 0) {
// get cumulative percentages
KeyedValues cumulative = DataUtilities.getCumulativePercentages(data);
CategoryDataset categoryDataset = DatasetUtilities.createCategoryDataset(
"Count for " + this.dataTable.getColumnName(this.countColumn) + " = " + countValue, data);
// create the chart...
final JFreeChart chart = ChartFactory.createBarChart(null, // chart title
this.dataTable.getColumnName(this.groupByColumn), // domain axis label
"Count", // range axis label
categoryDataset, // data
PlotOrientation.VERTICAL, true, // include legend
true, false);
// set the background color for the chart...
chart.setBackgroundPaint(Color.WHITE);
// get a reference to the plot for further customization...
CategoryPlot plot = chart.getCategoryPlot();
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setLowerMargin(0.02);
domainAxis.setUpperMargin(0.02);
domainAxis.setLabelFont(LABEL_FONT_BOLD);
domainAxis.setTickLabelFont(LABEL_FONT);
// set the range axis to display integers only...
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits(Locale.US));
rangeAxis.setLabelFont(LABEL_FONT_BOLD);
rangeAxis.setTickLabelFont(LABEL_FONT);
// second data set (cumulative percentages)
CategoryDataset dataset2 = DatasetUtilities.createCategoryDataset("Cumulative (Percent)", cumulative);
LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
renderer2.setSeriesPaint(0, SwingTools.VERY_DARK_BLUE.darker());
NumberAxis axis2 = new NumberAxis("Percent of " + countValue);
axis2.setNumberFormatOverride(NumberFormat.getPercentInstance());
axis2.setLabelFont(LABEL_FONT_BOLD);
axis2.setTickLabelFont(LABEL_FONT);
plot.setRangeAxis(1, axis2);
plot.setDataset(1, dataset2);
plot.setRenderer(1, renderer2);
plot.mapDatasetToRangeAxis(1, 1);
axis2.setTickUnit(new NumberTickUnit(0.1));
// show grid lines
plot.setRangeGridlinesVisible(true);
// bring cumulative line to front
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
if (isLabelRotating()) {
domainAxis.setTickLabelsVisible(true);
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
}
return chart;
} else {
return null;
}
}
示例7: main
import org.jfree.chart.plot.DatasetRenderingOrder; //导入依赖的package包/类
public static void main(String[] args) {
/**
* Getting time series
*/
TimeSeries series = CsvTradesLoader.loadBitstampSeries();
/**
* Creating the OHLC dataset
*/
OHLCDataset ohlcDataset = createOHLCDataset(series);
/**
* Creating the additional dataset
*/
TimeSeriesCollection xyDataset = createAdditionalDataset(series);
/**
* Creating the chart
*/
JFreeChart chart = ChartFactory.createCandlestickChart(
"Bitstamp BTC price",
"Time",
"USD",
ohlcDataset,
true);
// Candlestick rendering
CandlestickRenderer renderer = new CandlestickRenderer();
renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
XYPlot plot = chart.getXYPlot();
plot.setRenderer(renderer);
// Additional dataset
int index = 1;
plot.setDataset(index, xyDataset);
plot.mapDatasetToRangeAxis(index, 0);
XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
renderer2.setSeriesPaint(index, Color.blue);
plot.setRenderer(index, renderer2);
// Misc
plot.setRangeGridlinePaint(Color.lightGray);
plot.setBackgroundPaint(Color.white);
NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
numberAxis.setAutoRangeIncludesZero(false);
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
/**
* Displaying the chart
*/
displayChart(chart);
}
示例8: GeneratePlot
import org.jfree.chart.plot.DatasetRenderingOrder; //导入依赖的package包/类
public void GeneratePlot(String pngfile) throws IOException {
String modelfile = FilenameUtils.getFullPath(pngfile) + "/" + FilenameUtils.getBaseName(pngfile) + "_ModelPoints.txt";
FileWriter writer = new FileWriter(modelfile);
double[] IDObs = new double[IDEmpiricalDist.getN()];
double[] DecoyObs = new double[DecoyEmpiricalDist.getN()];
for (int i = 0; i < IDEmpiricalDist.getN(); i++) {
IDObs[i] = IDEmpiricalDist.getObs(i);
}
for (int i = 0; i < DecoyEmpiricalDist.getN(); i++) {
DecoyObs[i] = DecoyEmpiricalDist.getObs(i);
}
XYSeries model1 = new XYSeries("Incorrect matches");
XYSeries model2 = new XYSeries("Correct matches");
XYSeries model3 = new XYSeries("All target hits");
writer.write("UScore\tModel\tCorrect\tDecoy\n");
for (int i = 0; i < NoBinPoints; i++) {
model1.add(model_kde_x[i], decoy_kde_y[i]);
model2.add(model_kde_x[i], correct_kde_y[i]);
model3.add(model_kde_x[i], model_kde_y[i]);
writer.write(model_kde_x[i] + "\t" + model_kde_y[i] + "\t" + correct_kde_y[i] + "\t" + decoy_kde_y[i] + "\n");
}
writer.close();
MixtureModelProb = new Float[NoBinPoints + 1][3];
float positiveaccu = 0f;
float negativeaccu = 0f;
MixtureModelProb[0][0] = (float) model2.getMaxX() + Float.MIN_VALUE;
MixtureModelProb[0][1] = 1f;
MixtureModelProb[0][2] = 1f;
for (int i = 1; i < NoBinPoints + 1; i++) {
double positiveNumber = correct_kde_y[NoBinPoints - i];
double negativeNumber = decoy_kde_y[NoBinPoints - i];
MixtureModelProb[i][0] = (float) model_kde_x[NoBinPoints - i];
positiveaccu += positiveNumber;
negativeaccu += negativeNumber;
MixtureModelProb[i][2] = 0.999999f * (float) (positiveNumber / (negativeNumber + positiveNumber));
MixtureModelProb[i][1] = 0.999999f * (float) (positiveaccu / (negativeaccu + positiveaccu));
}
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(model1);
dataset.addSeries(model2);
dataset.addSeries(model3);
HistogramDataset histogramDataset = new HistogramDataset();
histogramDataset.setType(HistogramType.SCALE_AREA_TO_1);
histogramDataset.addSeries("ID hits", IDObs, 100);
histogramDataset.addSeries("Decoy hits", DecoyObs, 100);
//histogramDataset.addSeries("Model hits", ModelObs, 100);
JFreeChart chart = ChartFactory.createHistogram(FilenameUtils.getBaseName(pngfile), "Score", "Hits", histogramDataset, PlotOrientation.VERTICAL, true, false, false);
XYPlot plot = chart.getXYPlot();
NumberAxis domain = (NumberAxis) plot.getDomainAxis();
domain.setRange(min, max);
plot.setBackgroundPaint(Color.white);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setForegroundAlpha(0.8f);
chart.setBackgroundPaint(Color.white);
XYLineAndShapeRenderer render = new XYLineAndShapeRenderer();
plot.setDataset(1, dataset);
plot.setRenderer(1, render);
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
try {
ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
} catch (IOException e) {
}
}
示例9: createChart
import org.jfree.chart.plot.DatasetRenderingOrder; //导入依赖的package包/类
/**
* This method creates the JFreeChart based on all of the incoming data sets.
*
* @param eventsDataset This is the data set corresponding to the events bar chart graph.
* @param recordersDataset This is the data set corresponding to the recorders line graph.
* @param samplesDataset This is the data set corresponding to the samples line graph.
* @return This returns a JFreeChart with all 3 of the graphs described.
*/
private static JFreeChart createChart(final CategoryDataset eventsDataset, final CategoryDataset recordersDataset,
final CategoryDataset samplesDataset) {
final CategoryItemRenderer eventsRenderer = new BarRenderer();
((BarRenderer) eventsRenderer).setBarPainter(new StandardBarPainter()); // Remove shine
((BarRenderer) eventsRenderer).setShadowVisible(false);
eventsRenderer.setSeriesPaint(0, new Color(224, 0, 51));
eventsRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
final CategoryPlot plot = new CategoryPlot();
plot.setDataset(eventsDataset);
plot.setRenderer(eventsRenderer);
plot.setDomainAxis(new CategoryAxis(""));
plot.setRangeAxis(new NumberAxis(""));
plot.setOrientation(PlotOrientation.VERTICAL);
plot.setRangeGridlinesVisible(true);
plot.setDomainGridlinesVisible(true);
plot.setDomainAxis(new NumericCategoryAxis());
plot.getDomainAxis().setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
final CategoryItemRenderer recorderRenderer = new LineAndShapeRenderer(true, false);
recorderRenderer.setSeriesStroke(0,
new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f));
recorderRenderer.setSeriesPaint(0, new Color(102, 102, 255));
recorderRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
// Temporarily removing recorders dataset
// plot.setDataset(1, recordersDataset);
// plot.setRenderer(1, recorderRenderer);
final CategoryItemRenderer samplesRenderer = new LineAndShapeRenderer(true, false);
samplesRenderer.setSeriesStroke(0, new BasicStroke(2.0f));
samplesRenderer.setSeriesPaint(0, new Color(0, 153, 0));
samplesRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
plot.setDataset(2, samplesDataset);
plot.setRenderer(2, samplesRenderer);
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_90);
plot.getDomainAxis().setLowerMargin(0.025);
plot.getDomainAxis().setUpperMargin(0.025);
final JFreeChart chart = new JFreeChart(plot);
return chart;
}
示例10: createChart
import org.jfree.chart.plot.DatasetRenderingOrder; //导入依赖的package包/类
/**
* Creates a demo chart.
*
* @return A chart.
*/
@SuppressWarnings("deprecation")
public static JFreeChart createChart(String title, double[] meanByWindow, int lengthOfWindow, int yearsPriorOfEvent,
int yearsAfterEvent, double[][] leftEndPointSim, double[][] rightEndPointSim, String outputFilePrefix, int alphaLevel,
int segmentIndex) {
JSEABarChart.meanByWindow = meanByWindow;
JSEABarChart.lengthOfWindow = lengthOfWindow;
JSEABarChart.yearsPriorOfEvent = yearsPriorOfEvent;
JSEABarChart.leftEndPointSim = leftEndPointSim;
JSEABarChart.rightEndPointSim = rightEndPointSim;
JSEABarChart.alphaLevel = alphaLevel;
CategoryPlot plot = new CategoryPlot();
plot.setDataset(0, createDataset());
plot.setOrientation(PlotOrientation.VERTICAL);
CustomBarRenderer renderer = new CustomBarRenderer(createPaint(lengthOfWindow, Color.gray));
renderer.setBarPainter(new StandardBarPainter());
renderer.setDrawBarOutline(false);
renderer.setOutlinePaint(Color.yellow);
renderer.setOutlineStroke(new BasicStroke(1.1f, BasicStroke.JOIN_ROUND, BasicStroke.JOIN_BEVEL));
renderer.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
plot.setRenderer(0, renderer);
Color allcolors[] = { Color.red, Color.green, Color.blue };
System.out.println("here is the alphlevel " + alphaLevel);
// for (int k = 0; k <= 5; k++) {
// if (k <= 2) {
// / plot.setDataset(k + 1, createEndDataset(k, true));
// plot.setRenderer(k + 1, createCategoryItemRenderer(allcolors[k], k));
// } else {
// plot.setDataset(k + 1, createEndDataset(k - 3, false));
// plot.setRenderer(k + 1, createCategoryItemRenderer(allcolors[k - 3], k - 3));
// }
// }
// for (int k = 0; k <1; k++) {
// if (k <= 2) {
plot.setDataset(1, createEndDataset(alphaLevel, true));
plot.setRenderer(1, createCategoryItemRenderer(allcolors[alphaLevel], alphaLevel));
// } else {
plot.setDataset(4, createEndDataset(alphaLevel, false));
plot.setRenderer(4, createCategoryItemRenderer(allcolors[alphaLevel], alphaLevel));
// }
// }
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
// plot.setBackgroundPaint(Color.WHITE);
plot.setDomainAxis(new CategoryAxis("LAG"));
plot.addRangeMarker(new ValueMarker(0));
plot.setRangeAxis(new NumberAxis(outputFilePrefix));
plot.setRangeGridlinesVisible(true);
JFreeChart chart = new JFreeChart(plot);
chart.setTitle(title);
chart.removeLegend();
chart.setBackgroundPaint(Color.WHITE);
return chart;
}
示例11: AlignmentRansacPlot
import org.jfree.chart.plot.DatasetRenderingOrder; //导入依赖的package包/类
public AlignmentRansacPlot() {
super(null, true);
dataset = new XYSeriesCollection();
chart = ChartFactory.createXYLineChart("", null, null, dataset,
PlotOrientation.VERTICAL, true, true, false);
chart.setBackgroundPaint(Color.white);
setChart(chart);
// title
chartTitle = chart.getTitle();
chartTitle.setMargin(5, 0, 0, 0);
chartTitle.setFont(titleFont);
// legend constructed by ChartFactory
legend = chart.getLegend();
legend.setItemFont(legendFont);
legend.setFrame(BlockBorder.NONE);
// set the plot properties
plot = chart.getXYPlot();
plot.setBackgroundPaint(Color.white);
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
// set grid properties
plot.setDomainGridlinePaint(gridColor);
plot.setRangeGridlinePaint(gridColor);
// set crosshair (selection) properties
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
plot.setDomainCrosshairPaint(crossHairColor);
plot.setRangeCrosshairPaint(crossHairColor);
plot.setDomainCrosshairStroke(crossHairStroke);
plot.setRangeCrosshairStroke(crossHairStroke);
// set default renderer properties
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
renderer.setDefaultLinesVisible(false);
renderer.setDefaultShapesVisible(true);
renderer.setSeriesShape(0, dataPointsShape);
renderer.setSeriesShape(1, dataPointsShape);
renderer.setSeriesLinesVisible(2, true);
renderer.setSeriesShapesVisible(2, false);
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesPaint(1, Color.GRAY);
renderer.setSeriesPaint(2, Color.BLUE);
renderer.setDefaultItemLabelPaint(labelsColor);
renderer.setDrawSeriesLineAsPath(true);
plot.setRenderer(renderer);
}
示例12: HistogramChart
import org.jfree.chart.plot.DatasetRenderingOrder; //导入依赖的package包/类
public HistogramChart() {
super(null, true);
// initialize the chart by default time series chart from factory
chart = ChartFactory.createHistogram("", // title
"", // x-axis label
"", // y-axis label
null, // data set
PlotOrientation.VERTICAL, // orientation
true, // create legend
false, // generate tooltips
false // generate URLs
);
// title
chartTitle = chart.getTitle();
chartTitle.setFont(titleFont);
chartTitle.setMargin(5, 0, 0, 0);
chartSubTitle = new TextTitle();
chartSubTitle.setFont(subTitleFont);
chartSubTitle.setMargin(5, 0, 0, 0);
chart.addSubtitle(chartSubTitle);
// legend constructed by ChartFactory
LegendTitle legend = chart.getLegend();
legend.setItemFont(legendFont);
legend.setFrame(BlockBorder.NONE);
chart.setBackgroundPaint(Color.white);
setChart(chart);
// disable maximum size (we don't want scaling)
setMaximumDrawWidth(Integer.MAX_VALUE);
setMaximumDrawHeight(Integer.MAX_VALUE);
// set the plot properties
plot = chart.getXYPlot();
plot.setBackgroundPaint(Color.white);
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);
plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
// set grid properties
plot.setDomainGridlinePaint(gridColor);
plot.setRangeGridlinePaint(gridColor);
// set crosshair (selection) properties
plot.setDomainCrosshairVisible(false);
plot.setRangeCrosshairVisible(true);
// set the logarithmic axis
NumberAxis axisDomain = new HistogramDomainAxis();
axisDomain.setMinorTickCount(1);
axisDomain.setAutoRange(true);
NumberAxis axisRange = new NumberAxis();
axisRange.setMinorTickCount(1);
axisRange.setAutoRange(true);
plot.setDomainAxis(axisDomain);
plot.setRangeAxis(axisRange);
ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer();
renderer.setMargin(marginSize);
renderer.setShadowVisible(false);
plot.setRenderer(renderer);
this.setMinimumSize(new Dimension(400, 400));
this.setDismissDelay(Integer.MAX_VALUE);
this.setInitialDelay(0);
}
示例13: getIecChart
import org.jfree.chart.plot.DatasetRenderingOrder; //导入依赖的package包/类
private JFreeChart getIecChart(ThemeDisplay themeDisplay) throws SystemException {
final CategoryDataset porcentajeModulos = getDataSetPercentajes(themeDisplay);
String chartTitle = LanguageUtil.get(themeDisplay.getLocale(), "userprogress.export.pdf.title");
String chartLabelLegend = LanguageUtil.get(themeDisplay.getLocale(), "userprogress.export.pdf.chart.legend.label");
String chartLabellLeft = LanguageUtil.get(themeDisplay.getLocale(), "userprogress.export.pdf.chart.label.left");
final JFreeChart chart = ChartFactory.createBarChart(
chartTitle, // title
chartLabelLegend, // domain axis label
chartLabellLeft, // range axis label
porcentajeModulos, // data
PlotOrientation.VERTICAL,
true, // legend
true, // tooltips
false // url
);
chart.setBackgroundPaint(Color.white);
final CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(new Color(222,222,222));
plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
plot.getRangeAxis(0).setRange(0, 100);
final CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
plot.getRenderer().setSeriesPaint(0, gradientGray);
final CategoryDataset horasRestantes = getDataSetTimeLeft(themeDisplay);
plot.setDataset(1, horasRestantes);
plot.mapDatasetToRangeAxis(1, 1);
final ValueAxis axis2 = new NumberAxis(LanguageUtil.get(themeDisplay.getLocale(), "userprogress.export.pdf.chart.label.right"));
plot.setRangeAxis(1, axis2);
final LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
renderer2.setBaseLinesVisible(false);
renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
plot.setRenderer(1, renderer2);
plot.getRenderer(1).setSeriesPaint(0, gradientBlue);
// Mostrar el primer dataset por debajo del resto de dataset
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
return chart;
}
示例14: initialize
import org.jfree.chart.plot.DatasetRenderingOrder; //导入依赖的package包/类
public void initialize() {
final JFreeChart chart = chartNode.getChart();
final XYPlot plot = chart.getXYPlot();
// Do not set colors and strokes dynamically. They are instead provided
// by the dataset and configured in configureRenderer()
plot.setDrawingSupplier(null);
plot.setDomainGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor));
plot.setRangeGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor));
plot.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor));
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
plot.setDomainCrosshairVisible(false);
plot.setRangeCrosshairVisible(false);
// chart properties
chart.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor));
// legend properties
LegendTitle legend = chart.getLegend();
// legend.setItemFont(legendFont);
legend.setFrame(BlockBorder.NONE);
// set the X axis (m/z) properties
NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
xAxis.setLabel("m/z");
xAxis.setUpperMargin(0.03);
xAxis.setLowerMargin(0.03);
xAxis.setRangeType(RangeType.POSITIVE);
xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20));
// set the Y axis (intensity) properties
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
yAxis.setLabel("Intensity");
yAxis.setRangeType(RangeType.POSITIVE);
yAxis.setAutoRangeIncludesZero(true);
// set the fixed number formats, because otherwise JFreeChart sometimes
// shows exponent, sometimes it doesn't
DecimalFormat mzFormat = MZmineCore.getConfiguration().getMZFormat();
xAxis.setNumberFormatOverride(mzFormat);
DecimalFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat();
yAxis.setNumberFormatOverride(intensityFormat);
chartTitle = chartNode.getChart().getTitle();
chartTitle.setMargin(5, 0, 0, 0);
chartTitle.setFont(titleFont);
chartNode.setCursor(Cursor.CROSSHAIR);
// Remove the dataset if it is removed from the list
datasets.addListener((Change<? extends MsSpectrumDataSet> c) -> {
while (c.next()) {
if (c.wasRemoved()) {
for (MsSpectrumDataSet ds : c.getRemoved()) {
int index = plot.indexOf(ds);
plot.setDataset(index, null);
}
}
}
});
itemLabelsVisible.addListener((prop, oldVal, newVal) -> {
for (MsSpectrumDataSet dataset : datasets) {
int datasetIndex = plot.indexOf(dataset);
XYItemRenderer renderer = plot.getRenderer(datasetIndex);
renderer.setBaseItemLabelsVisible(newVal);
}
});
legendVisible.addListener((prop, oldVal, newVal) -> {
legend.setVisible(newVal);
});
}
示例15: initialize
import org.jfree.chart.plot.DatasetRenderingOrder; //导入依赖的package包/类
@FXML
public void initialize() {
final JFreeChart chart = chartNode.getChart();
final XYPlot plot = chart.getXYPlot();
// Do not set colors and strokes dynamically. They are instead provided
// by the dataset and configured in configureRenderer()
plot.setDrawingSupplier(null);
plot.setDomainGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor));
plot.setRangeGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor));
plot.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor));
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
plot.setDomainCrosshairPaint(JavaFXUtil.convertColorToAWT(crossHairColor));
plot.setRangeCrosshairPaint(JavaFXUtil.convertColorToAWT(crossHairColor));
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
// chart properties
chart.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor));
// legend properties
LegendTitle legend = chart.getLegend();
// legend.setItemFont(legendFont);
legend.setFrame(BlockBorder.NONE);
// set the X axis (retention time) properties
NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
xAxis.setLabel("Retention time (min)");
xAxis.setUpperMargin(0.03);
xAxis.setLowerMargin(0.03);
xAxis.setRangeType(RangeType.POSITIVE);
xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20));
// set the Y axis (intensity) properties
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
yAxis.setLabel("Intensity");
yAxis.setRangeType(RangeType.POSITIVE);
yAxis.setAutoRangeIncludesZero(true);
// set the fixed number formats, because otherwise JFreeChart sometimes
// shows exponent, sometimes it doesn't
DecimalFormat mzFormat = MZmineCore.getConfiguration().getMZFormat();
xAxis.setNumberFormatOverride(mzFormat);
DecimalFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat();
yAxis.setNumberFormatOverride(intensityFormat);
chartTitle = chartNode.getChart().getTitle();
chartTitle.setMargin(5, 0, 0, 0);
chartTitle.setFont(titleFont);
chartTitle.setText("Chromatogram");
chartNode.setCursor(Cursor.CROSSHAIR);
// Remove the dataset if it is removed from the list
datasets.addListener((Change<? extends ChromatogramPlotDataSet> c) -> {
while (c.next()) {
if (c.wasRemoved()) {
for (ChromatogramPlotDataSet ds : c.getRemoved()) {
int index = plot.indexOf(ds);
plot.setDataset(index, null);
}
}
}
});
itemLabelsVisible.addListener((prop, oldVal, newVal) -> {
for (ChromatogramPlotDataSet dataset : datasets) {
int datasetIndex = plot.indexOf(dataset);
XYItemRenderer renderer = plot.getRenderer(datasetIndex);
renderer.setBaseItemLabelsVisible(newVal);
}
});
legendVisible.addListener((prop, oldVal, newVal) -> {
legend.setVisible(newVal);
});
}