Search in sources :

Example 1 with StandardXYBarPainter

use of org.jfree.chart.renderer.xy.StandardXYBarPainter in project hmftools by hartwigmedical.

the class CopyNumberCharts method somaticPloidyPDF.

@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;
}
Also used : CategoryTableXYDataset(org.jfree.data.xy.CategoryTableXYDataset) XYPlot(org.jfree.chart.plot.XYPlot) StackedXYBarRenderer(org.jfree.chart.renderer.xy.StackedXYBarRenderer) StandardXYBarPainter(org.jfree.chart.renderer.xy.StandardXYBarPainter) JFreeChart(org.jfree.chart.JFreeChart) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with StandardXYBarPainter

use of org.jfree.chart.renderer.xy.StandardXYBarPainter in project hmftools by hartwigmedical.

the class CopyNumberCharts method minorAllelePDF.

@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;
}
Also used : CategoryTableXYDataset(org.jfree.data.xy.CategoryTableXYDataset) XYPlot(org.jfree.chart.plot.XYPlot) StackedXYBarRenderer(org.jfree.chart.renderer.xy.StackedXYBarRenderer) StandardXYBarPainter(org.jfree.chart.renderer.xy.StandardXYBarPainter) JFreeChart(org.jfree.chart.JFreeChart) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with StandardXYBarPainter

use of org.jfree.chart.renderer.xy.StandardXYBarPainter in project SIMVA-SoS by SESoS.

the class ChartFactory method setChartTheme.

/**
 * Sets the current chart theme.  This will be applied to all new charts
 * created via methods in this class.
 *
 * @param theme  the theme (<code>null</code> not permitted).
 *
 * @see #getChartTheme()
 * @see ChartUtilities#applyCurrentTheme(JFreeChart)
 *
 * @since 1.0.11
 */
public static void setChartTheme(ChartTheme theme) {
    ParamChecks.nullNotPermitted(theme, "theme");
    currentTheme = theme;
    // theme, and reset the bar painters in that case...
    if (theme instanceof StandardChartTheme) {
        StandardChartTheme sct = (StandardChartTheme) theme;
        if (sct.getName().equals("Legacy")) {
            BarRenderer.setDefaultBarPainter(new StandardBarPainter());
            XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter());
        } else {
            BarRenderer.setDefaultBarPainter(new GradientBarPainter());
            XYBarRenderer.setDefaultBarPainter(new GradientXYBarPainter());
        }
    }
}
Also used : GradientBarPainter(org.jfree.chart.renderer.category.GradientBarPainter) StandardBarPainter(org.jfree.chart.renderer.category.StandardBarPainter) GradientXYBarPainter(org.jfree.chart.renderer.xy.GradientXYBarPainter) StandardXYBarPainter(org.jfree.chart.renderer.xy.StandardXYBarPainter)

Example 4 with StandardXYBarPainter

use of org.jfree.chart.renderer.xy.StandardXYBarPainter in project SIMVA-SoS by SESoS.

the class StandardChartThemeTest method testEquals.

/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    StandardChartTheme t1 = new StandardChartTheme("Name");
    StandardChartTheme t2 = new StandardChartTheme("Name");
    assertTrue(t1.equals(t2));
    // name
    t1 = new StandardChartTheme("t1");
    assertFalse(t1.equals(t2));
    t2 = new StandardChartTheme("t1");
    assertTrue(t1.equals(t2));
    // extraLargeFont
    t1.setExtraLargeFont(new Font("Dialog", Font.PLAIN, 21));
    assertFalse(t1.equals(t2));
    t2.setExtraLargeFont(new Font("Dialog", Font.PLAIN, 21));
    assertTrue(t1.equals(t2));
    // largeFont
    t1.setLargeFont(new Font("Dialog", Font.PLAIN, 19));
    assertFalse(t1.equals(t2));
    t2.setLargeFont(new Font("Dialog", Font.PLAIN, 19));
    assertTrue(t1.equals(t2));
    // regularFont;
    t1.setRegularFont(new Font("Dialog", Font.PLAIN, 17));
    assertFalse(t1.equals(t2));
    t2.setRegularFont(new Font("Dialog", Font.PLAIN, 17));
    assertTrue(t1.equals(t2));
    // titlePaint;
    t1.setTitlePaint(new GradientPaint(0f, 1f, Color.red, 2f, 3f, Color.blue));
    assertFalse(t1.equals(t2));
    t2.setTitlePaint(new GradientPaint(0f, 1f, Color.red, 2f, 3f, Color.blue));
    assertTrue(t1.equals(t2));
    // subtitlePaint;
    t1.setSubtitlePaint(new GradientPaint(1f, 2f, Color.red, 3f, 4f, Color.blue));
    assertFalse(t1.equals(t2));
    t2.setSubtitlePaint(new GradientPaint(1f, 2f, Color.red, 3f, 4f, Color.blue));
    assertTrue(t1.equals(t2));
    // chartBackgroundPaint;
    t1.setChartBackgroundPaint(new GradientPaint(2f, 3f, Color.blue, 4f, 5f, Color.red));
    assertFalse(t1.equals(t2));
    t2.setChartBackgroundPaint(new GradientPaint(2f, 3f, Color.blue, 4f, 5f, Color.red));
    assertTrue(t1.equals(t2));
    // legendBackgroundPaint;
    t1.setLegendBackgroundPaint(new GradientPaint(3f, 4f, Color.gray, 1f, 2f, Color.red));
    assertFalse(t1.equals(t2));
    t2.setLegendBackgroundPaint(new GradientPaint(3f, 4f, Color.gray, 1f, 2f, Color.red));
    assertTrue(t1.equals(t2));
    // legendItemPaint;
    t1.setLegendItemPaint(new GradientPaint(9f, 8f, Color.red, 7f, 6f, Color.blue));
    assertFalse(t1.equals(t2));
    t2.setLegendItemPaint(new GradientPaint(9f, 8f, Color.red, 7f, 6f, Color.blue));
    assertTrue(t1.equals(t2));
    // drawingSupplier;
    t1.setDrawingSupplier(new DefaultDrawingSupplier(new Paint[] { Color.red }, new Paint[] { Color.blue }, new Stroke[] { new BasicStroke(1.0f) }, new Stroke[] { new BasicStroke(1.0f) }, new Shape[] { new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0) }));
    assertFalse(t1.equals(t2));
    t2.setDrawingSupplier(new DefaultDrawingSupplier(new Paint[] { Color.red }, new Paint[] { Color.blue }, new Stroke[] { new BasicStroke(1.0f) }, new Stroke[] { new BasicStroke(1.0f) }, new Shape[] { new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0) }));
    assertTrue(t1.equals(t2));
    // plotBackgroundPaint;
    t1.setPlotBackgroundPaint(new GradientPaint(4f, 3f, Color.red, 6f, 7f, Color.blue));
    assertFalse(t1.equals(t2));
    t2.setPlotBackgroundPaint(new GradientPaint(4f, 3f, Color.red, 6f, 7f, Color.blue));
    assertTrue(t1.equals(t2));
    // plotOutlinePaint;
    t1.setPlotOutlinePaint(new GradientPaint(5f, 2f, Color.blue, 6f, 7f, Color.red));
    assertFalse(t1.equals(t2));
    t2.setPlotOutlinePaint(new GradientPaint(5f, 2f, Color.blue, 6f, 7f, Color.red));
    assertTrue(t1.equals(t2));
    // labelLinkStyle;
    t1.setLabelLinkStyle(PieLabelLinkStyle.STANDARD);
    assertFalse(t1.equals(t2));
    t2.setLabelLinkStyle(PieLabelLinkStyle.STANDARD);
    assertTrue(t1.equals(t2));
    // labelLinkPaint;
    t1.setLabelLinkPaint(new GradientPaint(4f, 3f, Color.red, 2f, 9f, Color.blue));
    assertFalse(t1.equals(t2));
    t2.setLabelLinkPaint(new GradientPaint(4f, 3f, Color.red, 2f, 9f, Color.blue));
    assertTrue(t1.equals(t2));
    // domainGridlinePaint;
    t1.setDomainGridlinePaint(Color.blue);
    assertFalse(t1.equals(t2));
    t2.setDomainGridlinePaint(Color.blue);
    assertTrue(t1.equals(t2));
    // rangeGridlinePaint;
    t1.setRangeGridlinePaint(Color.red);
    assertFalse(t1.equals(t2));
    t2.setRangeGridlinePaint(Color.red);
    assertTrue(t1.equals(t2));
    // axisOffset;
    t1.setAxisOffset(new RectangleInsets(1, 2, 3, 4));
    assertFalse(t1.equals(t2));
    t2.setAxisOffset(new RectangleInsets(1, 2, 3, 4));
    assertTrue(t1.equals(t2));
    // axisLabelPaint;
    t1.setAxisLabelPaint(new GradientPaint(8f, 4f, Color.gray, 2f, 9f, Color.blue));
    assertFalse(t1.equals(t2));
    t2.setAxisLabelPaint(new GradientPaint(8f, 4f, Color.gray, 2f, 9f, Color.blue));
    assertTrue(t1.equals(t2));
    // tickLabelPaint;
    t1.setTickLabelPaint(new GradientPaint(3f, 4f, Color.red, 5f, 6f, Color.yellow));
    assertFalse(t1.equals(t2));
    t2.setTickLabelPaint(new GradientPaint(3f, 4f, Color.red, 5f, 6f, Color.yellow));
    assertTrue(t1.equals(t2));
    // itemLabelPaint;
    t1.setItemLabelPaint(new GradientPaint(2f, 5f, Color.gray, 1f, 2f, Color.blue));
    assertFalse(t1.equals(t2));
    t2.setItemLabelPaint(new GradientPaint(2f, 5f, Color.gray, 1f, 2f, Color.blue));
    assertTrue(t1.equals(t2));
    // shadowVisible;
    t1.setShadowVisible(!t1.isShadowVisible());
    assertFalse(t1.equals(t2));
    t2.setShadowVisible(t1.isShadowVisible());
    assertTrue(t1.equals(t2));
    // shadowPaint;
    t1.setShadowPaint(new GradientPaint(7f, 1f, Color.blue, 4f, 6f, Color.red));
    assertFalse(t1.equals(t2));
    t2.setShadowPaint(new GradientPaint(7f, 1f, Color.blue, 4f, 6f, Color.red));
    assertTrue(t1.equals(t2));
    // barPainter;
    t1.setBarPainter(new StandardBarPainter());
    assertFalse(t1.equals(t2));
    t2.setBarPainter(new StandardBarPainter());
    assertTrue(t1.equals(t2));
    // xyBarPainter;
    t1.setXYBarPainter(new StandardXYBarPainter());
    assertFalse(t1.equals(t2));
    t2.setXYBarPainter(new StandardXYBarPainter());
    assertTrue(t1.equals(t2));
    // thermometerPaint;
    t1.setThermometerPaint(new GradientPaint(9f, 7f, Color.red, 5f, 1f, Color.blue));
    assertFalse(t1.equals(t2));
    t2.setThermometerPaint(new GradientPaint(9f, 7f, Color.red, 5f, 1f, Color.blue));
    assertTrue(t1.equals(t2));
    // wallPaint;
    t1.setWallPaint(new GradientPaint(4f, 5f, Color.red, 1f, 0f, Color.gray));
    assertFalse(t1.equals(t2));
    t2.setWallPaint(new GradientPaint(4f, 5f, Color.red, 1f, 0f, Color.gray));
    assertTrue(t1.equals(t2));
    // errorIndicatorPaint;
    t1.setErrorIndicatorPaint(new GradientPaint(0f, 1f, Color.white, 2f, 3f, Color.blue));
    assertFalse(t1.equals(t2));
    t2.setErrorIndicatorPaint(new GradientPaint(0f, 1f, Color.white, 2f, 3f, Color.blue));
    assertTrue(t1.equals(t2));
    // gridBandPaint
    t1.setGridBandPaint(new GradientPaint(1f, 2f, Color.white, 4f, 8f, Color.red));
    assertFalse(t1.equals(t2));
    t2.setGridBandPaint(new GradientPaint(1f, 2f, Color.white, 4f, 8f, Color.red));
    assertTrue(t1.equals(t2));
    // gridBandAlternatePaint
    t1.setGridBandAlternatePaint(new GradientPaint(1f, 4f, Color.green, 1f, 2f, Color.red));
    assertFalse(t1.equals(t2));
    t2.setGridBandAlternatePaint(new GradientPaint(1f, 4f, Color.green, 1f, 2f, Color.red));
    assertTrue(t1.equals(t2));
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Shape(java.awt.Shape) StandardBarPainter(org.jfree.chart.renderer.category.StandardBarPainter) GradientPaint(java.awt.GradientPaint) RectangleInsets(org.jfree.ui.RectangleInsets) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) StandardXYBarPainter(org.jfree.chart.renderer.xy.StandardXYBarPainter) Font(java.awt.Font) DefaultDrawingSupplier(org.jfree.chart.plot.DefaultDrawingSupplier) Test(org.junit.Test)

Example 5 with StandardXYBarPainter

use of org.jfree.chart.renderer.xy.StandardXYBarPainter in project hmftools by hartwigmedical.

the class CopyNumberCharts method copyNumberPDF.

@NotNull
static JFreeChart copyNumberPDF(@NotNull final List<PurpleCopyNumber> copyNumbers) {
    final XYDataset dataset = ploidyPDF(copyNumbers, PurpleCopyNumber::averageTumorCopyNumber, PurpleCopyNumber::bafCount);
    JFreeChart chart = ChartFactory.createScatterPlot("Copy Number PDF", "Ploidy", "BAF Count", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYBarRenderer renderer = new XYBarRenderer(0.9);
    renderer.setShadowVisible(false);
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setSeriesPaint(0, Color.BLUE);
    XYPlot xyPlot = (XYPlot) chart.getPlot();
    xyPlot.getDomainAxis().setRange(0, 10);
    xyPlot.setRenderer(renderer);
    return chart;
}
Also used : XYPlot(org.jfree.chart.plot.XYPlot) XYDataset(org.jfree.data.xy.XYDataset) CategoryTableXYDataset(org.jfree.data.xy.CategoryTableXYDataset) PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber) StandardXYBarPainter(org.jfree.chart.renderer.xy.StandardXYBarPainter) JFreeChart(org.jfree.chart.JFreeChart) StackedXYBarRenderer(org.jfree.chart.renderer.xy.StackedXYBarRenderer) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

StandardXYBarPainter (org.jfree.chart.renderer.xy.StandardXYBarPainter)5 NotNull (org.jetbrains.annotations.NotNull)3 JFreeChart (org.jfree.chart.JFreeChart)3 XYPlot (org.jfree.chart.plot.XYPlot)3 StackedXYBarRenderer (org.jfree.chart.renderer.xy.StackedXYBarRenderer)3 CategoryTableXYDataset (org.jfree.data.xy.CategoryTableXYDataset)3 StandardBarPainter (org.jfree.chart.renderer.category.StandardBarPainter)2 PurpleCopyNumber (com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber)1 BasicStroke (java.awt.BasicStroke)1 Font (java.awt.Font)1 GradientPaint (java.awt.GradientPaint)1 Paint (java.awt.Paint)1 Shape (java.awt.Shape)1 Stroke (java.awt.Stroke)1 DefaultDrawingSupplier (org.jfree.chart.plot.DefaultDrawingSupplier)1 GradientBarPainter (org.jfree.chart.renderer.category.GradientBarPainter)1 GradientXYBarPainter (org.jfree.chart.renderer.xy.GradientXYBarPainter)1 XYBarRenderer (org.jfree.chart.renderer.xy.XYBarRenderer)1 XYDataset (org.jfree.data.xy.XYDataset)1 RectangleInsets (org.jfree.ui.RectangleInsets)1