Search in sources :

Example 1 with GanttCategoryDataset

use of org.jfree.data.gantt.GanttCategoryDataset in project tdq-studio-se by Talend.

the class HideSeriesGanttRenderer method drawItem.

/**
 * Draws the bar for a single (series, category) data item.
 *
 * @param g2 the graphics device.
 * @param state the renderer state.
 * @param dataArea the data area.
 * @param plot the plot.
 * @param domainAxis the domain axis.
 * @param rangeAxis the range axis.
 * @param dataset the dataset.
 * @param row the row index (zero-based).
 * @param column the column index (zero-based).
 * @param pass the pass index.
 */
@Override
public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) {
    if (dataset instanceof GanttCategoryDataset) {
        GanttCategoryDataset gcd = (GanttCategoryDataset) dataset;
        drawTasks(g2, state, dataArea, plot, domainAxis, rangeAxis, gcd, row, column);
    } else {
        // let the superclass handle it...
        super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass);
    }
}
Also used : GanttCategoryDataset(org.jfree.data.gantt.GanttCategoryDataset)

Example 2 with GanttCategoryDataset

use of org.jfree.data.gantt.GanttCategoryDataset in project watchdog by TestRoots.

the class EventStatistics method createDebugEventGanttChartDataset.

/**
 * Creates a dataset of all events that occurred during the selected debug
 * interval.
 */
public GanttCategoryDataset createDebugEventGanttChartDataset() {
    // Create and add the tasks for each event type.
    TaskSeries allTasks = new TaskSeries("Debug Events");
    for (TrackingEventType type : TrackingEventType.values()) {
        final List<EventBase> filteredEventList = events.stream().filter(e -> e.getType() == type).collect(Collectors.toList());
        allTasks.add(createTaskForEventsWithName(filteredEventList, type.getTextualDescription()));
    }
    // Create collection of the overall tasks.
    TaskSeriesCollection collection = new TaskSeriesCollection();
    collection.add(allTasks);
    return collection;
}
Also used : TrackingEventType(nl.tudelft.watchdog.core.logic.event.eventtypes.TrackingEventType) WatchDogItem(nl.tudelft.watchdog.core.logic.storage.WatchDogItem) Date(java.util.Date) TrackingEventType(nl.tudelft.watchdog.core.logic.event.eventtypes.TrackingEventType) PersisterBase(nl.tudelft.watchdog.core.logic.storage.PersisterBase) Collectors(java.util.stream.Collectors) TaskSeriesCollection(org.jfree.data.gantt.TaskSeriesCollection) ArrayList(java.util.ArrayList) Task(org.jfree.data.gantt.Task) List(java.util.List) Calendar(java.util.Calendar) GanttCategoryDataset(org.jfree.data.gantt.GanttCategoryDataset) TaskSeries(org.jfree.data.gantt.TaskSeries) DebugInterval(nl.tudelft.watchdog.core.logic.interval.intervaltypes.DebugInterval) Collections(java.util.Collections) EventBase(nl.tudelft.watchdog.core.logic.event.eventtypes.EventBase) EventBase(nl.tudelft.watchdog.core.logic.event.eventtypes.EventBase) TaskSeriesCollection(org.jfree.data.gantt.TaskSeriesCollection) TaskSeries(org.jfree.data.gantt.TaskSeries)

Example 3 with GanttCategoryDataset

use of org.jfree.data.gantt.GanttCategoryDataset in project watchdog by TestRoots.

the class WatchDogView method createDebugEventGanttChart.

private JFreeChart createDebugEventGanttChart() {
    eventStatistics = new EventStatistics(InitializationManager.getInstance().getTrackingEventManager(), selectedDebugInterval);
    GanttCategoryDataset dataset = eventStatistics.createDebugEventGanttChartDataset();
    JFreeChart chart = ChartFactory.createGanttChart("Debug Events During Selected Debug Interval", "Event", "Time", dataset, false, true, false);
    // Scale the chart based on the selected debug interval.
    CategoryPlot plot = chart.getCategoryPlot();
    ValueAxis axis = plot.getRangeAxis();
    axis.setRangeWithMargins(selectedDebugInterval.getStart().getTime() - EventStatistics.PRE_SESSION_TIME_TO_INCLUDE, selectedDebugInterval.getEnd().getTime());
    // Give each event type a different color.
    plot.setRenderer(new WatchDogGanttRenderer());
    return chart;
}
Also used : ValueAxis(org.jfree.chart.axis.ValueAxis) EventStatistics(nl.tudelft.watchdog.core.logic.event.EventStatistics) GanttCategoryDataset(org.jfree.data.gantt.GanttCategoryDataset) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Example 4 with GanttCategoryDataset

use of org.jfree.data.gantt.GanttCategoryDataset in project watchdog by TestRoots.

the class WatchDogView method createDebugEventGanttChart.

private JFreeChart createDebugEventGanttChart() {
    eventStatistics = new EventStatistics(InitializationManager.getInstance(WatchDogUtils.getProject()).getTrackingEventManager(), selectedDebugInterval);
    GanttCategoryDataset dataset = eventStatistics.createDebugEventGanttChartDataset();
    JFreeChart chart = ChartFactory.createGanttChart("Debug Events During Selected Debug Interval", "Event", "Time", dataset, false, true, false);
    // Scale the chart based on the selected debug interval.
    CategoryPlot plot = chart.getCategoryPlot();
    ValueAxis axis = plot.getRangeAxis();
    axis.setRangeWithMargins(selectedDebugInterval.getStart().getTime() - EventStatistics.PRE_SESSION_TIME_TO_INCLUDE, selectedDebugInterval.getEnd().getTime());
    // Give each event type a different color.
    plot.setRenderer(new WatchDogGanttRenderer());
    return chart;
}
Also used : ValueAxis(org.jfree.chart.axis.ValueAxis) EventStatistics(nl.tudelft.watchdog.core.logic.event.EventStatistics) GanttCategoryDataset(org.jfree.data.gantt.GanttCategoryDataset) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Aggregations

GanttCategoryDataset (org.jfree.data.gantt.GanttCategoryDataset)4 EventStatistics (nl.tudelft.watchdog.core.logic.event.EventStatistics)2 JFreeChart (org.jfree.chart.JFreeChart)2 ValueAxis (org.jfree.chart.axis.ValueAxis)2 CategoryPlot (org.jfree.chart.plot.CategoryPlot)2 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Collections (java.util.Collections)1 Date (java.util.Date)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 EventBase (nl.tudelft.watchdog.core.logic.event.eventtypes.EventBase)1 TrackingEventType (nl.tudelft.watchdog.core.logic.event.eventtypes.TrackingEventType)1 DebugInterval (nl.tudelft.watchdog.core.logic.interval.intervaltypes.DebugInterval)1 PersisterBase (nl.tudelft.watchdog.core.logic.storage.PersisterBase)1 WatchDogItem (nl.tudelft.watchdog.core.logic.storage.WatchDogItem)1 Task (org.jfree.data.gantt.Task)1 TaskSeries (org.jfree.data.gantt.TaskSeries)1 TaskSeriesCollection (org.jfree.data.gantt.TaskSeriesCollection)1