List of usage examples for org.jfree.data.category DefaultIntervalCategoryDataset DefaultIntervalCategoryDataset
public DefaultIntervalCategoryDataset(Number[][] starts, Number[][] ends)
From source file:org.jfree.chart.demo.IntervalBarChartDemo1.java
/** * Creates a new demo.//from w w w. j a v a2 s . co m */ public IntervalBarChartDemo1() { DefaultIntervalCategoryDataset data = null; final double[][] lows = { { -.0315, .0159, .0306, .0453, .0557 } }; final double[][] highs = { { .1931, .1457, .1310, .1163, .1059 } }; data = new DefaultIntervalCategoryDataset(lows, highs); data.setCategoryKeys(CATEGORIES); final String title = "Strategie Sicherheit"; final String xTitle = "Zeitraum (in Jahren)"; final String yTitle = "Performance"; final CategoryAxis xAxis = new CategoryAxis(xTitle); xAxis.setLabelFont(titleFont); xAxis.setTickLabelFont(labelFont); xAxis.setTickMarksVisible(false); final NumberAxis yAxis = new NumberAxis(yTitle); yAxis.setLabelFont(titleFont); yAxis.setTickLabelFont(labelFont); yAxis.setRange(-0.2, 0.40); final DecimalFormat formatter = new DecimalFormat("0.##%"); yAxis.setTickUnit(new NumberTickUnit(0.05, formatter)); final IntervalBarRenderer renderer = new IntervalBarRenderer(); renderer.setSeriesPaint(0, new Color(51, 102, 153)); // renderer.setLabelGenerator(new IntervalCategoryLabelGenerator()); renderer.setItemLabelsVisible(true); renderer.setItemLabelPaint(Color.white); final ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER); renderer.setPositiveItemLabelPosition(p); final CategoryPlot plot = new CategoryPlot(data, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setOutlinePaint(Color.white); plot.setOrientation(PlotOrientation.VERTICAL); this.chart = new JFreeChart(title, titleFont, plot, false); this.chart.setBackgroundPaint(Color.white); }
From source file:org.jfree.data.category.DefaultIntervalCategoryDatasetTest.java
/** * Some tests for the getRowCount() method. *//*w ww. j av a2s. c om*/ @Test public void testGetRowAndColumnCount() { double[] starts_S1 = new double[] { 0.1, 0.2, 0.3 }; double[] starts_S2 = new double[] { 0.3, 0.4, 0.5 }; double[] ends_S1 = new double[] { 0.5, 0.6, 0.7 }; double[] ends_S2 = new double[] { 0.7, 0.8, 0.9 }; double[][] starts = new double[][] { starts_S1, starts_S2 }; double[][] ends = new double[][] { ends_S1, ends_S2 }; DefaultIntervalCategoryDataset d = new DefaultIntervalCategoryDataset(starts, ends); assertEquals(2, d.getRowCount()); assertEquals(3, d.getColumnCount()); }
From source file:org.jfree.data.category.DefaultIntervalCategoryDatasetTest.java
/** * Confirm that the equals method can distinguish all the required fields. *//* www . ja va 2s .com*/ @Test public void testEquals() { double[] starts_S1A = new double[] { 0.1, 0.2, 0.3 }; double[] starts_S2A = new double[] { 0.3, 0.4, 0.5 }; double[] ends_S1A = new double[] { 0.5, 0.6, 0.7 }; double[] ends_S2A = new double[] { 0.7, 0.8, 0.9 }; double[][] startsA = new double[][] { starts_S1A, starts_S2A }; double[][] endsA = new double[][] { ends_S1A, ends_S2A }; DefaultIntervalCategoryDataset dA = new DefaultIntervalCategoryDataset(startsA, endsA); double[] starts_S1B = new double[] { 0.1, 0.2, 0.3 }; double[] starts_S2B = new double[] { 0.3, 0.4, 0.5 }; double[] ends_S1B = new double[] { 0.5, 0.6, 0.7 }; double[] ends_S2B = new double[] { 0.7, 0.8, 0.9 }; double[][] startsB = new double[][] { starts_S1B, starts_S2B }; double[][] endsB = new double[][] { ends_S1B, ends_S2B }; DefaultIntervalCategoryDataset dB = new DefaultIntervalCategoryDataset(startsB, endsB); assertTrue(dA.equals(dB)); assertTrue(dB.equals(dA)); // check that two empty datasets are equal DefaultIntervalCategoryDataset empty1 = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); DefaultIntervalCategoryDataset empty2 = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); assertTrue(empty1.equals(empty2)); }
From source file:org.jfree.data.category.DefaultIntervalCategoryDatasetTest.java
/** * Serialize an instance, restore it, and check for equality. *//* w w w .java 2 s . c o m*/ @Test public void testSerialization() { double[] starts_S1 = new double[] { 0.1, 0.2, 0.3 }; double[] starts_S2 = new double[] { 0.3, 0.4, 0.5 }; double[] ends_S1 = new double[] { 0.5, 0.6, 0.7 }; double[] ends_S2 = new double[] { 0.7, 0.8, 0.9 }; double[][] starts = new double[][] { starts_S1, starts_S2 }; double[][] ends = new double[][] { ends_S1, ends_S2 }; DefaultIntervalCategoryDataset d1 = new DefaultIntervalCategoryDataset(starts, ends); DefaultIntervalCategoryDataset d2 = (DefaultIntervalCategoryDataset) TestUtilities.serialised(d1); assertEquals(d1, d2); }
From source file:org.jfree.data.category.DefaultIntervalCategoryDatasetTest.java
/** * A check to ensure that an empty dataset can be cloned. *///from w ww . j ava 2 s. c om @Test public void testCloning2() throws CloneNotSupportedException { DefaultIntervalCategoryDataset d1 = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); DefaultIntervalCategoryDataset d2 = null; d2 = (DefaultIntervalCategoryDataset) d1.clone(); assertTrue(d1 != d2); assertTrue(d1.getClass() == d2.getClass()); assertTrue(d1.equals(d2)); }
From source file:org.jfree.data.category.DefaultIntervalCategoryDatasetTest.java
/** * Some checks for the getSeriesCount() method. *//*from w ww . ja v a 2 s . c o m*/ @Test public void testGetSeriesCount() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); assertEquals(0, empty.getSeriesCount()); }
From source file:org.jfree.data.category.DefaultIntervalCategoryDatasetTest.java
/** * Some checks for the getCategoryCount() method. *///w ww.j a v a 2 s. co m @Test public void testGetCategoryCount() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); assertEquals(0, empty.getCategoryCount()); }
From source file:org.jfree.data.category.DefaultIntervalCategoryDatasetTest.java
/** * Some checks for the getSeriesIndex() method. *//*from w ww . jav a 2 s . co m*/ @Test public void testGetSeriesIndex() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); assertEquals(-1, empty.getSeriesIndex("ABC")); }
From source file:org.jfree.data.category.DefaultIntervalCategoryDatasetTest.java
/** * Some checks for the getRowIndex() method. *///from w ww. j a v a 2s . co m @Test public void testGetRowIndex() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); assertEquals(-1, empty.getRowIndex("ABC")); }
From source file:org.jfree.data.category.DefaultIntervalCategoryDatasetTest.java
/** * Some checks for the setSeriesKeys() method. */// w ww . j a va 2 s.c om @Test public void testSetSeriesKeys() { // check an empty dataset DefaultIntervalCategoryDataset empty = new DefaultIntervalCategoryDataset(new double[0][0], new double[0][0]); boolean pass = true; try { empty.setSeriesKeys(new String[0]); } catch (RuntimeException e) { pass = false; } assertTrue(pass); }