Beispiel #1
0
  /** 複数円チャート用のサブチャートを取得する */
  private JFreeChart getSubPieChart() {

    MultiplePiePlot multiplePiePlot = (MultiplePiePlot) this.getPlot();

    // サブチャートの生成
    JFreeChart subChart = multiplePiePlot.getPieChart();

    return subChart;
  }
Beispiel #2
0
  /**
   * Creates a sample chart with the given dataset.
   *
   * @param dataset the dataset.
   * @return A sample chart.
   */
  private JFreeChart createChart(final CategoryDataset dataset) {
    final JFreeChart chart =
        ChartFactory.createMultiplePieChart(
            "Multiple Pie Chart", // chart title
            dataset, // dataset
            TableOrder.BY_ROW,
            true, // include legend
            true,
            true);
    final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot();
    final JFreeChart subchart = plot.getPieChart();
    final PiePlot p = (PiePlot) subchart.getPlot();
    p.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}"));
    p.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
    p.setInteriorGap(0.30);

    return chart;
  }
  /** Serialize an instance, restore it, and check for equality. */
  public void testSerialization() {
    MultiplePiePlot p1 = new MultiplePiePlot(null);
    p1.setAggregatedItemsPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.red));
    MultiplePiePlot p2 = null;
    try {
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      ObjectOutput out = new ObjectOutputStream(buffer);
      out.writeObject(p1);
      out.close();

      ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
      p2 = (MultiplePiePlot) in.readObject();
      in.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
    assertEquals(p1, p2);
  }
Beispiel #4
0
  /**
   * Creates a sample dataset for the demo.
   *
   * @return A sample dataset.
   */
  public static JFreeChart create3DPieChart(
      String title,
      java.awt.Font titleFont,
      CategoryDataset data,
      TableOrder order,
      boolean legend,
      boolean tooltips,
      boolean urls,
      PieURLGenerator urlGenerator) {

    MultiplePiePlot plot = new MultiplePiePlot(data);
    plot.setDataExtractOrder(order);

    // plot.setOutlineStroke(null);

    JFreeChart pieChart = new JFreeChart(new PiePlot3D(null));
    pieChart.setBackgroundPaint(null);
    plot.setPieChart(pieChart);

    PiePlot3D pp = (PiePlot3D) plot.getPieChart().getPlot();
    pp.setBackgroundPaint(null);
    // pp.setInsets(new Insets(0, 5, 5, 5));

    // no outline around each piechart
    pp.setOutlineStroke(null);

    PieToolTipGenerator tooltipGenerator = null;
    if (tooltips) {
      tooltipGenerator = new StandardPieToolTipGenerator();
    }

    if (!urls) {
      urlGenerator = null;
    }

    pp.setToolTipGenerator(tooltipGenerator);
    pp.setLabelGenerator(null);
    pp.setURLGenerator(urlGenerator);
    JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

    return chart;
  }
 /** Some basic checks for the clone() method. */
 public void testCloning() {
   MultiplePiePlot p1 = new MultiplePiePlot();
   MultiplePiePlot p2 = null;
   try {
     p2 = (MultiplePiePlot) p1.clone();
   } catch (CloneNotSupportedException e) {
     e.printStackTrace();
     System.err.println("Failed to clone.");
   }
   assertTrue(p1 != p2);
   assertTrue(p1.getClass() == p2.getClass());
   assertTrue(p1.equals(p2));
 }
  /** Check that the equals() method distinguishes the required fields. */
  public void testEquals() {
    MultiplePiePlot p1 = new MultiplePiePlot();
    MultiplePiePlot p2 = new MultiplePiePlot();
    assertTrue(p1.equals(p2));
    assertTrue(p2.equals(p1));

    p1.setDataExtractOrder(TableOrder.BY_ROW);
    assertFalse(p1.equals(p2));
    p2.setDataExtractOrder(TableOrder.BY_ROW);
    assertTrue(p1.equals(p2));

    p1.setLimit(1.23);
    assertFalse(p1.equals(p2));
    p2.setLimit(1.23);
    assertTrue(p1.equals(p2));

    p1.setAggregatedItemsKey("Aggregated Items");
    assertFalse(p1.equals(p2));
    p2.setAggregatedItemsKey("Aggregated Items");
    assertTrue(p1.equals(p2));

    p1.setAggregatedItemsPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow));
    assertFalse(p1.equals(p2));
    p2.setAggregatedItemsPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow));
    assertTrue(p1.equals(p2));

    p1.setPieChart(ChartFactory.createPieChart("Title", null, true, true, true));
    assertFalse(p1.equals(p2));
    p2.setPieChart(ChartFactory.createPieChart("Title", null, true, true, true));
    assertTrue(p1.equals(p2));
  }