use of org.jfree.chart.renderer.xy.DefaultXYItemRenderer in project SIMVA-SoS by SESoS.
the class XYPlotTest method testRendererIndices.
@Test
public void testRendererIndices() {
XYDataset dataset = new XYSeriesCollection();
NumberAxis xAxis = new NumberAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
XYItemRenderer renderer = new DefaultXYItemRenderer();
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
assertEquals(renderer, plot.getRenderer(0));
// we should be able to give a renderer an arbitrary index
XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
plot.setRenderer(20, renderer2);
assertEquals(2, plot.getRendererCount());
assertEquals(renderer2, plot.getRenderer(20));
assertEquals(20, plot.getIndexOf(renderer2));
}
use of org.jfree.chart.renderer.xy.DefaultXYItemRenderer in project SIMVA-SoS by SESoS.
the class XYPlotTest method testGetRangeAxisForDataset.
/**
* Some tests for the getRangeAxisForDataset() method.
*/
@Test
public void testGetRangeAxisForDataset() {
XYDataset dataset = new XYSeriesCollection();
NumberAxis xAxis = new NumberAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
XYItemRenderer renderer = new DefaultXYItemRenderer();
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
assertEquals(yAxis, plot.getRangeAxisForDataset(0));
// should get IllegalArgumentException for negative index
boolean pass = false;
try {
plot.getRangeAxisForDataset(-1);
} catch (IllegalArgumentException e) {
pass = true;
}
assertTrue(pass);
// if multiple axes are mapped, the first in the list should be
// returned...
NumberAxis yAxis2 = new NumberAxis("Y2");
plot.setRangeAxis(1, yAxis2);
assertEquals(yAxis, plot.getRangeAxisForDataset(0));
plot.mapDatasetToRangeAxis(0, 1);
assertEquals(yAxis2, plot.getRangeAxisForDataset(0));
List axisIndices = Arrays.asList(new Integer[] { new Integer(0), new Integer(1) });
plot.mapDatasetToRangeAxes(0, axisIndices);
assertEquals(yAxis, plot.getRangeAxisForDataset(0));
axisIndices = Arrays.asList(new Integer[] { new Integer(1), new Integer(2) });
plot.mapDatasetToRangeAxes(0, axisIndices);
assertEquals(yAxis2, plot.getRangeAxisForDataset(0));
}
use of org.jfree.chart.renderer.xy.DefaultXYItemRenderer in project mzmine2 by mzmine.
the class TICPlot method addDataSet.
// add data set
public synchronized void addDataSet(XYDataset dataSet, Color color, boolean transparency) {
XYItemRenderer newRenderer = new DefaultXYItemRenderer();
newRenderer.setDefaultFillPaint(color);
plot.setDataset(numOfDataSets, dataSet);
plot.setRenderer(numOfDataSets, newRenderer);
numOfDataSets++;
}
use of org.jfree.chart.renderer.xy.DefaultXYItemRenderer in project SIMVA-SoS by SESoS.
the class XYPlotTest method testAxisLocationIndices.
@Test
public void testAxisLocationIndices() {
XYDataset dataset = new XYSeriesCollection();
NumberAxis xAxis = new NumberAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
XYItemRenderer renderer = new DefaultXYItemRenderer();
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
NumberAxis xAxis2 = new NumberAxis("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.renderer.xy.DefaultXYItemRenderer in project SIMVA-SoS by SESoS.
the class XYPlotTest method testDomainMarkerIndices.
@Test
public void testDomainMarkerIndices() {
XYDataset dataset = new XYSeriesCollection();
NumberAxis xAxis = new NumberAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
XYItemRenderer renderer = new DefaultXYItemRenderer();
XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
// add a second dataset, plotted against a second x axis
XYSeriesCollection dataset2 = new XYSeriesCollection();
dataset2.addSeries(new XYSeries("Series in dataset 2"));
plot.setDataset(99, dataset);
NumberAxis xAxis2 = new NumberAxis("X2");
plot.setDomainAxis(1, xAxis2);
XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
plot.setRenderer(99, renderer2);
plot.mapDatasetToDomainAxis(99, 1);
ValueMarker xMarker1 = new ValueMarker(123);
plot.addDomainMarker(99, xMarker1, Layer.FOREGROUND);
assertTrue(plot.getDomainMarkers(99, Layer.FOREGROUND).contains(xMarker1));
}
Aggregations