/** * 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)); }
@NotNull static JFreeChart minorAllelePDF(@NotNull final List<PurpleCopyNumber> variants) { final CategoryTableXYDataset dataset = minorAllele(variants); final JFreeChart chart = ChartFactory.createXYBarChart("Minor Allele Ploidy PDF", "Ploidy", false, "BAF Count", dataset, PlotOrientation.VERTICAL, true, false, false); StackedXYBarRenderer renderer = new StackedXYBarRenderer(); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setShadowVisible(false); XYPlot xyPlot = (XYPlot) chart.getPlot(); xyPlot.setRenderer(renderer); xyPlot.getDomainAxis().setRange(-1.1, 5.1); for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesPaint(i, copyNumberColor(String.valueOf(dataset.getSeriesKey(i)))); } return chart; }
@NotNull static JFreeChart somaticPloidyPDF(@NotNull final List<PurityAdjustedSomaticVariant> variants) { final CategoryTableXYDataset dataset = variants(variants); final JFreeChart chart = ChartFactory.createXYBarChart("Somatic Variant Ploidy PDF", "Ploidy", false, "Count", dataset, PlotOrientation.VERTICAL, true, false, false); StackedXYBarRenderer renderer = new StackedXYBarRenderer(); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setShadowVisible(false); XYPlot xyPlot = (XYPlot) chart.getPlot(); xyPlot.setRenderer(renderer); for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesPaint(i, copyNumberColor(String.valueOf(dataset.getSeriesKey(i)))); } return chart; }
private JFreeChart createStackedTimeBarChart(ReportChart reportChart, ChartValue[] values, boolean displayInline) { XYDataset dataset = createTimeDataset(values); ValueAxis timeAxis = new DateAxis(reportChart.getXAxisLabel()); NumberAxis valueAxis = new NumberAxis(reportChart.getYAxisLabel()); XYItemRenderer renderer = new StackedXYBarRenderer(); renderer.setBaseToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); if (reportChart.getPlotOrientation() == ReportChart.HORIZONTAL) { plot.setOrientation(PlotOrientation.HORIZONTAL); } return new JFreeChart(reportChart.getTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, reportChart.isShowLegend()); }
private JFreeChart createStackedXYBarChart(ReportChart reportChart, ChartValue[] values, boolean displayInline) { XYDataset dataset = createXYDataset(values); NumberAxis xAxis = new NumberAxis(reportChart.getXAxisLabel()); NumberAxis yAxis = new NumberAxis(reportChart.getYAxisLabel()); StackedXYBarRenderer renderer = new StackedXYBarRenderer(); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); if (reportChart.getPlotOrientation() == ReportChart.HORIZONTAL) { plot.setOrientation(PlotOrientation.HORIZONTAL); } return new JFreeChart(reportChart.getTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, reportChart.isShowLegend()); }
/** * 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, 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)); }
/** * Test that the equals() method distinguishes all fields. */ public void testEquals() { // default instances StackedXYBarRenderer r1 = new StackedXYBarRenderer(); StackedXYBarRenderer r2 = new StackedXYBarRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); }
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { StackedXYBarRenderer r1 = new StackedXYBarRenderer(); StackedXYBarRenderer r2 = new StackedXYBarRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); }
/** * Test that the equals() method distinguishes all fields. */ public void testEquals() { StackedXYBarRenderer r1 = new StackedXYBarRenderer(); StackedXYBarRenderer r2 = new StackedXYBarRenderer(); assertTrue(r1.equals(r2)); assertTrue(r2.equals(r1)); r1.setRenderAsPercentages(true); assertFalse(r1.equals(r2)); r2.setRenderAsPercentages(true); assertTrue(r1.equals(r2)); }
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { StackedXYBarRenderer r1 = new StackedXYBarRenderer(); StackedXYBarRenderer r2 = new StackedXYBarRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); r1.setRenderAsPercentages(true); h1 = r1.hashCode(); h2 = r2.hashCode(); assertFalse(h1 == h2); }
/** * 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(); plot.setRenderer(new StackedXYBarRenderer()); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); Range bounds = rangeAxis.getRange(); assertTrue(bounds.contains(6.0)); assertTrue(bounds.contains(8.0)); }
/** * 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, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(new StackedXYBarRenderer()); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); Range bounds = rangeAxis.getRange(); assertTrue(bounds.contains(6.0)); assertTrue(bounds.contains(8.0)); }
/** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { StackedXYBarRenderer r1 = new StackedXYBarRenderer(); assertTrue(r1 instanceof PublicCloneable); }