private static JFreeChart createChart() { final CategoryAxis domainAxis = new CategoryAxis(""); final NumberAxis rangeAxis = new NumberAxis(""); final IntervalBarRenderer renderer = new IntervalBarRenderer(); renderer.setBaseToolTipGenerator(new IntervalCategoryToolTipGenerator()); renderer.setBaseToolTipGenerator((dataset, row, column) -> { final IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; return icd.getRowKey(row) + ": " + (icd.getEndValue(row, column).doubleValue() - icd.getStartValue(row, column).doubleValue()); }); final CategoryPlot plot = new CategoryPlot(null, domainAxis, rangeAxis, renderer); final JFreeChart chart = new JFreeChart("Unternehmenswert", plot); plot.setDomainGridlinesVisible(true); plot.setRangePannable(true); ChartUtilities.applyCurrentTheme(chart); return chart; }
/** * Creates a Gantt chart using the supplied attributes plus default values * where required. The chart object returned by this method uses a * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis} * for the domain axis, a {@link DateAxis} as the range axis, and a * {@link GanttRenderer} as the renderer. * * @param title the chart title (<code>null</code> permitted). * @param categoryAxisLabel the label for the category axis * (<code>null</code> permitted). * @param dateAxisLabel the label for the date axis * (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A Gantt chart. */ public static JFreeChart createGanttChart(String title, String categoryAxisLabel, String dateAxisLabel, IntervalCategoryDataset dataset, boolean legend) { CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); DateAxis dateAxis = new DateAxis(dateAxisLabel); CategoryItemRenderer renderer = new GanttRenderer(); renderer.setBaseToolTipGenerator( new IntervalCategoryToolTipGenerator( "{3} - {4}", DateFormat.getDateInstance())); CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
/** * Creates a Gantt chart using the supplied attributes plus default values where required. * <P> * The chart object returned by this method uses a {@link CategoryPlot} instance as the * plot, with a {@link CategoryAxis} for the domain axis, a {@link DateAxis} as the * range axis, and a {@link GanttRenderer} as the renderer. * * @param title the chart title (<code>null</code> permitted). * @param categoryAxisLabel the label for the category axis (<code>null</code> permitted). * @param dateAxisLabel the label for the date axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A Gantt chart. */ public static JFreeChart createGanttChart(String title, String categoryAxisLabel, String dateAxisLabel, IntervalCategoryDataset dataset, boolean legend, boolean tooltips, boolean urls) { CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); DateAxis dateAxis = new DateAxis(dateAxisLabel); CategoryItemRenderer renderer = new GanttRenderer(); if (tooltips) { renderer.setToolTipGenerator( new IntervalCategoryToolTipGenerator("{3} - {4}", DateFormat.getDateInstance()) ); } if (urls) { renderer.setItemURLGenerator(new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * Creates a Gantt chart using the supplied attributes plus default values * where required. The chart object returned by this method uses a * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis} * for the domain axis, a {@link DateAxis} as the range axis, and a * {@link GanttRenderer} as the renderer. * * @param title the chart title (<code>null</code> permitted). * @param categoryAxisLabel the label for the category axis * (<code>null</code> permitted). * @param dateAxisLabel the label for the date axis * (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A Gantt chart. */ public static JFreeChart createGanttChart(String title, String categoryAxisLabel, String dateAxisLabel, IntervalCategoryDataset dataset, boolean legend, boolean tooltips, boolean urls) { CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); DateAxis dateAxis = new DateAxis(dateAxisLabel); CategoryItemRenderer renderer = new GanttRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator( new IntervalCategoryToolTipGenerator( "{3} - {4}", DateFormat.getDateInstance())); } if (urls) { renderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * Creates a Gantt chart using the supplied attributes plus default values * where required. The chart object returned by this method uses a * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis} * for the domain axis, a {@link DateAxis} as the range axis, and a * {@link GanttRenderer} as the renderer. * * @param title the chart title (<code>null</code> permitted). * @param categoryAxisLabel the label for the category axis * (<code>null</code> permitted). * @param dateAxisLabel the label for the date axis * (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A Gantt chart. */ public static JFreeChart createGanttChart(String title, String categoryAxisLabel, String dateAxisLabel, IntervalCategoryDataset dataset, boolean legend, boolean tooltips, boolean urls) { CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); DateAxis dateAxis = new DateAxis(dateAxisLabel); CategoryItemRenderer renderer = new GanttRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator( new IntervalCategoryToolTipGenerator( "{3} - {4}", DateFormat.getDateInstance())); } if (urls) { renderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
/** * Creates a Gantt chart using the supplied attributes plus default values * where required. The chart object returned by this method uses a * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis} * for the domain axis, a {@link DateAxis} as the range axis, and a * {@link GanttRenderer} as the renderer. * * @param title the chart title ({@code null} permitted). * @param categoryAxisLabel the label for the category axis * ({@code null} permitted). * @param dateAxisLabel the label for the date axis * ({@code null} permitted). * @param dataset the dataset for the chart ({@code null} permitted). * @param legend a flag specifying whether or not a legend is required. * @param tooltips configure chart to generate tool tips? * @param urls configure chart to generate URLs? * * @return A Gantt chart. */ public static JFreeChart createGanttChart(String title, String categoryAxisLabel, String dateAxisLabel, IntervalCategoryDataset dataset, boolean legend, boolean tooltips, boolean urls) { CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); DateAxis dateAxis = new DateAxis(dateAxisLabel); CategoryItemRenderer renderer = new GanttRenderer(); if (tooltips) { renderer.setDefaultToolTipGenerator( new IntervalCategoryToolTipGenerator( "{3} - {4}", DateFormat.getDateInstance())); } if (urls) { renderer.setDefaultItemURLGenerator( new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
/** * Check that the subclass is not equal to an instance of the superclass. */ public void testEquals2() { IntervalCategoryToolTipGenerator g1 = new IntervalCategoryToolTipGenerator(); StandardCategoryToolTipGenerator g2 = new StandardCategoryToolTipGenerator( IntervalCategoryToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT_STRING, NumberFormat.getInstance()); assertFalse(g1.equals(g2)); }
/** * Simple check that hashCode is implemented. */ public void testHashCode() { IntervalCategoryToolTipGenerator g1 = new IntervalCategoryToolTipGenerator(); IntervalCategoryToolTipGenerator g2 = new IntervalCategoryToolTipGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); }
/** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { IntervalCategoryToolTipGenerator g1 = new IntervalCategoryToolTipGenerator(); assertTrue(g1 instanceof PublicCloneable); }