use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.
the class CombinedXYPlotDemo1 method createCombinedChart.
/**
* Creates an overlaid chart.
*
* @return The chart.
*/
private static JFreeChart createCombinedChart() {
// create plot ...
IntervalXYDataset data1 = createDataset1();
XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
renderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
renderer1.setSeriesStroke(0, new BasicStroke(4.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
renderer1.setSeriesPaint(0, Color.blue);
DateAxis domainAxis = new DateAxis("Year");
domainAxis.setLowerMargin(0.0);
domainAxis.setUpperMargin(0.02);
ValueAxis rangeAxis = new NumberAxis("$billion");
XYPlot plot1 = new XYPlot(data1, null, rangeAxis, renderer1);
plot1.setBackgroundPaint(Color.lightGray);
plot1.setDomainGridlinePaint(Color.white);
plot1.setRangeGridlinePaint(Color.white);
// add a second dataset and renderer...
IntervalXYDataset data2 = createDataset2();
XYBarRenderer renderer2 = new XYBarRenderer() {
public Paint getItemPaint(int series, int item) {
XYDataset dataset = getPlot().getDataset();
if (dataset.getYValue(series, item) >= 0.0) {
return Color.red;
} else {
return Color.green;
}
}
};
renderer2.setSeriesPaint(0, Color.red);
renderer2.setDrawBarOutline(false);
renderer2.setBaseToolTipGenerator(new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
XYPlot plot2 = new XYPlot(data2, null, new NumberAxis("$billion"), renderer2);
plot2.setBackgroundPaint(Color.lightGray);
plot2.setDomainGridlinePaint(Color.white);
plot2.setRangeGridlinePaint(Color.white);
CombinedXYPlot cplot = new CombinedXYPlot(domainAxis, rangeAxis);
cplot.add(plot1, 3);
cplot.add(plot2, 2);
cplot.setGap(8.0);
cplot.setDomainGridlinePaint(Color.white);
cplot.setDomainGridlinesVisible(true);
// return a new chart containing the overlaid plot...
JFreeChart chart = new JFreeChart("CombinedXYPlotDemo1", JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
chart.setBackgroundPaint(Color.white);
LegendTitle legend = new LegendTitle(cplot);
chart.addSubtitle(legend);
return chart;
}
use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.
the class PolarPlotTest method testTranslateToJava2D_NumberAxisAndMargin.
@Test
public void testTranslateToJava2D_NumberAxisAndMargin() {
Rectangle2D dataArea = new Rectangle2D.Double(10.0, 10.0, 80.0, 80.0);
ValueAxis axis = new NumberAxis();
axis.setRange(-2.0, 2.0);
PolarPlot plot = new PolarPlot(null, axis, null);
plot.setAngleOffset(0.0);
Point point = plot.translateToJava2D(0.0, 10.0, axis, dataArea);
assertEquals(110.0, point.getX(), 0.5);
assertEquals(50.0, point.getY(), 0.5);
point = plot.translateToJava2D(90.0, 5.0, axis, dataArea);
assertEquals(50.0, point.getX(), 0.5);
assertEquals(85.0, point.getY(), 0.5);
point = plot.translateToJava2D(45.0, 20.0, axis, dataArea);
assertEquals(128.0, point.getX(), 0.5);
assertEquals(128.0, point.getY(), 0.5);
point = plot.translateToJava2D(135.0, 20.0, axis, dataArea);
assertEquals(-28.0, point.getX(), 0.5);
assertEquals(128.0, point.getY(), 0.5);
point = plot.translateToJava2D(225.0, 15.0, axis, dataArea);
assertEquals(-10.0, point.getX(), 0.5);
assertEquals(-10.0, point.getY(), 0.5);
point = plot.translateToJava2D(315.0, 15.0, axis, dataArea);
assertEquals(110.0, point.getX(), 0.5);
assertEquals(-10.0, point.getY(), 0.5);
point = plot.translateToJava2D(21.0, 11.5, axis, dataArea);
assertEquals(113.0, point.getX(), 0.5);
assertEquals(74.0, point.getY(), 0.5);
point = plot.translateToJava2D(162.0, 7.0, axis, dataArea);
assertEquals(7.0, point.getX(), 0.5);
assertEquals(64.0, point.getY(), 0.5);
}
use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.
the class CategoryPlotTest method testAxisLocationIndices.
@Test
public void testAxisLocationIndices() {
CategoryDataset dataset = new DefaultCategoryDataset();
CategoryAxis xAxis = new CategoryAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
CategoryItemRenderer renderer = new BarRenderer();
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
CategoryAxis xAxis2 = new CategoryAxis("X2");
NumberAxis yAxis2 = new NumberAxis("Y2");
plot.setDomainAxis(99, xAxis2);
plot.setRangeAxis(99, yAxis2);
plot.setDomainAxisLocation(99, AxisLocation.BOTTOM_OR_RIGHT);
assertEquals(AxisLocation.BOTTOM_OR_RIGHT, plot.getDomainAxisLocation(99));
plot.setRangeAxisLocation(99, AxisLocation.BOTTOM_OR_LEFT);
assertEquals(AxisLocation.BOTTOM_OR_LEFT, plot.getRangeAxisLocation(99));
}
use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.
the class CategoryPlotTest method testRangeMarkerIndices.
@Test
public void testRangeMarkerIndices() {
CategoryDataset dataset = new DefaultCategoryDataset();
CategoryAxis xAxis = new CategoryAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
CategoryItemRenderer renderer = new BarRenderer();
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
// add a second dataset, plotted against a second axis
DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
dataset2.setValue(1, "R1", "C1");
plot.setDataset(99, dataset);
NumberAxis yAxis2 = new NumberAxis("Y2");
plot.setRangeAxis(1, yAxis2);
LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
plot.setRenderer(99, renderer2);
plot.mapDatasetToRangeAxis(99, 1);
ValueMarker yMarker1 = new ValueMarker(123);
plot.addRangeMarker(99, yMarker1, Layer.FOREGROUND);
assertTrue(plot.getRangeMarkers(99, Layer.FOREGROUND).contains(yMarker1));
}
use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.
the class CategoryPlotTest method testAxisRange.
/**
* A test for a bug reported in the forum.
*/
@Test
public void testAxisRange() {
DefaultCategoryDataset datasetA = new DefaultCategoryDataset();
DefaultCategoryDataset datasetB = new DefaultCategoryDataset();
datasetB.addValue(50.0, "R1", "C1");
datasetB.addValue(80.0, "R1", "C1");
CategoryPlot plot = new CategoryPlot(datasetA, new CategoryAxis(null), new NumberAxis(null), new LineAndShapeRenderer());
plot.setDataset(1, datasetB);
plot.setRenderer(1, new LineAndShapeRenderer());
Range r = plot.getRangeAxis().getRange();
assertEquals(84.0, r.getUpperBound(), 0.00001);
}
Aggregations