List of usage examples for org.jfree.data.gantt Task Task
public Task(String description, TimePeriod duration)
From source file:org.jfree.chart.demo.XYTaskDatasetDemo2.java
private static TaskSeriesCollection createTasks() { TaskSeriesCollection taskseriescollection = new TaskSeriesCollection(); TaskSeries taskseries = new TaskSeries("Team A"); taskseries.add(new Task("T1a", new Hour(11, new Day()))); taskseries.add(new Task("T1b", new Hour(14, new Day()))); taskseries.add(new Task("T1c", new Hour(16, new Day()))); TaskSeries taskseries1 = new TaskSeries("Team B"); taskseries1.add(new Task("T2a", new Hour(13, new Day()))); taskseries1.add(new Task("T2b", new Hour(19, new Day()))); taskseries1.add(new Task("T2c", new Hour(21, new Day()))); TaskSeries taskseries2 = new TaskSeries("Team C"); taskseries2.add(new Task("T3a", new Hour(13, new Day()))); taskseries2.add(new Task("T3b", new Hour(19, new Day()))); taskseries2.add(new Task("T3c", new Hour(21, new Day()))); TaskSeries taskseries3 = new TaskSeries("Team D"); taskseries3.add(new Task("T4a", new Day())); TaskSeries taskseries4 = new TaskSeries("Team E"); taskseries4.add(new Task("T5a", new Day())); taskseriescollection.add(taskseries); taskseriescollection.add(taskseries1); taskseriescollection.add(taskseries2); taskseriescollection.add(taskseries3); taskseriescollection.add(taskseries4); return taskseriescollection; }
From source file:graficos.GraficoGantt.java
private void agregarTareasConcretas(Suceso suceso, Date fecha_com, int unidad_tiempo) { Vector<Actividad> vec = suceso.getActividadesSalientes(); for (Iterator<Actividad> it = vec.iterator(); it.hasNext();) { Actividad a = it.next();//from w w w .j av a 2 s. c o m if (!a.esFicticia()) { Date fecha_fin = getFechaIncremento(fecha_com, unidad_tiempo, a.getParametrosNormales().getTiempo()); Task tarea; if (a.esCritica()) { tarea = new Task("(" + a.getIdentificador().toString() + ") " + a.getDescripcion(), new SimpleTimePeriod((Date) fecha_com.clone(), fecha_fin)); serie_tareas_c.add(tarea); } else { tarea = new Task("(" + a.getIdentificador().toString() + ") " + a.getDescripcion(), new SimpleTimePeriod((Date) fecha_com.clone(), fecha_fin)); serie_tareas_nc.add(tarea); } agregarTareasConcretas(a.getSucesoFin(), fecha_fin, unidad_tiempo); } else agregarTareasConcretas(a.getSucesoFin(), fecha_com, unidad_tiempo); } }
From source file:entropy.plan.visualization.GanttVisualizer.java
/** * Build the plan agenda//from ww w .j a v a2 s . com * * @param plan the plan to visualize * @return {@code true} if the generation succeeds */ @Override public boolean buildVisualization(TimedReconfigurationPlan plan) { File parent = new File(out).getParentFile(); if (parent != null && !parent.exists() && !parent.mkdirs()) { Plan.logger.error("Unable to create '" + out + "'"); return false; } final TaskSeriesCollection collection = new TaskSeriesCollection(); TaskSeries ts = new TaskSeries("actions"); for (Action action : plan) { Task t = new Task(action.toString(), new SimpleTimePeriod(action.getStartMoment(), action.getFinishMoment())); ts.add(t); } collection.add(ts); ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); final JFreeChart chart = ChartFactory.createGanttChart(null, // chart title "Actions", // domain axis label "Time", // range axis label collection, // data false, // include legend true, // tooltips false // urls ); CategoryPlot plot = chart.getCategoryPlot(); DateAxis da = (DateAxis) plot.getRangeAxis(); SimpleDateFormat sdfmt = new SimpleDateFormat(); sdfmt.applyPattern("S"); da.setDateFormatOverride(sdfmt); ((GanttRenderer) plot.getRenderer()).setShadowVisible(false); int width = 500 + 10 * plan.getDuration(); int height = 50 + 20 * plan.size(); try { switch (fmt) { case png: ChartUtilities.saveChartAsPNG(new File(out), chart, width, height); break; case jpg: ChartUtilities.saveChartAsJPEG(new File(out), chart, width, height); break; } } catch (IOException e) { Plan.logger.error(e.getMessage(), e); return false; } return true; }
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 a va 2s . c o m * @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; }
From source file:view.GanttView.java
/** * Creates a sample dataset for a Gantt chart. * * @return The dataset./* www.j a v a2s . com*/ */ 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.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 ww w . jav a2 s . c om } 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.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 ww w. j a v a2 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 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:graficos.GraficoGantt.java
private void agregarTareasFicticias(Hashtable<Integer, Date> actFecha_com, Hashtable<Integer, Date> actFecha_fin, Vector<Actividad> vec_ficticias) { for (Iterator<Actividad> it = vec_ficticias.iterator(); it.hasNext();) { Actividad a = it.next();/*from w ww . j a v a2 s . c om*/ Vector<Actividad> vec_ent = a.getSucesoOrigen().getActividadesEntrantes(); Vector<Actividad> vec_sal = a.getSucesoFin().getActividadesSalientes(); boolean listo_fc = false; boolean listo_ff = false; Date fecha_com = new Date(); Date fecha_fin = new Date(); for (Iterator<Actividad> it0 = vec_ent.iterator(); it0.hasNext() && !listo_fc;) { Actividad ae = it0.next(); if (!ae.esFicticia()) { fecha_com = actFecha_fin.get(ae.getIdentificador()); listo_fc = true; } } for (Iterator<Actividad> it0 = vec_sal.iterator(); it0.hasNext() && !listo_ff;) { Actividad as = it0.next(); if (!as.esFicticia()) { fecha_fin = actFecha_com.get(as.getIdentificador()); listo_ff = true; } } if (listo_fc && listo_ff) { Task tarea = new Task("F (" + a.getIdentificador().toString() + ") " + a.getDescripcion(), new SimpleTimePeriod(fecha_com, fecha_fin)); serie_tareas_nc.add(tarea); } } }
From source file:pisco.batch.visu.BatchingChartFactory.java
public static XYDataset createLatenessDataset(Batch[] batches) { final TaskSeriesCollection coll = new TaskSeriesCollection(); for (int i = 0; i < batches.length; i++) { TaskSeries series = new TaskSeries(String.valueOf(i)); final int dd = batches[i].getDueDate(); final int compl = batches[i].getCompletionTime(); TimePeriod p = dd < compl ? new SimpleTimePeriod(dd, compl) : new SimpleTimePeriod(compl, dd); series.add(new Task("B" + i, p)); coll.add(series);// ww w . ja va 2s .co m } final XYTaskDataset dataset = new XYTaskDataset(coll); dataset.setTransposed(true); return dataset; }
From source file:de.fhbingen.wbs.wpOverview.tabs.APCalendarPanel.java
/** * Convert work packages to tasks.//from w w w . j a v a2 s .c o m * @param userWp * list with work packages. * @return IntervalCategoryDataset: tasks of the work packages. */ public final IntervalCategoryDataset createDataset(final List<Workpackage> userWp) { final TaskSeries s1 = new TaskSeries(LocalizedStrings.getGeneralStrings().overview()); colorList = new ArrayList<Integer>(); for (Workpackage actualPackage : userWp) { if (actualPackage.getEndDateCalc() != null && actualPackage.getStartDateCalc() != null) { if (actualPackage.getlastRelevantIndex() <= showLevels) { Date endDateCalc = null; Date start = null; endDateCalc = actualPackage.getEndDateCalc(); start = actualPackage.getStartDateCalc(); String indent = ""; for (int i = 0; i < actualPackage.getlastRelevantIndex(); i++) { indent += " "; } if (!endDateCalc.before(start)) { Task t = new Task(indent + actualPackage.toString(), new SimpleTimePeriod(start, endDateCalc)); t.setPercentComplete(0.01 * WpManager.calcPercentComplete(actualPackage.getBac(), actualPackage.getEtc(), actualPackage.getAc())); s1.add(t); colorList.add(actualPackage.getlastRelevantIndex()); } } } } final TaskSeriesCollection collection = new TaskSeriesCollection(); collection.add(s1); return collection; }