⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boxandwhiskerrenderertests.java

📁 JFreeChart它主要是用来制作各种各样的图表
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                new NumberAxis("y"), new BoxAndWhiskerRenderer());        plot.setOrientation(PlotOrientation.HORIZONTAL);        JFreeChart chart = new JFreeChart(plot);        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,                    new ChartRenderingInfo());            g2.dispose();            success = true;        }        catch (Exception e) {            success = false;        }        assertTrue(success);    }    /**     * Some checks for the getLegendItem() method.     */    public void testGetLegendItem() {        DefaultBoxAndWhiskerCategoryDataset dataset                = new DefaultBoxAndWhiskerCategoryDataset();        List values = new ArrayList();        values.add(new Double(1.10));        values.add(new Double(1.45));        values.add(new Double(1.33));        values.add(new Double(1.23));        dataset.add(values, "R1", "C1");        BoxAndWhiskerRenderer r = new BoxAndWhiskerRenderer();        CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"),                new NumberAxis("y"), r);        /*JFreeChart chart =*/ new JFreeChart(plot);        LegendItem li = r.getLegendItem(0, 0);        assertNotNull(li);        r.setSeriesVisibleInLegend(0, Boolean.FALSE);        li = r.getLegendItem(0, 0);        assertNull(li);    }    /**     * A check for the datasetIndex and seriesIndex fields in the LegendItem     * returned by the getLegendItem() method.     */    public void testGetLegendItemSeriesIndex() {        DefaultCategoryDataset dataset0 = new DefaultCategoryDataset();        dataset0.addValue(21.0, "R1", "C1");        dataset0.addValue(22.0, "R2", "C1");        DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();        dataset1.addValue(23.0, "R3", "C1");        dataset1.addValue(24.0, "R4", "C1");        dataset1.addValue(25.0, "R5", "C1");        BoxAndWhiskerRenderer r = new BoxAndWhiskerRenderer();        CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"),                new NumberAxis("y"), r);        plot.setDataset(1, dataset1);        /*JFreeChart chart =*/ new JFreeChart(plot);        LegendItem li = r.getLegendItem(1, 2);        assertEquals("R5", li.getLabel());        assertEquals(1, li.getDatasetIndex());        assertEquals(2, li.getSeriesIndex());    }    /**     * Draws a chart where the dataset contains a null mean value.     */    public void testDrawWithNullMean() {        boolean success = false;        try {            DefaultBoxAndWhiskerCategoryDataset dataset                    = new DefaultBoxAndWhiskerCategoryDataset();            dataset.add(new BoxAndWhiskerItem(null, new Double(2.0),                    new Double(0.0), new Double(4.0), new Double(0.5),                    new Double(4.5), new Double(-0.5), new Double(5.5),                    null), "S1", "C1");            CategoryPlot plot = new CategoryPlot(dataset,                    new CategoryAxis("Category"), new NumberAxis("Value"),                    new BoxAndWhiskerRenderer());            ChartRenderingInfo info = new ChartRenderingInfo();            JFreeChart chart = new JFreeChart(plot);            /* BufferedImage image = */ chart.createBufferedImage(300, 200,                    info);            success = true;        }        catch (Exception e) {            success = false;        }        assertTrue(success);    }    /**     * Draws a chart where the dataset contains a null median value.     */    public void testDrawWithNullMedian() {        boolean success = false;        try {            DefaultBoxAndWhiskerCategoryDataset dataset                    = new DefaultBoxAndWhiskerCategoryDataset();            dataset.add(new BoxAndWhiskerItem(new Double(1.0), null,                    new Double(0.0), new Double(4.0), new Double(0.5),                    new Double(4.5), new Double(-0.5), new Double(5.5),                    null), "S1", "C1");            CategoryPlot plot = new CategoryPlot(dataset,                    new CategoryAxis("Category"), new NumberAxis("Value"),                    new BoxAndWhiskerRenderer());            ChartRenderingInfo info = new ChartRenderingInfo();            JFreeChart chart = new JFreeChart(plot);            /* BufferedImage image = */ chart.createBufferedImage(300, 200,                    info);            success = true;        }        catch (Exception e) {            success = false;        }        assertTrue(success);    }    /**     * Draws a chart where the dataset contains a null Q1 value.     */    public void testDrawWithNullQ1() {        boolean success = false;        try {            DefaultBoxAndWhiskerCategoryDataset dataset                    = new DefaultBoxAndWhiskerCategoryDataset();            dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0),                    null, new Double(4.0), new Double(0.5),                    new Double(4.5), new Double(-0.5), new Double(5.5),                    null), "S1", "C1");            CategoryPlot plot = new CategoryPlot(dataset,                    new CategoryAxis("Category"), new NumberAxis("Value"),                    new BoxAndWhiskerRenderer());            ChartRenderingInfo info = new ChartRenderingInfo();            JFreeChart chart = new JFreeChart(plot);            /* BufferedImage image = */ chart.createBufferedImage(300, 200,                    info);            success = true;        }        catch (Exception e) {            success = false;        }        assertTrue(success);    }    /**     * Draws a chart where the dataset contains a null Q3 value.     */    public void testDrawWithNullQ3() {        boolean success = false;        try {            DefaultBoxAndWhiskerCategoryDataset dataset                    = new DefaultBoxAndWhiskerCategoryDataset();            dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0),                    new Double(3.0), null, new Double(0.5),                    new Double(4.5), new Double(-0.5), new Double(5.5),                    null), "S1", "C1");            CategoryPlot plot = new CategoryPlot(dataset,                    new CategoryAxis("Category"), new NumberAxis("Value"),                    new BoxAndWhiskerRenderer());            ChartRenderingInfo info = new ChartRenderingInfo();            JFreeChart chart = new JFreeChart(plot);            /* BufferedImage image = */ chart.createBufferedImage(300, 200,                    info);            success = true;        }        catch (Exception e) {            success = false;        }        assertTrue(success);    }    /**     * Draws a chart where the dataset contains a null min regular value.     */    public void testDrawWithNullMinRegular() {        boolean success = false;        try {            DefaultBoxAndWhiskerCategoryDataset dataset                    = new DefaultBoxAndWhiskerCategoryDataset();            dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0),                    new Double(3.0), new Double(4.0), null,                    new Double(4.5), new Double(-0.5), new Double(5.5),                    null), "S1", "C1");            CategoryPlot plot = new CategoryPlot(dataset,                    new CategoryAxis("Category"), new NumberAxis("Value"),                    new BoxAndWhiskerRenderer());            ChartRenderingInfo info = new ChartRenderingInfo();            JFreeChart chart = new JFreeChart(plot);            /* BufferedImage image = */ chart.createBufferedImage(300, 200,                    info);            success = true;        }        catch (Exception e) {            success = false;        }        assertTrue(success);    }    /**     * Draws a chart where the dataset contains a null max regular value.     */    public void testDrawWithNullMaxRegular() {        boolean success = false;        try {            DefaultBoxAndWhiskerCategoryDataset dataset                    = new DefaultBoxAndWhiskerCategoryDataset();            dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0),                    new Double(3.0), new Double(4.0), new Double(0.5),                    null, new Double(-0.5), new Double(5.5),                    null), "S1", "C1");            CategoryPlot plot = new CategoryPlot(dataset,                    new CategoryAxis("Category"), new NumberAxis("Value"),                    new BoxAndWhiskerRenderer());            ChartRenderingInfo info = new ChartRenderingInfo();            JFreeChart chart = new JFreeChart(plot);            /* BufferedImage image = */ chart.createBufferedImage(300, 200,                    info);            success = true;        }        catch (Exception e) {            success = false;        }        assertTrue(success);    }    /**     * Draws a chart where the dataset contains a null min outlier value.     */    public void testDrawWithNullMinOutlier() {        boolean success = false;        try {            DefaultBoxAndWhiskerCategoryDataset dataset                    = new DefaultBoxAndWhiskerCategoryDataset();            dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0),                    new Double(3.0), new Double(4.0), new Double(0.5),                    new Double(4.5), null, new Double(5.5),                    null), "S1", "C1");            CategoryPlot plot = new CategoryPlot(dataset,                    new CategoryAxis("Category"), new NumberAxis("Value"),                    new BoxAndWhiskerRenderer());            ChartRenderingInfo info = new ChartRenderingInfo();            JFreeChart chart = new JFreeChart(plot);            /* BufferedImage image = */ chart.createBufferedImage(300, 200,                    info);            success = true;        }        catch (Exception e) {            success = false;        }        assertTrue(success);    }    /**     * Draws a chart where the dataset contains a null max outlier value.     */    public void testDrawWithNullMaxOutlier() {        boolean success = false;        try {            DefaultBoxAndWhiskerCategoryDataset dataset                    = new DefaultBoxAndWhiskerCategoryDataset();            dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0),                    new Double(3.0), new Double(4.0), new Double(0.5),                    new Double(4.5), new Double(-0.5), null,                    new java.util.ArrayList()), "S1", "C1");            CategoryPlot plot = new CategoryPlot(dataset,                    new CategoryAxis("Category"), new NumberAxis("Value"),                    new BoxAndWhiskerRenderer());            ChartRenderingInfo info = new ChartRenderingInfo();            JFreeChart chart = new JFreeChart(plot);            /* BufferedImage image = */ chart.createBufferedImage(300, 200,                    info);            success = true;        }        catch (Exception e) {            success = false;        }        assertTrue(success);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -