本文整理汇总了Java中org.jfree.data.xy.XYDataset类的典型用法代码示例。如果您正苦于以下问题:Java XYDataset类的具体用法?Java XYDataset怎么用?Java XYDataset使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XYDataset类属于org.jfree.data.xy包,在下文中一共展示了XYDataset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPolarChart
import org.jfree.data.xy.XYDataset; //导入依赖的package包/类
/**
* Creates a polar plot for the specified dataset (x-values interpreted as
* angles in degrees). The chart object returned by this method uses a
* {@link PolarPlot} instance as the plot, with a {@link NumberAxis} for
* the radial axis.
*
* @param title the chart title (<code>null</code> permitted).
* @param dataset the dataset (<code>null</code> permitted).
* @param legend legend required?
* @param tooltips tooltips required?
* @param urls URLs required?
*
* @return A chart.
*/
public static JFreeChart createPolarChart(String title,
XYDataset dataset,
boolean legend,
boolean tooltips,
boolean urls) {
PolarPlot plot = new PolarPlot();
plot.setDataset(dataset);
NumberAxis rangeAxis = new NumberAxis();
rangeAxis.setAxisLineVisible(false);
rangeAxis.setTickMarksVisible(false);
rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
plot.setAxis(rangeAxis);
plot.setRenderer(new DefaultPolarItemRenderer());
JFreeChart chart = new JFreeChart(
title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
return chart;
}
示例2: setDataset
import org.jfree.data.xy.XYDataset; //导入依赖的package包/类
/**
* Sets a dataset for the plot.
*
* @param index the dataset index.
* @param dataset the dataset (<code>null</code> permitted).
*/
public void setDataset(int index, XYDataset dataset) {
XYDataset existing = getDataset(index);
if (existing != null) {
existing.removeChangeListener(this);
}
this.datasets.set(index, dataset);
if (dataset != null) {
dataset.addChangeListener(this);
}
// map dataset to main axis by default
if (index >= this.domainAxisMap.size()) {
this.domainAxisMap.set(index, new Integer(0));
}
if (index >= this.rangeAxisMap.size()) {
this.rangeAxisMap.set(index, new Integer(0));
}
// send a dataset change event to self...
DatasetChangeEvent event = new DatasetChangeEvent(this, dataset);
datasetChanged(event);
}
示例3: findRangeBounds
import org.jfree.data.xy.XYDataset; //导入依赖的package包/类
/**
* Returns the range of values the renderer requires to display all the
* items from the specified dataset.
*
* @param dataset the dataset (<code>null</code> permitted).
*
* @return The range (or <code>null</code> if the dataset is
* <code>null</code> or empty).
*/
public Range findRangeBounds(XYDataset dataset) {
if (dataset == null) {
return null;
}
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
TableXYDataset d = (TableXYDataset) dataset;
int itemCount = d.getItemCount();
for (int i = 0; i < itemCount; i++) {
double[] stackValues = getStackValues((TableXYDataset) dataset,
d.getSeriesCount(), i);
min = Math.min(min, stackValues[0]);
max = Math.max(max, stackValues[1]);
}
if (min == Double.POSITIVE_INFINITY) {
return null;
}
return new Range(min, max);
}
示例4: testPowerRegression1b
import org.jfree.data.xy.XYDataset; //导入依赖的package包/类
/**
* Checks the results of a power regression on sample dataset 1 AFTER converting it to
* an XYSeries.
*/
public void testPowerRegression1b() {
final double[][] data = createSampleData1();
final XYSeries series = new XYSeries("Test");
for (int i = 0; i < 11; i++) {
series.add(data[i][0], data[i][1]);
}
final XYDataset ds = new XYSeriesCollection(series);
final double[] result = Regression.getPowerRegression(ds, 0);
assertEquals(0.91045813, result[0], 0.0000001);
assertEquals(0.88918346, result[1], 0.0000001);
}
示例5: createChart
import org.jfree.data.xy.XYDataset; //导入依赖的package包/类
private JFreeChart createChart(final XYDataset dataset) {
final JFreeChart chart = ChartFactory.createXYLineChart(
"MONA STORAGE GRAPH", "KeyGeneration per users ",
"KeyGenerating size in Bytes", dataset,
PlotOrientation.VERTICAL, true, true, false);
chart.setBackgroundPaint(Color.white);
final XYPlot plot1 = chart.getXYPlot();
plot1.setBackgroundPaint(Color.lightGray);
plot1.setDomainGridlinePaint(Color.white);
plot1.setRangeGridlinePaint(Color.white);
final XYPlot plot2 = chart.getXYPlot();
plot2.setBackgroundPaint(Color.lightGray);
plot2.setDomainGridlinePaint(Color.white);
plot2.setRangeGridlinePaint(Color.white);
final XYPlot plot3 = chart.getXYPlot();
plot3.setBackgroundPaint(Color.lightGray);
plot3.setDomainGridlinePaint(Color.white);
plot3.setRangeGridlinePaint(Color.white);
return chart;
}
开发者ID:cyberheartmi9,项目名称:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代码行数:24,代码来源:KeyStorageGraph.java
示例6: plotTradeBubblesOnChart
import org.jfree.data.xy.XYDataset; //导入依赖的package包/类
private void plotTradeBubblesOnChart(ArrayList<Integer> toPlot, String p, int k, int j)
{
final Plot main_plot = (Plot)((CombinedDomainXYPlot)this.candlestickChart.getPlot()).getSubplots().get(0);
final XYPlot plot = (XYPlot) main_plot;
final TimeSeries series = new TimeSeries(p);
///*
for(Integer i: toPlot)
{
switch(j)
{
case 0:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getOpen());
break;
case 1:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getHigh());
break;
case 2:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getLow());
break;
case 3:
series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getClose());
break;
}
}
/*
for (int i = 0; i < defaultHighLowDataset.getSeriesCount(); i++)
{
series.add(new Minute(defaultHighLowDataset.getXDate(0, i)),plot[i]);
}
*/
XYDataset dataSet = new TimeSeriesCollection(series);
plot.setDataset(k, dataSet);
XYItemRenderer ir = new XYShapeRenderer();
//ir.s
plot.setRenderer(k, ir);
}
示例7: createMovingAverage
import org.jfree.data.xy.XYDataset; //导入依赖的package包/类
/**
* Creates a new {@link XYDataset} containing the moving averages of each series in the
* <code>source</code> dataset.
*
* @param source the source dataset.
* @param suffix the string to append to source series names to create target series names.
* @param period the averaging period.
* @param skip the length of the initial skip period.
*
* @return The dataset.
*/
public static XYDataset createMovingAverage(XYDataset source, String suffix,
double period, double skip) {
// check arguments
if (source == null) {
throw new IllegalArgumentException(
"MovingAverage.createMovingAverage(...) : null source (XYDataset)."
);
}
final XYSeriesCollection result = new XYSeriesCollection();
for (int i = 0; i < source.getSeriesCount(); i++) {
final XYSeries s = createMovingAverage(source, i, source.getSeriesName(i) + suffix,
period, skip);
result.addSeries(s);
}
return result;
}
示例8: testReplaceDataset
import org.jfree.data.xy.XYDataset; //导入依赖的package包/类
/**
* Replaces the dataset and checks that it has changed as expected.
*/
public void testReplaceDataset() {
// create a dataset...
XYSeries series1 = new XYSeries("Series 1");
series1.add(10.0, 10.0);
series1.add(20.0, 20.0);
series1.add(30.0, 30.0);
XYDataset dataset = new XYSeriesCollection(series1);
LocalListener l = new LocalListener();
this.chart.addChangeListener(l);
XYPlot plot = (XYPlot) this.chart.getPlot();
plot.setDataset(dataset);
assertEquals(true, l.flag);
ValueAxis axis = plot.getRangeAxis();
Range range = axis.getRange();
assertTrue("Expecting the lower bound of the range to be around 10: "
+ range.getLowerBound(), range.getLowerBound() <= 10);
assertTrue("Expecting the upper bound of the range to be around 30: "
+ range.getUpperBound(), range.getUpperBound() >= 30);
}
示例9: KeySignatureGraph
import org.jfree.data.xy.XYDataset; //导入依赖的package包/类
public KeySignatureGraph(String title, int one, int two) {
super(title);
XYDataset dataset = null;
try {
dataset = createDataset(one, two);
} catch (Exception e) {
System.out.println("MultiLineChart -- Constructor" + e);
}
final JFreeChart chart = createChart(dataset);
final ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 370));
setContentPane(chartPanel);
this.pack();
RefineryUtilities.centerFrameOnScreen(this);
this.setVisible(true);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
}
开发者ID:cyberheartmi9,项目名称:Mona-Secure-Multi-Owner-Data-Sharing-for-Dynamic-Group-in-the-Cloud,代码行数:18,代码来源:KeySignatureGraph.java
示例10: createChart
import org.jfree.data.xy.XYDataset; //导入依赖的package包/类
/**
* Create a horizontal bar chart with sample data in the range -3 to +3.
*
* @return The chart.
*/
private static JFreeChart createChart() {
// create a dataset...
XYSeries series1 = new XYSeries("Series 1");
series1.add(1.0, 1.0);
series1.add(2.0, 2.0);
series1.add(3.0, 3.0);
XYDataset dataset = new XYSeriesCollection(series1);
// create the chart...
return ChartFactory.createXYAreaChart(
"Area Chart", // chart title
"Domain",
"Range",
dataset, // data
PlotOrientation.VERTICAL,
true, // include legend
true, // tooltips
true // urls
);
}
示例11: start
import org.jfree.data.xy.XYDataset; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
XYDataset dataset = createDataset();
JFreeChart chart = createChart(dataset);
ChartCanvas canvas = new ChartCanvas(chart);
StackPane stackPane = new StackPane();
stackPane.getChildren().add(canvas);
// Bind canvas size to stack pane size.
canvas.widthProperty().bind( stackPane.widthProperty());
canvas.heightProperty().bind( stackPane.heightProperty());
stage.setScene(new Scene(stackPane));
stage.setTitle("FXGraphics2DDemo1.java");
stage.setWidth(700);
stage.setHeight(390);
stage.show();
}
示例12: start
import org.jfree.data.xy.XYDataset; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
XYDataset dataset = createDataset();
JFreeChart chart = createChart(dataset);
ChartViewer viewer = new ChartViewer(chart);
stage.setScene(new Scene(viewer));
stage.setTitle("JFreeChart: TimeSeriesFXDemo1.java");
stage.setWidth(700);
stage.setHeight(390);
stage.show();
}
示例13: findRangeBounds
import org.jfree.data.xy.XYDataset; //导入依赖的package包/类
/**
* Returns the range of values in the range for the dataset. This method
* is the partner for the {@link #findDomainBounds(XYDataset)} method.
*
* @param dataset the dataset (<code>null</code> not permitted).
* @param includeInterval a flag that determines whether or not the
* y-interval is taken into account.
*
*
* @return The range (possibly <code>null</code>).
*/
public static Range findRangeBounds(XYDataset dataset,
boolean includeInterval) {
if (dataset == null) {
throw new IllegalArgumentException("Null 'dataset' argument.");
}
Range result = null;
if (dataset instanceof RangeInfo) {
RangeInfo info = (RangeInfo) dataset;
result = info.getRangeBounds(includeInterval);
}
else {
result = iterateXYRangeBounds(dataset);
}
return result;
}
示例14: createXYDataset1
import org.jfree.data.xy.XYDataset; //导入依赖的package包/类
/**
* Creates a dataset for testing.
*
* @return A dataset.
*/
private XYDataset createXYDataset1() {
XYSeries series1 = new XYSeries("S1");
series1.add(1.0, 100.0);
series1.add(2.0, 101.0);
series1.add(3.0, 102.0);
XYSeries series2 = new XYSeries("S2");
series2.add(1.0, 103.0);
series2.add(2.0, null);
series2.add(3.0, 105.0);
XYSeriesCollection result = new XYSeriesCollection();
result.addSeries(series1);
result.addSeries(series2);
result.setIntervalWidth(0.0);
return result;
}
示例15: createPolarChart
import org.jfree.data.xy.XYDataset; //导入依赖的package包/类
/**
* Creates a polar plot for the specified dataset (x-values interpreted as angles in degrees).
* <P>
* The chart object returned by this method uses a {@link PolarPlot} instance as the
* plot, with a {@link NumberAxis} for the radial axis.
*
* @param title the chart title (<code>null</code> permitted).
* @param dataset the dataset (<code>null</code> permitted).
* @param legend legend required?
* @param tooltips tooltips required?
* @param urls URLs required?
*
* @return A chart.
*/
public static JFreeChart createPolarChart(String title,
XYDataset dataset,
boolean legend,
boolean tooltips,
boolean urls) {
PolarPlot plot = new PolarPlot();
plot.setDataset(dataset);
NumberAxis rangeAxis = new NumberAxis();
rangeAxis.setAxisLineVisible(false);
rangeAxis.setTickMarksVisible(false);
rangeAxis.setTickLabelInsets(new Insets(0, 0, 0, 0));
plot.setRadialAxis(rangeAxis);
plot.setRenderer(new DefaultPolarItemRenderer());
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
return chart;
}