本文整理汇总了Java中org.jfree.chart.axis.NumberAxis.setAutoRangeIncludesZero方法的典型用法代码示例。如果您正苦于以下问题:Java NumberAxis.setAutoRangeIncludesZero方法的具体用法?Java NumberAxis.setAutoRangeIncludesZero怎么用?Java NumberAxis.setAutoRangeIncludesZero使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.axis.NumberAxis
的用法示例。
在下文中一共展示了NumberAxis.setAutoRangeIncludesZero方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: plotSeperate
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
private void plotSeperate(XYDataset dataset, String p)
{
NumberAxis rangeAxis1 = new NumberAxis(p);
rangeAxis1.setAutoRangeIncludesZero(false); // override default
rangeAxis1.setLowerMargin(0.40); // to leave room for volume bars
DecimalFormat format = new DecimalFormat("0");
rangeAxis1.setNumberFormatOverride(format);
final ValueAxis timeAxis = new DateAxis("Date");
timeAxis.setLowerMargin(0.02); // reduce the default margins
timeAxis.setUpperMargin(0.02);
XYPlot plot = new XYPlot(dataset, timeAxis, rangeAxis1, null);
XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
renderer1.setBaseToolTipGenerator(
new StandardXYToolTipGenerator(
StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#")
)
);
plot.setRenderer(0, renderer1);
final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot)this.candlestickChart.getPlot();
if (plot != null) cplot1.add(plot, 1); // weight is 1.
}
示例2: createBoxAndWhiskerChart
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* Creates and returns a default instance of a box and whisker chart.
*
* @param title the chart title (<code>null</code> permitted).
* @param timeAxisLabel a label for the time axis (<code>null</code> permitted).
* @param valueAxisLabel a label for the value axis (<code>null</code> permitted).
* @param dataset the dataset for the chart (<code>null</code> permitted).
* @param legend a flag specifying whether or not a legend is required.
*
* @return a box and whisker chart.
*/
public static JFreeChart createBoxAndWhiskerChart(String title,
String timeAxisLabel,
String valueAxisLabel,
BoxAndWhiskerXYDataset dataset,
boolean legend) {
ValueAxis timeAxis = new DateAxis(timeAxisLabel);
NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
valueAxis.setAutoRangeIncludesZero(false);
XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0);
XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
return chart;
}
示例3: testAutoRange3
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* A simple test for the auto-range calculation looking at a
* NumberAxis used as the range axis for a CategoryPlot. In this
* case, the 'autoRangeIncludesZero' flag is set to false AND the
* original dataset is replaced with a new dataset.
*/
public void testAutoRange3() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.setValue(100.0, "Row 1", "Column 1");
dataset.setValue(200.0, "Row 1", "Column 2");
JFreeChart chart = ChartFactory.createLineChart("Test", "Categories",
"Value", dataset, PlotOrientation.VERTICAL, false, false,
false);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
NumberAxis axis = (NumberAxis) plot.getRangeAxis();
axis.setAutoRangeIncludesZero(false);
assertEquals(axis.getLowerBound(), 95.0, EPSILON);
assertEquals(axis.getUpperBound(), 205.0, EPSILON);
// now replacing the dataset should update the axis range...
DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
dataset2.setValue(900.0, "Row 1", "Column 1");
dataset2.setValue(1000.0, "Row 1", "Column 2");
plot.setDataset(dataset2);
assertEquals(axis.getLowerBound(), 895.0, EPSILON);
assertEquals(axis.getUpperBound(), 1005.0, EPSILON);
}
示例4: testXYAutoRange2
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的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);
}
示例5: createBoxAndWhiskerChart
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* Creates and returns a default instance of a box and whisker chart.
*
* @param title the chart title (<code>null</code> permitted).
* @param timeAxisLabel a label for the time axis (<code>null</code>
* permitted).
* @param valueAxisLabel a label for the value axis (<code>null</code>
* permitted).
* @param dataset the dataset for the chart (<code>null</code> permitted).
* @param legend a flag specifying whether or not a legend is required.
*
* @return A box and whisker chart.
*/
public static JFreeChart createBoxAndWhiskerChart(String title,
String timeAxisLabel,
String valueAxisLabel,
BoxAndWhiskerXYDataset dataset,
boolean legend) {
ValueAxis timeAxis = new DateAxis(timeAxisLabel);
NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
valueAxis.setAutoRangeIncludesZero(false);
XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0);
XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot,
legend);
}
示例6: testFindDomainBounds
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* Check that the renderer is calculating the domain bounds correctly.
*/
public void testFindDomainBounds() {
XYSeriesCollection dataset
= RendererXYPackageTests.createTestXYSeriesCollection();
JFreeChart chart = ChartFactory.createXYBarChart(
"Test Chart", "X", false, "Y", dataset,
PlotOrientation.VERTICAL, false, false, false
);
XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
domainAxis.setAutoRangeIncludesZero(false);
Range bounds = domainAxis.getRange();
assertFalse(bounds.contains(0.3));
assertTrue(bounds.contains(0.5));
assertTrue(bounds.contains(2.5));
assertFalse(bounds.contains(2.8));
}
示例7: testFindRangeBounds
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* Check that the renderer is calculating the range bounds correctly.
*/
public void testFindRangeBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createXYLineChart(
"Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
false, false, false);
XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setAutoRangeIncludesZero(false);
Range bounds = rangeAxis.getRange();
assertFalse(bounds.contains(1.0));
assertTrue(bounds.contains(2.0));
assertTrue(bounds.contains(5.0));
assertFalse(bounds.contains(6.0));
}
示例8: createXYLineChart
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* Creates a line chart (based on an {@link XYDataset}) with default
* settings.
*
* @param title the chart title (<code>null</code> permitted).
* @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
* @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
* @param dataset the dataset for the chart (<code>null</code> permitted).
* @param orientation the plot orientation (horizontal or vertical)
* (<code>null</code> NOT permitted).
* @param legend a flag specifying whether or not a legend is required.
* @param tooltips configure chart to generate tool tips?
* @param urls configure chart to generate URLs?
*
* @return The chart.
*/
public static JFreeChart createXYLineChart(String title,
String xAxisLabel,
String yAxisLabel,
XYDataset dataset,
PlotOrientation orientation,
boolean legend,
boolean tooltips,
boolean urls) {
if (orientation == null) {
throw new IllegalArgumentException("Null 'orientation' argument.");
}
NumberAxis xAxis = new NumberAxis(xAxisLabel);
xAxis.setAutoRangeIncludesZero(false);
NumberAxis yAxis = new NumberAxis(yAxisLabel);
XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
plot.setOrientation(orientation);
if (tooltips) {
renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
}
if (urls) {
renderer.setURLGenerator(new StandardXYURLGenerator());
}
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
plot, legend);
return chart;
}
示例9: createBubbleChart
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* Creates a bubble chart with default settings. The chart is composed of
* an {@link XYPlot}, with a {@link NumberAxis} for the domain axis,
* a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer}
* to draw the data items.
*
* @param title the chart title (<code>null</code> permitted).
* @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
* @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
* @param dataset the dataset for the chart (<code>null</code> permitted).
* @param orientation the orientation (horizontal or vertical)
* (<code>null</code> NOT permitted).
* @param legend a flag specifying whether or not a legend is required.
* @param tooltips configure chart to generate tool tips?
* @param urls configure chart to generate URLs?
*
* @return A bubble chart.
*/
public static JFreeChart createBubbleChart(String title,
String xAxisLabel,
String yAxisLabel,
XYZDataset dataset,
PlotOrientation orientation,
boolean legend,
boolean tooltips,
boolean urls) {
if (orientation == null) {
throw new IllegalArgumentException("Null 'orientation' argument.");
}
NumberAxis xAxis = new NumberAxis(xAxisLabel);
xAxis.setAutoRangeIncludesZero(false);
NumberAxis yAxis = new NumberAxis(yAxisLabel);
yAxis.setAutoRangeIncludesZero(false);
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
XYItemRenderer renderer = new XYBubbleRenderer(
XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
if (tooltips) {
renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
}
if (urls) {
renderer.setURLGenerator(new StandardXYZURLGenerator());
}
plot.setRenderer(renderer);
plot.setOrientation(orientation);
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
plot, legend);
return chart;
}
示例10: addCashFlowAxis
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* Adds the cash flow axis to the plot.
* @param plot the plot
* @param dataset the cash flow dataset
*/
private static void addCashFlowAxis(XYPlot plot, TimeSeriesCollection dataset) {
final NumberAxis cashAxis = new NumberAxis("Cash Flow Ratio");
cashAxis.setAutoRangeIncludesZero(false);
plot.setRangeAxis(1, cashAxis);
plot.setDataset(1, dataset);
plot.mapDatasetToRangeAxis(1, 1);
final StandardXYItemRenderer cashFlowRenderer = new StandardXYItemRenderer();
cashFlowRenderer.setSeriesPaint(0, Color.blue);
plot.setRenderer(1, cashFlowRenderer);
}
示例11: MultipleChartFactory
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
public MultipleChartFactory(String title, String xAxis) {
super();
String yAxis = title;
XYSeriesCollection dataset = createDataset("Series");
JFreeChart chart = ChartFactory.createXYLineChart("", xAxis, yAxis,
dataset, PlotOrientation.VERTICAL, false, false, false);
chart.setBackgroundPaint(Color.white);
plot = chart.getXYPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
ValueAxis axis = plot.getDomainAxis();
axis.setAutoRange(true);
NumberAxis rangeAxis2 = new NumberAxis("Range Axis 2");
rangeAxis2.setAutoRangeIncludesZero(false);
JPanel content = new JPanel(new BorderLayout());
chartPanel = new ChartPanel(chart);
content.add(chartPanel);
CSVReader fileReader = new CSVReader();
try {
fileReader.read(plotChanelArray);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
示例12: testEquals
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* Confirm that the equals method can distinguish all the required fields.
*/
public void testEquals() {
NumberAxis a1 = new NumberAxis("Test");
NumberAxis a2 = new NumberAxis("Test");
assertTrue(a1.equals(a2));
//private boolean autoRangeIncludesZero;
a1.setAutoRangeIncludesZero(false);
assertFalse(a1.equals(a2));
a2.setAutoRangeIncludesZero(false);
assertTrue(a1.equals(a2));
//private boolean autoRangeStickyZero;
a1.setAutoRangeStickyZero(false);
assertFalse(a1.equals(a2));
a2.setAutoRangeStickyZero(false);
assertTrue(a1.equals(a2));
//private NumberTickUnit tickUnit;
a1.setTickUnit(new NumberTickUnit(25.0));
assertFalse(a1.equals(a2));
a2.setTickUnit(new NumberTickUnit(25.0));
assertTrue(a1.equals(a2));
//private NumberFormat numberFormatOverride;
a1.setNumberFormatOverride(new DecimalFormat("0.00"));
assertFalse(a1.equals(a2));
a2.setNumberFormatOverride(new DecimalFormat("0.00"));
assertTrue(a1.equals(a2));
a1.setRangeType(RangeType.POSITIVE);
assertFalse(a1.equals(a2));
a2.setRangeType(RangeType.POSITIVE);
assertTrue(a1.equals(a2));
}
示例13: createBubbleChart
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* Creates a bubble chart with default settings.
*
* @param title the chart title (<code>null</code> permitted).
* @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
* @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
* @param dataset the dataset for the chart (<code>null</code> permitted).
* @param orientation the orientation (horizontal or vertical) (<code>null</code> NOT
* permitted).
* @param legend a flag specifying whether or not a legend is required.
* @param tooltips configure chart to generate tool tips?
* @param urls configure chart to generate URLs?
*
* @return a bubble chart.
*/
public static JFreeChart createBubbleChart(String title,
String xAxisLabel,
String yAxisLabel,
XYZDataset dataset,
PlotOrientation orientation,
boolean legend,
boolean tooltips,
boolean urls) {
if (orientation == null) {
throw new IllegalArgumentException("Null 'orientation' argument.");
}
NumberAxis xAxis = new NumberAxis(xAxisLabel);
xAxis.setAutoRangeIncludesZero(false);
NumberAxis yAxis = new NumberAxis(yAxisLabel);
yAxis.setAutoRangeIncludesZero(false);
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
XYItemRenderer renderer = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
if (tooltips) {
renderer.setToolTipGenerator(new StandardXYZToolTipGenerator());
}
if (urls) {
renderer.setURLGenerator(new StandardXYZURLGenerator());
}
plot.setRenderer(renderer);
plot.setOrientation(orientation);
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
return chart;
}
示例14: createPlot
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* Creates a sample plot.
*
* @return A sample plot.
*/
private CombinedDomainXYPlot createPlot() {
// create subplot 1...
XYDataset data1 = createDataset1();
XYItemRenderer renderer1 = new StandardXYItemRenderer();
NumberAxis rangeAxis1 = new NumberAxis("Range 1");
XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0);
annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
annotation.setRotationAngle(Math.PI / 4.0);
subplot1.addAnnotation(annotation);
// create subplot 2...
XYDataset data2 = createDataset2();
XYItemRenderer renderer2 = new StandardXYItemRenderer();
NumberAxis rangeAxis2 = new NumberAxis("Range 2");
rangeAxis2.setAutoRangeIncludesZero(false);
XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);
subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
// parent plot...
CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain"));
plot.setGap(10.0);
// add the subplots...
plot.add(subplot1, 1);
plot.add(subplot2, 1);
plot.setOrientation(PlotOrientation.VERTICAL);
return plot;
}
示例15: testAutoRange2
import org.jfree.chart.axis.NumberAxis; //导入方法依赖的package包/类
/**
* A simple test for the auto-range calculation looking at a
* NumberAxis used as the range axis for a CategoryPlot. In this
* case, the 'autoRangeIncludesZero' flag is set to false.
*/
public void testAutoRange2() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.setValue(100.0, "Row 1", "Column 1");
dataset.setValue(200.0, "Row 1", "Column 2");
JFreeChart chart = ChartFactory.createLineChart("Test", "Categories",
"Value", dataset, PlotOrientation.VERTICAL, false, false,
false);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
NumberAxis axis = (NumberAxis) plot.getRangeAxis();
axis.setAutoRangeIncludesZero(false);
assertEquals(axis.getLowerBound(), 95.0, EPSILON);
assertEquals(axis.getUpperBound(), 205.0, EPSILON);
}