org.jfree.data.general.DefaultPieDataset Java Examples

The following examples show how to use org.jfree.data.general.DefaultPieDataset. 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: PieDatasetHandler.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Starts an element.
 *
 * @param namespaceURI  the namespace.
 * @param localName  the element name.
 * @param qName  the element name.
 * @param atts  the element attributes.
 *
 * @throws SAXException for errors.
 */
public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes atts) throws SAXException {

    DefaultHandler current = getCurrentHandler();
    if (current != this) {
        current.startElement(namespaceURI, localName, qName, atts);
    }
    else if (qName.equals(PIEDATASET_TAG)) {
        this.dataset = new DefaultPieDataset();
    }
    else if (qName.equals(ITEM_TAG)) {
        ItemHandler subhandler = new ItemHandler(this, this);
        getSubHandlers().push(subhandler);
        subhandler.startElement(namespaceURI, localName, qName, atts);
    }

}
 
Example #2
Source File: StandardEntityCollectionTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    StandardEntityCollection c1 = new StandardEntityCollection();
    StandardEntityCollection c2 = new StandardEntityCollection();
    assertTrue(c1.equals(c2));

    PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0,
            2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
            "ToolTip", "URL");
    c1.add(e1);
    assertFalse(c1.equals(c2));
    PieSectionEntity e2 = new PieSectionEntity(new Rectangle2D.Double(1.0,
            2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
            "ToolTip", "URL");
    c2.add(e2);
    assertTrue(c1.equals(c2));
}
 
Example #3
Source File: PieChart3DTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests that no exceptions are thrown when there is a <code>null</code> 
 * value in the dataset.
 */
public void testNullValueInDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("Section 1", 10.0);
    dataset.setValue("Section 2", 11.0);
    dataset.setValue("Section 3", null);
    JFreeChart chart = createPieChart3D(dataset);
    boolean success = false;
    try {
        BufferedImage image = new BufferedImage(200 , 100, 
                BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
        success = true;
    }
    catch (Throwable t) {
        success = false;
    }
    assertTrue(success);
}
 
Example #4
Source File: PiePlotTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Draws a pie chart where the label generator returns null.
 */
@Test
public void testDrawWithNullLegendLabels() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("L1", 12.0);
    dataset.setValue("L2", 11.0);
    JFreeChart chart = ChartFactory.createPieChart("Test", dataset, true,
            false, false);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLegendLabelGenerator(new NullLegendLabelGenerator());
    boolean success = false;
    try {
        BufferedImage image = new BufferedImage(200 , 100,
                BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
        success = true;
    }
    catch (Exception e) {
      success = false;
    }
    assertTrue(success);
}
 
Example #5
Source File: JFreeChartTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Common test setup.
 */
protected void setUp() {

    // create a dataset...
    DefaultPieDataset data = new DefaultPieDataset();
    data.setValue("Java", new Double(43.2));
    data.setValue("Visual Basic", new Double(0.0));
    data.setValue("C/C++", new Double(17.5));

    // create the chart...
    this.pieChart = ChartFactory.createPieChart(
        "Pie Chart",  // chart title
        data,         // data
        true,         // include legend
        true,
        false
    );

}
 
Example #6
Source File: PiePlotTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Draws a pie chart where the label generator returns null.
 */
@Test
public void testDrawWithNullLegendLabels() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("L1", 12.0);
    dataset.setValue("L2", 11.0);
    JFreeChart chart = ChartFactory.createPieChart("Test", dataset, true,
            false, false);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLegendLabelGenerator(new NullLegendLabelGenerator());
    boolean success = false;
    try {
        BufferedImage image = new BufferedImage(200 , 100,
                BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
        success = true;
    }
    catch (Exception e) {
      success = false;
    }
    assertTrue(success);
}
 
Example #7
Source File: StandardEntityCollectionTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0,
            2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
            "ToolTip", "URL");
    StandardEntityCollection c1 = new StandardEntityCollection();
    c1.add(e1);
    StandardEntityCollection c2 = (StandardEntityCollection) c1.clone();
    assertTrue(c1 != c2);
    assertTrue(c1.getClass() == c2.getClass());
    assertTrue(c1.equals(c2));

    // check independence
    c1.clear();
    assertFalse(c1.equals(c2));
    c2.clear();
    assertTrue(c1.equals(c2));
}
 
Example #8
Source File: HomeAdmin.java    From StudentGradesManageSystem with Apache License 2.0 6 votes vote down vote up
public void makeChartByMap(Map<String, Object> map,String title) {
    DefaultPieDataset dpd = new DefaultPieDataset(); //建立一个默认的饼图
    System.out.println(map);

    dpd.setValue("优", Integer.parseInt(map.get("优").toString()));
    dpd.setValue("良", Integer.parseInt(map.get("良").toString()));
    dpd.setValue("中", Integer.parseInt(map.get("中").toString()));
    dpd.setValue("差", Integer.parseInt(map.get("差").toString()));
    dpd.setValue("不及格", Integer.parseInt(map.get("不及格").toString()));

    JFreeChart chart = ChartFactory.createPieChart(title, dpd, true, true, false);
    PiePlot piePlot = (PiePlot) chart.getPlot();
    piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(("{0}:({2})"), NumberFormat.getNumberInstance(), new DecimalFormat("0.00%")));
    //可以查具体的API文档,第一个参数是标题,第二个参数是一个数据集,第三个参数表示是否显示Legend,第四个参数表示是否显示提示,第五个参数表示图中是否存在URL
    ChartFrame chartFrame = new ChartFrame(title, chart);
    //chart要放在Java容器组件中,ChartFrame继承自java的Jframe类。该第一个参数的数据是放在窗口左上角的,不是正中间的标题。
    chartFrame.pack(); //以合适的大小展现图形
    chartFrame.setVisible(true);//图形是否可见
}
 
Example #9
Source File: PieDatasetHandler.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Starts an element.
 *
 * @param namespaceURI  the namespace.
 * @param localName  the element name.
 * @param qName  the element name.
 * @param atts  the element attributes.
 *
 * @throws SAXException for errors.
 */
@Override
public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes atts) throws SAXException {

    DefaultHandler current = getCurrentHandler();
    if (current != this) {
        current.startElement(namespaceURI, localName, qName, atts);
    }
    else if (qName.equals(PIEDATASET_TAG)) {
        this.dataset = new DefaultPieDataset();
    }
    else if (qName.equals(ITEM_TAG)) {
        ItemHandler subhandler = new ItemHandler(this, this);
        getSubHandlers().push(subhandler);
        subhandler.startElement(namespaceURI, localName, qName, atts);
    }

}
 
Example #10
Source File: StandardEntityCollectionTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    StandardEntityCollection c1 = new StandardEntityCollection();
    StandardEntityCollection c2 = new StandardEntityCollection();
    assertTrue(c1.equals(c2));
    
    PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, 
            2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", 
            "ToolTip", "URL");
    c1.add(e1);
    assertFalse(c1.equals(c2));
    PieSectionEntity e2 = new PieSectionEntity(new Rectangle2D.Double(1.0, 
            2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", 
            "ToolTip", "URL");
    c2.add(e2);
    assertTrue(c1.equals(c2));        
}
 
Example #11
Source File: StandardEntityCollectionTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    StandardEntityCollection c1 = new StandardEntityCollection();
    StandardEntityCollection c2 = new StandardEntityCollection();
    assertTrue(c1.equals(c2));

    PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0,
            2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
            "ToolTip", "URL");
    c1.add(e1);
    assertFalse(c1.equals(c2));
    PieSectionEntity e2 = new PieSectionEntity(new Rectangle2D.Double(1.0,
            2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
            "ToolTip", "URL");
    c2.add(e2);
    assertTrue(c1.equals(c2));
}
 
Example #12
Source File: PieChartTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a pie chart.
 *
 * @return The pie chart.
 */
private static JFreeChart createPieChart() {
    // create a dataset...
    DefaultPieDataset data = new DefaultPieDataset();
    data.setValue("Java", new Double(43.2));
    data.setValue("Visual Basic", new Double(0.0));
    data.setValue("C/C++", new Double(17.5));

    // create the chart...
    return ChartFactory.createPieChart("Pie Chart",  // chart title
                                       data,         // data
                                       true,         // include legend
                                       true,
                                       false
                                       );
}
 
Example #13
Source File: StatisticsController.java    From JDeSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
@Secured({"ROLE_ADMIN","ROLE_SURVEY_ADMIN"})
private PieDataset createDataset(Long questionId, Long recordCount)	{
	try{
		String columnValue=""; 
		Question question = surveySettingsService.question_findById(questionId);
		List<QuestionStatistic> questionStatistics =surveyService.questionStatistic_getStatistics(question,recordCount);
		DefaultPieDataset defaultPieDataset = new  DefaultPieDataset ();
		for (QuestionStatistic questionStatistic: questionStatistics) {
			//double percentage = ((double)questionStatistic.getCount()/(double)recordCount) * 100;
			//percentage = Double.valueOf(new DecimalFormat("#.##").format(percentage));
			defaultPieDataset.setValue(questionStatistic.getEntry(), questionStatistic.getFrequency() *100);
		}
		return defaultPieDataset;
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example #14
Source File: StandardEntityCollectionTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0,
            2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
            "ToolTip", "URL");
    StandardEntityCollection c1 = new StandardEntityCollection();
    c1.add(e1);
    StandardEntityCollection c2 = (StandardEntityCollection) c1.clone();
    assertTrue(c1 != c2);
    assertTrue(c1.getClass() == c2.getClass());
    assertTrue(c1.equals(c2));

    // check independence
    c1.clear();
    assertFalse(c1.equals(c2));
    c2.clear();
    assertTrue(c1.equals(c2));
}
 
Example #15
Source File: PieDataSetCollector.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected void buildDataset() {
  final DefaultPieDataset localPieDataset = (DefaultPieDataset) getDataSet();
  final Comparable seriesComparable = querySeriesValue( 0 );
  if ( seriesComparable == null ) {
    return;
  }

  final Object valueObject = getDataRow().get( getValueColumn() );
  final Number value = ( valueObject instanceof Number ) ? (Number) valueObject : null;
  final Number existingValue =
    CollectorFunctionUtil.queryExistingValueFromDataSet( localPieDataset, seriesComparable );
  if ( existingValue != null ) {
    if ( value != null ) {
      localPieDataset.setValue( seriesComparable, CollectorFunctionUtil.add( existingValue, value ) );
    }
  } else {
    localPieDataset.setValue( seriesComparable, value );
  }
}
 
Example #16
Source File: PieDatasetHandler.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Starts an element.
 *
 * @param namespaceURI  the namespace.
 * @param localName  the element name.
 * @param qName  the element name.
 * @param atts  the element attributes.
 *
 * @throws SAXException for errors.
 */
@Override
public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes atts) throws SAXException {

    DefaultHandler current = getCurrentHandler();
    if (current != this) {
        current.startElement(namespaceURI, localName, qName, atts);
    }
    else if (qName.equals(PIEDATASET_TAG)) {
        this.dataset = new DefaultPieDataset();
    }
    else if (qName.equals(ITEM_TAG)) {
        ItemHandler subhandler = new ItemHandler(this, this);
        getSubHandlers().push(subhandler);
        subhandler.startElement(namespaceURI, localName, qName, atts);
    }

}
 
Example #17
Source File: StandardEntityCollectionTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    StandardEntityCollection c1 = new StandardEntityCollection();
    StandardEntityCollection c2 = new StandardEntityCollection();
    assertTrue(c1.equals(c2));

    PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0,
            2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
            "ToolTip", "URL");
    c1.add(e1);
    assertFalse(c1.equals(c2));
    PieSectionEntity e2 = new PieSectionEntity(new Rectangle2D.Double(1.0,
            2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
            "ToolTip", "URL");
    c2.add(e2);
    assertTrue(c1.equals(c2));
}
 
Example #18
Source File: Prd4442Test.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void testPieURL() throws Exception {
  DebugExpressionRuntime runtime = new DebugExpressionRuntime();
  FormulaPieURLGenerator gen = new FormulaPieURLGenerator( runtime, "=[chart::item]" );

  DefaultPieDataset dataSet = new DefaultPieDataset();
  dataSet.setValue( "Key-1", 5 );
  dataSet.setValue( "Key-2", 7 );
  dataSet.setValue( "Key-3", 10 );
  assertEquals( "5.0", gen.generateURL( dataSet, "Key-1", 0 ) );
  assertEquals( "7.0", gen.generateURL( dataSet, "Key-2", 1 ) );
  assertEquals( "10.0", gen.generateURL( dataSet, "Key-3", 2 ) );
}
 
Example #19
Source File: PieChartTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a pie chart.
 *
 * @return The pie chart.
 */
private static JFreeChart createPieChart() {
    DefaultPieDataset data = new DefaultPieDataset();
    data.setValue("Java", new Double(43.2));
    data.setValue("Visual Basic", new Double(0.0));
    data.setValue("C/C++", new Double(17.5));
    return ChartFactory.createPieChart("Pie Chart", data);
}
 
Example #20
Source File: PiePlotTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testBug1126_c() throws CloneNotSupportedException {
    DefaultPieDataset dataset1 = new DefaultPieDataset();
    PiePlot plot1 = new PiePlot(dataset1);
    plot1.setSectionOutlineStroke("A", new BasicStroke(5.0f));
    plot1.setSectionOutlineStroke("B", new BasicStroke(6.0f));
    PiePlot plot2 = (PiePlot) plot1.clone();
    plot2.setSectionOutlineStroke("A", new BasicStroke(7.0f));
    plot2.setSectionOutlineStroke("B", new BasicStroke(8.0f));
    assertEquals(new BasicStroke(5.0f), plot1.getSectionOutlineStroke("A"));
    assertEquals(new BasicStroke(6.0f), plot1.getSectionOutlineStroke("B"));
    assertEquals(new BasicStroke(7.0f), plot2.getSectionOutlineStroke("A"));
    assertEquals(new BasicStroke(8.0f), plot2.getSectionOutlineStroke("B"));
}
 
Example #21
Source File: TableJFreeChartDemo.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates a sample dataset for the demo.
 *
 * @return A sample dataset.
 */
private PieDataset createSampleDataset(final int[] votes)
{
  final DefaultPieDataset result = new DefaultPieDataset();
  // cheating: java has a higher chance to be the best language :)
  result.setValue("Java", new Integer(votes[0]));
  result.setValue("Visual Basic", new Integer(votes[1]));
  result.setValue("C/C++", new Integer(votes[2]));
  result.setValue("PHP", new Integer(votes[3]));
  result.setValue("Perl", new Integer(votes[4]));
  return result;
}
 
Example #22
Source File: PiePlotTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
@Test
public void testBug1126() throws CloneNotSupportedException {
    DefaultPieDataset dataset1 = new DefaultPieDataset();
    PiePlot plot1 = new PiePlot(dataset1);
    plot1.setSectionPaint("A", Color.RED);
    plot1.setSectionPaint("B", Color.GREEN);
    PiePlot plot2 = (PiePlot) plot1.clone();
    plot2.setSectionPaint("A", Color.BLUE);
    plot2.setSectionPaint("B", Color.YELLOW);
    assertEquals(Color.RED, plot1.getSectionPaint("A"));
    assertEquals(Color.GREEN, plot1.getSectionPaint("B"));
    assertEquals(Color.BLUE, plot2.getSectionPaint("A"));
    assertEquals(Color.YELLOW, plot2.getSectionPaint("B"));
}
 
Example #23
Source File: JFreeChartTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Some checks for the getSubtitles() method.
 */
@Test
public void testGetSubtitles() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    JFreeChart chart = ChartFactory.createPieChart("title", dataset);
    List subtitles = chart.getSubtitles();

    assertEquals(1, chart.getSubtitleCount());

    // adding something to the returned list should NOT change the chart
    subtitles.add(new TextTitle("T"));
    assertEquals(1, chart.getSubtitleCount());
}
 
Example #24
Source File: JFreeChartTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Some checks for the default legend firing change events.
 */
@Test
public void testLegendEvents() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    JFreeChart chart = ChartFactory.createPieChart("title", dataset);
    chart.addChangeListener(this);
    this.lastChartChangeEvent = null;
    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.TOP);
    assertNotNull(this.lastChartChangeEvent);
}
 
Example #25
Source File: JFreeChartTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for title changes and event notification.
 */
@Test
public void testTitleChangeEvent() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    JFreeChart chart = ChartFactory.createPieChart("title", dataset);
    chart.addChangeListener(this);
    this.lastChartChangeEvent = null;
    TextTitle t = chart.getTitle();
    t.setFont(new Font("Dialog", Font.BOLD, 9));
    assertNotNull(this.lastChartChangeEvent);
    this.lastChartChangeEvent = null;

    // now create a new title and replace the existing title, several
    // things should happen:
    // (1) Adding the new title should trigger an immediate
    //     ChartChangeEvent;
    // (2) Modifying the new title should trigger a ChartChangeEvent;
    // (3) Modifying the old title should NOT trigger a ChartChangeEvent
    TextTitle t2 = new TextTitle("T2");
    chart.setTitle(t2);
    assertNotNull(this.lastChartChangeEvent);
    this.lastChartChangeEvent = null;

    t2.setFont(new Font("Dialog", Font.BOLD, 9));
    assertNotNull(this.lastChartChangeEvent);
    this.lastChartChangeEvent = null;

    t.setFont(new Font("Dialog", Font.BOLD, 9));
    assertNull(this.lastChartChangeEvent);
    this.lastChartChangeEvent = null;
}
 
Example #26
Source File: JFreeChartTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Serialize a pie chart, restore it, and check for equality.
 */
@Test
public void testSerialization1() {
    DefaultPieDataset data = new DefaultPieDataset();
    data.setValue("Type 1", 54.5);
    data.setValue("Type 2", 23.9);
    data.setValue("Type 3", 45.8);

    JFreeChart c1 = ChartFactory.createPieChart("Test", data);
    JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1);
    assertEquals(c1, c2);
    LegendTitle lt2 = c2.getLegend();
    assertSame(lt2.getSources()[0], c2.getPlot());
}
 
Example #27
Source File: PiePlotTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testBug1126() throws CloneNotSupportedException {
    DefaultPieDataset dataset1 = new DefaultPieDataset();
    PiePlot plot1 = new PiePlot(dataset1);
    plot1.setSectionPaint("A", Color.RED);
    plot1.setSectionPaint("B", Color.GREEN);
    PiePlot plot2 = (PiePlot) plot1.clone();
    plot2.setSectionPaint("A", Color.BLUE);
    plot2.setSectionPaint("B", Color.YELLOW);
    assertEquals(Color.RED, plot1.getSectionPaint("A"));
    assertEquals(Color.GREEN, plot1.getSectionPaint("B"));
    assertEquals(Color.BLUE, plot2.getSectionPaint("A"));
    assertEquals(Color.YELLOW, plot2.getSectionPaint("B"));
}
 
Example #28
Source File: PiePlotTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testBug1126_b() throws CloneNotSupportedException {
    DefaultPieDataset dataset1 = new DefaultPieDataset();
    PiePlot plot1 = new PiePlot(dataset1);
    plot1.setSectionOutlinePaint("A", Color.RED);
    plot1.setSectionOutlinePaint("B", Color.GREEN);
    PiePlot plot2 = (PiePlot) plot1.clone();
    plot2.setSectionOutlinePaint("A", Color.BLUE);
    plot2.setSectionOutlinePaint("B", Color.YELLOW);
    assertEquals(Color.RED, plot1.getSectionOutlinePaint("A"));
    assertEquals(Color.GREEN, plot1.getSectionOutlinePaint("B"));
    assertEquals(Color.BLUE, plot2.getSectionOutlinePaint("A"));
    assertEquals(Color.YELLOW, plot2.getSectionOutlinePaint("B"));
}
 
Example #29
Source File: PieChart3DTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Tests that no exceptions are thrown when there is a <code>null</code>
 * value in the dataset.
 */
@Test
public void testNullValueInDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("Section 1", 10.0);
    dataset.setValue("Section 2", 11.0);
    dataset.setValue("Section 3", null);
    JFreeChart chart = createPieChart3D(dataset);
    BufferedImage image = new BufferedImage(200 , 100,
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = image.createGraphics();
    chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
    g2.dispose();
    //FIXME we should really assert a value here
}
 
Example #30
Source File: PieChart3DTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Common test setup.
 */
@Before
public void setUp() {
    // create a dataset...
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("Java", new Double(43.2));
    dataset.setValue("Visual Basic", new Double(0.0));
    dataset.setValue("C/C++", new Double(17.5));
    this.pieChart = createPieChart3D(dataset);
}