Example usage for org.jfree.data.category CategoryToPieDataset getKeys

List of usage examples for org.jfree.data.category CategoryToPieDataset getKeys

Introduction

In this page you can find the example usage for org.jfree.data.category CategoryToPieDataset getKeys.

Prototype

@Override
public List getKeys() 

Source Link

Document

Returns the keys for the dataset.

Usage

From source file:org.jfree.data.category.CategoryToPieDatasetTest.java

/**
 * Some tests for the constructor.//  w  w  w .j a va2  s  . c o m
 */
@Test
public void testConstructor() {
    // try a null source
    CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0);
    assertNull(p1.getUnderlyingDataset());
    assertEquals(p1.getItemCount(), 0);
    assertTrue(p1.getKeys().isEmpty());
    assertNull(p1.getValue("R1"));
}

From source file:org.jfree.data.category.junit.CategoryToPieDatasetTest.java

/**
 * Some tests for the constructor./*from w  w w .  j a va  2 s. c om*/
 */
public void testConstructor() {
    // try a null source
    CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0);
    assertNull(p1.getUnderlyingDataset());
    assertEquals(p1.getItemCount(), 0);
    assertTrue(p1.getKeys().isEmpty());
    assertNull(p1.getValue("R1"));
}

From source file:org.openfaces.component.chart.impl.plots.PiePlotAdapter.java

private void sectorProcessing(PiePlot plot, PieChartView chartView, PieDataset dataset,
        CategoryDataset categoryDataset) {
    List<PieSectorProperties> sectors = chartView.getSectors();
    if (sectors == null || sectors.size() == 0)
        return;//  ww  w  . j  a va2  s . co m

    for (PieSectorProperties sector : sectors) {
        DynamicPieGenerator generator = new DynamicPieGenerator(chartView, null);

        int index = -1;

        Float sectorPulled = sector.getPulled();
        if (dataset instanceof CategoryToPieDataset) {
            CategoryToPieDataset cds = (CategoryToPieDataset) dataset;
            int count = getIterationCount(cds);
            for (int q = 0; q < count; q++) {
                CategoryToPieDataset currPieDataset = new CategoryToPieDataset(categoryDataset, order, q);
                List keys = currPieDataset.getKeys();
                index = -1;
                for (int j = 0; j < keys.size(); j++) {
                    index++;

                    boolean conditionValue = generator.getConditionValue(sector, q, currPieDataset,
                            currPieDataset.getKey(j));
                    if (!conditionValue)
                        continue;

                    if (sectorPulled != null && sectorPulled > 0) {
                        plot.setExplodePercent(index, (double) sectorPulled);
                    }

                    StyleObjectModel cssSectorModel = sector.getStyleObjectModel();
                    if (cssSectorModel != null && cssSectorModel.getBorder() != null) {
                        StyleBorderModel border = cssSectorModel.getBorder();
                        Color borderColor = border.getColor();
                        if (borderColor != null) {
                            plot.setSectionOutlinePaint(index, borderColor);
                            plot.setSectionOutlineStroke(index, PropertiesConverter.toStroke(border));
                        }

                        Color sectorModelColor = cssSectorModel.getColor();
                        if (sectorModelColor != null) {
                            plot.setSectionPaint(index, sectorModelColor);
                        }
                    }
                }
            }
        } else {
            if (dataset == null || dataset.getKeys() == null)
                continue;

            for (int j = 0; j < dataset.getKeys().size(); j++) {
                index++;

                boolean conditionValue = generator.getConditionValue(sector, 0, dataset, dataset.getKey(j));
                if (!conditionValue)
                    continue;

                if (sectorPulled != null && sectorPulled > 0) {
                    plot.setExplodePercent(index, (double) sectorPulled);
                }

                StyleObjectModel cssSectorModel = sector.getStyleObjectModel();
                if (cssSectorModel != null && cssSectorModel.getBorder() != null) {
                    StyleBorderModel border = cssSectorModel.getBorder();
                    if (border.getColor() != null) {
                        plot.setSectionOutlinePaint(index, border.getColor());
                        plot.setSectionOutlineStroke(index, PropertiesConverter.toStroke(border));
                    }

                }
                if (cssSectorModel != null && cssSectorModel.getColor() != null) {
                    plot.setSectionPaint(index, cssSectorModel.getColor());
                }
            }
        }

    }

}

From source file:org.openfaces.component.chart.impl.plots.PiePlot3DAdapter.java

private void sectorProcessing(PiePlot plot, PieChartView chartView, PieDataset dataset,
        CategoryDataset categoryDataset) {
    java.util.List<PieSectorProperties> sectors = chartView.getSectors();
    if (sectors == null || sectors.size() == 0)
        return;/*  www .  j  av a2  s  .  co m*/

    for (PieSectorProperties sector : sectors) {
        DynamicPieGenerator generator = new DynamicPieGenerator(chartView, null);

        int index = -1;

        Float sectorPulled = sector.getPulled();
        if (dataset instanceof CategoryToPieDataset) {
            CategoryToPieDataset cds = (CategoryToPieDataset) dataset;
            int count = getIterationCount(cds);
            for (int q = 0; q < count; q++) {
                CategoryToPieDataset currPieDataset = new CategoryToPieDataset(categoryDataset, order, q);
                java.util.List keys = currPieDataset.getKeys();
                index = -1;
                for (int j = 0; j < keys.size(); j++) {
                    index++;

                    boolean conditionValue = generator.getConditionValue(sector, q, currPieDataset,
                            currPieDataset.getKey(j));
                    if (!conditionValue)
                        continue;

                    if (sectorPulled != null && sectorPulled > 0) {
                        plot.setExplodePercent(index, (double) sectorPulled);
                    }

                    StyleObjectModel cssSectorModel = sector.getStyleObjectModel();
                    if (cssSectorModel != null && cssSectorModel.getBorder() != null) {
                        StyleBorderModel border = cssSectorModel.getBorder();
                        Color borderColor = border.getColor();
                        if (borderColor != null) {
                            plot.setSectionOutlinePaint(index, borderColor);
                            plot.setSectionOutlineStroke(index, PropertiesConverter.toStroke(border));
                        }

                        Color sectorModelColor = cssSectorModel.getColor();
                        if (sectorModelColor != null) {
                            plot.setSectionPaint(index, sectorModelColor);
                        }
                    }
                }
            }
        } else {
            if (dataset == null || dataset.getKeys() == null)
                continue;

            for (int j = 0; j < dataset.getKeys().size(); j++) {
                index++;

                boolean conditionValue = generator.getConditionValue(sector, 0, dataset, dataset.getKey(j));
                if (!conditionValue)
                    continue;

                if (sectorPulled != null && sectorPulled > 0) {
                    plot.setExplodePercent(index, (double) sectorPulled);
                }

                StyleObjectModel cssSectorModel = sector.getStyleObjectModel();
                if (cssSectorModel != null && cssSectorModel.getBorder() != null) {
                    StyleBorderModel border = cssSectorModel.getBorder();
                    if (border.getColor() != null) {
                        plot.setSectionOutlinePaint(index, border.getColor());
                        plot.setSectionOutlineStroke(index, PropertiesConverter.toStroke(border));
                    }

                }
                if (cssSectorModel != null && cssSectorModel.getColor() != null) {
                    plot.setSectionPaint(index, cssSectorModel.getColor());
                }
            }
        }

    }

}