Example usage for org.jfree.data.gantt Task getDuration

List of usage examples for org.jfree.data.gantt Task getDuration

Introduction

In this page you can find the example usage for org.jfree.data.gantt Task getDuration.

Prototype

public TimePeriod getDuration() 

Source Link

Document

Returns the duration (actual or estimated) of the task.

Usage

From source file:org.ietr.preesm.mapper.ui.MapperGanttToolTipGenerator.java

@Override
public String generateToolTip(CategoryDataset set, int row, int column) {

    String tooltip = new String();

    TaskSeriesCollection collection = (TaskSeriesCollection) set;

    if ((collection.getSeries(0).getItemCount() > column)
            && (collection.getSeries(0).get(column).getSubtaskCount() > row)) {
        Task currentTask = collection.getSeries(0).get(column).getSubtask(row);
        long startTime = currentTask.getDuration().getStart().getTime();
        long endTime = currentTask.getDuration().getEnd().getTime();

        tooltip = currentTask.getDescription() + "(" + startTime + "-" + endTime + "-" + (endTime - startTime)
                + ")";
    }/*  w ww.  jav a  2  s.  c  om*/

    return tooltip;
}

From source file:pt.lsts.neptus.plugins.trex.TrexTimelinePanel.java

private Task setEndTime(Task t, double time) {
    TimePeriod tp = t.getDuration();
    t.setDuration(new SimpleTimePeriod(tp.getStart(), new Date((long) (time * 1000))));
    return t;//ww  w  .ja va  2s.c  om
}

From source file:org.jfree.data.gantt.XYTaskDataset.java

private double getItemStartValue(int series, int item) {
    TaskSeries s = this.underlying.getSeries(series);
    Task t = s.get(item);
    TimePeriod duration = t.getDuration();
    Date start = duration.getStart();
    return start.getTime();
}

From source file:org.jfree.data.gantt.XYTaskDataset.java

private double getItemEndValue(int series, int item) {
    TaskSeries s = this.underlying.getSeries(series);
    Task t = s.get(item);
    TimePeriod duration = t.getDuration();
    Date end = duration.getEnd();
    return end.getTime();
}

From source file:org.jfree.data.gantt.XYTaskDataset.java

private double getItemValue(int series, int item) {
    TaskSeries s = this.underlying.getSeries(series);
    Task t = s.get(item);
    TimePeriod duration = t.getDuration();
    Date start = duration.getStart();
    Date end = duration.getEnd();
    return (start.getTime() + end.getTime()) / 2.0;
}

From source file:org.jfree.data.gantt.TaskSeriesCollection.java

/**
 * Returns the start value for a task.  This is a date/time value, measured
 * in milliseconds since 1-Jan-1970.//from www  .j a va2s. co  m
 *
 * @param rowKey  the series.
 * @param columnKey  the category.
 *
 * @return The start value (possibly <code>null</code>).
 */
@Override
public Number getStartValue(Comparable rowKey, Comparable columnKey) {
    Number result = null;
    int row = getRowIndex(rowKey);
    TaskSeries series = (TaskSeries) this.data.get(row);
    Task task = series.get(columnKey.toString());
    if (task != null) {
        TimePeriod duration = task.getDuration();
        if (duration != null) {
            result = new Long(duration.getStart().getTime());
        }
    }
    return result;
}

From source file:org.jfree.data.gantt.TaskSeriesCollection.java

/**
 * Returns the end value for a task.  This is a date/time value, measured
 * in milliseconds since 1-Jan-1970./* w  w w  . ja v  a 2s  .  c o  m*/
 *
 * @param rowKey  the series.
 * @param columnKey  the category.
 *
 * @return The end value (possibly <code>null</code>).
 */
@Override
public Number getEndValue(Comparable rowKey, Comparable columnKey) {
    Number result = null;
    int row = getRowIndex(rowKey);
    TaskSeries series = (TaskSeries) this.data.get(row);
    Task task = series.get(columnKey.toString());
    if (task != null) {
        TimePeriod duration = task.getDuration();
        if (duration != null) {
            result = new Long(duration.getEnd().getTime());
        }
    }
    return result;
}

From source file:org.jfree.data.gantt.TaskSeriesCollection.java

/**
 * Returns the start value of a sub-interval for a given item.
 *
 * @param rowKey  the row key.//  ww  w . jav  a  2  s  .com
 * @param columnKey  the column key.
 * @param subinterval  the subinterval.
 *
 * @return The start value (possibly <code>null</code>).
 */
@Override
public Number getStartValue(Comparable rowKey, Comparable columnKey, int subinterval) {
    Number result = null;
    int row = getRowIndex(rowKey);
    TaskSeries series = (TaskSeries) this.data.get(row);
    Task task = series.get(columnKey.toString());
    if (task != null) {
        Task sub = task.getSubtask(subinterval);
        if (sub != null) {
            TimePeriod duration = sub.getDuration();
            result = new Long(duration.getStart().getTime());
        }
    }
    return result;
}

From source file:org.jfree.data.gantt.TaskSeriesCollection.java

/**
 * Returns the end value of a sub-interval for a given item.
 *
 * @param rowKey  the row key./*from   w w w. ja va 2  s  . c  o m*/
 * @param columnKey  the column key.
 * @param subinterval  the subinterval.
 *
 * @return The end value (possibly <code>null</code>).
 */
@Override
public Number getEndValue(Comparable rowKey, Comparable columnKey, int subinterval) {
    Number result = null;
    int row = getRowIndex(rowKey);
    TaskSeries series = (TaskSeries) this.data.get(row);
    Task task = series.get(columnKey.toString());
    if (task != null) {
        Task sub = task.getSubtask(subinterval);
        if (sub != null) {
            TimePeriod duration = sub.getDuration();
            result = new Long(duration.getEnd().getTime());
        }
    }
    return result;
}

From source file:org.talend.dataprofiler.chart.TOPChartService.java

@Override
public void createAnnotOnGantt(Object chart, List<Object[]> rowList, int multiDateColumn, int nominal) {
    Map<String, RowColumPair> hightlightSeriesMap = new HashMap<String, RowColumPair>();
    CategoryPlot xyplot = (CategoryPlot) ((JFreeChart) chart).getPlot();
    CategoryTextAnnotation an;/*  ww  w .j  a  v  a  2  s.  c  o  m*/
    for (int seriesCount = 0; seriesCount < ((TaskSeriesCollection) xyplot.getDataset())
            .getSeriesCount(); seriesCount++) {
        int indexOfRow = 0;
        int columnCount = 0;
        for (int itemCount = 0; itemCount < ((TaskSeriesCollection) xyplot.getDataset()).getSeries(seriesCount)
                .getItemCount(); itemCount++, columnCount++) {
            Task task = ((TaskSeriesCollection) xyplot.getDataset()).getSeries(seriesCount).get(itemCount);
            String taskDescription = task.getDescription();
            String[] taskArray = taskDescription.split("\\|"); //$NON-NLS-1$
            boolean isSameTime = task.getDuration().getStart().getTime() == task.getDuration().getEnd()
                    .getTime();
            if (!isSameTime && (rowList.get(indexOfRow))[multiDateColumn - 3] != null
                    && (rowList.get(indexOfRow))[multiDateColumn - 2] != null
                    && !((rowList.get(indexOfRow))[multiDateColumn]).equals(new BigDecimal(0L))) {
                RowColumPair pair = new RowColumPair();
                pair.setRow(seriesCount);
                pair.setColumn(columnCount);

                hightlightSeriesMap.put(String.valueOf(seriesCount) + String.valueOf(columnCount), pair);

                an = new CategoryTextAnnotation("#nulls = " + (rowList.get(indexOfRow))[multiDateColumn], //$NON-NLS-1$
                        taskDescription, task.getDuration().getStart().getTime());
                an.setTextAnchor(TextAnchor.CENTER_LEFT);
                an.setCategoryAnchor(CategoryAnchor.MIDDLE);
                xyplot.addAnnotation(an);
            }
            if (taskArray.length == nominal) {
                indexOfRow++;

                if (rowList.size() != indexOfRow && ((rowList.get(indexOfRow))[multiDateColumn - 3] == null
                        || (rowList.get(indexOfRow))[multiDateColumn - 2] == null)) {
                    indexOfRow++;
                }
            }
        }
    }
    CustomHideSeriesGanttRender renderer = new CustomHideSeriesGanttRender(hightlightSeriesMap);
    xyplot.setRenderer(renderer);
    renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {

        @Override
        public String generateToolTip(CategoryDataset dataset, int row, int column) {
            TaskSeriesCollection taskSeriesColl = (TaskSeriesCollection) dataset;
            List<Task> taskList = new ArrayList<Task>();
            for (int i = 0; i < taskSeriesColl.getSeriesCount(); i++) {
                for (int j = 0; j < taskSeriesColl.getSeries(i).getItemCount(); j++) {
                    taskList.add(taskSeriesColl.getSeries(i).get(j));
                }
            }
            Task task = taskList.get(column);
            // Task task = taskSeriesColl.getSeries(row).get(column);
            String taskDescription = task.getDescription();

            Date startDate = task.getDuration().getStart();
            Date endDate = task.getDuration().getEnd();
            return taskDescription + ",     " + startDate + "---->" + endDate; //$NON-NLS-1$ //$NON-NLS-2$
            // return "this is a tooltip";
        }
    });
    xyplot.getDomainAxis().setMaximumCategoryLabelWidthRatio(10.0f);

}