本文整理汇总了Java中org.jfree.chart.plot.XYPlot.getRangeAxis方法的典型用法代码示例。如果您正苦于以下问题:Java XYPlot.getRangeAxis方法的具体用法?Java XYPlot.getRangeAxis怎么用?Java XYPlot.getRangeAxis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.plot.XYPlot
的用法示例。
在下文中一共展示了XYPlot.getRangeAxis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testReplaceDataset
import org.jfree.chart.plot.XYPlot; //导入方法依赖的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);
}
示例2: createChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private static JFreeChart createChart(XYDataset dataset) {
// create the chart...
JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
null, // x axis label
null, // y axis label
dataset, // data
PlotOrientation.VERTICAL, false, // include legend
true, // tooltips
false // urls
);
chart.setBackgroundPaint(Color.white);
// get a reference to the plot for further customization...
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.WHITE);
ValueAxis valueAxis = plot.getRangeAxis();
valueAxis.setLabelFont(LABEL_FONT_BOLD);
valueAxis.setTickLabelFont(LABEL_FONT);
return chart;
}
示例3: testFindRangeBounds
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Check that the renderer is calculating the range bounds correctly.
*/
public void testFindRangeBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
false, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
plot.setRenderer(renderer);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
Range bounds = rangeAxis.getRange();
assertTrue(bounds.contains(6.0));
assertTrue(bounds.contains(8.0));
// try null argument
assertNull(renderer.findRangeBounds(null));
// try empty dataset
assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
示例4: updateYFieldValue
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Updates the preselected y-value.
*/
private void updateYFieldValue() {
// update preselected y value because range axis has been changed
if (mousePosition != null) {
Rectangle2D plotArea = engine.getChartPanel().getScreenDataArea();
if (engine.getChartPanel().getChart().getPlot() instanceof XYPlot) {
XYPlot plot = (XYPlot) engine.getChartPanel().getChart().getPlot();
// calculate y value
for (int i = 0; i < plot.getRangeAxisCount(); i++) {
ValueAxis config = plot.getRangeAxis(i);
if (config != null && config.getLabel() != null) {
if (config.getLabel().equals(String.valueOf(rangeAxisSelectionCombobox.getSelectedItem()))) {
double chartY = config.java2DToValue(mousePosition.getY(), plotArea, plot.getRangeAxisEdge());
yField.setText(String.valueOf(chartY));
}
}
}
}
}
}
示例5: testXYAutoRange2
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Checks that the auto-range for the range axis on an XYPlot is
* working as expected.
*/
public void testXYAutoRange2() {
XYSeries series = new XYSeries("Series 1");
series.add(1.0, 1.0);
series.add(2.0, 2.0);
series.add(3.0, 3.0);
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series);
JFreeChart chart = ChartFactory.createScatterPlot(
"Test",
"X",
"Y",
dataset,
PlotOrientation.VERTICAL,
false,
false,
false
);
XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis axis = (NumberAxis) plot.getRangeAxis();
axis.setAutoRangeIncludesZero(false);
assertEquals(0.9, axis.getLowerBound(), EPSILON);
assertEquals(3.1, axis.getUpperBound(), EPSILON);
}
示例6: plot
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public static void plot(double[] predicts, double[] actuals, String name) {
double[] index = new double[predicts.length];
for (int i = 0; i < predicts.length; i++)
index[i] = i;
int min = minValue(predicts, actuals);
int max = maxValue(predicts, actuals);
final XYSeriesCollection dataSet = new XYSeriesCollection();
addSeries(dataSet, index, predicts, "Predicts");
addSeries(dataSet, index, actuals, "Actuals");
final JFreeChart chart = ChartFactory.createXYLineChart(
"Prediction Result", // chart title
"Index", // x axis label
name, // y axis label
dataSet, // data
PlotOrientation.VERTICAL,
true, // include legend
true, // tooltips
false // urls
);
XYPlot xyPlot = chart.getXYPlot();
// X-axis
final NumberAxis domainAxis = (NumberAxis) xyPlot.getDomainAxis();
domainAxis.setRange((int) index[0], (int) (index[index.length - 1] + 2));
domainAxis.setTickUnit(new NumberTickUnit(20));
domainAxis.setVerticalTickLabels(true);
// Y-axis
final NumberAxis rangeAxis = (NumberAxis) xyPlot.getRangeAxis();
rangeAxis.setRange(min, max);
rangeAxis.setTickUnit(new NumberTickUnit(50));
final ChartPanel panel = new ChartPanel(chart);
final JFrame f = new JFrame();
f.add(panel);
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.pack();
f.setVisible(true);
}
示例7: createChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private JFreeChart createChart(String chartContent, String title, String yaxisName){
//创建时序图对象
XYSeries = new XYSeries(chartContent);
XYSeriesCollection xySeriesCollection=new XYSeriesCollection(XYSeries);
// 设置中文主题样式 解决乱码
StandardChartTheme chartTheme = new StandardChartTheme("CN");
// 设置标题字体
chartTheme.setExtraLargeFont(font);
// 设置图例的字体
chartTheme.setRegularFont(font);
// 设置轴向的字体
chartTheme.setLargeFont(font);
chartTheme.setSmallFont(font);
ChartFactory.setChartTheme(chartTheme);
JFreeChart jfreechart = ChartFactory.createXYLineChart(title,"帧数",yaxisName,xySeriesCollection);
XYPlot xyplot = jfreechart.getXYPlot();
//纵坐标设定
ValueAxis valueaxis = xyplot.getDomainAxis();
//自动设置数据轴数据范围
valueaxis.setAutoRange(true);
//数据轴固定数据范围 30s
//valueaxis.setFixedAutoRange(100);
valueaxis = xyplot.getRangeAxis();
return jfreechart;
}
示例8: updateChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的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();
}
示例9: testFindRangeBounds
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Check that the renderer is calculating the range bounds correctly.
*/
public void testFindRangeBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"Test Chart", "X", "Y", dataset,
PlotOrientation.VERTICAL, false, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StackedXYBarRenderer());
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
Range bounds = rangeAxis.getRange();
assertTrue(bounds.contains(6.0));
assertTrue(bounds.contains(8.0));
}
示例10: testFindRangeBounds
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
/**
* Check that the renderer is calculating the range bounds correctly.
*/
public void testFindRangeBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
false, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
Range bounds = rangeAxis.getRange();
assertTrue(bounds.contains(6.0));
assertTrue(bounds.contains(8.0));
}
示例11: TimeSeriesChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public TimeSeriesChart() {
XYDataset xydataset = createDataset();
JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General单位信托基金价格", "日期", "价格", xydataset, true, true, true);
XYPlot xyplot = (XYPlot) jfreechart.getPlot();
DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
frame1 = new ChartPanel(jfreechart, true);
dateaxis.setLabelFont(new Font("黑体", Font.BOLD, 14)); //水平底部标题
dateaxis.setTickLabelFont(new Font("宋体", Font.BOLD, 12)); //垂直标题
ValueAxis rangeAxis = xyplot.getRangeAxis();//获取柱状
rangeAxis.setLabelFont(new Font("黑体", Font.BOLD, 15));
jfreechart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15));
jfreechart.getTitle().setFont(new Font("宋体", Font.BOLD, 20));//设置标题字体
}
示例12: getChartPanel
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public ChartPanel getChartPanel(List<String> industrys) {
XYDataset xydataset = createDataset(industrys);
JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("行业资金流入流出", "日期(日/单位)", "价格(亿/单位)", xydataset, true, true, true);
XYPlot xyplot = (XYPlot) jfreechart.getPlot();
DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
dateaxis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd"));
dateaxis.setLabelFont(new Font("黑体", Font.BOLD, 14)); //水平底部标题
dateaxis.setTickLabelFont(new Font("宋体", Font.BOLD, 12)); //垂直标题
ValueAxis rangeAxis = xyplot.getRangeAxis();//获取柱状
rangeAxis.setLabelFont(new Font("黑体", Font.BOLD, 15));
jfreechart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15));
jfreechart.getTitle().setFont(new Font("宋体", Font.BOLD, 20));//设置标题字体
ChartPanel frame1 = new ChartPanel(jfreechart, true);
return frame1;
}
示例13: getChartPanel
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public ChartPanel getChartPanel(List<String> industrys) {
XYDataset xydataset = createDataset(industrys);
JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("行业涨跌", "日期(日/单位)", "价格(%/单位)", xydataset, true, true, true);
XYPlot xyplot = (XYPlot) jfreechart.getPlot();
DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
dateaxis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd"));
dateaxis.setLabelFont(new Font("黑体", Font.BOLD, 14)); //水平底部标题
dateaxis.setTickLabelFont(new Font("宋体", Font.BOLD, 12)); //垂直标题
ValueAxis rangeAxis = xyplot.getRangeAxis();//获取柱状
rangeAxis.setLabelFont(new Font("黑体", Font.BOLD, 15));
jfreechart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15));
jfreechart.getTitle().setFont(new Font("宋体", Font.BOLD, 20));//设置标题字体
ChartPanel frame1 = new ChartPanel(jfreechart, true);
return frame1;
}
示例14: createChart
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
private JFreeChart createChart(XYDataset dataset) {
// create the chart...
JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
null, // x axis label
null, // y axis label
dataset, // data
PlotOrientation.VERTICAL, true, // include legend
true, // tooltips
false // urls
);
chart.setBackgroundPaint(Color.white);
// get a reference to the plot for further customisation...
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.WHITE);
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
ValueAxis valueAxis = plot.getRangeAxis();
valueAxis.setLabelFont(PlotterAdapter.LABEL_FONT_BOLD);
valueAxis.setTickLabelFont(PlotterAdapter.LABEL_FONT);
ValueAxis domainAxis = plot.getDomainAxis();
domainAxis.setLabelFont(PlotterAdapter.LABEL_FONT_BOLD);
domainAxis.setTickLabelFont(PlotterAdapter.LABEL_FONT);
DeviationRenderer renderer = new DeviationRenderer(true, false);
Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
if (dataset.getSeriesCount() == 1) {
renderer.setSeriesStroke(0, stroke);
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesFillPaint(0, Color.RED);
} else if (dataset.getSeriesCount() == 2) {
renderer.setSeriesStroke(0, stroke);
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesFillPaint(0, Color.RED);
renderer.setSeriesStroke(1, stroke);
renderer.setSeriesPaint(1, Color.BLUE);
renderer.setSeriesFillPaint(1, Color.BLUE);
} else {
for (int i = 0; i < dataset.getSeriesCount(); i++) {
renderer.setSeriesStroke(i, stroke);
Color color = colorProvider.getPointColor((double) i / (double) (dataset.getSeriesCount() - 1));
renderer.setSeriesPaint(i, color);
renderer.setSeriesFillPaint(i, color);
}
}
renderer.setAlpha(0.12f);
plot.setRenderer(renderer);
// legend settings
LegendTitle legend = chart.getLegend();
if (legend != null) {
legend.setPosition(RectangleEdge.TOP);
legend.setFrame(BlockBorder.NONE);
legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
legend.setItemFont(PlotterAdapter.LABEL_FONT);
}
return chart;
}
示例15: GraphGenerator
import org.jfree.chart.plot.XYPlot; //导入方法依赖的package包/类
public GraphGenerator(final String title, AthenaFeatures athenaFeatures, String feature) {
super(title);
this.feature = feature;
final XYDataset dataset = createDatasetFromFeatureData(athenaFeatures, feature);
final JFreeChart chart = createChart(dataset);
chart.setTitle("");
LegendTitle legend = (LegendTitle) chart.getLegend();
chart.removeLegend();
Font nwfont = new Font("Arial",1,12);
legend.setItemFont(nwfont);
legend.setPosition(RectangleEdge.TOP);
// legend.setWidth(200);
legend.setItemLabelPadding(new RectangleInsets(3, 3, 3, 3));
legend.setHeight(10);
// legend.setPadding(new RectangleInsets(10, 10, 10, 10));
XYTitleAnnotation ta = new XYTitleAnnotation(0.99, 0.98, legend, RectangleAnchor.TOP_RIGHT);
ta.setMaxWidth(0.95);
// chart.addLegend(legend);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.white);
plot.setDomainZeroBaselinePaint(Color.gray);
plot.setDomainGridlinePaint(Color.gray);
plot.setDomainGridlineStroke(new BasicStroke(0.7f));
plot.setRangeGridlinePaint(Color.gray);
plot.setRangeGridlineStroke(new BasicStroke(0.7f));
plot.setDomainMinorGridlinePaint(Color.black);
plot.addAnnotation(ta);
final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
renderer.setSeriesPaint(0, Color.black);
renderer.setSeriesShape(0, ShapeUtilities.createDiamond(5));
renderer.setSeriesPaint(1, Color.red);
renderer.setSeriesShape(1, ShapeUtilities.createUpTriangle(5));
renderer.setSeriesPaint(2, Color.blue);
Shape shape = new Ellipse2D.Double(-5.0,-5.0,10,10);
renderer.setSeriesShape(2, shape);
renderer.setShapesFilled(false);
// renderer.setSeriesShapesVisible(1, false);
//apply theme
// StandardChartTheme.createJFreeTheme().apply(chart);
plot.setRenderer(renderer);
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
yAxis.setLabel(feature + " (K)");
yAxis.setAxisLineVisible(false);
yAxis.setTickUnit(new NumberTickUnit(50000));
yAxis.setNumberFormatOverride(new ByteFormat());
yAxis.setRange(new Range(0, 160000));
plot.getRenderer().setBaseItemLabelsVisible(true);
DateAxis xAxis = (DateAxis) plot.getDomainAxis();
xAxis.setAxisLineVisible(false);
xAxis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss"));
xAxis.setTickUnit(new DateTickUnit(DateTickUnit.MINUTE, 3));
xAxis.setLabelFont(new Font("Arial",1,12));
final ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(631, 381));
chartPanel.setMouseZoomable(true, true);
setContentPane(chartPanel);
try {
ChartUtilities.saveChartAsPNG(new File("result.png"), chart, 631, 381);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}