本文整理汇总了Java中org.jfree.data.Range类的典型用法代码示例。如果您正苦于以下问题:Java Range类的具体用法?Java Range怎么用?Java Range使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Range类属于org.jfree.data包,在下文中一共展示了Range类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDrawWithNullInfo
import org.jfree.data.Range; //导入依赖的package包/类
/**
* Draws the chart with a single range. At one point, this caused a null
* pointer exception (fixed now).
*/
public void testDrawWithNullInfo() {
boolean success = false;
MeterPlot plot = new MeterPlot(new DefaultValueDataset(60.0));
plot.addInterval(new MeterInterval("Normal", new Range(0.0, 80.0)));
JFreeChart chart = new JFreeChart(plot);
try {
BufferedImage image = new BufferedImage(200, 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
g2.dispose();
success = true;
}
catch (Exception e) {
success = false;
}
assertTrue(success);
}
示例2: testReplaceDataset
import org.jfree.data.Range; //导入依赖的package包/类
/**
* Replaces the chart's dataset and then checks that the new dataset is OK.
*/
public void testReplaceDataset() {
// create a dataset...
Number[][] data = new Integer[][]
{{new Integer(-30), new Integer(-20)},
{new Integer(-10), new Integer(10)},
{new Integer(20), new Integer(30)}};
CategoryDataset newData = DatasetUtilities.createCategoryDataset("S",
"C", data);
LocalListener l = new LocalListener();
this.chart.addChangeListener(l);
CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
plot.setDataset(newData);
assertEquals(true, l.flag);
ValueAxis axis = plot.getRangeAxis();
Range range = axis.getRange();
assertTrue("Expecting the lower bound of the range to be around -30: "
+ range.getLowerBound(), range.getLowerBound() <= -30);
assertTrue("Expecting the upper bound of the range to be around 30: "
+ range.getUpperBound(), range.getUpperBound() >= 30);
}
示例3: findRangeBounds
import org.jfree.data.Range; //导入依赖的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;
}
示例4: setAdditionalParameter
import org.jfree.data.Range; //导入依赖的package包/类
@Override
public void setAdditionalParameter(String key, String value) {
super.setAdditionalParameter(key, value);
if (key.startsWith(PARAMETER_PREFIX_RANGE_LIST)) {
List<String[]> dimensionRangePairs = ParameterTypeList.transformString2List(value);
for (String[] dimensionRangePair : dimensionRangePairs) {
String[] rangeTupel = ParameterTypeTupel.transformString2Tupel(dimensionRangePair[1]);
if (rangeTupel.length == 2) {
try {
Range range = new Range(Double.parseDouble(rangeTupel[0]), Double.parseDouble(rangeTupel[1]));
nameRangeMap.put(PlotterAdapter.transformParameterName(dimensionRangePair[0]), range);
updatePlotter();
} catch (NumberFormatException e) {
}
}
}
return;
}
}
示例5: testFindDomainBounds
import org.jfree.data.Range; //导入依赖的package包/类
/**
* Check that the renderer is calculating the domain bounds correctly.
*/
public void testFindDomainBounds() {
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 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));
}
示例6: testFindRangeBounds
import org.jfree.data.Range; //导入依赖的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()));
}
示例7: testReplaceDataset
import org.jfree.data.Range; //导入依赖的package包/类
/**
* Replaces the dataset and checks that it has changed as expected.
*/
public void testReplaceDataset() {
// create a dataset...
Number[][] data = new Integer[][]
{{new Integer(-30), new Integer(-20)},
{new Integer(-10), new Integer(10)},
{new Integer(20), new Integer(30)}};
CategoryDataset newData = DatasetUtilities.createCategoryDataset("S",
"C", data);
LocalListener l = new LocalListener();
this.chart.addChangeListener(l);
CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
plot.setDataset(newData);
assertEquals(true, l.flag);
ValueAxis axis = plot.getRangeAxis();
Range range = axis.getRange();
assertTrue("Expecting the lower bound of the range to be around -30: "
+ range.getLowerBound(), range.getLowerBound() <= -30);
assertTrue("Expecting the upper bound of the range to be around 30: "
+ range.getUpperBound(), range.getUpperBound() >= 30);
}
示例8: getDomainBounds
import org.jfree.data.Range; //导入依赖的package包/类
/**
* Returns the range of the values in this dataset's domain.
*
* @param includeInterval a flag that controls whether or not the
* x-intervals are taken into account.
*
* @return The range.
*/
public Range getDomainBounds(boolean includeInterval) {
List keys = this.values.getRowKeys();
if (keys.isEmpty()) {
return null;
}
TimePeriod first = (TimePeriod) keys.get(0);
TimePeriod last = (TimePeriod) keys.get(keys.size() - 1);
if (!includeInterval || this.domainIsPointsInTime) {
return new Range(getXValue(first), getXValue(last));
}
else {
return new Range(first.getStart().getTime(),
last.getEnd().getTime());
}
}
示例9: testReplaceDataset
import org.jfree.data.Range; //导入依赖的package包/类
/**
* Replaces the chart's dataset and then checks that the new dataset is OK.
*/
public void testReplaceDataset() {
Number[][] data = new Integer[][]
{{new Integer(-30), new Integer(-20)},
{new Integer(-10), new Integer(10)},
{new Integer(20), new Integer(30)}};
CategoryDataset newData = DatasetUtilities.createCategoryDataset(
"S", "C", data);
LocalListener l = new LocalListener();
this.chart.addChangeListener(l);
CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
plot.setDataset(newData);
assertEquals(true, l.flag);
ValueAxis axis = plot.getRangeAxis();
Range range = axis.getRange();
assertTrue("Expecting the lower bound of the range to be around -30: "
+ range.getLowerBound(), range.getLowerBound() <= -30);
assertTrue("Expecting the upper bound of the range to be around 30: "
+ range.getUpperBound(), range.getUpperBound() >= 30);
}
示例10: java2DToValue
import org.jfree.data.Range; //导入依赖的package包/类
/**
* Converts a coordinate in Java2D space to the corresponding data value,
* assuming that the axis runs along one edge of the specified dataArea.
*
* @param java2DValue the coordinate in Java2D space.
* @param area the area in which the data is plotted.
* @param edge the location.
*
* @return The data value.
*/
public double java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge) {
Range range = getRange();
double axisMin = range.getLowerBound();
double axisMax = range.getUpperBound();
double min = 0.0;
double max = 0.0;
if (RectangleEdge.isTopOrBottom(edge)) {
min = area.getX();
max = area.getMaxX();
}
else if (RectangleEdge.isLeftOrRight(edge)) {
min = area.getMaxY();
max = area.getY();
}
if (isInverted()) {
return axisMax - (java2DValue - min) / (max - min) * (axisMax - axisMin);
}
else {
return axisMin + (java2DValue - min) / (max - min) * (axisMax - axisMin);
}
}
示例11: testFindDomainBounds
import org.jfree.data.Range; //导入依赖的package包/类
/**
* Check that the renderer is calculating the domain bounds correctly.
*/
public void testFindDomainBounds() {
XYSeriesCollection dataset
= RendererXYPackageTests.createTestXYSeriesCollection();
JFreeChart chart = ChartFactory.createXYLineChart(
"Test Chart", "X", "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.9));
assertTrue(bounds.contains(1.0));
assertTrue(bounds.contains(2.0));
assertFalse(bounds.contains(2.10));
}
示例12: restoreAutoDomainAxisBounds
import org.jfree.data.Range; //导入依赖的package包/类
@Override
public List<Pair<Integer, Range>> restoreAutoDomainAxisBounds(boolean zoomOut) {
List<Pair<Integer, Range>> newRanges = new LinkedList<Pair<Integer, Range>>();
for (int i = 0; i < getDomainAxisCount(); i++) {
ValueAxis domainAxis = getDomainAxis(i);
if (domainAxis != null) {
if (domainAxis instanceof LinkAndBrushAxis) {
Range zoomedOutRange = ((LinkAndBrushAxis) domainAxis).restoreAutoRange(zoomOut);
newRanges.add(new Pair<Integer, Range>(i, zoomedOutRange));
}
}
}
return newRanges;
}
示例13: restoreAutoRangeAxisBounds
import org.jfree.data.Range; //导入依赖的package包/类
@Override
public List<Pair<Integer, Range>> restoreAutoRangeAxisBounds(boolean zoomOut) {
List<Pair<Integer, Range>> newRanges = new LinkedList<Pair<Integer, Range>>();
for (int i = 0; i < getRangeAxisCount(); i++) {
ValueAxis rangeAxis = getRangeAxis(i);
if (rangeAxis != null) {
if (rangeAxis instanceof LinkAndBrushAxis) {
Range zoomedOutRange = ((LinkAndBrushAxis) rangeAxis).restoreAutoRange(zoomOut);
newRanges.add(new Pair<Integer, Range>(i, zoomedOutRange));
}
}
}
return newRanges;
}
示例14: testReplaceDataset
import org.jfree.data.Range; //导入依赖的package包/类
/**
* Replaces the dataset and checks that the data range is as expected.
*/
public void testReplaceDataset() {
// create a dataset...
Number[][] data = new Integer[][]
{{new Integer(-30), new Integer(-20)},
{new Integer(-10), new Integer(10)},
{new Integer(20), new Integer(30)}};
CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data);
LocalListener l = new LocalListener();
this.chart.addChangeListener(l);
this.chart.getCategoryPlot().setDataset(newData);
assertEquals(true, l.flag);
ValueAxis axis = this.chart.getCategoryPlot().getRangeAxis();
Range range = axis.getRange();
assertTrue("Expecting the lower bound of the range to be around -30: "
+ range.getLowerBound(), range.getLowerBound() <= -30);
assertTrue("Expecting the upper bound of the range to be around 30: "
+ range.getUpperBound(), range.getUpperBound() >= 30);
}
示例15: testReplaceDataset
import org.jfree.data.Range; //导入依赖的package包/类
/**
* Replaces the dataset and checks that it has changed as expected.
*/
public void testReplaceDataset() {
// create a dataset...
Number[][] data = new Integer[][]
{{new Integer(-30), new Integer(-20)},
{new Integer(-10), new Integer(10)},
{new Integer(20), new Integer(30)}};
CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data);
LocalListener l = new LocalListener();
this.chart.addChangeListener(l);
this.chart.getCategoryPlot().setDataset(newData);
assertEquals(true, l.flag);
ValueAxis axis = this.chart.getCategoryPlot().getRangeAxis();
Range range = axis.getRange();
assertTrue("Expecting the lower bound of the range to be around -30: "
+ range.getLowerBound(), range.getLowerBound() <= -30);
assertTrue("Expecting the upper bound of the range to be around 30: "
+ range.getUpperBound(), range.getUpperBound() >= 30);
}