Package org.jfree.data.category

Examples of org.jfree.data.category.CategoryToPieDataset


     */
    public void testGetValue() {
        DefaultCategoryDataset underlying = new DefaultCategoryDataset();
        underlying.addValue(1.1, "R1", "C1");
        underlying.addValue(2.2, "R1", "C2");
        CategoryToPieDataset d1 = new CategoryToPieDataset(underlying,
                TableOrder.BY_ROW, 0);
        assertEquals(d1.getValue("C1"), new Double(1.1));
        assertEquals(d1.getValue("C2"), new Double(2.2));

        // check negative index throws exception
        try {
            /* Number n = */ d1.getValue(-1);
            fail("Expected IndexOutOfBoundsException.");
        }
        catch (IndexOutOfBoundsException e) {
            // this is expected
        }

        // check index == getItemCount() throws exception
        try {
            /* Number n = */ d1.getValue(d1.getItemCount());
            fail("Expected IndexOutOfBoundsException.");
        }
        catch (IndexOutOfBoundsException e) {
            // this is expected
        }

        // test null source
        CategoryToPieDataset p1 = new CategoryToPieDataset(null,
                TableOrder.BY_COLUMN, 0);
        try {
            /* Number n = */ p1.getValue(0);
            fail("Expected IndexOutOfBoundsException.");
        }
        catch (IndexOutOfBoundsException e) {
            // this is expected
        }
View Full Code Here


     */
    public void testGetKey() {
        DefaultCategoryDataset underlying = new DefaultCategoryDataset();
        underlying.addValue(1.1, "R1", "C1");
        underlying.addValue(2.2, "R1", "C2");
        CategoryToPieDataset d1 = new CategoryToPieDataset(underlying,
                TableOrder.BY_ROW, 0);
        assertEquals(d1.getKey(0), "C1");
        assertEquals(d1.getKey(1), "C2");

        // check negative index throws exception
        try {
            /* Number n = */ d1.getKey(-1);
            fail("Expected IndexOutOfBoundsException.");
        }
        catch (IndexOutOfBoundsException e) {
            // this is expected
        }

        // check index == getItemCount() throws exception
        try {
            /* Number n = */ d1.getKey(d1.getItemCount());
            fail("Expected IndexOutOfBoundsException.");
        }
        catch (IndexOutOfBoundsException e) {
            // this is expected
        }

        // test null source
        CategoryToPieDataset p1 = new CategoryToPieDataset(null,
                TableOrder.BY_COLUMN, 0);
        try {
            /* Number n = */ p1.getKey(0);
            fail("Expected IndexOutOfBoundsException.");
        }
        catch (IndexOutOfBoundsException e) {
            // this is expected
        }
View Full Code Here

     */
    public void testGetIndex() {
        DefaultCategoryDataset underlying = new DefaultCategoryDataset();
        underlying.addValue(1.1, "R1", "C1");
        underlying.addValue(2.2, "R1", "C2");
        CategoryToPieDataset d1 = new CategoryToPieDataset(underlying,
                TableOrder.BY_ROW, 0);
        assertEquals(0, d1.getIndex("C1"));
        assertEquals(1, d1.getIndex("C2"));
        assertEquals(-1, d1.getIndex("XX"));

        // try null
        boolean pass = false;
        try {
            d1.getIndex(null);
        }
        catch (IllegalArgumentException e) {
            pass = true;
        }
        assertTrue(pass);
View Full Code Here

     */
    public void testEquals() {
        DefaultCategoryDataset underlying = new DefaultCategoryDataset();
        underlying.addValue(1.1, "R1", "C1");
        underlying.addValue(2.2, "R1", "C2");
        CategoryToPieDataset d1 = new CategoryToPieDataset(underlying,
                TableOrder.BY_COLUMN, 1);
        DefaultPieDataset d2 = new DefaultPieDataset();
        d2.setValue("R1", 2.2);
        assertTrue(d1.equals(d2));
    }
View Full Code Here

     */
    public void testSerialization() {
        DefaultCategoryDataset underlying = new DefaultCategoryDataset();
        underlying.addValue(1.1, "R1", "C1");
        underlying.addValue(2.2, "R1", "C2");
        CategoryToPieDataset d1 = new CategoryToPieDataset(underlying,
                TableOrder.BY_COLUMN, 1);
        CategoryToPieDataset d2 = null;

        try {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            ObjectOutput out = new ObjectOutputStream(buffer);
            out.writeObject(d1);
            out.close();

            ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
                    buffer.toByteArray()));
            d2 = (CategoryToPieDataset) in.readObject();
            in.close();
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        assertEquals(d1, d2);

        // regular equality for the datasets doesn't check the fields, just
        // the data values...so let's check some more things...
        assertEquals(d1.getUnderlyingDataset(), d2.getUnderlyingDataset());
        assertEquals(d1.getExtractType(), d2.getExtractType());
        assertEquals(d1.getExtractIndex(), d2.getExtractIndex());
    }
View Full Code Here

    }

    PiePlot3DAdapter(PiePlot piePlot, CategoryDataset categoryDataset, TableOrder order, PieChartView chartView, Chart chart) {
        // todo: consider refactoring -- view the usage
        this.order = order;
        PieDataset dataset = new CategoryToPieDataset(categoryDataset, order, 0);
        init(piePlot, chart, chartView, dataset, categoryDataset);
    }
View Full Code Here

            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);
View Full Code Here

        init(this, chart, chartView, pieDataset, null);
    }

    PiePlotAdapter(PiePlot piePlot, CategoryDataset categoryDataset, TableOrder order, PieChartView chartView, Chart chart) { // todo: consider refactoring -- view the usage
        this.order = order;
        PieDataset dataset = new CategoryToPieDataset(categoryDataset, order, 0);
        init(piePlot, chart, chartView, dataset, categoryDataset);
    }
View Full Code Here

            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);
View Full Code Here

        TextTitle seriesTitle = getSeriesTitle(chart);
        getPieChart().setTitle(seriesTitle);

        PiePlot piePlot = (PiePlot) getPieChart().getPlot();
        piePlot.setDataset(new CategoryToPieDataset(ds, order, 0));
        setDataExtractOrder(order);

        if (view.isEnable3D()) {
            new PiePlot3DAdapter(piePlot, ds, order, view, chart);
        } else {
View Full Code Here

TOP

Related Classes of org.jfree.data.category.CategoryToPieDataset

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.