List of usage examples for org.jfree.data.gantt TaskSeriesCollection TaskSeriesCollection
public TaskSeriesCollection()
From source file:org.datacleaner.widgets.result.DateGapAnalyzerResultSwingRenderer.java
@Override public JComponent render(DateGapAnalyzerResult result) { final TaskSeriesCollection dataset = new TaskSeriesCollection(); final Set<String> groupNames = result.getGroupNames(); final TaskSeries completeDurationTaskSeries = new TaskSeries(LABEL_COMPLETE_DURATION); final TaskSeries gapsTaskSeries = new TaskSeries(LABEL_GAPS); final TaskSeries overlapsTaskSeries = new TaskSeries(LABEL_OVERLAPS); for (final String groupName : groupNames) { final String groupDisplayName; if (groupName == null) { if (groupNames.size() == 1) { groupDisplayName = "All"; } else { groupDisplayName = LabelUtils.NULL_LABEL; }/*ww w .j a v a 2 s. co m*/ } else { groupDisplayName = groupName; } final TimeInterval completeDuration = result.getCompleteDuration(groupName); final Task completeDurationTask = new Task(groupDisplayName, createTimePeriod(completeDuration.getFrom(), completeDuration.getTo())); completeDurationTaskSeries.add(completeDurationTask); // plot gaps { final SortedSet<TimeInterval> gaps = result.getGaps(groupName); int i = 1; Task rootTask = null; for (TimeInterval interval : gaps) { final TimePeriod timePeriod = createTimePeriod(interval.getFrom(), interval.getTo()); if (rootTask == null) { rootTask = new Task(groupDisplayName, timePeriod); gapsTaskSeries.add(rootTask); } else { Task task = new Task(groupDisplayName + " gap" + i, timePeriod); rootTask.addSubtask(task); } i++; } } // plot overlaps { final SortedSet<TimeInterval> overlaps = result.getOverlaps(groupName); int i = 1; Task rootTask = null; for (TimeInterval interval : overlaps) { final TimePeriod timePeriod = createTimePeriod(interval.getFrom(), interval.getTo()); if (rootTask == null) { rootTask = new Task(groupDisplayName, timePeriod); overlapsTaskSeries.add(rootTask); } else { Task task = new Task(groupDisplayName + " overlap" + i, timePeriod); rootTask.addSubtask(task); } i++; } } } dataset.add(overlapsTaskSeries); dataset.add(gapsTaskSeries); dataset.add(completeDurationTaskSeries); final SlidingGanttCategoryDataset slidingDataset = new SlidingGanttCategoryDataset(dataset, 0, GROUPS_VISIBLE); final JFreeChart chart = ChartFactory.createGanttChart( "Date gaps and overlaps in " + result.getFromColumnName() + " / " + result.getToColumnName(), result.getGroupColumnName(), "Time", slidingDataset, true, true, false); ChartUtils.applyStyles(chart); // make sure the 3 timeline types have correct coloring { final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDrawingSupplier(new DCDrawingSupplier(WidgetUtils.ADDITIONAL_COLOR_GREEN_BRIGHT, WidgetUtils.ADDITIONAL_COLOR_RED_BRIGHT, WidgetUtils.BG_COLOR_BLUE_BRIGHT)); } final int visibleLines = Math.min(GROUPS_VISIBLE, groupNames.size()); final ChartPanel chartPanel = ChartUtils.createPanel(chart, ChartUtils.WIDTH_WIDE, visibleLines * 50 + 200); chartPanel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseMoved(ChartMouseEvent event) { Cursor cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); ChartEntity entity = event.getEntity(); if (entity instanceof PlotEntity) { cursor = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR); } chartPanel.setCursor(cursor); } @Override public void chartMouseClicked(ChartMouseEvent event) { // do nothing } }); final JComponent decoratedChartPanel; final StringBuilder chartDescription = new StringBuilder("<html>"); chartDescription.append("<p>The chart displays the recorded timeline based on FROM and TO dates.</p>"); chartDescription.append( "<p>The <b>red items</b> represent gaps in the timeline and the <b>green items</b> represent points in the timeline where more than one record show activity.</p>"); chartDescription.append( "<p>You can <b>zoom in</b> by clicking and dragging the area that you want to examine in further detail.</p>"); if (groupNames.size() > GROUPS_VISIBLE) { final JScrollBar scroll = new JScrollBar(JScrollBar.VERTICAL); scroll.setMinimum(0); scroll.setMaximum(groupNames.size()); scroll.addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent e) { int value = e.getAdjustable().getValue(); slidingDataset.setFirstCategoryIndex(value); } }); chartPanel.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { int scrollType = e.getScrollType(); if (scrollType == MouseWheelEvent.WHEEL_UNIT_SCROLL) { int wheelRotation = e.getWheelRotation(); scroll.setValue(scroll.getValue() + wheelRotation); } } }); final DCPanel outerPanel = new DCPanel(); outerPanel.setLayout(new BorderLayout()); outerPanel.add(chartPanel, BorderLayout.CENTER); outerPanel.add(scroll, BorderLayout.EAST); chartDescription.append("<p>Use the right <b>scrollbar</b> to scroll up and down on the chart.</p>"); decoratedChartPanel = outerPanel; } else { decoratedChartPanel = chartPanel; } chartDescription.append("</html>"); final JLabel chartDescriptionLabel = new JLabel(chartDescription.toString()); final DCPanel panel = new DCPanel(); panel.setLayout(new VerticalLayout()); panel.add(chartDescriptionLabel); panel.add(decoratedChartPanel); return panel; }
From source file:org.metacsp.utility.UI.PlotActivityNetworkGantt.java
/** * Creates a sample data set for a Gantt chart. * /* w ww .j a v a2s . c o m*/ * @return The data set. */ private IntervalCategoryDataset createDataset() { TaskSeries ts = null; TaskSeriesCollection collection = new TaskSeriesCollection(); if (solver.getVariables().length == 0) { return collection; } ts = new TaskSeries("All"); for (int i = 0; i < solver.getVariables().length; i++) { String label = solver.getVariables()[i].getComponent(); //dn.getNodes().elementAt(i).getLabel(); if (this.selectedVariables == null || this.selectedVariables.contains(label)) { SymbolicTimeline tl1 = new SymbolicTimeline(solver, label); for (int j = 0; j < tl1.getPulses().length - 1; j++) { if (tl1.getValues()[j] != null) { long startTime = tl1.getPulses()[j].longValue(); long endTime = startTime + tl1.getDurations()[j].longValue(); Date startTask = new Date(startTime); Date endTask = new Date(endTime); Task task; String value = tl1.getValues()[j].toString().replace("[", "").replace("]", ""); if (value.equals("true")) task = new Task(label, startTask, endTask); else task = new Task(label + " := " + value, startTask, endTask); ts.add(task); } } } } collection.add(ts); return collection; }
From source file:org.jfree.chart.demo.GanttDemo3.java
public static IntervalCategoryDataset createDataset() { TaskSeries taskseries = new TaskSeries("Scheduled"); taskseries.add(new Task("Write Proposal", new SimpleTimePeriod(date(1, 3, 2001), date(5, 3, 2001)))); taskseries.add(new Task("Obtain Approval", new SimpleTimePeriod(date(9, 3, 2001), date(9, 3, 2001)))); taskseries// ww w .j a v a 2s . c om .add(new Task("Requirements Analysis", new SimpleTimePeriod(date(10, 3, 2001), date(5, 4, 2001)))); taskseries.add(new Task("Design Phase", new SimpleTimePeriod(date(6, 4, 2001), date(30, 4, 2001)))); taskseries.add(new Task("Design Signoff", new SimpleTimePeriod(date(2, 5, 2001), date(2, 5, 2001)))); taskseries.add(new Task("Alpha Implementation", new SimpleTimePeriod(date(3, 5, 2001), date(31, 6, 2001)))); taskseries.add(new Task("Design Review", new SimpleTimePeriod(date(1, 7, 2001), date(8, 7, 2001)))); taskseries.add( new Task("Revised Design Signoff", new SimpleTimePeriod(date(10, 7, 2001), date(10, 7, 2001)))); taskseries.add(new Task("Beta Implementation", new SimpleTimePeriod(date(12, 7, 2001), date(12, 8, 2001)))); taskseries.add(new Task("Testing", new SimpleTimePeriod(date(13, 8, 2001), date(31, 9, 2001)))); taskseries .add(new Task("Final Implementation", new SimpleTimePeriod(date(1, 10, 2001), date(15, 10, 2001)))); taskseries.add(new Task("Signoff", new SimpleTimePeriod(date(28, 10, 2001), date(30, 10, 2001)))); TaskSeries taskseries1 = new TaskSeries("Actual"); taskseries1.add(new Task("Write Proposal", new SimpleTimePeriod(date(1, 3, 2001), date(5, 3, 2001)))); taskseries1.add(new Task("Obtain Approval", new SimpleTimePeriod(date(9, 3, 2001), date(9, 3, 2001)))); taskseries1 .add(new Task("Requirements Analysis", new SimpleTimePeriod(date(10, 3, 2001), date(15, 4, 2001)))); taskseries1.add(new Task("Design Phase", new SimpleTimePeriod(date(15, 4, 2001), date(17, 5, 2001)))); taskseries1.add(new Task("Design Signoff", new SimpleTimePeriod(date(30, 5, 2001), date(30, 5, 2001)))); taskseries1 .add(new Task("Alpha Implementation", new SimpleTimePeriod(date(1, 6, 2001), date(12, 8, 2001)))); taskseries1.add(new Task("Design Review", new SimpleTimePeriod(date(12, 8, 2001), date(22, 8, 2001)))); taskseries1.add( new Task("Revised Design Signoff", new SimpleTimePeriod(date(25, 8, 2001), date(27, 8, 2001)))); taskseries1 .add(new Task("Beta Implementation", new SimpleTimePeriod(date(27, 8, 2001), date(30, 9, 2001)))); taskseries1.add(new Task("Testing", new SimpleTimePeriod(date(31, 9, 2001), date(17, 10, 2001)))); taskseries1 .add(new Task("Final Implementation", new SimpleTimePeriod(date(18, 10, 2001), date(5, 11, 2001)))); taskseries1.add(new Task("Signoff", new SimpleTimePeriod(date(10, 11, 2001), date(11, 11, 2001)))); TaskSeriesCollection taskseriescollection = new TaskSeriesCollection(); taskseriescollection.add(taskseries); taskseriescollection.add(taskseries1); return taskseriescollection; }
From source file:org.jfree.data.gantt.SlidingGanttCategoryDatasetTest.java
/** * Serialize an instance, restore it, and check for equality. *///from w w w . jav a2s.c o m @Test public void testSerialization() { TaskSeries s1 = new TaskSeries("Series"); s1.add(new Task("Task 1", new Date(0L), new Date(1L))); TaskSeriesCollection u1 = new TaskSeriesCollection(); u1.add(s1); SlidingGanttCategoryDataset d1 = new SlidingGanttCategoryDataset(u1, 0, 5); SlidingGanttCategoryDataset d2 = (SlidingGanttCategoryDataset) TestUtilities.serialised(d1); assertEquals(d1, d2); // basic check for independence s1.add(new Task("Task 2", new Date(10L), new Date(11L))); assertFalse(d1.equals(d2)); TaskSeriesCollection u2 = (TaskSeriesCollection) d2.getUnderlyingDataset(); TaskSeries s2 = u2.getSeries("Series"); s2.add(new Task("Task 2", new Date(10L), new Date(11L))); assertTrue(d1.equals(d2)); }
From source file:org.endeavour.mgmt.controller.servlet.CreateProjectPlan.java
private void createReportPage(Document aDocument, TaskSeries aTaskSeries, Date aStartDate, Date aEndDate, String aDescription) throws Exception { TaskSeriesCollection theDataset = new TaskSeriesCollection(); theDataset.add(aTaskSeries);/*from w w w . j ava 2s . c o m*/ DateAxis theDateRange = new DateAxis(TIMELINE); theDateRange.setMinimumDate(aStartDate); theDateRange.setMaximumDate(aEndDate); JFreeChart theChart = ChartFactory.createGanttChart(aDescription, ARTIFACTS, null, theDataset, true, false, false); CategoryPlot theCategoryPlot = theChart.getCategoryPlot(); theCategoryPlot.setRangeAxis(theDateRange); BufferedImage theChartImage = theChart.createBufferedImage(780, 520); ByteArrayOutputStream theOutputStream = new ByteArrayOutputStream(); ImageIO.write(theChartImage, "png", theOutputStream); Image theDocumentImage = Image.getInstance(theOutputStream.toByteArray()); aDocument.add(theDocumentImage); }
From source file:org.eobjects.datacleaner.widgets.result.DateGapAnalyzerResultSwingRenderer.java
@Override public JComponent render(DateGapAnalyzerResult result) { final TaskSeriesCollection dataset = new TaskSeriesCollection(); final Set<String> groupNames = result.getGroupNames(); final TaskSeries completeDurationTaskSeries = new TaskSeries(LABEL_COMPLETE_DURATION); final TaskSeries gapsTaskSeries = new TaskSeries(LABEL_GAPS); final TaskSeries overlapsTaskSeries = new TaskSeries(LABEL_OVERLAPS); for (final String groupName : groupNames) { final String groupDisplayName; if (groupName == null) { if (groupNames.size() == 1) { groupDisplayName = "All"; } else { groupDisplayName = LabelUtils.NULL_LABEL; }//from w w w. j a v a 2 s. c o m } else { groupDisplayName = groupName; } final TimeInterval completeDuration = result.getCompleteDuration(groupName); final Task completeDurationTask = new Task(groupDisplayName, createTimePeriod(completeDuration.getFrom(), completeDuration.getTo())); completeDurationTaskSeries.add(completeDurationTask); // plot gaps { final SortedSet<TimeInterval> gaps = result.getGaps(groupName); int i = 1; Task rootTask = null; for (TimeInterval interval : gaps) { final TimePeriod timePeriod = createTimePeriod(interval.getFrom(), interval.getTo()); if (rootTask == null) { rootTask = new Task(groupDisplayName, timePeriod); gapsTaskSeries.add(rootTask); } else { Task task = new Task(groupDisplayName + " gap" + i, timePeriod); rootTask.addSubtask(task); } i++; } } // plot overlaps { final SortedSet<TimeInterval> overlaps = result.getOverlaps(groupName); int i = 1; Task rootTask = null; for (TimeInterval interval : overlaps) { final TimePeriod timePeriod = createTimePeriod(interval.getFrom(), interval.getTo()); if (rootTask == null) { rootTask = new Task(groupDisplayName, timePeriod); overlapsTaskSeries.add(rootTask); } else { Task task = new Task(groupDisplayName + " overlap" + i, timePeriod); rootTask.addSubtask(task); } i++; } } } dataset.add(overlapsTaskSeries); dataset.add(gapsTaskSeries); dataset.add(completeDurationTaskSeries); final SlidingGanttCategoryDataset slidingDataset = new SlidingGanttCategoryDataset(dataset, 0, GROUPS_VISIBLE); final JFreeChart chart = ChartFactory.createGanttChart( "Date gaps and overlaps in " + result.getFromColumnName() + " / " + result.getToColumnName(), result.getGroupColumnName(), "Time", slidingDataset, true, true, false); ChartUtils.applyStyles(chart); // make sure the 3 timeline types have correct coloring { final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDrawingSupplier(new DCDrawingSupplier(WidgetUtils.ADDITIONAL_COLOR_GREEN_BRIGHT, WidgetUtils.ADDITIONAL_COLOR_RED_BRIGHT, WidgetUtils.BG_COLOR_BLUE_BRIGHT)); } final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseMoved(ChartMouseEvent event) { Cursor cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); ChartEntity entity = event.getEntity(); if (entity instanceof PlotEntity) { cursor = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR); } chartPanel.setCursor(cursor); } @Override public void chartMouseClicked(ChartMouseEvent event) { // do nothing } }); final int visibleLines = Math.min(GROUPS_VISIBLE, groupNames.size()); chartPanel.setPreferredSize(new Dimension(0, visibleLines * 50 + 200)); final JComponent decoratedChartPanel; StringBuilder chartDescription = new StringBuilder(); chartDescription .append("<html><p>The chart displays the recorded timeline based on FROM and TO dates.<br/><br/>"); chartDescription.append( "The <b>red items</b> represent gaps in the timeline and the <b>green items</b> represent points in the timeline where more than one record show activity.<br/><br/>"); chartDescription.append( "You can <b>zoom in</b> by clicking and dragging the area that you want to examine in further detail."); if (groupNames.size() > GROUPS_VISIBLE) { final JScrollBar scroll = new JScrollBar(JScrollBar.VERTICAL); scroll.setMinimum(0); scroll.setMaximum(groupNames.size()); scroll.addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent e) { int value = e.getAdjustable().getValue(); slidingDataset.setFirstCategoryIndex(value); } }); chartPanel.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { int scrollType = e.getScrollType(); if (scrollType == MouseWheelEvent.WHEEL_UNIT_SCROLL) { int wheelRotation = e.getWheelRotation(); scroll.setValue(scroll.getValue() + wheelRotation); } } }); final DCPanel outerPanel = new DCPanel(); outerPanel.setLayout(new BorderLayout()); outerPanel.add(chartPanel, BorderLayout.CENTER); outerPanel.add(scroll, BorderLayout.EAST); chartDescription.append("<br/><br/>Use the right <b>scrollbar</b> to scroll up and down on the chart."); decoratedChartPanel = outerPanel; } else { decoratedChartPanel = chartPanel; } chartDescription.append("</p></html>"); final JLabel chartDescriptionLabel = new JLabel(chartDescription.toString()); chartDescriptionLabel.setBorder(new EmptyBorder(4, 10, 4, 10)); final JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.add(decoratedChartPanel); split.add(chartDescriptionLabel); split.setDividerLocation(550); return split; }
From source file:GanttChart.Gantt.java
/** * Crea un dataset per il gantt// ww w. j a v a 2s. co m * * @return dataset */ public IntervalCategoryDataset createDataset() { // fff TaskSeries taskseries = new TaskSeries("Elendo delle attivit di " + progetto.getNome()); /* Day day = new Day(); Day day1 = new Day(); for (int i = 0; i < 50; i++) { int j = (int) (Math.random() * 10D) + 1; for (int k = 0; k < j; k++) day1 = (Day) day1.next(); taskseries.add(new Task("Task " + i, new Date(day.getMiddleMillisecond()), new Date(day1.getMiddleMillisecond()))); day = (Day) day1.next(); day1 = (Day) day1.next(); }*/ for (Sequenza sequenza : progetto.getStato()) { //aggiungo le attivit alla sequenza for (Attivita attivita : sequenza.getStato()) { taskseries.add(attivita.getTask()); } } TaskSeriesCollection dataset = new TaskSeriesCollection(); dataset.add(taskseries); return dataset; }
From source file:org.matsim.contrib.dvrp.util.chart.ScheduleChartUtils.java
private static <T extends Task> TaskSeriesCollection createScheduleDataset(List<? extends Vehicle> vehicles, DescriptionCreator<T> descriptionCreator) { TaskSeriesCollection collection = new TaskSeriesCollection(); for (Vehicle v : vehicles) { @SuppressWarnings("unchecked") Schedule<T> schedule = (Schedule<T>) v.getSchedule(); final TaskSeries scheduleTaskSeries = new TaskSeries(v.getId().toString()); if (schedule.getStatus() == ScheduleStatus.UNPLANNED) { collection.add(scheduleTaskSeries); continue; }/*from ww w . j av a2s . co m*/ List<T> tasks = schedule.getTasks(); for (T t : tasks) { String description = descriptionCreator.create(t); TimePeriod duration = new SimpleTimePeriod(// new Date((int) Math.floor(t.getBeginTime() * 1000)), // new Date((int) Math.ceil(t.getEndTime() * 1000))); scheduleTaskSeries.add(new ChartTask<T>(description, duration, t)); } collection.add(scheduleTaskSeries); } return collection; }
From source file:view.GanttView.java
/** * Creates a sample dataset for a Gantt chart. * * @return The dataset.//from ww w . j a v a2 s.co m */ public IntervalCategoryDataset createDataset() { /*Task is polymorphic : Task(java.lang.String description, java.util.Date start, java.util.Date end) Creates a new task. Task(java.lang.String description, TimePeriod duration) Creates a new task. */ ArrayList<Activity> projActs = getProj().getProjectActivities(); final TaskSeries s1 = new TaskSeries("Scheduled"); for (Activity act : projActs) { Calendar start = getStartDate(act.getStartDate()); int year = start.get(Calendar.YEAR); int month = start.get(Calendar.MONTH); int day = start.get(Calendar.DAY_OF_MONTH); Calendar end = getStartDate(act.getFinishDate()); int endyear = end.get(Calendar.YEAR); int endmonth = end.get(Calendar.MONTH); int endday = end.get(Calendar.DAY_OF_MONTH); s1.add(new Task(act.getName(), new SimpleTimePeriod(date(day, month, year), date(endday, endmonth, endyear)))); } TaskSeriesCollection collection = new TaskSeriesCollection(); collection.add(s1); return collection; }
From source file:org.ietr.preesm.mapper.ui.GanttPlotter.java
/** * Creates a dataset from a MapperDAGVertex. This dataset is used to prepare * display of a Gantt chart with one line per populated SLAM component. * //from w ww . j av a 2 s . com * @return The dataset. */ private static IntervalCategoryDataset createDataset(GanttData ganttData) { TaskSeries series = new TaskSeries("Scheduled"); // Creating the component lines (operator or communicator) List<GanttComponent> components = ganttData.getComponents(); for (GanttComponent cmp : components) { Task currentJFreeCmp = new Task(cmp.getId(), new SimpleTimePeriod(0, 1)); series.add(currentJFreeCmp); // Setting the series length to the maximum end time of a task long finalCost = cmp.getEndTime(); series.get(cmp.getId()).setDuration(new SimpleTimePeriod(0, finalCost)); for (GanttTask ganttTask : cmp.getTasks()) { String taskName = ganttTask.getId(); long start = ganttTask.getStartTime(); long end = start + ganttTask.getDuration(); Task currentJFreeTask = new Task(taskName, new SimpleTimePeriod(start, end)); currentJFreeCmp.addSubtask(currentJFreeTask); } } TaskSeriesCollection collection = new TaskSeriesCollection(); collection.add(series); return collection; }