XYPlot extends AbstractPlot implements Navigable, AxisListener { public void addPointRenderer(DataSource s, PointRenderer pointRenderer) { List<PointRenderer> pointRenderers = pointRenderersByDataSource.get(s); if (pointRenderers == null) { pointRenderers = new ArrayList<>(); pointRenderersByDataSource.put(s, pointRenderers); } pointRenderers.add(pointRenderer); } XYPlot(DataSource... data); List<PointRenderer> getPointRenderers(DataSource s); void addPointRenderer(DataSource s, PointRenderer pointRenderer); void removePointRenderer(DataSource s, PointRenderer pointRenderer); void setPointRenderers(DataSource s, List<PointRenderer> pointRenderers); void setPointRenderers(DataSource s, PointRenderer pointRendererFirst, PointRenderer... pointRenderers); List<LineRenderer> getLineRenderers(DataSource s); void setLineRenderers(DataSource s, List<LineRenderer> lineRenderers); void setLineRenderers(DataSource s, LineRenderer lineRendererFirst, LineRenderer... lineRenderers); List<AreaRenderer> getAreaRenderers(DataSource s); void setAreaRenderers(DataSource s, List<AreaRenderer> areaRenderers); void setAreaRenderers(DataSource s, AreaRenderer areaRendererFirst, AreaRenderer... areaRenderers); @Override void setAxisRenderer(String axisName, AxisRenderer renderer); @Override void add(int index, DataSource source, boolean visible); Navigator getNavigator(); @Override void draw(DrawingContext context); void rangeChanged(Axis axis, Number min, Number max); static final String AXIS_X; static final String AXIS_X2; static final String AXIS_Y; static final String AXIS_Y2; }
@Test public void testAddPointRenderer() { DataSource data = new DummyData(2, 1, 1); MockXYPlot plot = new MockXYPlot(); assertTrue(plot.getPointRenderers(data).isEmpty()); PointRenderer renderer = new DefaultPointRenderer2D(); plot.addPointRenderer(data, renderer); List<PointRenderer> pointRenderers = plot.getPointRenderers(data); assertEquals(pointRenderers.size(), 1); assertEquals(pointRenderers.get(0), renderer); }