org.jfree.chart.plot.RingPlot Java Examples

The following examples show how to use org.jfree.chart.plot.RingPlot. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChartFactory.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A ring chart.
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #2
Source File: ChartFactory.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A ring chart.
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #3
Source File: ChartFactory.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A ring chart.
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #4
Source File: ChartFactory.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A ring chart.
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #5
Source File: ChartFactory.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot} 
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A pie chart.
 */
public static JFreeChart createRingChart(String title,
                                         PieDataset dataset,
                                         boolean legend,
                                         boolean tooltips,
                                         boolean urls) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator(
                StandardPieToolTipGenerator.DEFAULT_SECTION_LABEL_FORMAT));
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
            legend);

}
 
Example #6
Source File: ChartFactory.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A ring chart.
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #7
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot} 
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A ring chart.
 */
public static JFreeChart createRingChart(String title,
                                         PieDataset dataset,
                                         boolean legend,
                                         boolean tooltips,
                                         boolean urls) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
            legend);

}
 
Example #8
Source File: ChartFactory.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A ring chart.
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, boolean urls) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #9
Source File: RingPlotTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Some checks for the equals() method.
 */
public void testEquals() {

    RingPlot plot1 = new RingPlot(null);
    RingPlot plot2 = new RingPlot(null);
    assertTrue(plot1.equals(plot2));
    assertTrue(plot2.equals(plot1));

    // separatorsVisible
    plot1.setSeparatorsVisible(false);
    assertFalse(plot1.equals(plot2));
    plot2.setSeparatorsVisible(false);
    assertTrue(plot1.equals(plot2));

    // separatorStroke
    Stroke s = new BasicStroke(1.1f);
    plot1.setSeparatorStroke(s);
    assertFalse(plot1.equals(plot2));
    plot2.setSeparatorStroke(s);
    assertTrue(plot1.equals(plot2));

    // separatorPaint
    plot1.setSeparatorPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            2.0f, 1.0f, Color.blue));
    assertFalse(plot1.equals(plot2));
    plot2.setSeparatorPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            2.0f, 1.0f, Color.blue));
    assertTrue(plot1.equals(plot2));

    // innerSeparatorExtension
    plot1.setInnerSeparatorExtension(0.01);
    assertFalse(plot1.equals(plot2));
    plot2.setInnerSeparatorExtension(0.01);
    assertTrue(plot1.equals(plot2));

    // outerSeparatorExtension
    plot1.setOuterSeparatorExtension(0.02);
    assertFalse(plot1.equals(plot2));
    plot2.setOuterSeparatorExtension(0.02);
    assertTrue(plot1.equals(plot2));

    // sectionDepth
    plot1.setSectionDepth(0.12);
    assertFalse(plot1.equals(plot2));
    plot2.setSectionDepth(0.12);
    assertTrue(plot1.equals(plot2));

}
 
Example #10
Source File: JFreeChartTest.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check that the equals() method can distinguish all fields.
 */
@Test
public void testEquals() {
    JFreeChart chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    JFreeChart chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    assertEquals(chart1, chart2);
    assertEquals(chart2, chart1);

    // renderingHints
    chart1.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertFalse(chart1.equals(chart2));
    chart2.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertEquals(chart1, chart2);

    // borderVisible
    chart1.setBorderVisible(true);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderVisible(true);
    assertEquals(chart1, chart2);

    // borderStroke
    BasicStroke s = new BasicStroke(2.0f);
    chart1.setBorderStroke(s);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderStroke(s);
    assertEquals(chart1, chart2);

    // borderPaint
    chart1.setBorderPaint(Color.red);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderPaint(Color.red);
    assertEquals(chart1, chart2);

    // padding
    chart1.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertFalse(chart1.equals(chart2));
    chart2.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertEquals(chart1, chart2);

    // title
    chart1.setTitle("XYZ");
    assertFalse(chart1.equals(chart2));
    chart2.setTitle("XYZ");
    assertEquals(chart1, chart2);

    // subtitles
    chart1.addSubtitle(new TextTitle("Subtitle"));
    assertFalse(chart1.equals(chart2));
    chart2.addSubtitle(new TextTitle("Subtitle"));
    assertEquals(chart1, chart2);

    // plot
    chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), false);
    assertFalse(chart1.equals(chart2));
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    assertEquals(chart1, chart2);

    // backgroundPaint
    chart1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertEquals(chart1, chart2);

    // backgroundImage
    chart1.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertEquals(chart1, chart2);

    // backgroundImageAlignment
    chart1.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertEquals(chart1, chart2);

    // backgroundImageAlpha
    chart1.setBackgroundImageAlpha(0.1f);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlpha(0.1f);
    assertEquals(chart1, chart2);
}
 
Example #11
Source File: RingChartExpression.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void configureChart( final JFreeChart chart ) {
  super.configureChart( chart );

  final RingPlot ringPlot = (RingPlot) chart.getPlot();
  ringPlot.setSectionDepth( sectionDepth );
}
 
Example #12
Source File: RingPlotTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Some checks for the equals() method.
 */
public void testEquals() {
    
    RingPlot plot1 = new RingPlot(null);
    RingPlot plot2 = new RingPlot(null);
    assertTrue(plot1.equals(plot2));
    assertTrue(plot2.equals(plot1));
            
    // separatorsVisible
    plot1.setSeparatorsVisible(false);
    assertFalse(plot1.equals(plot2));
    plot2.setSeparatorsVisible(false);
    assertTrue(plot1.equals(plot2));
    
    // separatorStroke
    Stroke s = new BasicStroke(1.1f);
    plot1.setSeparatorStroke(s);
    assertFalse(plot1.equals(plot2));
    plot2.setSeparatorStroke(s);
    assertTrue(plot1.equals(plot2));

    // separatorPaint
    plot1.setSeparatorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 
            2.0f, 1.0f, Color.blue));
    assertFalse(plot1.equals(plot2));
    plot2.setSeparatorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 
            2.0f, 1.0f, Color.blue));
    assertTrue(plot1.equals(plot2));
    
    // innerSeparatorExtension
    plot1.setInnerSeparatorExtension(0.01);
    assertFalse(plot1.equals(plot2));
    plot2.setInnerSeparatorExtension(0.01);
    assertTrue(plot1.equals(plot2));
    
    // outerSeparatorExtension
    plot1.setOuterSeparatorExtension(0.02);
    assertFalse(plot1.equals(plot2));
    plot2.setOuterSeparatorExtension(0.02);
    assertTrue(plot1.equals(plot2));

    // sectionDepth
    plot1.setSectionDepth(0.12);
    assertFalse(plot1.equals(plot2));
    plot2.setSectionDepth(0.12);
    assertTrue(plot1.equals(plot2));
    
}
 
Example #13
Source File: JFreeChartTest.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check that the equals() method can distinguish all fields.
 */
@Test
public void testEquals() {
    JFreeChart chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    JFreeChart chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    assertEquals(chart1, chart2);
    assertEquals(chart2, chart1);

    // renderingHints
    chart1.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertFalse(chart1.equals(chart2));
    chart2.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertEquals(chart1, chart2);

    // borderVisible
    chart1.setBorderVisible(true);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderVisible(true);
    assertEquals(chart1, chart2);

    // borderStroke
    BasicStroke s = new BasicStroke(2.0f);
    chart1.setBorderStroke(s);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderStroke(s);
    assertEquals(chart1, chart2);

    // borderPaint
    chart1.setBorderPaint(Color.red);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderPaint(Color.red);
    assertEquals(chart1, chart2);

    // padding
    chart1.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertFalse(chart1.equals(chart2));
    chart2.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertEquals(chart1, chart2);

    // title
    chart1.setTitle("XYZ");
    assertFalse(chart1.equals(chart2));
    chart2.setTitle("XYZ");
    assertEquals(chart1, chart2);

    // subtitles
    chart1.addSubtitle(new TextTitle("Subtitle"));
    assertFalse(chart1.equals(chart2));
    chart2.addSubtitle(new TextTitle("Subtitle"));
    assertEquals(chart1, chart2);

    // plot
    chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), false);
    assertFalse(chart1.equals(chart2));
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    assertEquals(chart1, chart2);

    // backgroundPaint
    chart1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertEquals(chart1, chart2);

    // backgroundImage
    chart1.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertEquals(chart1, chart2);

    // backgroundImageAlignment
    chart1.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertEquals(chart1, chart2);

    // backgroundImageAlpha
    chart1.setBackgroundImageAlpha(0.1f);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlpha(0.1f);
    assertEquals(chart1, chart2);
}
 
Example #14
Source File: JFreeChartTest.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check that the equals() method can distinguish all fields.
 */
@Test
public void testEquals() {
    JFreeChart chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    JFreeChart chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    assertEquals(chart1, chart2);
    assertEquals(chart2, chart1);

    // renderingHints
    chart1.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertFalse(chart1.equals(chart2));
    chart2.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertEquals(chart1, chart2);

    // borderVisible
    chart1.setBorderVisible(true);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderVisible(true);
    assertEquals(chart1, chart2);

    // borderStroke
    BasicStroke s = new BasicStroke(2.0f);
    chart1.setBorderStroke(s);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderStroke(s);
    assertEquals(chart1, chart2);

    // borderPaint
    chart1.setBorderPaint(Color.red);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderPaint(Color.red);
    assertEquals(chart1, chart2);

    // padding
    chart1.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertFalse(chart1.equals(chart2));
    chart2.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertEquals(chart1, chart2);

    // title
    chart1.setTitle("XYZ");
    assertFalse(chart1.equals(chart2));
    chart2.setTitle("XYZ");
    assertEquals(chart1, chart2);

    // subtitles
    chart1.addSubtitle(new TextTitle("Subtitle"));
    assertFalse(chart1.equals(chart2));
    chart2.addSubtitle(new TextTitle("Subtitle"));
    assertEquals(chart1, chart2);

    // plot
    chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), false);
    assertFalse(chart1.equals(chart2));
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    assertEquals(chart1, chart2);

    // backgroundPaint
    chart1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertEquals(chart1, chart2);

    // backgroundImage
    chart1.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertEquals(chart1, chart2);

    // backgroundImageAlignment
    chart1.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertEquals(chart1, chart2);

    // backgroundImageAlpha
    chart1.setBackgroundImageAlpha(0.1f);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlpha(0.1f);
    assertEquals(chart1, chart2);
}
 
Example #15
Source File: JFreeChartTest.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Check that the equals() method can distinguish all fields.
 */
@Test
public void testEquals() {
    JFreeChart chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    JFreeChart chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    assertEquals(chart1, chart2);
    assertEquals(chart2, chart1);

    // renderingHints
    chart1.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertFalse(chart1.equals(chart2));
    chart2.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertEquals(chart1, chart2);

    // borderVisible
    chart1.setBorderVisible(true);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderVisible(true);
    assertEquals(chart1, chart2);

    // borderStroke
    BasicStroke s = new BasicStroke(2.0f);
    chart1.setBorderStroke(s);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderStroke(s);
    assertEquals(chart1, chart2);

    // borderPaint
    chart1.setBorderPaint(Color.red);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderPaint(Color.red);
    assertEquals(chart1, chart2);

    // padding
    chart1.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertFalse(chart1.equals(chart2));
    chart2.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertEquals(chart1, chart2);

    // title
    chart1.setTitle("XYZ");
    assertFalse(chart1.equals(chart2));
    chart2.setTitle("XYZ");
    assertEquals(chart1, chart2);

    // subtitles
    chart1.addSubtitle(new TextTitle("Subtitle"));
    assertFalse(chart1.equals(chart2));
    chart2.addSubtitle(new TextTitle("Subtitle"));
    assertEquals(chart1, chart2);

    // plot
    chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), false);
    assertFalse(chart1.equals(chart2));
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    assertEquals(chart1, chart2);

    // backgroundPaint
    chart1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertEquals(chart1, chart2);

    // backgroundImage
    chart1.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertEquals(chart1, chart2);

    // backgroundImageAlignment
    chart1.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertEquals(chart1, chart2);

    // backgroundImageAlpha
    chart1.setBackgroundImageAlpha(0.1f);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlpha(0.1f);
    assertEquals(chart1, chart2);
}
 
Example #16
Source File: JFreeChartTest.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check that the equals() method can distinguish all fields.
 */
@Test
public void testEquals() {
    JFreeChart chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    JFreeChart chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    assertEquals(chart1, chart2);
    assertEquals(chart2, chart1);

    // renderingHints
    chart1.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertFalse(chart1.equals(chart2));
    chart2.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertEquals(chart1, chart2);

    // borderVisible
    chart1.setBorderVisible(true);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderVisible(true);
    assertEquals(chart1, chart2);

    // borderStroke
    BasicStroke s = new BasicStroke(2.0f);
    chart1.setBorderStroke(s);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderStroke(s);
    assertEquals(chart1, chart2);

    // borderPaint
    chart1.setBorderPaint(Color.red);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderPaint(Color.red);
    assertEquals(chart1, chart2);

    // padding
    chart1.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertFalse(chart1.equals(chart2));
    chart2.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertEquals(chart1, chart2);

    // title
    chart1.setTitle("XYZ");
    assertFalse(chart1.equals(chart2));
    chart2.setTitle("XYZ");
    assertEquals(chart1, chart2);

    // subtitles
    chart1.addSubtitle(new TextTitle("Subtitle"));
    assertFalse(chart1.equals(chart2));
    chart2.addSubtitle(new TextTitle("Subtitle"));
    assertEquals(chart1, chart2);

    // plot
    chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), false);
    assertFalse(chart1.equals(chart2));
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    assertEquals(chart1, chart2);

    // backgroundPaint
    chart1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertEquals(chart1, chart2);

    // backgroundImage
    chart1.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertEquals(chart1, chart2);

    // backgroundImageAlignment
    chart1.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertEquals(chart1, chart2);

    // backgroundImageAlpha
    chart1.setBackgroundImageAlpha(0.1f);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlpha(0.1f);
    assertEquals(chart1, chart2);
}
 
Example #17
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @return A ring chart.
 *
 * @since 1.0.7
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, Locale locale) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #18
Source File: ChartFactory.java    From ECG-Viewer with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @return A ring chart.
 *
 * @since 1.0.7
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, Locale locale) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #19
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot} 
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @return A ring chart.
 * 
 * @since 1.0.7
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, Locale locale) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
    }
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
            legend);

}
 
Example #20
Source File: ChartFactory.java    From SIMVA-SoS with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @return A ring chart.
 *
 * @since 1.0.7
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, Locale locale) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #21
Source File: ChartFactory.java    From ccu-historian with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @return A ring chart.
 *
 * @since 1.0.7
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, Locale locale) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #22
Source File: ChartFactory.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @return A ring chart.
 *
 * @since 1.0.7
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, Locale locale) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #23
Source File: ChartFactory.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @return A ring chart.
 *
 * @since 1.0.7
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, Locale locale) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}
 
Example #24
Source File: ChartFactory.java    From openstock with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Creates a ring chart with default settings.
 * <P>
 * The chart object returned by this method uses a {@link RingPlot}
 * instance as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @return A ring chart.
 *
 * @since 1.0.7
 */
public static JFreeChart createRingChart(String title, PieDataset dataset,
        boolean legend, boolean tooltips, Locale locale) {

    RingPlot plot = new RingPlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;
}